Ubuntu下GCC之libpcap库数据库通信协议解析基础框架(2)

struct db_tcp {
        u_short th_sport;               /* source port */
        u_short th_dport;               /* destination port */
        tcp_seq th_seq;                 /* sequence number */
        tcp_seq th_ack;                 /* acknowledgement number */
        u_char  th_offx2;               /* data offset, rsvd */
#define TH_OFF(th)      (((th)->th_offx2 & 0xf0) >> 4)
        u_char  th_flags;
        #define TH_FIN  0x01
        #define TH_SYN  0x02
        #define TH_RST  0x04
        #define TH_PUSH 0x08
        #define TH_ACK  0x10
        #define TH_URG  0x20
        #define TH_ECE  0x40
        #define TH_CWR  0x80
        #define TH_FLAGS        (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
        u_short th_win;                 /* window */
        u_short th_sum;                 /* checksum */
        u_short th_urp;                 /* urgent pointer */
};

/* UDP header */
struct db_udp//udp protocol
{
 u_int16_t udp_source_port;
 u_int16_t udp_destination_port;
 u_int16_t udp_length;
 u_int16_t udp_checksum;
};

/* MySQL header */
struct db_mysql
{
 u_int8_t mysql_header_length;
 u_int16_t unknow1;
 u_int8_t packet_num;
 u_int8_t qry;
 u_int16_t q1;
 u_int16_t q2;
 u_int16_t q3;
};


/*Oracle header-tns protocol*/

struct db_tns
{
 u_short length;//package  length
 u_short packet_checksum;//
 u_char type;//tns type
 u_char flag;//status
 u_short header_checksum;
};

struct db_tns_connect//0x01
{
 u_short ns_vr;
 u_short ns_compatible_ver;
 u_short ser_opt;
// u_char ser_opt2;
 u_short SDU_size;
 u_short TDU_size;
 u_short NT_protocol_ch;
// u_char NT_protocol_ch2;
 u_short max_packets;
 u_short hardware;
 u_short data_length;
 u_short offset;
 u_int32_t max_data;
 u_char flag0;
 u_char flag1;
/*
if not jdbc,use offet to override these;
*/
 u_int32_t item;
 u_int32_t item2;
 u_char id[8];
 u_char unkonwn[8];
// u_char *buff; //no need
};

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/ppjzz.html