2 * Header for use in defining a given protocol for connection tracking.
4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp>
5 * - generalized L3 protocol dependent part.
7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h
10 #ifndef _NF_CONNTRACK_PROTOCOL_H
11 #define _NF_CONNTRACK_PROTOCOL_H
12 #include <net/netfilter/nf_conntrack.h>
17 struct nf_conntrack_protocol
20 struct list_head list
;
22 /* L3 Protocol number. */
25 /* Protocol number. */
31 /* Try to fill in the third arg: dataoff is offset past network protocol
32 hdr. Return true if possible. */
33 int (*pkt_to_tuple
)(const struct sk_buff
*skb
,
35 struct nf_conntrack_tuple
*tuple
);
37 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.
38 * Some packets can't be inverted: return 0 in that case.
40 int (*invert_tuple
)(struct nf_conntrack_tuple
*inverse
,
41 const struct nf_conntrack_tuple
*orig
);
43 /* Print out the per-protocol part of the tuple. Return like seq_* */
44 int (*print_tuple
)(struct seq_file
*s
,
45 const struct nf_conntrack_tuple
*);
47 /* Print out the private part of the conntrack. */
48 int (*print_conntrack
)(struct seq_file
*s
, const struct nf_conn
*);
50 /* Returns verdict for packet, or -1 for invalid. */
51 int (*packet
)(struct nf_conn
*conntrack
,
52 const struct sk_buff
*skb
,
54 enum ip_conntrack_info ctinfo
,
56 unsigned int hooknum
);
58 /* Called when a new connection for this protocol found;
59 * returns TRUE if it's OK. If so, packet() called next. */
60 int (*new)(struct nf_conn
*conntrack
, const struct sk_buff
*skb
,
61 unsigned int dataoff
);
63 /* Called when a conntrack entry is destroyed */
64 void (*destroy
)(struct nf_conn
*conntrack
);
66 int (*error
)(struct sk_buff
*skb
, unsigned int dataoff
,
67 enum ip_conntrack_info
*ctinfo
,
68 int pf
, unsigned int hooknum
);
70 /* convert protoinfo to nfnetink attributes */
71 int (*to_nfattr
)(struct sk_buff
*skb
, struct nfattr
*nfa
,
72 const struct nf_conn
*ct
);
74 /* convert nfnetlink attributes to protoinfo */
75 int (*from_nfattr
)(struct nfattr
*tb
[], struct nf_conn
*ct
);
77 int (*tuple_to_nfattr
)(struct sk_buff
*skb
,
78 const struct nf_conntrack_tuple
*t
);
79 int (*nfattr_to_tuple
)(struct nfattr
*tb
[],
80 struct nf_conntrack_tuple
*t
);
82 /* Module (if any) which this is connected to. */
86 /* Existing built-in protocols */
87 extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6
;
88 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4
;
89 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6
;
90 extern struct nf_conntrack_protocol nf_conntrack_generic_protocol
;
92 #define MAX_NF_CT_PROTO 256
93 extern struct nf_conntrack_protocol
**nf_ct_protos
[PF_MAX
];
95 extern struct nf_conntrack_protocol
*
96 __nf_ct_proto_find(u_int16_t l3proto
, u_int8_t protocol
);
98 extern struct nf_conntrack_protocol
*
99 nf_ct_proto_find_get(u_int16_t l3proto
, u_int8_t protocol
);
101 extern void nf_ct_proto_put(struct nf_conntrack_protocol
*p
);
103 /* Protocol registration. */
104 extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol
*proto
);
105 extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol
*proto
);
107 /* Generic netlink helpers */
108 extern int nf_ct_port_tuple_to_nfattr(struct sk_buff
*skb
,
109 const struct nf_conntrack_tuple
*tuple
);
110 extern int nf_ct_port_nfattr_to_tuple(struct nfattr
*tb
[],
111 struct nf_conntrack_tuple
*t
);
113 /* Log invalid packets */
114 extern unsigned int nf_ct_log_invalid
;
117 #ifdef DEBUG_INVALID_PACKETS
118 #define LOG_INVALID(proto) \
119 (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW)
121 #define LOG_INVALID(proto) \
122 ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \
126 #define LOG_INVALID(proto) 0
127 #endif /* CONFIG_SYSCTL */
129 #endif /*_NF_CONNTRACK_PROTOCOL_H*/