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>
16 struct nf_conntrack_protocol
19 struct list_head list
;
21 /* L3 Protocol number. */
24 /* Protocol number. */
30 /* Try to fill in the third arg: dataoff is offset past network protocol
31 hdr. Return true if possible. */
32 int (*pkt_to_tuple
)(const struct sk_buff
*skb
,
34 struct nf_conntrack_tuple
*tuple
);
36 /* Invert the per-proto part of the tuple: ie. turn xmit into reply.
37 * Some packets can't be inverted: return 0 in that case.
39 int (*invert_tuple
)(struct nf_conntrack_tuple
*inverse
,
40 const struct nf_conntrack_tuple
*orig
);
42 /* Print out the per-protocol part of the tuple. Return like seq_* */
43 int (*print_tuple
)(struct seq_file
*s
,
44 const struct nf_conntrack_tuple
*);
46 /* Print out the private part of the conntrack. */
47 int (*print_conntrack
)(struct seq_file
*s
, const struct nf_conn
*);
49 /* Returns verdict for packet, or -1 for invalid. */
50 int (*packet
)(struct nf_conn
*conntrack
,
51 const struct sk_buff
*skb
,
53 enum ip_conntrack_info ctinfo
,
55 unsigned int hooknum
);
57 /* Called when a new connection for this protocol found;
58 * returns TRUE if it's OK. If so, packet() called next. */
59 int (*new)(struct nf_conn
*conntrack
, const struct sk_buff
*skb
,
60 unsigned int dataoff
);
62 /* Called when a conntrack entry is destroyed */
63 void (*destroy
)(struct nf_conn
*conntrack
);
65 int (*error
)(struct sk_buff
*skb
, unsigned int dataoff
,
66 enum ip_conntrack_info
*ctinfo
,
67 int pf
, unsigned int hooknum
);
69 /* Module (if any) which this is connected to. */
73 /* Existing built-in protocols */
74 extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6
;
75 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4
;
76 extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6
;
77 extern struct nf_conntrack_protocol nf_conntrack_generic_protocol
;
79 #define MAX_NF_CT_PROTO 256
80 extern struct nf_conntrack_protocol
**nf_ct_protos
[PF_MAX
];
82 extern struct nf_conntrack_protocol
*
83 nf_ct_find_proto(u_int16_t l3proto
, u_int8_t protocol
);
85 /* Protocol registration. */
86 extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol
*proto
);
87 extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol
*proto
);
89 /* Log invalid packets */
90 extern unsigned int nf_ct_log_invalid
;
93 #ifdef DEBUG_INVALID_PACKETS
94 #define LOG_INVALID(proto) \
95 (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW)
97 #define LOG_INVALID(proto) \
98 ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \
102 #define LOG_INVALID(proto) 0
103 #endif /* CONFIG_SYSCTL */
105 #endif /*_NF_CONNTRACK_PROTOCOL_H*/