Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C)2003,2004 USAGI/WIDE Project |
| 3 | * |
| 4 | * Header for use in defining a given L3 protocol for connection tracking. |
| 5 | * |
| 6 | * Author: |
| 7 | * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> |
| 8 | * |
| 9 | * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h |
| 10 | */ |
| 11 | |
| 12 | #ifndef _NF_CONNTRACK_L3PROTO_H |
| 13 | #define _NF_CONNTRACK_L3PROTO_H |
| 14 | #include <linux/seq_file.h> |
| 15 | #include <net/netfilter/nf_conntrack.h> |
| 16 | |
Pablo Neira Ayuso | c1d10ad | 2006-01-05 12:19:05 -0800 | [diff] [blame] | 17 | struct nfattr; |
| 18 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 19 | struct nf_conntrack_l3proto |
| 20 | { |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 21 | /* L3 Protocol Family number. ex) PF_INET */ |
| 22 | u_int16_t l3proto; |
| 23 | |
| 24 | /* Protocol name */ |
| 25 | const char *name; |
| 26 | |
| 27 | /* |
| 28 | * Try to fill in the third arg: nhoff is offset of l3 proto |
| 29 | * hdr. Return true if possible. |
| 30 | */ |
| 31 | int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, |
| 32 | struct nf_conntrack_tuple *tuple); |
| 33 | |
| 34 | /* |
| 35 | * Invert the per-proto part of the tuple: ie. turn xmit into reply. |
| 36 | * Some packets can't be inverted: return 0 in that case. |
| 37 | */ |
| 38 | int (*invert_tuple)(struct nf_conntrack_tuple *inverse, |
| 39 | const struct nf_conntrack_tuple *orig); |
| 40 | |
| 41 | /* Print out the per-protocol part of the tuple. */ |
| 42 | int (*print_tuple)(struct seq_file *s, |
| 43 | const struct nf_conntrack_tuple *); |
| 44 | |
| 45 | /* Print out the private part of the conntrack. */ |
| 46 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); |
| 47 | |
| 48 | /* Returns verdict for packet, or -1 for invalid. */ |
| 49 | int (*packet)(struct nf_conn *conntrack, |
| 50 | const struct sk_buff *skb, |
| 51 | enum ip_conntrack_info ctinfo); |
| 52 | |
| 53 | /* |
| 54 | * Called when a new connection for this protocol found; |
| 55 | * returns TRUE if it's OK. If so, packet() called next. |
| 56 | */ |
| 57 | int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); |
| 58 | |
| 59 | /* Called when a conntrack entry is destroyed */ |
| 60 | void (*destroy)(struct nf_conn *conntrack); |
| 61 | |
| 62 | /* |
| 63 | * Called before tracking. |
| 64 | * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb |
| 65 | * *protonum: protocol number |
| 66 | */ |
| 67 | int (*prepare)(struct sk_buff **pskb, unsigned int hooknum, |
| 68 | unsigned int *dataoff, u_int8_t *protonum); |
| 69 | |
| 70 | u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple); |
| 71 | |
Pablo Neira Ayuso | c1d10ad | 2006-01-05 12:19:05 -0800 | [diff] [blame] | 72 | int (*tuple_to_nfattr)(struct sk_buff *skb, |
| 73 | const struct nf_conntrack_tuple *t); |
| 74 | |
| 75 | int (*nfattr_to_tuple)(struct nfattr *tb[], |
| 76 | struct nf_conntrack_tuple *t); |
| 77 | |
Patrick McHardy | d62f9ed | 2006-11-29 02:35:17 +0100 | [diff] [blame] | 78 | #ifdef CONFIG_SYSCTL |
| 79 | struct ctl_table_header *ctl_table_header; |
| 80 | struct ctl_table *ctl_table_path; |
| 81 | struct ctl_table *ctl_table; |
| 82 | #endif /* CONFIG_SYSCTL */ |
| 83 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 84 | /* Module (if any) which this is connected to. */ |
| 85 | struct module *me; |
| 86 | }; |
| 87 | |
| 88 | extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; |
| 89 | |
| 90 | /* Protocol registration. */ |
| 91 | extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); |
Martin Josefsson | ae5718f | 2006-11-29 02:35:08 +0100 | [diff] [blame] | 92 | extern int nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 93 | |
Pablo Neira Ayuso | c1d10ad | 2006-01-05 12:19:05 -0800 | [diff] [blame] | 94 | extern struct nf_conntrack_l3proto * |
| 95 | nf_ct_l3proto_find_get(u_int16_t l3proto); |
| 96 | |
| 97 | extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p); |
| 98 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 99 | /* Existing built-in protocols */ |
| 100 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; |
| 101 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 102 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic; |
Yasuyuki Kozakai | ddc8d02 | 2006-02-04 02:12:14 -0800 | [diff] [blame] | 103 | |
| 104 | static inline struct nf_conntrack_l3proto * |
| 105 | __nf_ct_l3proto_find(u_int16_t l3proto) |
| 106 | { |
| 107 | if (unlikely(l3proto >= AF_MAX)) |
Martin Josefsson | 605dcad | 2006-11-29 02:35:06 +0100 | [diff] [blame] | 108 | return &nf_conntrack_l3proto_generic; |
Yasuyuki Kozakai | ddc8d02 | 2006-02-04 02:12:14 -0800 | [diff] [blame] | 109 | return nf_ct_l3protos[l3proto]; |
| 110 | } |
| 111 | |
Yasuyuki Kozakai | 9fb9cbb | 2005-11-09 16:38:16 -0800 | [diff] [blame] | 112 | #endif /*_NF_CONNTRACK_L3PROTO_H*/ |