diff options
Diffstat (limited to 'other/3wahas/packet.h')
| -rw-r--r-- | other/3wahas/packet.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/other/3wahas/packet.h b/other/3wahas/packet.h new file mode 100644 index 0000000..4bc5b65 --- /dev/null +++ b/other/3wahas/packet.h | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | /* snifflib | ||
| 2 | * | ||
| 3 | * by scut | ||
| 4 | * | ||
| 5 | */ | ||
| 6 | |||
| 7 | #ifndef Z_PACKET_H | ||
| 8 | #define Z_PACKET_H | ||
| 9 | |||
| 10 | #include <sys/types.h> | ||
| 11 | #include <sys/time.h> | ||
| 12 | #include <unistd.h> | ||
| 13 | #include <netinet/in.h> | ||
| 14 | #include <pcap.h> | ||
| 15 | #include <semaphore.h> | ||
| 16 | #include <pthread.h> | ||
| 17 | |||
| 18 | /* packet structures | ||
| 19 | * parts ripped from snorts excellent include files | ||
| 20 | */ | ||
| 21 | |||
| 22 | |||
| 23 | typedef struct eth_hdr | ||
| 24 | { | ||
| 25 | u_char eth_dst[6]; /* ethernet destination address (MAC) */ | ||
| 26 | u_char eth_src[6]; /* ethernet source address (MAC) */ | ||
| 27 | u_short eth_type; /* enclosed packet type */ | ||
| 28 | } eth_hdr; | ||
| 29 | |||
| 30 | typedef struct ip_hdr | ||
| 31 | { | ||
| 32 | u_char ip_hlen:4, ip_ver:4; /* IP header length, IP version */ | ||
| 33 | u_char ip_tos; /* IP type of service */ | ||
| 34 | u_short ip_len; /* IP data length */ | ||
| 35 | u_short ip_id; /* IP fragmentation identification */ | ||
| 36 | u_short ip_off; /* IP fragment offset */ | ||
| 37 | u_char ip_ttl; /* IP time to live */ | ||
| 38 | u_char ip_proto; /* subprotocol of enclosed packet */ | ||
| 39 | u_short ip_csum; /* IP header checksum */ | ||
| 40 | struct in_addr ip_src; /* IP source address */ | ||
| 41 | struct in_addr ip_dst; /* IP destination address */ | ||
| 42 | } ip_hdr; | ||
| 43 | |||
| 44 | #define TH_FIN 0x01 | ||
| 45 | #define TH_SYN 0x02 | ||
| 46 | #define TH_RST 0x04 | ||
| 47 | #define TH_PUSH 0x08 | ||
| 48 | #define TH_ACK 0x10 | ||
| 49 | #define TH_URG 0x20 | ||
| 50 | |||
| 51 | typedef struct tcp_hdr | ||
| 52 | { | ||
| 53 | u_short th_sport; | ||
| 54 | u_short th_dport; | ||
| 55 | u_long th_seq; | ||
| 56 | u_long th_ack; | ||
| 57 | u_char th_x2:4, th_off:4; | ||
| 58 | u_char th_flags; | ||
| 59 | u_short th_win; | ||
| 60 | u_short th_sum; | ||
| 61 | u_short th_urp; | ||
| 62 | } tcp_hdr; | ||
| 63 | |||
| 64 | |||
| 65 | #define ETHHDRSIZE sizeof (eth_hdr); | ||
| 66 | #define IPHDRSIZE sizeof (ip_hdr); | ||
| 67 | |||
| 68 | |||
| 69 | void pq_grind (void *sinfov, struct pcap_pkthdr *pkthdr, unsigned char *pkt); | ||
| 70 | void pq_3whs (struct ip_hdr *ip, struct tcp_hdr *tcp); | ||
| 71 | void pq_syns (char *ip_src_c, char *ip_dst_c, u_short dst_prt); | ||
| 72 | |||
| 73 | #endif | ||
| 74 | |||
