summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author杨威 <[email protected]>2023-06-20 16:01:35 +0800
committer杨威 <[email protected]>2023-06-26 20:18:26 +0800
commit096bbda71ea301fe6dbdc603b5cbf06bfc0d73ed (patch)
tree7009752d8a71c4f7f4aafcce6263464d5277be80 /test
parentacc0ee76193f032c64dca379acad9c7256d6e13f (diff)
🦄 refactor(Remove obsolete code): makefile and dictator
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt2
-rw-r--r--test/MESA_path_trace/Makefile28
-rw-r--r--test/Makefile75
-rw-r--r--test/Makefile_kill24
-rw-r--r--test/Makefile_proxy25
-rw-r--r--test/dpdk_ip_hash/Makefile7
-rw-r--r--test/terminal_tag.c398
-rw-r--r--test/terminal_tag.h61
8 files changed, 1 insertions, 619 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d76c1d8..812d7db 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,7 +21,7 @@ LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/test)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/sapp_devel.cpp "")
set(LIBS sapp_dev dealpkt packet_io packet_io_pcap packet_io_marsio common
- config inline_keepalive gdev_assistant sapp_assistant plugctrl project timer dictator2
+ config inline_keepalive gdev_assistant sapp_assistant sapp_metrics plugctrl project timer
md5 symbol_check tomlc99_wrap MESA_socket_wrap timestamp_record
MESA_sleep dpdk_ip_hash cpu_limit timeout libdabloom-static )
diff --git a/test/MESA_path_trace/Makefile b/test/MESA_path_trace/Makefile
deleted file mode 100644
index caf968f..0000000
--- a/test/MESA_path_trace/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += -D__FAVOR_BSD=1 -D__USE_MISC=1 -D_GNU_SOURCE=1
-CFLAGS += $(OPTFLAGS)
-OBJECTS = MESA_path_trace.o
-MODULES =
-TARGET = MESA_path_trace.so
-
-INCS = -I ../../include
-INCS += -I ../../include/net
-INCS += -I ../../dealpkt
-INCS += -I /usr/include/MESA
-INCS += -I../../include/stream_inc
-
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../../plug/business/MESA_path_trace/
- cp MESA_path_trace.inf ../../plug/business/MESA_path_trace/
-
-MESA_path_trace.o:MESA_path_trace.c
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile b/test/Makefile
deleted file mode 100644
index 4166e8f..0000000
--- a/test/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-CC = gcc
-CCC = g++
-CFLAGS = -g -fPIC
-CFLAGS += -D__USE_BSD=1 -D__FAVOR_BSD=1 -D__USE_MISC=1 -D_GNU_SOURCE=1
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_app_sapp.o trace_delay.o terminal_tag.o g_device_plug.o
-MODULES =
-
-BIN_PATH = ../bin/
-
-TARGET = test_app_sapp.so
-TARGET += inline_device_measurement.so
-TARGET += test_sendpacket_performance.so
-#TARGET += test_anti_flood_hijack
-#TARGET += sapp_so_run
-
-TARGET += test_sapp_dev_static test_sapp_dev_dynamic
-
-INCS =
-
-INCS += -I ../include
-INCS += -I../include/private
-INCS += -I../include/public
-INCS += -I../include/public/stream_inc/
-INCS += -I../include/support/
-INCS += -I/opt/MESA/include
-INCS += -I/opt/MESA/include/MESA
-
-
-.PHONY: all
-all: $(TARGET)
-
-test_app_sapp.so: test_app_sapp.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_sendpacket_performance.so: test_sendpacket_performance.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-trace_delay.so: trace_delay.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-terminal_tag.so: terminal_tag.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-g_device_plug.so: g_device_plug.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_http.so:test_http.o
- $(CC) -o $@ -shared -fPIC $(CFLAGS) $^ $(MODULES)
-
-test_anti_flood_hijack:test_anti_flood_hijack.c ../lib/libavltree.a
- g++ -o $@ $(CFLAGS) $^ -I../inner_plug -I../support/avl_tree -lpcap -lpthread -lanti_flood_hijack -lMESA_htable -lMESA_handle_logger
-
-inline_device_measurement.so:inline_device_measurement.c
- $(CC) -o $@ -shared -fPIC $(INCS) $(CFLAGS) -DIOMODE_MARSIO=1 $^ $(MODULES)
-
-
-sapp_so_run:test_sapp_so.o
- $(CC) -o $@ -g $(INCS) $(CFLAGS) $^ -lpcap -ldl
-
-test_sapp_dev_static:test_sapp_dev.c
- gcc -o $@ $^ ../build/src/sapp_dev/libsapp_dev.a -I/opt/MESA/include/MESA -I/opt/MESA/include/MESA/stream_inc -L/opt/MESA/lib -lpcap -lpthread -ldl -lMESA_htable -lMESA_prof_load -lMESA_handle_logger -lMESA_field_stat2
-
-test_sapp_dev_dynamic:test_sapp_dev.c
- gcc -o $@ $^ -lsapp_devel -I/opt/MESA/include/MESA -I/opt/MESA/include/MESA/stream_inc -L/opt/MESA/lib -lpcap -lpthread -ldl -lMESA_htable -lMESA_prof_load -lMESA_handle_logger -lMESA_field_stat2 -lsystemd -lMESA_jump_layer -lbreakpad_mini
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.cpp.o:
- $(CCC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile_kill b/test/Makefile_kill
deleted file mode 100644
index cec4fa3..0000000
--- a/test/Makefile_kill
+++ /dev/null
@@ -1,24 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_kill.o
-MODULES =
-TARGET = test_kill.so
-
-INCS = -I ../../include
-
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../plug/general
-
-test_app.o: test_kill.c
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/Makefile_proxy b/test/Makefile_proxy
deleted file mode 100644
index 18ec183..0000000
--- a/test/Makefile_proxy
+++ /dev/null
@@ -1,25 +0,0 @@
-CC = gcc
-CFLAGS = -g -Wall -fPIC
-CFLAGS += $(OPTFLAGS)
-OBJECTS = test_connect.o
-MODULES =
-TARGET = test_app.so
-
-INCS = -I ../../include
-INCS += -I../../include/stream_inc/
-
-
-.c.o:
- $(CC) -c -o $@ $(CFLAGS) -I. $(INCS) $<
-
-.PHONY: all clean
-all: $(TARGET)
-$(TARGET):$(OBJECTS)
- $(CC) -o $(TARGET) -shared -fPIC $(CFLAGS) $(OBJECTS) $(MODULES)
- cp $@ ../plug/business/test_app/
-
-test_connect.o: test_connect.c
-
-clean:
- rm -f $(TARGET) $(OBJECTS)
-
diff --git a/test/dpdk_ip_hash/Makefile b/test/dpdk_ip_hash/Makefile
deleted file mode 100644
index 26d266f..0000000
--- a/test/dpdk_ip_hash/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-all:test_dpdk_hash.so
-
-test_dpdk_hash.o:test_dpdk_hash.c
- gcc -c -o $@ -fPIC $^ -I./include -I/opt/MESA/include/MESA
-
-test_dpdk_hash.so:test_dpdk_hash.o
- gcc -o $@ -fPIC -shared $^
diff --git a/test/terminal_tag.c b/test/terminal_tag.c
deleted file mode 100644
index 1e89eb7..0000000
--- a/test/terminal_tag.c
+++ /dev/null
@@ -1,398 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __FAVOR_BSD
-#define __FAVOR_BSD 1
-#endif
-
-#include "stream_base.h"
-#include "stream_internal.h"
-#include "stream_manage.h"
-#include "mesa_net.h"
-#include "project_requirement.h"
-#include "terminal_tag.h"
-#include <netinet/ip.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <assert.h>
-
-
-#define TERMINAL_TAG_SIZE_MAX (48)
-extern int project_req_terminal_tag_id;
-unsigned char terminal_tag_checksum_hash(unsigned char rand_num,
- unsigned int ip_addr, unsigned short dev_id)
-{
- unsigned char checksum_key = 0x5A;
- unsigned char *p;
-
- checksum_key += rand_num;
- p = (unsigned char *)&ip_addr;
- checksum_key += p[0];
- checksum_key += p[1];
- checksum_key += p[2];
- checksum_key += p[3];
- p = (unsigned char *)&dev_id;
- checksum_key += p[0];
- checksum_key += p[1];
-
- return checksum_key;
-}
-
-unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,
- unsigned char checksum_key)
-{
- unsigned char checksum = 0x77;
- unsigned char *p = (unsigned char *)terminal_tag;
-
- terminal_tag->check_sum = 0;
-
- checksum += p[0];
- checksum += p[1];
- checksum += p[2];
- checksum += p[3];
- checksum += p[4];
- checksum += p[5];
- checksum += p[6];
- checksum += p[7];
- checksum += p[8];
- checksum += p[9];
- checksum += checksum_key;
-
- return checksum;
-}
-
-unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr)
-{
- unsigned char encrypt_key = 0xA5;
- unsigned char *p;
-
- encrypt_key ^= rand_num;
- p = (unsigned char *)&ip_addr;
- encrypt_key ^= p[0];
- encrypt_key ^= p[1];
- encrypt_key ^= p[2];
- encrypt_key ^= p[3];
-
- return encrypt_key;
-}
-
-static void *terminal_tag_create_struct(int thread_num)
-{
- void *info = dictator_malloc(thread_num, TERMINAL_TAG_SIZE_MAX);
- memset(info, 0, TERMINAL_TAG_SIZE_MAX);
-
- return info;
-}
-
-static void terminal_tag_transform(struct terminal_tag_t *terminal_tag,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- char ip_str[16];
- unsigned char *mac;
- struct stream_tuple4_v4 *st4;
- int sip_addr;
- void *stream_tag_value;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- sip_addr = st4->saddr;
- }else{
- return; /* ��֧��ipv6 */
- }
-
- switch(terminal_tag->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- mac = (unsigned char *)terminal_tag->local_addr.local_mac;
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%02x%02x-%02x%02x-%02x%02x",
- "M",ntohs(terminal_tag->dev_id), mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
- break;
-
- case TERMINAL_ADDR_TYPE_IP:
- inet_ntop(AF_INET, &terminal_tag->local_addr.local_ip.ipaddr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%05u:%s",
- "I", ntohs(terminal_tag->dev_id), ip_str);
- break;
-
- case TERMINAL_ADDR_TYPE_TRACE:
- // to do!
- break;
-
- case TERMINAL_ADDR_TYPE_GLOBAL_SIP:
- break;
-
- default:
- inet_ntop(AF_INET, &sip_addr, ip_str, 16);
- snprintf((char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX, "%s:%s", "G:00000", ip_str);
- break;
- }
-
-#if 0
- if(terminal_tag->type < 2)
- {
- printf("Tagv4 is: %s\n", stream->terminal_tag);
- }
- //mac = (unsigned char *)terminal_tag;
- //printf("Clear-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- //mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return;
-}
-
-static int terminal_tag_checksum_check(struct terminal_tag_t *terminal_tag_clear,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- unsigned char checksum_key;
- unsigned char raw_checksum, new_checksum;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- checksum_key = terminal_tag_checksum_hash(terminal_tag_clear->random,
- dip_addr,
- ntohs(terminal_tag_clear->dev_id));
-
- raw_checksum = terminal_tag_clear->check_sum;
-
- new_checksum = terminal_tag_checksum(terminal_tag_clear, checksum_key);
-
- if(raw_checksum != new_checksum)
- {
- //printf("Checksum error!\n");
- goto err; /* У��Ͳ��ԣ����ܴ�����󡢻򱻴۸ġ������α��� */
- }
-
- switch(terminal_tag_clear->type)
- {
- case TERMINAL_ADDR_TYPE_MAC:
- break;
-
- case TERMINAL_ADDR_TYPE_IP: /* IP����,���������ֽ�����������У�� */
- if(IP_STRUCT_MAGIC != terminal_tag_clear->local_addr.local_ip.ip_magic_num)
- {
- goto err;
- }
- break;
-
- default: /* �û���ǩ�豸���ӵı�־ֻ����MAC��IP */
- return -1;
- break;
- }
-
- terminal_tag_transform(terminal_tag_clear, stream, stack_tag_string);
- return 0;
-
-err:
- return -1;
-}
-
-/* �û���ǩ���� */
-static int terminal_tag_decrypt(struct terminal_tag_t *terminal_tag_enc,
- struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- unsigned char rand_num, encrypt_key;
- unsigned char *clear, *encrypt;
- struct stream_tuple4_v4 *st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- int dip_addr;
-
- if(ADDR_TYPE_IPV4 == stream->addr.addrtype){
- st4 = (struct stream_tuple4_v4 *)stream->addr.tuple4_v4;
- dip_addr = st4->daddr;
- }else{
- return -1; /* ��֧��ipv6 */
- }
-
- /* copy��һ����ʱ�ռ䣬���޸�ԭʼ���ݰ� */
- memcpy(&terminal_tag, terminal_tag_enc, sizeof(struct terminal_tag_t));
-
-#if 0
- unsigned char * mac = (unsigned char *)&terminal_tag;
- printf("Encrypt-bin is: %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
- mac[0],mac[1],mac[2],mac[3],mac[4],mac[5],mac[6],mac[7],mac[8],mac[9]);
-#endif
-
- clear = (unsigned char *)&terminal_tag;
- encrypt = (unsigned char *)terminal_tag_enc;
-
- clear[0] = ror(encrypt[0], 4);
- rand_num = terminal_tag.random;
-
- encrypt_key = terminal_tag_encrypt_hash(rand_num, dip_addr);
-
- /* ������һ���ֽڣ�type��random�ֶβ�����˷�ʽ���� */
-
- clear[1] = encrypt[1] ^ encrypt_key;
- clear[2] = encrypt[2] ^ encrypt_key;
- clear[3] = encrypt[3] ^ encrypt_key;
- clear[4] = encrypt[4] ^ encrypt_key;
- clear[5] = encrypt[5] ^ encrypt_key;
- clear[6] = encrypt[6] ^ encrypt_key;
- clear[7] = encrypt[7] ^ encrypt_key;
- clear[8] = encrypt[8] ^ encrypt_key;
- clear[9] = encrypt[9] ^ encrypt_key;
-
- return terminal_tag_checksum_check(&terminal_tag, stream, stack_tag_string);
-}
-
-
-static int terminal_tag_trace(struct streaminfo *stream, unsigned char *stack_tag_string)
-{
- struct terminal_tag_t terminal_tag;
- /* ��Դϵͳ��ѯ */
- /* to do:
- terminal_tag_trace();
- if(err)
- {
- goto def_tag;
- }
- terminal_tag_clear->type = TERMINAL_ADDR_TYPE_TRACE;
- */
- terminal_tag.type = TERMINAL_ADDR_TYPE_GLOBAL_SIP;
- terminal_tag_transform(&terminal_tag, stream, stack_tag_string);
- return 0;
-}
-
-
-
-
-static int terminal_tag_set_ipv6(struct streaminfo *stream, unsigned char *stack_tag_string, const void *rawippkt)
-{
- void *stream_tag_value;
- const struct mesa_ip6_hdr *ip6h = (struct mesa_ip6_hdr *)rawippkt;
-
- /* ��ʱʹ��IPv6��Դ��ַ��Ϊv6_tag */
- if(NULL == inet_ntop(AF_INET6, &ip6h->ip6_src, (char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX))
- {
- return -1;
- }
-
- stream_tag_value = terminal_tag_create_struct(stream->threadnum);
- strncpy((char *)stream_tag_value, (const char *)stack_tag_string, TERMINAL_TAG_SIZE_MAX);
- project_req_add_struct(stream, project_req_terminal_tag_id, stream_tag_value);
-
- return 0;
-}
-
-
-/* �豸��ȡ�û�TAG, �ж��Ƿ���ȷ�����ܺ����stream�ṹ�� */
-static int terminal_tag_probe(struct streaminfo *stream, struct tcphdr *api_tcp_hdr,
- const void *rawippkt)
-{
- struct mesa_tcp_hdr *this_tcphdr;
- unsigned char *stream_tag_string = NULL;
- unsigned char stack_tag_string[TERMINAL_TAG_SIZE_MAX];
- u_int8_t *option;
- int tcp_hdr_len;
- u_int16_t option_len;
- int ret = 0;
-
- if(likely(-1 == project_req_terminal_tag_id)){
- return -1;
- }
-
- this_tcphdr = (struct mesa_tcp_hdr *)api_tcp_hdr;
- option = (u_int8_t *)this_tcphdr + 20; /* TCP��׼ͷ������=20 */
- tcp_hdr_len = 4 * this_tcphdr->th_off;
-
- stream_tag_string = (unsigned char *)project_req_get_struct(stream, project_req_terminal_tag_id);
- if((NULL != stream_tag_string) && (stream_tag_string[0] != '\0')){ /* �Ѿ���ȡ����ǩ */
- return 0;
- }
-
- if(ADDR_TYPE_IPV6 == stream->addr.addrtype)
- {
- return terminal_tag_set_ipv6(stream, stack_tag_string, rawippkt);
- }else if(ADDR_TYPE_IPV4 != stream->addr.addrtype){
- return -1;
- }
-
- if(this_tcphdr->th_flags != TH_SYN)
- {
- ret = -2;
- goto trace_tag;
- }
- tcp_hdr_len -= 20;
- if(tcp_hdr_len < TCP_SYN_TAG_LEN)
- {
- ret = -3;
- goto trace_tag;
- }
-
- while(tcp_hdr_len > 0)
- {
- switch(*option)
- {
- case 0: /* type=0ԭ����ѡ���������׷������ѡ�����Ҫ���������� */
- case 1:
- option_len = 1;
- break;
-
- case TCP_SYN_TAG_TYPE:
- option_len = *(option+1);
- if(TCP_SYN_TAG_LEN == option_len)
- {
- ret = terminal_tag_decrypt((struct terminal_tag_t *)(option+2), stream, stack_tag_string);
- if(0 == ret)
- {
- return 0;
- }
- }
- break;
-
- default:
- option_len = *(option+1);
- }
- if(0 == option_len)
- {
- goto trace_tag;
- }
- if(option_len > tcp_hdr_len)
- {
- goto trace_tag;
- }
- option += option_len;
- tcp_hdr_len -= option_len;
- }
-
-trace_tag:
- return terminal_tag_trace(stream, stack_tag_string);
- //return -1;
-}
-
-
-char terminal_tag_tcp_all_entry(struct streaminfo *a_tcp, void **pme, int thread_seq,void *a_packet)
-{
- const struct mesa_ip4_hdr *ip4h = (const struct mesa_ip4_hdr *)a_packet;
-
- if(OP_STATE_PENDING == a_tcp->pktstate){
- terminal_tag_probe(a_tcp, (struct tcphdr *)((char *)a_packet + ip4h->ip_hl*4), a_packet);
- }
-
- return APP_STATE_DROPME;
-}
-
-int terminal_tag_init(void)
-{
- return 0;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
diff --git a/test/terminal_tag.h b/test/terminal_tag.h
deleted file mode 100644
index 335ce39..0000000
--- a/test/terminal_tag.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef _TERMINAL_TAG_H_
-#define _TERMINAL_TAG_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "mesa_net.h"
-#include <stdio.h>
-#include <sys/types.h>
-
-#define TERMINAL_MODULE_NAME "terminal_tag"
-
-#define TCP_SYN_TAG_TYPE (0xF1)
-#define TCP_SYN_TAG_LEN (12) /* 6BMAC+2B�豸ID+1B����+1BУ���+1B����+1B���� */
-#define TCP_HDR_MAX_LEN (60) /* TCPͷ����󳤶� */
-
-#define rol(x,n) (((x)<<(n)) | ((x)>>(8*sizeof(x)-(n))))
-#define ror(x,n) (((x)>>(n)) | ((x)<<(8*sizeof(x)-(n))))
-
-
-#define IP_STRUCT_MAGIC (0x8633)
-struct local_ip_t{
- unsigned int ipaddr; /* �ն��豸����IP, ������ */
- unsigned short ip_magic_num; /* ħ��,�洢IPʱ����������ֽ�,��������֤ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-union local_addr_t{
- unsigned char local_mac[6]; /* �ն��豸MAC��ַ */
- struct local_ip_t local_ip; /* �ն��豸����IP�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=6B
-
-#define TERMINAL_ADDR_TYPE_MAC (0)
-#define TERMINAL_ADDR_TYPE_IP (1)
-#define TERMINAL_ADDR_TYPE_TRACE (2)
-#define TERMINAL_ADDR_TYPE_GLOBAL_SIP (3)
-struct terminal_tag_t{
-#if __BYTE_ORDER == __BIG_ENDIAN
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
- unsigned char random:6; /* �����,���ڼ��� */
-#elif __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned char random:6; /* �����,���ڼ��� */
- unsigned char type:2; /* ����������ȡ��ʽ, 1:MAC; 2:IP */
-#endif
-
- unsigned char check_sum; /* У��ͣ�������������֤����α�� */
- unsigned short dev_id; /* �豸ID (����ID���������� */
- union local_addr_t local_addr; /* �豸������ַ�ṹ */
-}BYTE_ALIGNED(1); //sizeof(this)=10B
-
-extern unsigned char terminal_tag_encrypt_hash(unsigned char rand_num, unsigned int ip_addr);
-extern unsigned char terminal_tag_checksum_hash(unsigned char rand_num, unsigned int ip_addr, unsigned short dev_id);
-extern unsigned char terminal_tag_checksum(struct terminal_tag_t *terminal_tag,unsigned char checksum_key);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-