summaryrefslogtreecommitdiff
path: root/include
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 /include
parentbff48cc28a94e72540c1cdb65b3fc55e892b0201 (diff)
🔧 build(integrate tcpdump_mesa): in toolsFeature-merge-jump-layer
Diffstat (limited to 'include')
-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
6 files changed, 123 insertions, 173 deletions
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);