-
Notifications
You must be signed in to change notification settings - Fork 3
/
hook.h
74 lines (61 loc) · 1.29 KB
/
hook.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef __HOOK_H__
#define __HOOK_H__
enum {
NH_SET_FILTER = 1,
NH_RM_FILTER = 2,
NH_SET_WRITE_MODE = 3,
};
enum {
TO_INTERFACE = (1 << 0),
TO_INTERFACE_QUEUE = (1 << 1),
TO_ROUTING_STACK = (1 << 2),
};
struct nh_writer {
char dest_dev_str[255];
void *dest_dev;
int mode;
};
struct nh_filter {
unsigned char proto;
unsigned long saddr;
unsigned long daddr;
unsigned short dport;
unsigned short sport;
char in_dev[255];
char out_dev[255];
void *in;
void *out;
int priority;
int hooknum;
int flags;
};
#ifndef __KERNEL__
#include <stdio.h>
#include <linux/netfilter.h>
#define printk printf
#define KERN_ERR
#endif
static void dump_line(char *data, int offset, int limit)
{
int i;
printk(KERN_ERR "%03x:", offset);
for (i = 0; i < limit; i++) {
printk(" %02x", (unsigned char)data[offset + i]);
}
printk("\n");
}
static void __attribute__((unused)) dump_zone(void *buf, int len)
{
int i;
char *data = buf;
printk(KERN_ERR "================================================================================\n");
for (i=0; i < len; i+=16) {
int limit;
limit = 16;
if (i + limit > len)
limit = len - i;
dump_line(data, i, limit);
}
printk(KERN_ERR "================================================================================\n");
}
#endif /* __HOOK_H__ */