4 #include <linux/version.h>
7 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 7, 0)
10 #include <linux/netfilter_ipv4/ip_conntrack.h>
11 #include <linux/netfilter_ipv4/ip_conntrack_tuple.h>
20 #include <linux/netfilter/nf_conntrack_common.h>
23 #include <linux/netfilter_ipv4/ipt_conntrack_tuple.h>
33 #include <linux/netfilter/nf_conntrack_common.h>
34 #include <linux/netfilter_ipv4/ipt_conntrack.h>
35 #include <linux/netfilter_ipv4/ipt_connmark.h>
36 #include <linux/netfilter_ipv4/ipt_CONNMARK.h>
41 #include <linux/netfilter/nf_conntrack_common.h>
46 #define MANGLE_TABLE "mangle"
47 #define FILTER_TABLE "filter"
48 #define NTK_MARK_CHAIN "ntk_mark_chain"
49 #define CHAIN_OUTPUT "OUTPUT"
50 #define CHAIN_POSTROUTING "POSTROUTING"
51 #define CHAIN_PREROUTING "PREROUTING"
52 #define CHAIN_POSTROUTING "POSTROUTING"
53 #define CHAIN_FORWARD "FORWARD"
55 #define MOD_CONNTRACK "conntrack"
56 #define MOD_CONNMARK "CONNMARK"
57 #define MARK_TARGET "MARK"
59 #define NTK_NET_STR "10.0.0.0"
60 #define NTK_NET_MASK_STR "255.0.0.0"
62 #define IPT_ENTRY_SZ sizeof(struct ipt_entry)
63 #define IPT_ENTRY_MATCH_SZ sizeof(struct ipt_entry_match)
64 #define IPT_ENTRY_TARGET_SZ sizeof(struct ipt_entry_target)
65 #define IPT_CT_INFO_SZ sizeof(struct ipt_conntrack_info)
66 #define IPT_CM_TARGET_INFO_SZ sizeof(struct ipt_connmark_target_info)
68 #define MATCH_SZ IPT_ENTRY_MATCH_SZ+IPT_CT_INFO_SZ
69 #define TARGET_SZ IPT_ENTRY_TARGET_SZ+IPT_CM_TARGET_INFO_SZ
71 #define RESTORE_OUTPUT_RULE_SZ IPT_ENTRY_SZ+MATCH_SZ+TARGET_SZ
73 #define OFFSET_MATCH IPT_ENTRY_SZ
74 #define OFFSET_MATCH_INFO OFFSET_MATCH+IPT_ENTRY_MATCH_SZ
75 #define OFFSET_TARGET OFFSET_MATCH_INFO+IPT_CT_INFO_SZ
76 #define OFFSET_TARGET_INFO OFFSET_TARGET+IPT_ENTRY_TARGET_SZ
78 #define MARK_RULE_SZ IPT_ENTRY_SZ+TARGET_SZ
79 #define MAX_MARK_RULES 100
81 #define NTK_FORWARD_RULE_SZ OFFSET_TARGET_INFO+4
83 #define IGW_FILTER_RULE_SZ IPT_ENTRY_SZ+IPT_ENTRY_SZ+4
86 #define MAX_RULE_SZ RESTORE_OUTPUT_RULE_SZ
int ntk_mark_chain_init(iptc_handle_t *t)
Definition: mark.c:268
int commit_rules(iptc_handle_t *t)
Definition: mark.c:104
int append_rule(const char *rule, iptc_handle_t *t, const char *chain)
Definition: mark.c:88
int delete_ntk_forward_chain(iptc_handle_t *t)
Definition: mark.c:564
void igw_mark_rule_init(char *rule)
Definition: mark.c:243
int delete_first_rule(iptc_handle_t *t, const char *chain)
Definition: mark.c:586
int insert_rule(const char *rule, iptc_handle_t *t, const char *chain, int pos)
Definition: mark.c:72
struct iptc_handle * iptc_handle_t
Definition: libiptc.h:51
int table_init(const char *table, iptc_handle_t *t)
Definition: mark.c:55
int sz
Definition: mark.h:92
int store_rules()
Definition: mark.c:297
void ntk_forward_rule_init(char *rule)
Definition: mark.c:170
int delete_rule(rule_store *rule, iptc_handle_t *t)
Definition: mark.c:633
char * chain
Definition: mark.h:93
int count_ntk_mark_chain(iptc_handle_t *t)
Definition: mark.c:489
char e[sizeof(struct ipt_entry)+sizeof(struct ipt_entry_match)+sizeof(struct ipt_conntrack_info)+sizeof(struct ipt_entry_target)+sizeof(struct ipt_connmark_target_info)]
Definition: mark.h:91
struct rule_store rule_store
int create_mark_rules(int n)
Definition: mark.c:519
#define RESTORE_OUTPUT_RULE_SZ
Definition: mark.h:71
int mark_init(int igw)
Definition: mark.c:400
void restore_output_rule_init(char *rule)
Definition: mark.c:125
int mark_close()
Definition: mark.c:657
void mark_rule_init(char *rule, char *outiface, int outiface_num)
Definition: mark.c:209
int rule_position(rule_store *rule, iptc_handle_t *t)
Definition: mark.c:609