-
Notifications
You must be signed in to change notification settings - Fork 0
/
packet_sniffer.h
57 lines (45 loc) · 1019 Bytes
/
packet_sniffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef PACKET_SNIFFER_H
#define PACKET_SNIFFER_H
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/icmpv6.h>
#include <linux/icmp.h>
#include <linux/igmp.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#define DEVICE_NAME "packet_sniffer"
#define BUFFER_SIZE 4096
#define HTTP_METHOD_SIZE 8
#define HTTP_BODY_SIZE 1024
#define HOSTNAME_SIZE 256
#define MASK_NETWORK 0x0000ffff
#define MASK_TRANSPORT 0xffff0000
struct net_packet {
unsigned long timestamp_sec;
unsigned long timestamp_nsec;
struct ethhdr ethh;
union {
struct tcphdr tcph;
struct udphdr udph;
struct igmphdr igmph;
union {
struct icmphdr icmpv4h;
struct icmp6hdr icmpv6h;
} icmph;
} transport;
union {
struct ipv6hdr ipv6h;
struct iphdr ipv4h;
} network;
int protocol;
int eth_protocol;
// Not used yet
//char http_method[HTTP_METHOD_SIZE];
//char http_body[HTTP_BODY_SIZE];
//char hostname[HOSTNAME_SIZE];
int length;
int skb_len;
int cpu_id;
};
#endif