diff options
| author | yulingjing <[email protected]> | 2019-07-31 16:03:48 +0800 |
|---|---|---|
| committer | yulingjing <[email protected]> | 2019-07-31 16:03:48 +0800 |
| commit | f69cf0b3c639b4744649d2f851ea1d3bf8c36128 (patch) | |
| tree | 06c01b360f94cd3dd5036c9f85b48d0353104ac1 /src/include/MESA/stream_inc | |
Diffstat (limited to 'src/include/MESA/stream_inc')
| -rw-r--r-- | src/include/MESA/stream_inc/stream_base.h | 358 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_control.h | 29 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_entry.h | 79 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_inject.h | 71 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_project.h | 112 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_proxy.h | 53 | ||||
| -rw-r--r-- | src/include/MESA/stream_inc/stream_rawpkt.h | 69 |
7 files changed, 771 insertions, 0 deletions
diff --git a/src/include/MESA/stream_inc/stream_base.h b/src/include/MESA/stream_inc/stream_base.h new file mode 100644 index 0000000..b34ba8c --- /dev/null +++ b/src/include/MESA/stream_inc/stream_base.h @@ -0,0 +1,358 @@ +#ifndef _APP_STREAM_BASE_H_ +#define _APP_STREAM_BASE_H_ + + + +#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 <stdlib.h> +#include <string.h> + +#ifndef UINT8 +typedef unsigned char UINT8; +#endif +#ifndef UCHAR +typedef unsigned char UCHAR; +#endif +#ifndef UINT16 +typedef unsigned short UINT16; +#endif + +#ifndef UINT32 +typedef unsigned int UINT32; +#endif +#ifndef UINT64 +typedef unsigned long long UINT64; +#endif + +//���ķ����� +#define DIR_C2S 0x01 +#define DIR_S2C 0x02 +#define DIR_DOUBLE 0x03 + +//�����ķ����� +#define DIR_ROUTE_UP 0x00 +#define DIR_ROUTE_DOWN 0x01 + +//���������Ͷ��� +#define PKT_TYPE_NORMAL (0x0) +#define PKT_TYPE_IPREBUILD (1<<0) //ip��Ƭ���鱨�� +#define PKT_TYPE_TCPUNORDER (1<<1) //TCP������ + +//��ַ���Ͷ���, ��ͨ������ addr_type_to_string() ת���ַ�����ʽ. +enum addr_type_t{ + __ADDR_TYPE_INIT = 0, + ADDR_TYPE_IPV4, /* 1, ����IPv4��ַ����Ԫ����Ϣ */ + ADDR_TYPE_IPV6, /* 2, ����IPv6��ַ����Ԫ����Ϣ */ + ADDR_TYPE_VLAN, /* 3 */ + ADDR_TYPE_MAC, /* 4 */ + ADDR_TYPE_ARP = 5, /* 5 */ + ADDR_TYPE_GRE, /* 6 */ + ADDR_TYPE_MPLS, /* 7 */ + ADDR_TYPE_PPPOE_SES, /* 8 */ + ADDR_TYPE_TCP, /* 9 */ + ADDR_TYPE_UDP = 10, /* 10 */ + ADDR_TYPE_L2TP, /* 11 */ + __ADDR_TYPE_IP_PAIR_V4, /* 12, ��IPv4��ַ�� */ + __ADDR_TYPE_IP_PAIR_V6, /* 13, ��IPv6��ַ�� */ + ADDR_TYPE_PPP, /* 14 */ + __ADDR_TYPE_MAX, /* 15 */ +}; + +#define TCP_TAKEOVER_STATE_FLAG_OFF 0 +#define TCP_TAKEOVER_STATE_FLAG_ON 1 + + +//Ӧ�ò㿴��������״̬���� +#define OP_STATE_PENDING 0 +#define OP_STATE_REMOVE_ME 1 +#define OP_STATE_CLOSE 2 +#define OP_STATE_DATA 3 + +//Ӧ�ò㷵�ؽ������ +#define APP_STATE_GIVEME 0x00 +#define APP_STATE_DROPME 0x01 +#define APP_STATE_FAWPKT 0x00 +#define APP_STATE_DROPPKT 0x10 + +//�������Ͷ��� +enum stream_type_t{ + STREAM_TYPE_NON = 0, /* �����ĸ���, ��VLAN, IP��� */ + STREAM_TYPE_TCP, + STREAM_TYPE_UDP, + STREAM_TYPE_VLAN, + STREAM_TYPE_SOCKS4, + STREAM_TYPE_SOCKS5, + STREAM_TYPE_HTTP_PROXY, + STREAM_TYPE_PPPOE, +}; + + + +typedef struct raw_ipfrag_list{ + void *frag_packet; + int pkt_len; + int type; /* IPv4 or IPv6 */ + struct raw_ipfrag_list *next; +}raw_ipfrag_list_t; + + + + +/* 2014-11-19 lijia modify */ +#ifndef STRUCT_TUPLE4_DEFINED +#define STRUCT_TUPLE4_DEFINED (1) +/* ����papp */ +struct tuple4 { + u_int saddr; + u_int daddr; + u_short source; + u_short dest; +}; +#endif + +struct tuple6 +{ + UCHAR saddr[16] ; + UCHAR daddr[16] ; + UINT16 source; + UINT16 dest; +}; + +/* network-order */ +struct stream_tuple4_v4{ + UINT32 saddr; /* network order */ + UINT32 daddr; /* network order */ + UINT16 source; /* network order */ + UINT16 dest; /* network order */ +}; + + +#ifndef IPV6_ADDR_LEN +#define IPV6_ADDR_LEN (sizeof(struct in6_addr)) +#endif + +struct stream_tuple4_v6 +{ + UCHAR saddr[IPV6_ADDR_LEN] ; + UCHAR daddr[IPV6_ADDR_LEN] ; + UINT16 source; /* network order */ + UINT16 dest; /* network order */ +}; + + + +#define GRE_TAG_LEN (4) +struct layer_addr_gre +{ + UINT16 gre_id; +}; + + +#define VLAN_ID_MASK (0x0FFF) +#define VLAN_TAG_LEN (4) +struct layer_addr_vlan +{ + UINT16 vlan_id; /* network order */ +}; + +#define VLAN_ID_LEN 4 +struct tuplevlan +{ + UCHAR vlan_id[VLAN_ID_LEN]; +}; + +struct layer_addr_pppoe_session +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ver:4; + unsigned int type:4; +#endif +#if __BYTE_ORDER == __BIG_ENDIAN + unsigned int type:4; + unsigned int ver:4; +#endif + unsigned char code; + unsigned short session_id; +}; + +#ifndef MAC_ADDR_LEN +#define MAC_ADDR_LEN (6) +#endif + +struct layer_addr_mac +{ + UCHAR src_mac[MAC_ADDR_LEN]; /* network order */ + UCHAR dst_mac[MAC_ADDR_LEN]; /* network order */ +}; + +struct layer_addr_ipv4 +{ + UINT32 saddr; /* network order */ + UINT32 daddr; /* network order */ + /* 2014-04-21 lijia add, + Ϊ�˿ռ䡢�����ԡ���Ч��, ��ǿ�ư�Э���δ���, + IP��洢��������Ԫ����Ϣ, TCP��ֻ��ָ��ָ��˿��ڴ�, + �����ȡ��Ԫ��ʱ, ������Ҫget_tuple4()����. + �����������IP, �˿���ϢΪ0; + */ + UINT16 source; /* network order */ + UINT16 dest; /* network order */ +}; + +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��ֻ��ָ��ָ��˿��ڴ�, + �����ȡ��Ԫ��ʱ, ������Ҫget_tuple4()����. + �����������IP, �˿���ϢΪ0; + */ + UINT16 source;/* network order */ + UINT16 dest;/* network order */ +}; + +struct layer_addr_tcp +{ + UINT16 source; /* network order */ + UINT16 dest; /* network order */ +}; + +struct layer_addr_udp +{ + UINT16 source; /* network order */ + UINT16 dest; /* network order */ +}; + +struct layer_addr_l2tp +{ + UINT32 tunnelid; /* network order */ + UINT32 sessionid; /* network order */ +}; + +struct layer_addr_mpls +{ + unsigned int mpls_pkt; +}; + + +struct layer_addr +{ + UCHAR addrtype; // ��ַ����, ��� enum addr_type_t + UCHAR addrlen; + UCHAR pkttype; //�������� ,�μ��궨��PKT_TYPE_xxx + UCHAR __pad[5]; //����8�ֽڶ��� + // Ϊ�˷���Ӧ�ò��ȡ��ַ, �˴�ʹ��������, ʡȥָ������ǿ��ת������ + union + { + struct stream_tuple4_v4 *tuple4_v4; + struct stream_tuple4_v6 *tuple4_v6; + struct layer_addr_ipv4 *ipv4; + struct layer_addr_ipv6 *ipv6; + struct layer_addr_vlan *vlan; + struct layer_addr_mac *mac; + struct layer_addr_gre *gre; + struct layer_addr_tcp *tcp; + struct layer_addr_udp *udp; + struct layer_addr_pppoe_session *pppoe_ses; + struct layer_addr_l2tp *l2tp; + void *paddr; + }; + +}; + +// �����˽ṹ���ں�papp����, ����ָ��ʱ, ����struct layer_addrǿת. +struct ipaddr +{ + UCHAR addrtype; // ��ַ����, ��� enum addr_type_t + UCHAR addrlen; + UCHAR pkttype; //�������� ,�μ��궨��PKT_TYPE_xxx + UCHAR __pad[5]; //����8�ֽڶ��� + union + { + struct stream_tuple4_v4 *v4; + struct stream_tuple4_v6 *v6; + void *paddr; + }; + +}; + +struct tcpdetail +{ + void *pdata; //���� + UINT32 datalen; //���ݳ��� + UINT32 lostlen; + UINT32 serverpktnum; + UINT32 clientpktnum; + UINT32 serverbytes; + UINT32 clientbytes; + UINT64 createtime; + UINT64 lastmtime; +}; + +struct udpdetail +{ + void *pdata; //���� + UINT32 datalen; //���ݳ��� + UINT32 pad; //Ԥ����Ϣ + UINT32 serverpktnum; + UINT32 clientpktnum; + UINT32 serverbytes; + UINT32 clientbytes; + UINT64 createtime; + UINT64 lastmtime; +}; + +struct streaminfo +{ + struct layer_addr addr; //����Э���ַ��Ϣ + struct streaminfo *pfather;//�ϲ����ṹ�� + UCHAR type; // �������� + UCHAR threadnum; // �����߳� + UCHAR dir; // ��������������Ч, ���ĵ���˫�������0x01:c-->s; 0x02:s-->c; 0x03 c<-->s; + UCHAR curdir; // ������Ч, ��ǰ�����ϲ�����������, 0x01:c-->s; 0x02:s-->c + UCHAR opstate; //��ǰ��������״̬ + UCHAR pktstate; //���ӵİ����� + UCHAR routedir; // ����������, ������Ч, ���˹�ָ��, �����ڷ���ʱ����Ƿ������������Ƿ���ͬ, �������� + UCHAR stream_state; // ÿ������ǰ���ڵĶ���״̬ + UINT32 hash_index; // ÿ������hash���� + UINT32 stream_index; // ÿ��stream�ڵ��߳�ȫ�ֵ����� + union + { + struct tcpdetail *ptcpdetail; + struct udpdetail *pudpdetail; + void *pdetail; //������ϸ��Ϣ + }; + }; + + + +#ifdef __cplusplus +extern "C" { +#endif + +//�ڴ������غ��� +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); + +//��ȡ��ǰϵͳ���еIJ��������߳����� +int get_thread_count(void); + +/* ����ַ����ת���ɿɴ�ӡ���ַ�����ʽ */ +const char *addr_type_to_string(enum addr_type_t type); + +const char *printaddr (struct layer_addr *paddrinfo,int threadindex); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/include/MESA/stream_inc/stream_control.h b/src/include/MESA/stream_inc/stream_control.h new file mode 100644 index 0000000..f81502d --- /dev/null +++ b/src/include/MESA/stream_inc/stream_control.h @@ -0,0 +1,29 @@ +#ifndef _APP_STREAM_CONTROL_H_ +#define _APP_STREAM_CONTROL_H_ + + +#ifdef __cplusplus +extern "C" { +#endif + + +//���õ������ӵ���ز�����Ϣ +int tcp_set_single_stream(const struct streaminfo *stream,UCHAR optype,void *value,int valuelen); +/* +//���õ������ӣ���������������Ŀ +����ֵ 0: ���óɹ���-1:����ʧ�� +*/ +int tcp_set_single_stream_max_unorder(const struct streaminfo *stream, UCHAR dir, unsigned short unorder_num); +int tcp_set_single_stream_needack(const struct streaminfo *pstream); +int tcp_set_single_stream_takeoverflag(const struct streaminfo *pstream,int flag); + +int stream_set_single_stream_timeout(const struct streaminfo *pstream,unsigned short timeout); + + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/include/MESA/stream_inc/stream_entry.h b/src/include/MESA/stream_inc/stream_entry.h new file mode 100644 index 0000000..0bd5c39 --- /dev/null +++ b/src/include/MESA/stream_inc/stream_entry.h @@ -0,0 +1,79 @@ +#ifndef _APP_STREAM_ENTRY_H_ +#define _APP_STREAM_ENTRY_H_ + + +//ҵ�����ý�����ʱsession_state״̬ +#define SESSION_STATE_PENDING 0x01 +#define SESSION_STATE_DATA 0x02 +#define SESSION_STATE_CLOSE 0x04 + +//���������ҵ���ʱ�ķ���ֵ�� +#define PROT_STATE_GIVEME 0x01 +#define PROT_STATE_DROPME 0x02 +#define PROT_STATE_DROPPKT 0x04 + +//������������ҵ�����ʱ������� +typedef struct _plugin_session_info +{ + unsigned short plugid; //plugid��ƽ̨���� + char session_state; //�Ự״̬��PENDING,DATA,CLOSE + char _pad_; //���� + int buflen; //��ǰ�ֶγ��� + long long prot_flag; //��ǰ�ֶε�flagֵ + void *buf; //��ǰ�ֶ� + void* app_info; //��������������Ϣ +}stSessionInfo; + + + + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef char (*STREAM_CB_FUN_T)(const struct streaminfo *pstream,void **pme, int thread_seq,const void *ip_hdr); +typedef char (*IPv4_CB_FUN_T)(const struct streaminfo *pstream,unsigned char routedir,int thread_seq, const void *ipv4_hdr); +typedef char (*IPv6_CB_FUN_T)(const struct streaminfo *pstream,unsigned char routedir,int thread_seq, const void *ipv6_hdr); + + +typedef char (*SAPP_PKT_CB_FUN_T)(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt); +typedef char (*SAPP_STREAM_FUN_T)(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt, void **pme); + + +/*���������� + a_*�� ������������Ϣ; + f_*: ��������Ӧ�ĸ�����Ϣ; + raw_pkt: ԭʼ��ָ��, ʵ������Ϊ'raw_pkt_t'; + pme: ˽������ָ�룬������չ�ã���ʱΪNULL; + thread_seq���߳����; + +��������ֵ������Ϊ�����ĸ�ֵ������ + + APP_STATE_GIVEME�����������Ͱ��� + APP_STATE_DROPME�����������Ͱ��� + APP_STATE_FAWPKT����ע�����ݰ� + APP_STATE_DROPPKT������ע�����ݰ� +*/ +char IPv4_ENTRY_EXAMPLE(const struct streaminfo *f_stream,unsigned char routedir,int thread_seq, const void *raw_pkt); +char IPv6_ENTRY_EXAMPLE(const struct streaminfo *f_stream,unsigned char routedir,int thread_seq,const void *raw_pkt); +char TCP_ENTRY_EXAMPLE(const struct streaminfo *a_tcp, void **pme, int thread_seq,const void *raw_pkt); +char UDP_ENTRY_EXAMPLE(const struct streaminfo *a_udp, void **pme, int thread_seq,const void *raw_pkt); + +char SAPP_PKT_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt); +char SAPP_STREAM_EXAMPLE(const struct streaminfo *pstream, const void *this_hdr, const void *raw_pkt, void **pme); + + +//ҵ���ص��ӿ� +char PROT_PROCESS(stSessionInfo* session_info, void **pme, int thread_seq,struct streaminfo *a_stream,const void *a_packet); + + + + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/src/include/MESA/stream_inc/stream_inject.h b/src/include/MESA/stream_inc/stream_inject.h new file mode 100644 index 0000000..4890ee6 --- /dev/null +++ b/src/include/MESA/stream_inc/stream_inject.h @@ -0,0 +1,71 @@ +#ifndef _APP_STREAM_INJECT_H_ +#define _APP_STREAM_INJECT_H_ + +#include "stream_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + +//���ӹܿ���غ��� + +int MESA_kill_tcp(struct streaminfo *stream, const void *raw_pkt); +int MESA_kill_tcp_synack(struct streaminfo *stream, const void *raw_pkt); + +/* 2014-11-15 lijia add, for drop NO-TCP protocol in serial mode. + return value: + >= 0: success. + -1 : error. +*/ +int MESA_kill_connection(struct streaminfo *stream, const void *ext_raw_pkt); + +/* ����route_dir����, */ +unsigned char MESA_dir_reverse(unsigned char raw_route_dir); + +/* + ARG: + stream: ���ṹ��ָ��; + payload: Ҫ���͵�����ָ��; + payload_len: Ҫ���͵����ݸ��س���; + raw_pkt: ԭʼ��ָ��; + snd_routedir: Ҫ�������ݵķ���, ԭʼ������Ϊ:stream->routedir , + �����ԭʼ��ͬ��, snd_dir = stream->routedir, + �����ԭʼ������, snd_dir = MESA_dir_reverse(stream->routedir). + return value: + -1: error. + >0: ���͵����ݰ�ʵ���ܳ���(payload_len + �ײ��ͷ����); +*/ +int MESA_inject_pkt(struct streaminfo *stream, const char *payload, int payload_len, const void *raw_pkt, UCHAR snd_routedir); + + +int MESA_sendpacket_ethlayer(int thread_index,const char *buf, int buf_len, unsigned int target_id);//papp online, shuihu + +/* �����ѹ���õ�����IP��, У��͵Ⱦ���������� */ +int MESA_sendpacket_iplayer(int thread_index,const char *buf, int buf_len, u_int8_t dir); + +/* ����ָ������IP��, ��ָ����������, У�����ƽ̨�Զ�����, + sip, dipΪ������. */ +int MESA_fakepacket_send_ipv4(int thread_index,u_int8_t ttl,u_int8_t protocol, + u_int32_t sip_host_order, u_int32_t dip_host_order, + const char *payload, int payload_len,u_int8_t dir); + +/* ����ָ������TCP��, ��ָ����������, У�����ƽ̨�Զ�����, + sip, dip,sport,dport,sseq,sack��Ϊ������. */ +int MESA_fakepacket_send_tcp(int thread_index,u_int sip_host_order,u_int dip_host_order, + u_short sport_host_order,u_short dport_host_order, + u_int sseq_host_order,u_int sack_host_order, + u_char control,const char* payload,int payload_len, u_int8_t dir); + +/* ����ָ������UDP��, ��ָ����������, У�����ƽ̨�Զ�����, + sip, dip,sport,dport��Ϊ������. */ +int MESA_fakepacket_send_udp(int thread_index, u_int sip_host_order, u_int dip_host_order, + u_short sport_host_order,u_short dport_host_order, + const char *payload, int payload_len,u_int8_t dir); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/include/MESA/stream_inc/stream_project.h b/src/include/MESA/stream_inc/stream_project.h new file mode 100644 index 0000000..9a23212 --- /dev/null +++ b/src/include/MESA/stream_inc/stream_project.h @@ -0,0 +1,112 @@ +#ifndef _PROJECT_REQUIREMENT_H_ +#define _PROJECT_REQUIREMENT_H_ + +#include "stream_base.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define PROJECT_REQ_NAME_MAX_LEN (64) + +typedef void (project_req_free_t)(int thread_seq, void *project_req_value); + +#define PROJECT_VAL_TYPE_CHAR "char" +#define PROJECT_VAL_TYPE_SHORT "short" +#define PROJECT_VAL_TYPE_INT "int" +#define PROJECT_VAL_TYPE_LONG "long" +#define PROJECT_VAL_TYPE_STRUCT "struct" + + +int project_requirement_global_init(void); + +/* + must call this function in initialization, only one times, + the 'free_cb' should be NULL if 'project_req_val_type' is simple type, + otherwise please implement it by youself. + + args: + project_req_name: for example, "terminal_tag", "stream_id". + project_req_val_type: support "char","short","int","long","struct". + free_cb: used to free resource when 'project_req_val_type' is "struct". + + + return value: 'project_req_id' of this project_req_name, must use this id in following functions. + >= 0 : success; + -1 : error. +*/ +int project_producer_register(const char *project_req_name, const char *project_req_val_type, project_req_free_t *free_cb); + +/* args and return value same with project_producer_register() */ +int project_customer_register(const char *project_req_name, const char *project_req_val_type); + +/* + Function project_req_add_struct: 'project_req_value' must be a pointer to heap memory(obtain by malloc). + + return value: + 0 : success; + -1: error. +*/ +int project_req_add_char(struct streaminfo *stream, int project_req_id, char project_req_value); +int project_req_add_short(struct streaminfo *stream, int project_req_id, short project_req_value); +int project_req_add_int(struct streaminfo *stream, int project_req_id, int project_req_value); +int project_req_add_long(struct streaminfo *stream, int project_req_id, long project_req_value); + +int project_req_add_uchar(struct streaminfo *stream, int project_req_id, unsigned char project_req_value); +int project_req_add_ushort(struct streaminfo *stream, int project_req_id, unsigned short project_req_value); +int project_req_add_uint(struct streaminfo *stream, int project_req_id, unsigned int project_req_value); +int project_req_add_ulong(struct streaminfo *stream, int project_req_id, unsigned long project_req_value); + + +int project_req_add_struct(struct streaminfo *stream, int project_req_id, const void *project_req_value); + + +/* + return value: + -1(or all bit is '1' in Hex mode, 0xFF, 0xFFFF): + maybe error, maybe the actual project_req_value is -1 indeed, + must check tht 'errno' in this case, + the 'errno' will be set to 'ERANGE' indicate an error. + others: success. + + for example: + int value = project_req_get_int(stream, req_id); + if((-1 == value) && (ERANGE == errno)){ + error_handle(); + }else{ + do_somgthing(); + } + + for example2: + unsigned short value = project_req_get_ushort(stream, req_id); + if((0xFF == value) && (ERANGE == errno)){ + error_handle(); + }else{ + do_somgthing(); + } + +*/ +char project_req_get_char(const struct streaminfo *stream, int project_req_id); +short project_req_get_short(const struct streaminfo *stream, int project_req_id); +int project_req_get_int(const struct streaminfo *stream, int project_req_id); +long project_req_get_long(const struct streaminfo *stream, int project_req_id); + +unsigned char project_req_get_uchar(const struct streaminfo *stream, int project_req_id); +unsigned short project_req_get_ushort(const struct streaminfo *stream, int project_req_id); +unsigned int project_req_get_uint(const struct streaminfo *stream, int project_req_id); +unsigned long project_req_get_ulong(const struct streaminfo *stream, int project_req_id); + +/* + return value: + NULL : error; + others: success. +*/ +const void *project_req_get_struct(const struct streaminfo *stream, int project_req_id); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/include/MESA/stream_inc/stream_proxy.h b/src/include/MESA/stream_inc/stream_proxy.h new file mode 100644 index 0000000..54023ed --- /dev/null +++ b/src/include/MESA/stream_inc/stream_proxy.h @@ -0,0 +1,53 @@ +#ifndef _STREAM_PROXY_H_ +#define _STREAM_PROXY_H_ + +#include "stream_base.h" + + + + +#define PROXY_STATE_SEL 0 +#define PROXY_STATE_LINK_IN 1 + +// ������Ϣ +struct proxydetail +{ + UINT16 iType; // ��������, 0 ��ʾ��Ч + UINT16 uiPort; // ��������ʵ�������˿� + UINT16 uiUserLen; + UINT16 uiPwdLen; + UINT16 uiApendLen; + + UCHAR pad; + UCHAR dealstate; //��������״̬ + UINT32 uiIP; // ��������ʵ������IP��ַv4, �������ֽ��� + UCHAR *pIpv6; // ��������ʵ������IP��ַ, v6��ַ + UCHAR *pUser; // �����û��� + UCHAR *pPwd; // �������� + UCHAR *append; // ����������Ϣ������url + void *apme; //Ӧ�ò������� + void *pAllpktpme; //��״̬��tcp���������� + UINT32 serverpktnum; + UINT32 clientpktnum; + UINT32 serverbytes; + UINT32 clientbytes; +} ; + +#ifdef __cplusplus +extern "C" { +#endif + +/*��һ����������Ϣ�����һ��fatherstream,���ҹ��ص�stream��*/ +void set_proxy_fstream(struct streaminfo *pstream,struct streaminfo *pProxy); + +/*��������������Ϣ������ɺ��� �ڲ� ����*/ +int deal_tcp_in_proxy_stream(struct streaminfo *a_tcp,void * a_packet,struct streaminfo *pProxy); + +/*�ص��ϲ���Ϣ���ͷŴ�������������Ϣ*/ +void free_tcp_proxy_stream(struct streaminfo *pstream,struct streaminfo *pProxy); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/include/MESA/stream_inc/stream_rawpkt.h b/src/include/MESA/stream_inc/stream_rawpkt.h new file mode 100644 index 0000000..bba9988 --- /dev/null +++ b/src/include/MESA/stream_inc/stream_rawpkt.h @@ -0,0 +1,69 @@ +#ifndef _APP_STREAM_RAWPKT_H_ +#define _APP_STREAM_RAWPKT_H_ + +enum{ + RAW_PKT_GET_DATA = 1, //value type: void *, out_value should be void ** + RAW_PKT_GET_RAW_PKT_TYPE, //value type: enum addr_type_t in stream_base.h, out_value should be enum addr_type_t* + RAW_PKT_GET_TOT_LEN, //value type: int , out_value should be int * + RAW_PKT_GET_TIMESTAMP, //value type: struct timeval , out_value should be struct timeval * + RAW_PKT_GET_THIS_LAYER_HDR, //value type: void *, out_value should be void ** + RAW_PKT_GET_THIS_LAYER_REMAIN_LEN, //value type: int , out_value should be int * +}; + +#ifdef __cplusplus +extern "C" { +#endif + +/* +for example: + ��ȡԭʼ���ܳ���: + int tot_len; + get_opt_from_rawpkt(voidpkt, RAW_PKT_GET_TOT_LEN, &tot_len); + + ��ȡ�����ͷ��ʼ��ַ: + void *this_layer_hdr; + get_opt_from_rawpkt(voidpkt, RAW_PKT_GET_THIS_LAYER_HDR, &this_layer_hdr); + + ��ȡԭʼ��ʱ���: + struct timeval pkt_stamp; + get_opt_from_rawpkt(voidpkt, RAW_PKT_GET_TIMESTAMP, &pkt_stamp); + + return value: + 0:success; + -1:error, or not support. +*/ +int get_opt_from_rawpkt(const void *rawpkt, int type, void *out_value); + + +/* ��ȡ��������ԭʼ���ж�Ӧ��ͷ����ַ, + ���豾��������ΪTCP, ���ô˺�����, �õ�ԭʼ���ж�Ӧ��TCPͷ����ַ. +*/ +const void *get_this_layer_header(const struct streaminfo *pstream); + +/* + ԭʼ��ͷ��ƫ�ƺ���. + + ����: + raw_data: ��ǰ���ͷ��ָ��; + raw_layer_type: ��ǰ��ĵ�ַ����; + expect_layer_type: ������ת���ĵ�ַ����; + + ����ֵ: + 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_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type); + + +#ifdef __cplusplus +} +#endif + +#endif + |
