| skipped 26 lines |
27 | 27 | | #define IP_HL(ip) (((ip)->ip_vhl) & 0x0f) |
28 | 28 | | #define IP_V(ip) (((ip)->ip_vhl) >> 4) |
29 | 29 | | |
| 30 | + | typedef unsigned int tcp_seq; |
| 31 | + | |
| 32 | + | // tcp header |
| 33 | + | struct sniff_tcp{ |
| 34 | + | unsigned short th_sport; // source port |
| 35 | + | unsigned short th_dport; // destination port |
| 36 | + | tcp_seq th_seq; // sequence number |
| 37 | + | tcp_seq th_ack; // acknowledgement number |
| 38 | + | unsigned char th_offx2; // data offset, rsvd |
| 39 | + | #define TH_OFF(th) (((th)->th_offx2 & 0xf0) >> 4) |
| 40 | + | unsigned char th_flags; |
| 41 | + | #define TH_FIN 0x01 |
| 42 | + | #define TH_SYN 0x02 |
| 43 | + | #define TH_RST 0x04 |
| 44 | + | #define TH_PUSH 0x08 |
| 45 | + | #define TH_ACK 0x10 |
| 46 | + | #define TH_URG 0x20 |
| 47 | + | #define TH_ECE 0x40 |
| 48 | + | #define TH_CWR 0x80 |
| 49 | + | #define TH_FLAGS (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR) |
| 50 | + | unsigned short th_win; // window |
| 51 | + | unsigned short th_sum; // checksum |
| 52 | + | unsigned short th_urp; // urgent pointer |
| 53 | + | }; |
| 54 | + | |
30 | 55 | | // udp header |
31 | 56 | | struct sniff_udp{ |
32 | 57 | | unsigned short udph_sport; |
| skipped 9 lines |