-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpfwall_public.h
90 lines (72 loc) · 1.69 KB
/
pfwall_public.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
Code shared between both kernel space and userspace including admin module are defined here
*/
#ifndef __PF_PUBLIC_H__
#define __PF_PUBLIC_H__
#include <linux/types.h>
struct PF_rule {
__u8 direction; // 0: ALL. 1: IN. 2: OUT.
__u8 proto; // 0: ALL. 1: TCP. 2: UDP.
__u32 srcip; // Source IP address.
__u32 dstip; // Destination IP address.
__u16 srcport; // Source port number.
__u16 dstport; // Destination port number.
__u8 action; // 0: DROP. 1: LOG.
__u32 index; // Rule index. Must be > 0
// For rules list in module.
#ifdef PF_KERNELSPACE
struct list_head list;
#endif
};
// Command values: Add rule, Delete rule, Flush rules etc,
enum {
CMD_ADD = 0,
CMD_DEL,
CMD_FLUSH,
CMD_MAX
};
// Action values: Drop, Pass, Log etc,.
enum {
ACT_DROP = 0,
ACT_PASS,
ACT_LOG,
ACT_MAX
};
// Traffic direction: All (Both), In or Out.
enum {
DIRECTION_ALL = 0,
DIRECTION_IN,
DIRECTION_OUT,
DIRECTION_MAX
};
// Network protocol: All, TCP, UDP etc,.
enum {
PROTO_ALL = 0,
PROTO_TCP,
PROTO_UDP,
PROTO_MAX
};
// Max network port value
#define PORT_MAX 65535
// Command strings
#define CMD_ADD_STR "ADD"
#define CMD_DEL_STR "DELETE"
#define CMD_FLUSH_STR "FLUSH"
// Action strings
#define ACT_DROP_STR "DROP"
#define ACT_PASS_STR "PASS"
#define ACT_LOG_STR "LOG"
// Direction strings
#define DIRECTION_ALL_STR "ALL"
#define DIRECTION_IN_STR "IN"
#define DIRECTION_OUT_STR "OUT"
// Protocol strings
#define PROTO_ALL_STR "ALL"
#define PROTO_TCP_STR "TCP"
#define PROTO_UDP_STR "UDP"
// Function prototypes
char* cmd_to_str(int cmd);
char* action_to_str(int action);
char* direction_to_str(int direction);
char* proto_to_str(int proto);
#endif