Blame view

include/net/netfilter/nf_conntrack_l3proto.h 2.68 KB
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
1
2
3
4
5
6
7
8
9
10
11
12
13
  /*
   * Copyright (C)2003,2004 USAGI/WIDE Project
   *
   * Header for use in defining a given L3 protocol for connection tracking.
   *
   * Author:
   *	Yasuyuki Kozakai @USAGI	<yasuyuki.kozakai@toshiba.co.jp>
   *
   * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h
   */
  
  #ifndef _NF_CONNTRACK_L3PROTO_H
  #define _NF_CONNTRACK_L3PROTO_H
df6fb868d   Patrick McHardy   [NETFILTER]: nfne...
14
  #include <linux/netlink.h>
f73e924cd   Patrick McHardy   [NETFILTER]: ctne...
15
  #include <net/netlink.h>
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
16
17
  #include <linux/seq_file.h>
  #include <net/netfilter/nf_conntrack.h>
fd2c3ef76   Eric Dumazet   net: cleanup incl...
18
  struct nf_conntrack_l3proto {
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
19
20
21
22
23
24
25
26
27
28
  	/* L3 Protocol Family number. ex) PF_INET */
  	u_int16_t l3proto;
  
  	/* Protocol name */
  	const char *name;
  
  	/*
  	 * Try to fill in the third arg: nhoff is offset of l3 proto
           * hdr.  Return true if possible.
  	 */
8ce8439a3   Jan Engelhardt   [NETFILTER]: nf_c...
29
30
  	bool (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff,
  			     struct nf_conntrack_tuple *tuple);
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
31
32
33
34
35
  
  	/*
  	 * Invert the per-proto part of the tuple: ie. turn xmit into reply.
  	 * Some packets can't be inverted: return 0 in that case.
  	 */
8ce8439a3   Jan Engelhardt   [NETFILTER]: nf_c...
36
37
  	bool (*invert_tuple)(struct nf_conntrack_tuple *inverse,
  			     const struct nf_conntrack_tuple *orig);
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
38
39
40
41
  
  	/* Print out the per-protocol part of the tuple. */
  	int (*print_tuple)(struct seq_file *s,
  			   const struct nf_conntrack_tuple *);
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
42
43
  	/*
  	 * Called before tracking. 
ffc306904   Yasuyuki Kozakai   [NETFILTER]: nf_c...
44
  	 *	*dataoff: offset of protocol header (TCP, UDP,...) in skb
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
45
46
  	 *	*protonum: protocol number
  	 */
ffc306904   Yasuyuki Kozakai   [NETFILTER]: nf_c...
47
48
  	int (*get_l4proto)(const struct sk_buff *skb, unsigned int nhoff,
  			   unsigned int *dataoff, u_int8_t *protonum);
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
49

fdf708322   Patrick McHardy   [NETFILTER]: nfne...
50
  	int (*tuple_to_nlattr)(struct sk_buff *skb,
c1d10adb4   Pablo Neira Ayuso   [NETFILTER]: Add ...
51
  			       const struct nf_conntrack_tuple *t);
d0dba7255   Holger Eitzenberger   netfilter: ctnetl...
52
53
54
55
  	/*
  	 * Calculate size of tuple nlattr
  	 */
  	int (*nlattr_tuple_size)(void);
fdf708322   Patrick McHardy   [NETFILTER]: nfne...
56
  	int (*nlattr_to_tuple)(struct nlattr *tb[],
c1d10adb4   Pablo Neira Ayuso   [NETFILTER]: Add ...
57
  			       struct nf_conntrack_tuple *t);
f73e924cd   Patrick McHardy   [NETFILTER]: ctne...
58
  	const struct nla_policy *nla_policy;
c1d10adb4   Pablo Neira Ayuso   [NETFILTER]: Add ...
59

d0dba7255   Holger Eitzenberger   netfilter: ctnetl...
60
  	size_t nla_size;
d62f9ed4a   Patrick McHardy   [NETFILTER]: nf_c...
61
62
  #ifdef CONFIG_SYSCTL
  	struct ctl_table_header	*ctl_table_header;
b3fd3ffe3   Pavel Emelyanov   [NETFILTER]: Use ...
63
  	struct ctl_path		*ctl_table_path;
d62f9ed4a   Patrick McHardy   [NETFILTER]: nf_c...
64
65
  	struct ctl_table	*ctl_table;
  #endif /* CONFIG_SYSCTL */
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
66
67
68
  	/* Module (if any) which this is connected to. */
  	struct module *me;
  };
0e60ebe04   Eric Dumazet   netfilter: add __...
69
  extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX];
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
70
71
72
  
  /* Protocol registration. */
  extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto);
fe3eb20c1   Patrick McHardy   [NETFILTER]: nf_c...
73
  extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto);
a3c5029cf   Patrick McHardy   [NETFILTER]: nfne...
74
  extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto);
c1d10adb4   Pablo Neira Ayuso   [NETFILTER]: Add ...
75
  extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p);
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
76
  /* Existing built-in protocols */
605dcad6c   Martin Josefsson   [NETFILTER]: nf_c...
77
  extern struct nf_conntrack_l3proto nf_conntrack_l3proto_generic;
ddc8d029a   Yasuyuki Kozakai   [NETFILTER]: nf_c...
78
79
80
81
82
  
  static inline struct nf_conntrack_l3proto *
  __nf_ct_l3proto_find(u_int16_t l3proto)
  {
  	if (unlikely(l3proto >= AF_MAX))
605dcad6c   Martin Josefsson   [NETFILTER]: nf_c...
83
  		return &nf_conntrack_l3proto_generic;
923f4902f   Patrick McHardy   [NETFILTER]: nf_c...
84
  	return rcu_dereference(nf_ct_l3protos[l3proto]);
ddc8d029a   Yasuyuki Kozakai   [NETFILTER]: nf_c...
85
  }
9fb9cbb10   Yasuyuki Kozakai   [NETFILTER]: Add ...
86
  #endif /*_NF_CONNTRACK_L3PROTO_H*/