summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryangwei <[email protected]>2024-11-12 13:24:11 +0800
committeryangwei <[email protected]>2024-11-12 14:22:04 +0800
commit421d4ed459f6656f7f67c301530891e332b49959 (patch)
tree8f59efe9755f458d9570f6900883d0cf4027378a
parentbff48cc28a94e72540c1cdb65b3fc55e892b0201 (diff)
🔧 build(integrate tcpdump_mesa): in toolsFeature-merge-jump-layer
-rw-r--r--benchmark/include/sapp_bchmk_inner.h33
-rw-r--r--benchmark/include/sapp_benchmark.h8
-rw-r--r--benchmark/src/sapp_benchmark.cpp14
-rw-r--r--benchmark/src/sapp_benchmark_utils.cpp64
-rw-r--r--include/private/mesa_net.h37
-rw-r--r--include/private/sapp_declaration.h1
-rw-r--r--include/private/stream_internal.h6
-rw-r--r--include/public/stream_inc/MESA_jump_layer.h57
-rw-r--r--include/public/stream_inc/stream_base.h168
-rw-r--r--include/public/stream_inc/stream_rawpkt.h27
-rw-r--r--module_test/src/gtest_sapp_comm.cpp2
-rw-r--r--module_test/src/gtest_sapp_fun.h11
-rw-r--r--src/common/MESA_jump_layer.cpp7
-rw-r--r--tools/CMakeLists.txt15
-rw-r--r--tools/tcpdumpmesa.zipbin0 -> 1465218 bytes
15 files changed, 201 insertions, 249 deletions
diff --git a/benchmark/include/sapp_bchmk_inner.h b/benchmark/include/sapp_bchmk_inner.h
index 935bde3..76a7f5b 100644
--- a/benchmark/include/sapp_bchmk_inner.h
+++ b/benchmark/include/sapp_bchmk_inner.h
@@ -1,29 +1,20 @@
#ifndef _SAPP_BCHMK_INNER_H_
#define _SAPP_BCHMK_INNER_H_ 1
-#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
-#include <assert.h>
-#include <time.h>
#include <arpa/inet.h>
#include <sys/types.h> /* See NOTES */
#include <sys/socket.h>
#include <sys/un.h>
#include <linux/limits.h>
-#include <errno.h>
-#include "stream.h"
-#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <pthread.h>
#include <pcap/pcap.h>
#include "wrap_cJSON.h"
-#include "MESA_jump_layer.h"
-#include "MESA_handle_logger.h"
-#include "MESA_prof_load.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -58,10 +49,11 @@ extern "C" {
#define SAPP_BCHMK_DEFAULT_CFG_FILE_DIR "sapp_default_config"
+#include "MESA_handle_logger.h"
extern void * __g_sapp_benchmark_log_handle;
#define sapp_bchmk_log(h, log_level, format, args...) do{if(((benchmark_engine_t *)h)->plug_opt.MESA_log_handle) {MESA_handle_runtime_log(((benchmark_engine_t *)h)->plug_opt.MESA_log_handle, log_level, "sapp_benchmark", format, ##args);} }while(0)
-/* �ڴ����index��0��ʼ, ����Ϊ�˷����wireshark�Աȷ���, ���������ļ���index����1��ʼ, ��Ҫ��һ��ת�� */
+/* �ڴ����index��0��ʼ, ����Ϊ�˷����wireshark�Աȷ���, ���������ļ���index����1��ʼ, ��Ҫ��һ��ת�� */
#define ADJUST_ARRAY_INDEX_to_WIRESHARK(n) do{ n = n + 1;}while(0)
#define ADJUST_WIRESHARK_INDEX_to_ARRAY(n) do{ n = n + 1;}while(0)
@@ -88,23 +80,24 @@ typedef struct{
typedef struct{
- int pkt_len; /* pcapÿ��eth���ij��� */
- const struct ethhdr *pkt_data; /* �洢pcap�����ݵ�ָ������ */
- //char md5sum_with_timestamp[MD5_STRING_MAX_LEN]; /* ��Ϊ�ظ������ش���md5������ȫ��һ����, Ҫ����ʱ��� */
+ int pkt_len; /* pcapÿ��eth���ij��� */
+ const struct ethhdr *pkt_data; /* �洢pcap�����ݵ�ָ������ */
+ //char md5sum_with_timestamp[MD5_STRING_MAX_LEN]; /* ��Ϊ�ظ������ش���md5������ȫ��һ����, Ҫ����ʱ��� */
}pcap_pkt_detail_t;
typedef struct{
- int pkt_num; /* ���pcap����һ�����ٸ����ݰ� */
+ int pkt_num; /* ���pcap����һ�����ٸ����ݰ� */
pcap_pkt_detail_t *pkt_array;
}pcap_pkt_image_t;
+#include "stream.h"
typedef struct{
enum sapp_deploment_mode_t sapp_deploy_mode;
int tap_internal_fd;
int tap_external_fd;
- int last_replay_fd; /* ��¼�Ǵ��ĸ���������ȥ��, ֻ��˫��ģʽ������, inline��mirror�϶�����tap_up */
+ int last_replay_fd; /* ��¼�Ǵ��ĸ���������ȥ��, ֻ��˫��ģʽ������, inline��mirror�϶�����tap_up */
}pkt_process_engine_t;
@@ -118,8 +111,8 @@ typedef struct{
}plug_opt_t;
-/* ����debug, ԭʼ��ע���, �ִ������յ������ݰ�, (������Э��ջ�Զ������Ĺ㲥���鲥��),
- ������forward��, �����Dz����ע���, Ҳ����һ����û��, ����DROP��!
+/* ����debug, ԭʼ��ע���, �ִ������յ������ݰ�, (������Э��ջ�Զ������Ĺ㲥���鲥��),
+ ������forward��, �����Dz����ע���, Ҳ����һ����û��, ����DROP��!
*/
typedef struct{
int pkt_index;
@@ -168,9 +161,9 @@ int sapp_bchmk_create_process_engine(benchmark_engine_t *bch_engine);
int sapp_bchmk_md5_checksum(const char *filename, const char *expect_md5sum);
/*
- ע��:
- �˺���ʵ�ʷ��ص���TRUE��FALSE,
- 0��ʾ��һ��, 1��ʾһ��!!
+ ע��:
+ �˺���ʵ�ʷ��ص���TRUE��FALSE,
+ 0��ʾ��һ��, 1��ʾһ��!!
*/
cJSON_bool sapp_bchmk_json_file_compare(benchmark_engine_t *, const char *json_file1, const char *json_file2, cJSON_Compare_Opt_t opt);
diff --git a/benchmark/include/sapp_benchmark.h b/benchmark/include/sapp_benchmark.h
index 0067149..401078f 100644
--- a/benchmark/include/sapp_benchmark.h
+++ b/benchmark/include/sapp_benchmark.h
@@ -1,23 +1,17 @@
#ifndef _SAPP_BENCHMARK_H_
#define _SAPP_BENCHMARK_H_ 1
-#include <stdlib.h>
-#include <stdio.h>
#include <unistd.h>
#include <netinet/ip.h>
+#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
-#include <assert.h>
-#include <time.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
-#include <errno.h>
-#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
-#include "stream.h"
#ifdef __cplusplus
diff --git a/benchmark/src/sapp_benchmark.cpp b/benchmark/src/sapp_benchmark.cpp
index d122591..554cdbc 100644
--- a/benchmark/src/sapp_benchmark.cpp
+++ b/benchmark/src/sapp_benchmark.cpp
@@ -1,16 +1,18 @@
-#include "wrap_cJSON.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "wrap_cJSON.h"
#include "sapp_benchmark.h"
#include "sapp_bchmk_inner.h"
-#include "stream.h"
#include "stream_entry.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/ip.h>
+#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
-#include <assert.h>
#include <time.h>
#include <arpa/inet.h>
#include <sys/types.h> /* See NOTES */
@@ -21,10 +23,9 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include "MESA_prof_load.h"
+
-#ifdef __cplusplus
-extern "C" {
-#endif
/* 因为sapp插件获取不到 benchmark_engine_t 句柄, 只能暂时靠全局变量传递一下,
TODO: 有什么更好的方式?
@@ -470,7 +471,6 @@ static int sapp_bchmk_env_prepare(benchmark_engine_t *bch_engine)
return 0;
}
-
/*
根据内层ip确定一个传输方向, 用于双臂串联模式从哪个网卡发出.
*/
diff --git a/benchmark/src/sapp_benchmark_utils.cpp b/benchmark/src/sapp_benchmark_utils.cpp
index 40aec01..6c80c7e 100644
--- a/benchmark/src/sapp_benchmark_utils.cpp
+++ b/benchmark/src/sapp_benchmark_utils.cpp
@@ -1,8 +1,13 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include "sapp_benchmark.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <netinet/ip.h>
+#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <assert.h>
@@ -12,8 +17,6 @@
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
-#include "stream.h"
-#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
@@ -26,9 +29,8 @@
#include "wrap_cJSON.h"
#include "sapp_bchmk_inner.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include "MESA_prof_load.h"
+
@@ -102,9 +104,9 @@ static int ifconfig_device_up(const char *interface_name)
printf("Create Socket Failed.\n");
return -2;
}
- //ָ������������up
+ //ָ������������up
sprintf(ifr.ifr_name, "%s", interface_name);
- /* ��ýӿڵı�־ */
+ /* ��ýӿڵı�־ */
if ((err = ioctl(socket_fd, SIOCGIFFLAGS, (void *)&ifr)) < 0) {
fprintf(stderr, "ifconfig_device_up(%s), ioctl SIOCGIFFLAGS: %s\n", interface_name, strerror(errno));
close(socket_fd);
@@ -143,7 +145,7 @@ int ifconfig_device_mtu(const char *interface_name, int mtu_val)
return -2;
}
sprintf(ifr.ifr_name, "%s", interface_name);
- /* ��ýӿڵı�־ */
+ /* ��ýӿڵı�־ */
if ((err = ioctl(socket_fd, SIOCGIFMTU, (void *)&ifr)) < 0) {
fprintf(stderr, "ifconfig_device_mtu(%s), ioctl SIOCGIFMTU: %s\n", interface_name, strerror(errno));
close(socket_fd);
@@ -191,14 +193,14 @@ static int tuntap_dev_create(char *dev, int flags)
ifconfig_device_up(dev);
- ifconfig_device_mtu(dev, 2000); /* ijЩpcap�����ܿ�����offload, ����vlan, vxlan��, ����MTU */
+ ifconfig_device_mtu(dev, 2000); /* ijЩpcap�����ܿ�����offload, ����vlan, vxlan��, ����MTU */
return fd;
}
/*
- �������, ���mirror, inlineģʽ�Ǵ���һ��TAP, transparent�Ǵ�������TAP,
- ֱ�Ӷ�ȡ����sapp.toml�ļ�.
+ �������, ���mirror, inlineģʽ�Ǵ���һ��TAP, transparent�Ǵ�������TAP,
+ ֱ�Ӷ�ȡ����sapp.toml�ļ�.
*/
int sapp_bchmk_create_process_engine(benchmark_engine_t *bch_engine)
{
@@ -289,9 +291,9 @@ int sapp_bchmk_md5_checksum(const char *filename, const char *expect_md5sum)
}
/*
- ע��:
- �˺���ʵ�ʷ��ص���TRUE��FALSE,
- 0��ʾ��һ��, 1��ʾһ��!!
+ ע��:
+ �˺���ʵ�ʷ��ص���TRUE��FALSE,
+ 0��ʾ��һ��, 1��ʾһ��!!
*/
cJSON_bool sapp_bchmk_json_file_compare(benchmark_engine_t *bchmk_engine, const char *json_file1, const char *json_file2, cJSON_Compare_Opt_t opt)
{
@@ -429,7 +431,7 @@ int sapp_bchmk_gen_pcap_file(benchmark_engine_t *bchmk_engine, const pcap_pkt_de
/*
- ���ڴ��е�һ��ԭʼ����, ������pcap�ļ�, �ٵ���tshark -T ����һ��json�ļ�.
+ ���ڴ��е�һ��ԭʼ����, ������pcap�ļ�, �ٵ���tshark -T ����һ��json�ļ�.
*/
int sapp_bchmk_gen_tshark_json(benchmark_engine_t *bchmk_engine, const pcap_pkt_detail_t *pkt_detail, int pkt_num, const char *tshark_json_filename)
{
@@ -478,7 +480,7 @@ int sapp_bchmk_need_drop_cur_pkt(benchmark_engine_t *bchmk_engine, int pkt_index
array_size = cJSON_GetArraySize(sub_pkt_index_item);
- /* ��C�����±�ת��Ϊwireshark�����ݰ����, ��ʵ���Ǽ�1 */
+ /* ��C�����±�ת��Ϊwireshark�����ݰ����, ��ʵ���Ǽ�1 */
ADJUST_ARRAY_INDEX_to_WIRESHARK(pkt_index);
for(i = 0; i < array_size; i++){
@@ -492,9 +494,9 @@ int sapp_bchmk_need_drop_cur_pkt(benchmark_engine_t *bchmk_engine, int pkt_index
}
/*
- ����ֵ: Ҫ���˰����������json file name.
+ ����ֵ: Ҫ���˰����������json file name.
- �����NULL, ��Ҫ�����ж�һ��errno, �Ƿ�����Ϊjson��ʽ����, û��дpacket_detail_json_file.
+ �����NULL, ��Ҫ�����ж�һ��errno, �Ƿ�����Ϊjson��ʽ����, û��дpacket_detail_json_file.
*/
const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine, int pkt_index)
{
@@ -520,7 +522,7 @@ const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine,
array_size = cJSON_GetArraySize(sub_pkt_detail_item);
- /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �����±��0��ʼ */
+ /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �����±��0��ʼ */
ADJUST_ARRAY_INDEX_to_WIRESHARK(pkt_index);
for(i = 0; i < array_size; i++){
@@ -546,7 +548,7 @@ const char *sapp_bchmk_need_check_forward_pkt(benchmark_engine_t *bchmk_engine,
}
/*
- ����ֵ: ָ��inject���cjson�ṹ��ָ��.
+ ����ֵ: ָ��inject���cjson�ṹ��ָ��.
*/
const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine, int carray_pkt_index)
{
@@ -566,9 +568,9 @@ const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine,
return NULL;
}
- /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �˴������0��ʼ */
+ /* ע��: Ϊ�˷����wireshark�Ա�, pkt index��1��ʼ����, �˴������0��ʼ */
if(sub_array_pkt_index_item->valueint != (carray_pkt_index+1)){
- /* ��ǰ�����ᴥ��inject����, do nothing */
+ /* ��ǰ�����ᴥ��inject����, do nothing */
sapp_bchmk_log(bchmk_engine,RLOG_LV_DEBUG, "pkt index:%d, don't need check inject json, ignore it", carray_pkt_index+1);
errno = 0;
return NULL;
@@ -578,7 +580,7 @@ const cJSON *sapp_bchmk_need_check_inject_pkt(benchmark_engine_t *bchmk_engine,
}
/*
- ����ֵ: ָ��control���cjson�ṹ��ָ��.
+ ����ֵ: ָ��control���cjson�ṹ��ָ��.
*/
const cJSON *sapp_bchmk_need_process_control(benchmark_engine_t *bchmk_engine, int carray_pkt_index)
{
@@ -604,13 +606,13 @@ const cJSON *sapp_bchmk_need_process_control(benchmark_engine_t *bchmk_engine, i
/*
- ÿ�β���ǰ, ����sapp��Ĭ�����ø������л���,
- ��Ҫ�޸ĵ����ò���, ÿ��ҲҪ�ֳ��޸�,
- ������Ĭ�ϲ��������²��Բ�ͨ��.
+ ÿ�β���ǰ, ����sapp��Ĭ�����ø������л���,
+ ��Ҫ�޸ĵ����ò���, ÿ��ҲҪ�ֳ��޸�,
+ ������Ĭ�ϲ��������²��Բ�ͨ��.
- ��sapp�������ļ�ֱ�ӷ������.c����, ����cmake install, ��rpm -iʱ�Ͳ���װһ���ļ���,
- ���������װʱʹ��--prefix����, ������Ҳ�����Щ�ļ���.
- ֱ�Ӵӳ�����copy����.
+ ��sapp�������ļ�ֱ�ӷ������.c����, ����cmake install, ��rpm -iʱ�Ͳ���װһ���ļ���,
+ ���������װʱʹ��--prefix����, ������Ҳ�����Щ�ļ���.
+ ֱ�Ӵӳ�����copy����.
*/
static void sapp_bchmk_write_to_file(const char *config_name, const void *content, int content_len)
@@ -657,7 +659,7 @@ void sapp_bchmk_set_default_config(void)
sapp_bchmk_write_to_file("etc/send_raw_pkt.conf", templete_send_raw_pkt, templete_send_raw_pkt_len);
sapp_bchmk_write_to_file("etc/send_log.conf", templete_sapp_log, templete_sapp_log_len);
- /* ������plug.inf����, ֻ���������ͷ���ֶ� */
+ /* ������plug.inf����, ֻ���������ͷ���ֶ� */
system("mkdir -p ./plug/business/gtest_sapp");
system("echo \"[PLUGINFO]\" > ./plug/business/gtest_sapp/gtest_sapp.inf");
system("echo \"PLUGNAME=xxxx\" >> ./plug/business/gtest_sapp/gtest_sapp.inf");
@@ -734,7 +736,7 @@ const char *sapp_bchmk_rawpkt_ntop_v6(const struct ip6_hdr *ip6hdr, char *res_bu
dport = inner_uhdr->dest;
snprintf(res_buf, buf_len, "%s.%u --> %s.%u, %s", ip_src_str, ntohs(sport),
ip_dst_str, ntohs(dport), "UDP");
- }else if(IPPROTO_ICMPV6 == inner_ip_proto){ /* ע��: ipv6��icmpͷ���ֶ���ipv4��һ��!! */
+ }else if(IPPROTO_ICMPV6 == inner_ip_proto){ /* ע��: ipv6��icmpͷ���ֶ���ipv4��һ��!! */
snprintf(res_buf, buf_len, "%s --> %s,ICMP", ip_src_str, ip_dst_str);
}else{
snprintf(res_buf, buf_len, "%s --> %s, unknown protocol:%u", ip_src_str, ip_dst_str, inner_ip_proto);
diff --git a/include/private/mesa_net.h b/include/private/mesa_net.h
index ceff7cc..4da2513 100644
--- a/include/private/mesa_net.h
+++ b/include/private/mesa_net.h
@@ -1,7 +1,5 @@
-#ifndef _MESA_NET_H_
-#define _MESA_NET_H_
+#pragma once
-#include <stdio.h>
#include <endian.h>
#include <netinet/in.h>
#include <netinet/ip_icmp.h>
@@ -412,8 +410,8 @@ struct mesa_pppoe_session_hdr{
unsigned short session_id;
unsigned short len;
/* to do:
- pppӦ�õ�����Ϊһ�����, Ϊ�˼򻯴���, ǿ�ƽ����PPPOE_SES����һ��,
- �����Ҫ����PPPЭ�̹���, �˽ṹ��Ҫ�Ķ�.
+ pppӦ�õ�����Ϊһ�����, Ϊ�˼򻯴���, ǿ�ƽ����PPPOE_SES����һ��,
+ �����Ҫ����PPPЭ�̹���, �˽ṹ��Ҫ�Ķ�.
*/
unsigned short ppp_protocol;
}BYTE_ALIGNED(1);
@@ -500,11 +498,11 @@ enum pptp_control_message_type{
};
struct mesa_pptp_control_hdr{
- unsigned short length; /* ȫ�����ݳ���, ������ͷ�� */
+ unsigned short length; /* ȫ�����ݳ���, ������ͷ�� */
unsigned short pptp_message_type;
unsigned int magic_cookie;
unsigned short control_message_type;
- char ignore_bytes[0]; /* �����ֶ��ݲ�����, ����Ҳ��һ�� */
+ char ignore_bytes[0]; /* �����ֶ��ݲ�����, ����Ҳ��һ�� */
};
struct mesa_vlan_hdr{
@@ -520,7 +518,7 @@ struct mesa_vlan_detail_hdr{
unsigned short type;
};
-/* 2018-08-28 lijia add, for pangu ��Ŀmac_in_mac���� */
+/* 2018-08-28 lijia add, for pangu ��Ŀmac_in_mac���� */
struct mesa_mac_in_mac_net_hdr{
unsigned int route_dir:1;
unsigned int link_id:3;
@@ -595,7 +593,7 @@ struct mesa_gre_base_hdr_v1{
unsigned short protocol;
};
-#define GRE_SRE_MAX_LEN (256) /* �����Ϊһ���ֽ�, 256 */
+#define GRE_SRE_MAX_LEN (256) /* �����Ϊһ���ֽ�, 256 */
struct gre_source_route_entry_hdr{
unsigned short address_family;
unsigned char sre_offset;
@@ -603,7 +601,7 @@ struct gre_source_route_entry_hdr{
unsigned char sre_entry_list[GRE_SRE_MAX_LEN];
};
-/* ���п��ܵ�ֵ����, ��Ҫ����mesa_gre_base_hdr����bit��ֵ, �ж��Ƿ�������ֵ */
+/* ���п��ܵ�ֵ����, ��Ҫ����mesa_gre_base_hdr����bit��ֵ, �ж��Ƿ�������ֵ */
struct mesa_gre_extend_hdr{
unsigned short checksum; //version0
unsigned short offset; //version0, if checksum present, then offset also present
@@ -616,7 +614,7 @@ struct mesa_gre_extend_hdr{
};
struct mesa_gre_hdr{
- /* version0��version1��ͷ����, version�ֶ�ʱһ�µ�, ������С����, Ĭ��ʹ��v0��ʽ���� */
+ /* version0��version1��ͷ����, version�ֶ�ʱһ�µ�, ������С����, Ĭ��ʹ��v0��ʽ���� */
struct mesa_gre_base_hdr_v0 gre_base;
struct mesa_gre_extend_hdr gre_extend;
};
@@ -732,8 +730,8 @@ struct l2tp_avp{
#define ISAKMP_EXCHANGE_TYPE_AUTH (3)
#define ISAKMP_EXCHANGE_TYPE_AGGRESS (4)/* RFC-2409 page8, Aggressive mode is instantiation os ISAKMP Aggressive Exchange */
#define ISAKMP_EXCHANGE_TYPE_INFO (5)
-#define ISAKMP_EXCHANGE_TYPE_FEATURE_USE_BEGIN (6) /* 6-31��ֵ�ݲ����� */
-#define ISAKMP_EXCHANGE_TYPE_FEATURE_USE_END (31) /* 6-31��ֵ�ݲ����� */
+#define ISAKMP_EXCHANGE_TYPE_FEATURE_USE_BEGIN (6) /* 6-31��ֵ�ݲ����� */
+#define ISAKMP_EXCHANGE_TYPE_FEATURE_USE_END (31) /* 6-31��ֵ�ݲ����� */
struct mesa_isakmp_hdr{ /* RFC2408-Page22 */
unsigned long long init_cookie;
@@ -807,14 +805,14 @@ struct teredo_auth_hdr{
#define MAX_ADDR_TYPE_STRING_LEN (64)
#define MAX_ADDR_LIST_STRING_LEN (2048)
-#define MAX_ADDR_EMBED_LAYER_NUM (20) /* ����ַǶ�ײ��� */
-#define MAX_ADDR_BIN_VALUE_LEN (40) /* paddrʵ��������󳤶�, Ŀǰ��tuple4v6� */
+#define MAX_ADDR_EMBED_LAYER_NUM (20) /* ����ַǶ�ײ��� */
+#define MAX_ADDR_BIN_VALUE_LEN (40) /* paddrʵ��������󳤶�, Ŀǰ��tuple4v6� */
-/* ����ģʽ��, ��¼MAC��ַ���ڷ��� */
+/* ����ģʽ��, ��¼MAC��ַ���ڷ��� */
struct packet_io_mac_addr{
struct mesa_ethernet_hdr eth_hdr;
char route_dir;
- char __pad__; /* ����ṹ8�ֽڶ��� */
+ char __pad__; /* ����ṹ8�ֽڶ��� */
};
@@ -827,7 +825,7 @@ struct hdlc_net_hdr{
-/* ������������ֶ�, ��Ϊ������, network order */
+/* ������������ֶ�, ��Ϊ������, network order */
#define VXLAN_KEEPALIVE_PKT_PORT (3784)
#define VXLAN_OVERLAY_PKT_PORT (4789)
@@ -843,7 +841,7 @@ struct __inline_vxlan_hdr{
unsigned char reserved[3];
/*--------int delim -------*/
unsigned char vlan_id_half_high;
- unsigned char link_layer_type : 4; /* ���㱨�ķ�װ��ʽ */
+ unsigned char link_layer_type : 4; /* ���㱨�ķ�װ��ʽ */
unsigned char vlan_id_half_low : 4;
unsigned int dir : 1;
@@ -879,5 +877,4 @@ const char *sapp_raw_ipv6_ntop(const struct mesa_ip6_hdr *ip6_hdr, char *out_buf
}
#endif
-#endif
diff --git a/include/private/sapp_declaration.h b/include/private/sapp_declaration.h
index 4d11b23..6b9c21c 100644
--- a/include/private/sapp_declaration.h
+++ b/include/private/sapp_declaration.h
@@ -98,6 +98,7 @@ extern volatile long long g_current_time_ms;
#define g_ipv6_send_packet_enabled sapp_global_val->config.protocol_feature.ipv6_send_packet_enabled
#define G_SKIP_NOT_IP_LAYER sapp_global_val->config.protocol_feature.skip_not_ip_layer_over_eth
+#include "MESA_handle_logger.h"
#define sapp_runtime_log(log_level, format, ...) \
do \
{ \
diff --git a/include/private/stream_internal.h b/include/private/stream_internal.h
index e103920..f68b518 100644
--- a/include/private/stream_internal.h
+++ b/include/private/stream_internal.h
@@ -2,14 +2,10 @@
#define _APP_STREAM_INTERNAL_H_
#include "mesa_net.h"
-#include "public/stream.h"
#include "private/mesa_net.h"
-#include "private/sysinfo.h"
-#include "MESA_handle_logger.h"
#include "mesa_pkt_dump.h"
#include "sapp_limits.h"
-#include "sapp_mem.h"
-#include "MESA_jump_layer.h"
+#include "stream.h"
//#define STREAM_BASE_MD5_CHECK "dd09b3b11993cc835200db477dad7d4b"
//#define STREAM_CONTROL_MD5_CHECK "75aab0821e489b84355fa22ad02a2e78"
diff --git a/include/public/stream_inc/MESA_jump_layer.h b/include/public/stream_inc/MESA_jump_layer.h
deleted file mode 100644
index d5715fe..0000000
--- a/include/public/stream_inc/MESA_jump_layer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __MESA_JUMP_LAYER_H_
-#define __MESA_JUMP_LAYER_H_ 1
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "stream.h"
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-
-
-const char *MESA_jump_layer_get_last_error(void);
-
-
-/*
- CHN : ���ݰ�ͷ��ƫ�ƺ���.
-
- ����:
- raw_data: ��ǰ���ͷ��ָ��;
- raw_layer_type: ��ǰ��ĵ�ַ����, ���: enum addr_type_t ;
- expect_layer_type: ������ת���ĵ�ַ����, ���: enum addr_type_t ;
-
- ����ֵ:
- NULL: �޴˵�ַ;
- NON-NULL: ��Ӧ���ͷ����ַ.
-
- ����:
- ���赱ǰ��ΪEthernet, ��ʼ��ͷ��ַΪthis_layer_hdr, ����ת��IPv6��ͷ��:
- struct ip6_hdr *ip6_header;
- ip6_header = MESA_net_jump_to_layer(this_layer_hdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
-*/
-const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
-
-/*
- MESA_jump_layer_greedy��MESA_jump_layer������:
- ��������Ƕ��Э����˵,
- MESA_jump_layer��ת����һ��expect_layer_type;
- MESA_jump_layer_greedy��ת�����ڲ��expect_layer_type;
-*/
-const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
-
-
-
-/* ��ǰ������ǰ�Ľӿ�����, ����ͬ�� */
-const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
-const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
-
-
-
-const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len );
-const char *MESA_jump_layer_ipv6_ntop(const struct ip6_hdr *ip6_hdr, char *out_buf, int buf_len);
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/include/public/stream_inc/stream_base.h b/include/public/stream_inc/stream_base.h
index 0bf8f55..58d78d4 100644
--- a/include/public/stream_inc/stream_base.h
+++ b/include/public/stream_inc/stream_base.h
@@ -5,13 +5,7 @@
#include <sys/types.h>
#include <netinet/in.h>
-#include <netinet/ip.h>
-#include <netinet/ip6.h>
-#include <netinet/tcp.h>
-#include <netinet/udp.h>
#include <linux/if_ether.h>
-#include <stdlib.h>
-#include <string.h>
#ifndef UINT8
typedef unsigned char UINT8;
@@ -30,28 +24,28 @@ typedef unsigned int UINT32;
typedef unsigned long long UINT64;
#endif
-/* CHN : ������� */
+/* CHN : ������� */
/* ENG : stream direction definition*/
#define DIR_C2S 0x01
#define DIR_S2C 0x02
#define DIR_DOUBLE 0x03
-/* CHN : ����ײ㴫�䷽����,����ģʽ������ */
+/* CHN : ����ײ㴫�䷽����,����ģʽ������ */
/* ENG : network topology route direction, is valid in serial mode */
#define DIR_ROUTE_UP 0x00
#define DIR_ROUTE_DOWN 0x01
-/* CHN : ���������Ͷ��� */
+/* CHN : ���������Ͷ��� */
/* ENG : single packet type definition */
#define PKT_TYPE_NORMAL (0x0) /* normal, common */
-#define PKT_TYPE_IPREBUILD (1<<0) /* ip frag reassembled packet; ip��Ƭ���鱨�� */
-#define PKT_TYPE_TCPUNORDER (1<<1) /* TCP out of order packet; TCP������ */
-#define PKT_TYPE_TCPREORDER (1<<2) /* TCP sequential packet; TCP��������õ����ݰ� */
-#define PKT_TYPE_TCPRETRANS (1<<3) /* TCP retransmit packet; TCP�ش����� */
-#define PKT_TYPE_IP_FRAG (1<<4) /* IP frag packet; IP��Ƭ�� */
-#define PKT_TYPE_IP_FRAG_LAST (1<<5) /* last IP frag packet; ͬ����һ��ԭʼ����IP�������һ��IP��Ƭ�� */
-
-/* CHN : ��ַ���Ͷ���, ��ͨ������ addr_type_to_string() ת���ַ�����ʽ. */
+#define PKT_TYPE_IPREBUILD (1<<0) /* ip frag reassembled packet; ip��Ƭ���鱨�� */
+#define PKT_TYPE_TCPUNORDER (1<<1) /* TCP out of order packet; TCP������ */
+#define PKT_TYPE_TCPREORDER (1<<2) /* TCP sequential packet; TCP��������õ����ݰ� */
+#define PKT_TYPE_TCPRETRANS (1<<3) /* TCP retransmit packet; TCP�ش����� */
+#define PKT_TYPE_IP_FRAG (1<<4) /* IP frag packet; IP��Ƭ�� */
+#define PKT_TYPE_IP_FRAG_LAST (1<<5) /* last IP frag packet; ͬ����һ��ԭʼ����IP�������һ��IP��Ƭ�� */
+
+/* CHN : ��ַ���Ͷ���, ��ͨ������ addr_type_to_string() ת���ַ�����ʽ. */
/* ENG : address type, transform to string mode by call addr_type_to_string(). */
enum addr_type_t{
__ADDR_TYPE_INIT = 0,
@@ -80,14 +74,14 @@ enum addr_type_t{
#define TCP_TAKEOVER_STATE_FLAG_ON 1
-/* CHN : Ӧ�ò㿴��������״̬���� */
+/* CHN : Ӧ�ò㿴��������״̬���� */
/* ENG : stream state for protocol or business plug*/
#define OP_STATE_PENDING 0
#define OP_STATE_TIMED 1 /* is obsolete */
#define OP_STATE_CLOSE 2
#define OP_STATE_DATA 3
-/* CHN : Ӧ�ò㷵�ؽ������ */
+/* CHN : Ӧ�ò㷵�ؽ������ */
/* ENG : return value of plug */
#define APP_STATE_GIVEME 0x00
#define APP_STATE_FAWPKT 0x00
@@ -98,14 +92,14 @@ enum addr_type_t{
#define APP_STATE_DROPPKT 0x10
-#define APP_STATE_KILL_FOLLOW 0x40 /* ǿ��CLOSE��ǰ������������в�� */
-#define APP_STATE_KILL_OTHER 0x80 /* ǿ��CLOSE����ǰ���������в�� */
+#define APP_STATE_KILL_FOLLOW 0x40 /* ǿ��CLOSE��ǰ������������в�� */
+#define APP_STATE_KILL_OTHER 0x80 /* ǿ��CLOSE����ǰ���������в�� */
-/* CHN : �������Ͷ��� */
+/* CHN : �������Ͷ��� */
/* ENG : stream type */
enum stream_type_t{
- STREAM_TYPE_NON = 0, /* No stream concept indeed, such as vlan, IP, etc.; �����ĸ���, ��VLAN, IP��� */
+ STREAM_TYPE_NON = 0, /* No stream concept indeed, such as vlan, IP, etc.; �����ĸ���, ��VLAN, IP��� */
STREAM_TYPE_TCP,
STREAM_TYPE_UDP, /* there is no stream of UDP in RFC, but in MESA platform, we build a UDP stream with same tuple4 packet */
STREAM_TYPE_VLAN,
@@ -120,12 +114,12 @@ enum stream_type_t{
};
/*
- CHN: ���ĵײ������������,
- ��ͬ��stream_type_t, ���統ǰ��ΪSTREAM_TYPE_TCP, ���ײ��������Ϳ�����STREAM_TUNNLE_PPTP.
- ��Ϊ���������Ƕ��ֲ�ͬ����Ƕ�����, ֻ��¼��ײ�(��MAC�������)��������.
+ CHN: ���ĵײ������������,
+ ��ͬ��stream_type_t, ���統ǰ��ΪSTREAM_TYPE_TCP, ���ײ��������Ϳ�����STREAM_TUNNLE_PPTP.
+ ��Ϊ���������Ƕ��ֲ�ͬ����Ƕ�����, ֻ��¼��ײ�(��MAC�������)��������.
*/
enum stream_carry_tunnel_t{
- STREAM_TUNNLE_NON = 0, /* default is 0, not tunnel; Ĭ��Ϊ0, ������; */
+ STREAM_TUNNLE_NON = 0, /* default is 0, not tunnel; Ĭ��Ϊ0, ������; */
STREAM_TUNNLE_6OVER4 = 1 << 0,
STREAM_TUNNLE_4OVER6 = 1 << 1,
STREAM_TUNNLE_GRE = 1 << 2,
@@ -138,7 +132,7 @@ enum stream_carry_tunnel_t{
};
typedef struct raw_ipfrag_list{
- void *frag_packet; /* ��ip��ͷ, �ӵײ�������ȡ��ԭʼ��ͷ */
+ void *frag_packet; /* ��ip��ͷ, �ӵײ�������ȡ��ԭʼ��ͷ */
int pkt_len;
int type; /* IPv4 or IPv6 */
struct raw_ipfrag_list *next;
@@ -147,7 +141,7 @@ typedef struct raw_ipfrag_list{
#ifndef STRUCT_TUPLE4_DEFINED
#define STRUCT_TUPLE4_DEFINED (1)
-/* compat for start, papp; ����start, papp */
+/* compat for start, papp; ����start, papp */
struct tuple4 {
u_int saddr;
u_int daddr;
@@ -235,9 +229,9 @@ struct layer_addr_pppoe_session
struct layer_addr_mac
{
/*
- C2S��S2C�������Բ�ͬ����·���豸, �ᵼ�����������mac��ַȫ��һ��, ����ע��ʱ�����ô�ͳ��ʽ, ���򵥵ĵߵ�src��dst,
- �޸Ķ�������, mirrorģʽ��, ���Ǵ洢��src_addr��,
- API��ͬ��, ABI������ǰ���ݵ�, �ṹ���ڴ�ֲ���֮ǰ��һ��.
+ C2S��S2C�������Բ�ͬ����·���豸, �ᵼ�����������mac��ַȫ��һ��, ����ע��ʱ�����ô�ͳ��ʽ, ���򵥵ĵߵ�src��dst,
+ �޸Ķ�������, mirrorģʽ��, ���Ǵ洢��src_addr��,
+ API��ͬ��, ABI������ǰ���ݵ�, �ṹ���ڴ�ֲ���֮ǰ��һ��.
*/
struct ethhdr src_addr;
struct ethhdr dst_addr;
@@ -251,9 +245,9 @@ struct layer_addr_ipv4
UINT32 saddr; /* network order */
UINT32 daddr; /* network order */
/* 2014-04-21 lijia add,
- Ϊ�˽�Լ�ڴ�ռ䡢�ʹ���Ч��, ��ǿ�ư�Э���δ���,
- IP���TCP����Ϊһ����,
- �����������IP, �˿���ϢΪ0;
+ Ϊ�˽�Լ�ڴ�ռ䡢�ʹ���Ч��, ��ǿ�ư�Э���δ���,
+ IP���TCP����Ϊһ����,
+ �����������IP, �˿���ϢΪ0;
*/
UINT16 source; /* network order */
UINT16 dest; /* network order */
@@ -264,9 +258,9 @@ struct layer_addr_ipv6
UCHAR saddr[IPV6_ADDR_LEN] ; /* network order */
UCHAR daddr[IPV6_ADDR_LEN] ; /* network order */
/* 2014-04-21 lijia add,
- Ϊ�˽�Լ�ڴ�ռ䡢�ʹ���Ч��, ��ǿ�ư�Э���δ���,
- IP���TCP����Ϊһ����,
- �����������IP, �˿���ϢΪ0;
+ Ϊ�˽�Լ�ڴ�ռ䡢�ʹ���Ч��, ��ǿ�ư�Э���δ���,
+ IP���TCP����Ϊһ����,
+ �����������IP, �˿���ϢΪ0;
*/
UINT16 source;/* network order */
UINT16 dest;/* network order */
@@ -291,17 +285,17 @@ struct layer_ppp_hdr{
unsigned short protocol; /* network order */
}__attribute__((packed));
-/* һ�������, address,control���ǹ̶������,����0xFF,0x03, ppp hdr�ǿ���ѹ���Խ�Լ����,ֻ����һ���ֽڵ�protocol�ֶ� */
+/* һ�������, address,control���ǹ̶������,����0xFF,0x03, ppp hdr�ǿ���ѹ���Խ�Լ����,ֻ����һ���ֽڵ�protocol�ֶ� */
struct layer_compress_ppp_hdr{
unsigned char protocol;
};
struct layer_addr_l2tp_v2_t{
- UINT16 tunnelid_C2S; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
- UINT16 tunnelid_S2C; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
- UINT16 sessionid_C2S; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
- UINT16 sessionid_S2C; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
+ UINT16 tunnelid_C2S; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
+ UINT16 tunnelid_S2C; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
+ UINT16 sessionid_C2S; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
+ UINT16 sessionid_S2C; /* network order, �Դ���㴴�����ķ���Ϊ׼ */
unsigned char seq_present_C2S;
unsigned char seq_present_S2C;
unsigned char ppp_hdr_compress_enable;
@@ -335,15 +329,15 @@ struct single_layer_mpls_addr{ /* refer to RFC3032 */
};
/*
- MPLS�п����Ƕ��Ƕ��, sapp�Ѷ��ϲ�����, Ŀǰ���֧��4��, ���������⵽������, 0��ʾ�����, 3��ʾ���ڲ�
- ����һ���ڲ�TCP/UDP����˵, �ײ�MPLS��������ĵ�ַ���ܲ�һ��, �ֱ��Ϊcs2_addr, s2c_addr.
+ MPLS�п����Ƕ��Ƕ��, sapp�Ѷ��ϲ�����, Ŀǰ���֧��4��, ���������⵽������, 0��ʾ�����, 3��ʾ���ڲ�
+ ����һ���ڲ�TCP/UDP����˵, �ײ�MPLS��������ĵ�ַ���ܲ�һ��, �ֱ��Ϊcs2_addr, s2c_addr.
*/
struct layer_addr_mpls
{
struct single_layer_mpls_addr c2s_addr_array[MAX_MPLS_ADDR_LAYER];
struct single_layer_mpls_addr s2c_addr_array[MAX_MPLS_ADDR_LAYER];
- char c2s_layer_num; /* ʵ��mpls���� */
- char s2c_layer_num; /* ʵ��mpls���� */
+ char c2s_layer_num; /* ʵ��mpls���� */
+ char s2c_layer_num; /* ʵ��mpls���� */
char c2s_has_ctrl_word;
char s2c_has_ctrl_word;
unsigned int c2s_mpls_ctrl_word; /* refer to RFC4623 */
@@ -353,8 +347,8 @@ struct layer_addr_mpls
struct layer_addr_pptp
{
- UINT16 C2S_call_id; /* C2S�Դ����Э�鷽��Ϊ׼, TCP SYNΪC2S, UDPԴ�˿ڴ��ΪC2S, callid, network order */
- UINT16 S2C_call_id; /* S2Ck�Դ����Э�鷽��Ϊ׼, TCP SYN/ACKΪS2C, UDPĿ�Ķ˿ڴ��ΪS2C, callid, network order */
+ UINT16 C2S_call_id; /* C2S�Դ����Э�鷽��Ϊ׼, TCP SYNΪC2S, UDPԴ�˿ڴ��ΪC2S, callid, network order */
+ UINT16 S2C_call_id; /* S2Ck�Դ����Э�鷽��Ϊ׼, TCP SYN/ACKΪS2C, UDPĿ�Ķ˿ڴ��ΪS2C, callid, network order */
};
struct layer_addr_gtp
@@ -366,10 +360,10 @@ struct layer_addr_gtp
#define MAC_IN_MAC_HDR_LEN (sizeof(struct mesa_ethernet_hdr) + sizeof(struct mesa_ethernet_hdr))
struct layer_addr_mac_in_mac
{
- UCHAR outer_dst_mac[MAC_ADDR_LEN]; /* �����mac��ַ, network order */
- UCHAR outer_src_mac[MAC_ADDR_LEN]; /* �����mac��ַ, network order */
- UCHAR inner_dst_mac[MAC_ADDR_LEN]; /* �ڲ�mac��ַ, network order */
- UCHAR inner_src_mac[MAC_ADDR_LEN]; /* �ڲ�mac��ַ, network order */
+ UCHAR outer_dst_mac[MAC_ADDR_LEN]; /* �����mac��ַ, network order */
+ UCHAR outer_src_mac[MAC_ADDR_LEN]; /* �����mac��ַ, network order */
+ UCHAR inner_dst_mac[MAC_ADDR_LEN]; /* �ڲ�mac��ַ, network order */
+ UCHAR inner_src_mac[MAC_ADDR_LEN]; /* �ڲ�mac��ַ, network order */
};
struct single_layer_addr_vxlan
@@ -420,7 +414,7 @@ struct layer_addr
};
-/* CHN : �����˽ṹ���ں�papp����, ����ָ��ʱ, ����struct layer_addrǿת */
+/* CHN : �����˽ṹ���ں�papp����, ����ָ��ʱ, ����struct layer_addrǿת */
/* ENG : compat for papp, can be transform to struct layer_addr pointer */
struct ipaddr
{
@@ -467,7 +461,7 @@ struct udpdetail
struct streaminfo
{
struct layer_addr addr;
- struct streaminfo *pfather; /* this stream's carry layer stream; �ϲ����ṹ�� */
+ struct streaminfo *pfather; /* this stream's carry layer stream; �ϲ����ṹ�� */
UCHAR type; /* stream type, definition in enum stream_type_t */
UCHAR threadnum;
UCHAR dir; /* valid in all stream life, current stream direction state, 0x01:c-->s; 0x02:s-->c; 0x03 c<-->s; */
@@ -504,13 +498,13 @@ typedef struct {
extern "C" {
#endif
-/* CHN : �ڴ������غ���, ����ƽ̨�IJ������ʹ�ô��ຯ��������ͷ��ڴ� */
+/* CHN : �ڴ������غ���, ����ƽ̨�IJ������ʹ�ô��ຯ��������ͷ��ڴ� */
/* ENG : memory management function, plugs must call these functions instead of malloc, free in <stdlib.h> */
void *dictator_malloc(int thread_seq,size_t size);
void dictator_free(int thread_seq,void *pbuf);
void *dictator_realloc(int thread_seq, void* pbuf, size_t size);
-/* CHN : ��ȡ��ǰϵͳ���еIJ��������߳����� */
+/* CHN : ��ȡ��ǰϵͳ���еIJ��������߳����� */
/* ENG : get current total thread of platfomr */
int get_thread_count(void);
@@ -520,19 +514,19 @@ long long get_timestamp_ms(void);
//if return -1, it means caller not in worker thread context
int get_current_worker_thread_id();
-/* CHN : ����enum addr_type_tַ����ת���ɿɴ�ӡ���ַ�����ʽ */
+/* CHN : ����enum addr_type_tַ����ת���ɿɴ�ӡ���ַ�����ʽ */
/* ENG : transform binary addr_type_t to string mode */
const char *addr_type_to_string(enum addr_type_t type);
/*
ENG : transform tuple4 to string mode, must used in packet process thread context;
- CHN : ��layer_addr��ַת�����ַ�����ʽ, �������ڰ������߳�.
+ CHN : ��layer_addr��ַת�����ַ�����ʽ, �������ڰ������߳�.
*/
const char *printaddr (const struct layer_addr *paddrinfo, int threadindex);
/*
ENG : a reentrant version of printaddr, thread safe;
- CHN : printaddr�Ŀ�����汾, ���̰߳�ȫ��.
+ CHN : printaddr�Ŀ�����汾, ���̰߳�ȫ��.
*/
const char *printaddr_r(const struct layer_addr *paddrinfo, char *out_buf, int out_buf_len);
@@ -540,45 +534,45 @@ const char *printaddr_r(const struct layer_addr *paddrinfo, char *out_buf, int o
/*
ENG : transform layer address to string mode, must used in packet process thread context,
the return value is read-only, user can't free it;
- CHN : ��layer_addr��ַת�����ַ�����ʽ, �������ڰ������߳�, ���ص�ָ��Ϊֻ��, ʹ���߲���free.
+ CHN : ��layer_addr��ַת�����ַ�����ʽ, �������ڰ������߳�, ���ص�ָ��Ϊֻ��, ʹ���߲���free.
*/
const char *layer_addr_ntop(const struct streaminfo *pstream);
/*
ENG : a reentrant version of layer_addr_ntop, thread safe, return a pointer to the destination string 'out_buf';
- CHN : layer_addr_ntop_r�Ŀ�����汾, ���̰߳�ȫ��, ���ص�ָ��ִ��ʹ�����ṩ��out_buf, ���ڴ�����֯.
+ CHN : layer_addr_ntop_r�Ŀ�����汾, ���̰߳�ȫ��, ���ص�ָ��ִ��ʹ�����ṩ��out_buf, ���ڴ�����֯.
*/
char *layer_addr_ntop_r(const struct streaminfo *pstream, char *out_buf, int out_buf_len);
/*
ENG : transform layer type to abbr string mode, is reentrant, the return value is read-only, user can't free it;.
- CHN : ��layer_addr��ַ����ת������д�ַ�����ʽ, �������̰߳�ȫ, ���ص�ָ��Ϊֻ��, ʹ���߲���free..
+ CHN : ��layer_addr��ַ����ת������д�ַ�����ʽ, �������̰߳�ȫ, ���ص�ָ��Ϊֻ��, ʹ���߲���free..
*/
const char *layer_addr_prefix_ntop(const struct streaminfo *pstream);
/*
ENG : duplicate a same layer_addr struct, memory obtained with malloc(3);
- CHN : ����һ����ȫ��ͬ��layer_addr�ṹ��, �ڴ�ͨ��malloc(3)��ȡ.
+ CHN : ����һ����ȫ��ͬ��layer_addr�ṹ��, �ڴ�ͨ��malloc(3)��ȡ.
*/
struct layer_addr * layer_addr_dup(const struct layer_addr *paddrinfo);
/*
ENG: used to free all memory of paddrinfo;
- CHN: �����ͷ�paddrinfo�ڴ�.
+ CHN: �����ͷ�paddrinfo�ڴ�.
*/
void layer_addr_free(struct layer_addr *paddrinfo);
/*
ENG : duplicate a same streaminfo list, memory obtained with malloc(3);
- CHN : ����һ����ȫ��ͬ��streaminfo�ṹ�弰�����ṹ, �ڴ�ͨ��malloc(3)��ȡ.
+ CHN : ����һ����ȫ��ͬ��streaminfo�ṹ�弰�����ṹ, �ڴ�ͨ��malloc(3)��ȡ.
*/
struct streaminfo *streaminfo_dup(const struct streaminfo *stream);
/*
ENG: used to free all memory of streaminfo;
- CHN: �����ͷŽṹ�弰�����ṹ���ڴ�.
+ CHN: �����ͷŽṹ�弰�����ṹ���ڴ�.
*/
void streaminfo_free(struct streaminfo *stream);
@@ -598,46 +592,46 @@ void streaminfo_free(struct streaminfo *stream);
addr_list_str: addr list string;
thread_index : thread index;
- ����ֵ:
- >0:ת����Ľ��ʵ��ռ���ڴ泤��, stream_addr_list_ntop()�������ַ���ĩβ��'\0';
- -1:dst����ռ䳤�Ȳ���;
- -2:��ʽ����;
- -3:��������;
+ ����ֵ:
+ >0:ת����Ľ��ʵ��ռ���ڴ泤��, stream_addr_list_ntop()�������ַ���ĩβ��'\0';
+ -1:dst����ռ䳤�Ȳ���;
+ -2:��ʽ����;
+ -3:��������;
*/
int stream_addr_list_ntop(const struct streaminfo *pstream, char *dst, int size);
int stream_addr_list_pton(const char *addr_list_str, void *dst, int size, int thread_index);
/*
- TCP,UDP��ģʽ��, ��ȡ��ǰIP����ԭʼ��Ƭ��.
+ TCP,UDP��ģʽ��, ��ȡ��ǰIP����ԭʼ��Ƭ��.
*/
const raw_ipfrag_list_t *get_raw_frag_list(const struct streaminfo *stream);
/*
- IP���ģʽ��, ��ȡ��ǰIP����ԭʼ��Ƭ��.
+ IP���ģʽ��, ��ȡ��ǰIP����ԭʼ��Ƭ��.
*/
const raw_ipfrag_list_t *ip_plug_get_raw_ipfrag_list(int thread_num, enum addr_type_t addr_type);
/*
- ��Ϊ������Ƕ��Э���ԭ��, ����һ������Ԫ��, ʵ���п��ܲ�ѯ�����streaminfo,
- ��������������:
+ ��Ϊ������Ƕ��Э���ԭ��, ����һ������Ԫ��, ʵ���п��ܲ�ѯ�����streaminfo,
+ ��������������:
(1) tuple4->gtp->ip->udp->ethernet;
(2) tuple4->l2tp->ip->udp->ethernet;
- ��������ڲ�ʹ��˽�е�ַ, ��һЩ���˴��ɵ������, ��1����2���ڲ�tuple4������һ����, ��sapp�ᴴ��������ͬ��streaminfo.
+ ��������ڲ�ʹ��˽�е�ַ, ��һЩ���˴��ɵ������, ��1����2���ڲ�tuple4������һ����, ��sapp�ᴴ��������ͬ��streaminfo.
- �������:
- thread_index: �߳�id;
- tuple4v4 or tuple4v6: ��Ԫ���ַ, Դ��Ŀ�ĵ�ַ˳����Ҫ��, C2S, S2c�������;
- streamtype: ֻ֧����������, STREAM_TYPE_TCP or STREAM_TYPE_UDP;
- array_max_num: ����streaminfo_array�����Ԫ�ظ���.
+ �������:
+ thread_index: �߳�id;
+ tuple4v4 or tuple4v6: ��Ԫ���ַ, Դ��Ŀ�ĵ�ַ˳����Ҫ��, C2S, S2c�������;
+ streamtype: ֻ֧����������, STREAM_TYPE_TCP or STREAM_TYPE_UDP;
+ array_max_num: ����streaminfo_array�����Ԫ�ظ���.
- �������:
- streaminfo_array: ��ѯ���ķ���������Ԫ���ַ��streaminfo�ṹ��ָ��.
+ �������:
+ streaminfo_array: ��ѯ���ķ���������Ԫ���ַ��streaminfo�ṹ��ָ��.
- ����ֵ:
+ ����ֵ:
-1: error;
- 0: û�ж�Ӧ��streaminfo�ṹ;
- >0: ʵ���ҵ�streaminfo�ṹ������;
+ 0: û�ж�Ӧ��streaminfo�ṹ;
+ >0: ʵ���ҵ�streaminfo�ṹ������;
*/
int find_streaminfo_by_addrv4(int thread_index, const struct stream_tuple4_v4 *tuplev4, enum stream_type_t streamtype, struct streaminfo *streaminfo_array[], int array_max_num);
int find_streaminfo_by_addrv6(int thread_index, const struct stream_tuple4_v6 *tuplev6, enum stream_type_t streamtype, struct streaminfo *streaminfo_array[], int array_max_num);
diff --git a/include/public/stream_inc/stream_rawpkt.h b/include/public/stream_inc/stream_rawpkt.h
index 7c709c2..500f860 100644
--- a/include/public/stream_inc/stream_rawpkt.h
+++ b/include/public/stream_inc/stream_rawpkt.h
@@ -86,16 +86,35 @@ const void *get_current_layer3_header(const struct streaminfo *pstream);
const void *get_current_layer4_header(const struct streaminfo *pstream);
/*
- NULL: layer not exist;
- NON-NULL: layer start buff
-
- Ethernet, jump to ipv6 header:
+ parameters:
+ raw_data: current layer header address;
+ raw_layer_type: current layer type, enum addr_type_t define in stream_base.h;
+ expect_layer_type: except layer type, enum addr_type_t define in stream_base.h;
+
+ return value:
+ NULL: no expect layer;
+ NON-NULL: expect layer header.
+
+ example:
+ For ethernet data, jump to ipv6 hdr:
struct ip6_hdr *ip6_header;
ip6_header = MESA_jump_layer(this_layer_hdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
*/
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
+/*
+ MESA_jump_layer_greedy vs MESA_jump_layer:
+ for tunnels,
+ MESA_jump_layer return to first expect_layer_type;
+ MESA_jump_layer_greedy return to inner most expect_layer_type;
+*/
+const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
+
+/* same as MESA_jump_layer_ */
+const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
+const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
+
const void *get_current_rawpkt_from_streaminfo(const struct streaminfo *pstream);
const void *get_rawpkt_from_streaminfo(const struct streaminfo *pstream, int route_direction);
diff --git a/module_test/src/gtest_sapp_comm.cpp b/module_test/src/gtest_sapp_comm.cpp
index 6fe2062..5533c85 100644
--- a/module_test/src/gtest_sapp_comm.cpp
+++ b/module_test/src/gtest_sapp_comm.cpp
@@ -27,9 +27,7 @@
#include <net/if.h>
#include <stdarg.h>
-#include "stream.h"
#include "gtest_sapp_fun.h"
-#include "MESA_jump_layer.h"
static int gtest_sapp_master_fd;
diff --git a/module_test/src/gtest_sapp_fun.h b/module_test/src/gtest_sapp_fun.h
index f597a0e..96f76d1 100644
--- a/module_test/src/gtest_sapp_fun.h
+++ b/module_test/src/gtest_sapp_fun.h
@@ -8,7 +8,11 @@
#include <pcap/pcap.h>
#include <linux/if_tun.h>
#include <net/if.h>
-#include "MESA_jump_layer.h"
+
+#include <netinet/ip.h>
+#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
/*
说明:
@@ -26,10 +30,7 @@
#define SAPP_MAX_PLUG_ENTRY_NUM (256)
#endif
-#include "stream.h"
-#include "packet_io.h"
-#include "sapp_cla_private.h"
-//#include "sapp_global_val.h"
+#include "stream_internal.h"
#include "mesa_net.h"
#include "MESA_handle_logger.h"
diff --git a/src/common/MESA_jump_layer.cpp b/src/common/MESA_jump_layer.cpp
index b603949..c8cbd11 100644
--- a/src/common/MESA_jump_layer.cpp
+++ b/src/common/MESA_jump_layer.cpp
@@ -1,14 +1,11 @@
-#include "stream.h"
#include "mesa_net.h"
#include "deal_ipv6.h"
/* Linux OS std */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <stdarg.h>
#include <unistd.h>
#include <assert.h>
-#include <errno.h>
#include <dlfcn.h>
#include <linux/if_ether.h>
#include <linux/limits.h>
@@ -23,7 +20,6 @@
#include <linux/version.h>
#include <net/if.h>
#include <sys/ioctl.h>
-#include <signal.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/prctl.h>
@@ -1429,6 +1425,9 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty
return MESA_jump_layer_greedy(raw_data, raw_layer_type, expect_layer_type);
}
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+
/* ģ��tcpdump��ʽ: 192.168.40.137.22 > 192.168.36.40.49429 */
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len )
{
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 0e8edf8..407196d 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -11,3 +11,18 @@ add_definitions(-D_DEFAULT_SOURCE -D__FAVOR_BSD -D_XOPEN_SOURCE -D_ISOC99_SOURCE
add_executable(stream_id_decode stream_id_decode.c)
+set(TCPDUMPMESA_LIBS "-L${CMAKE_BINARY_DIR}/src/common -lMESA_jump_layer")
+set(TCPDUMPMESA_CFLAGS "-I${CMAKE_SOURCE_DIR}/include/public/stream_inc -Wall -O2")
+ExternalProject_Add(tcpdump_mesa
+ PREFIX tcpdump_mesa
+ URL ${CMAKE_CURRENT_SOURCE_DIR}/tcpdumpmesa.zip
+ CONFIGURE_COMMAND env ADDITIONAL_LIBS=${TCPDUMPMESA_LIBS} ./configure
+ BUILD_COMMAND make CFLAGS+=${TCPDUMPMESA_CFLAGS}
+ INSTALL_COMMAND ""
+ BUILD_IN_SOURCE 1
+)
+ExternalProject_Get_Property(tcpdump_mesa BINARY_DIR)
+install(PROGRAMS ${BINARY_DIR}/tcpdump
+ DESTINATION ./tools/
+ RENAME tcpdump_mesa
+ COMPONENT EXECUTABLE) \ No newline at end of file
diff --git a/tools/tcpdumpmesa.zip b/tools/tcpdumpmesa.zip
new file mode 100644
index 0000000..c760289
--- /dev/null
+++ b/tools/tcpdumpmesa.zip
Binary files differ