?? tcp_get.h
字號:
/*ethernet header*/
typedef struct ether_header
{
u_char ether_dhost[6]; /* 以太網(wǎng)目的地址 */
u_char ether_shost[6]; /* 源以太網(wǎng)地址 */
u_short ether_type; /* 以太網(wǎng)類型 */
u_char ver_ihl; /* Version (4 bits) + Internet header length (4 bits)*/
u_char tos;
}ethernet_header;
/* 4 bytes IP address */
typedef struct ip_address
{
u_char byte1;
u_char byte2;
u_char byte3;
u_char byte4;
}ip_address;
/* IPv4 header */
typedef struct ip_header
{
u_char ver_ihl; /* Version (4 bits) + Internet header length (4 bits)*/
u_char tos; /* Type of service */
u_short tlen; /* Total length */
u_short identification; /* Identification */
u_short flags_fo; /* Flags (3 bits) + Fragment offset (13 bits)*/
u_char ttl; /* Time to live */
u_char proto; /* Protocol */
u_short crc; /* Header checksum */
ip_address saddr;/* Source address */
ip_address daddr;/* Destination address */
u_int op_pad; /* Option + Padding */
}ip_header;
///記錄每個(gè)到來的tcp數(shù)據(jù)報(bào)的信息;
typedef struct tcpfrag
{
u_short sport; /* Source port */
u_short dport; /* Destination port */
u_long seq;
u_long ack;
u_short headlen_6res_6flag;
u_short winsize;
u_short checksum;
u_short urgentptr;
u_int op_pad; /* Option + Padding */
}tcpfrag;
//應(yīng)用層程序注冊函數(shù)中所需的結(jié)構(gòu)體;
typedef struct tcp_register
{
ip_address saddr; /* Source address */
u_short sport; /* Source port */
ip_address daddr; /* Destination address */
u_short dport; /* Destination port */
void (* app_process)(short int link_posi, short int applen);
}tcp_register;
//描述tcp連接狀態(tài)的tcp連接表的結(jié)構(gòu)體;
///描述某個(gè)tcp連接的當(dāng)前狀態(tài)
typedef struct tcp_linker
{
u_short nullflag;
u_short linkstate;
ip_address saddr;/* Source address */
u_short sport; /* Source port */
ip_address daddr;/* Destination address */
u_short dport; /* Destination port */
void (* app_process)(short int link_posi, short int applen);
u_long curr_seq;
u_long next_seq;
const u_char * uppkt;
u_long disorder_seq[10];
u_long disorder_ack[10];
u_short disorder_sum;
const u_char * disorder_pkt[10]; ////緩存未按序到達(dá)的tcp分片;
}tcp_linker;
#define newtcpreg() (tcp_register *)malloc(sizeof(tcp_register))
#define newtcplinkptr() (tcp_linker *)malloc(sizeof(tcp_linker))
#define newtcpfragptr() (tcpfrag *)malloc(sizeof(tcpfrag))
#define newudpptr() (udpinfo *)malloc(sizeof(udpinfo))
#define newfragptr() (fraginfo *)malloc(sizeof(fraginfo))
/* prototype of the packet handler */
void packet_handler(u_char *param, const struct pcap_pkthdr *header, const u_char *pkt_data);
void firstinit();
void tcp_register_func();//應(yīng)用層程序注冊函數(shù)
short int find_tcpreg(ip_header* ih, const u_char *pkt_data);
short int find_tcplink(ip_header* ih, const u_char *pkt_data);
///tcp數(shù)據(jù)報(bào)處理函數(shù);
short int tcp_reassemble(ip_header* ih, const u_char *pkt_data, short int link_posi);
short int upmore_func(ip_header* ih, const u_char *pkt_data, short int link_posi);
void ftp_print(short int link_posi, short int applen);
void http_print(short int link_posi, short int applen);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -