Home | History | Annotate | Download | only in netfilter
      1 /* This file was manually copied from the Linux kernel source
      2  * and manually stripped from __KERNEL__ sections and unused functions.
      3  */
      4 
      5 /*
      6  * Definitions and Declarations for tuple.
      7  *
      8  * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai (at) toshiba.co.jp>
      9  *	- generalize L3 protocol dependent part.
     10  *
     11  * Derived from include/linux/netfiter_ipv4/ip_conntrack_tuple.h
     12  */
     13 
     14 #ifndef _NF_CONNTRACK_TUPLE_H
     15 #define _NF_CONNTRACK_TUPLE_H
     16 
     17 #include <linux/netfilter/x_tables.h>
     18 #include <linux/netfilter/nf_conntrack_tuple_common.h>
     19 
     20 /* A `tuple' is a structure containing the information to uniquely
     21   identify a connection.  ie. if two packets have the same tuple, they
     22   are in the same connection; if not, they are not.
     23 
     24   We divide the structure along "manipulatable" and
     25   "non-manipulatable" lines, for the benefit of the NAT code.
     26 */
     27 
     28 #define NF_CT_TUPLE_L3SIZE	ARRAY_SIZE(((union nf_inet_addr *)NULL)->all)
     29 
     30 /* The protocol-specific manipulable parts of the tuple: always in
     31    network order! */
     32 union nf_conntrack_man_proto
     33 {
     34 	/* Add other protocols here. */
     35 	__be16 all;
     36 
     37 	struct {
     38 		__be16 port;
     39 	} tcp;
     40 	struct {
     41 		__be16 port;
     42 	} udp;
     43 	struct {
     44 		__be16 id;
     45 	} icmp;
     46 	struct {
     47 		__be16 port;
     48 	} dccp;
     49 	struct {
     50 		__be16 port;
     51 	} sctp;
     52 	struct {
     53 		__be16 key;	/* GRE key is 32bit, PPtP only uses 16bit */
     54 	} gre;
     55 };
     56 
     57 /* The manipulable part of the tuple. */
     58 struct nf_conntrack_man
     59 {
     60 	union nf_inet_addr u3;
     61 	union nf_conntrack_man_proto u;
     62 	/* Layer 3 protocol */
     63 	u_int16_t l3num;
     64 };
     65 
     66 /* This contains the information to distinguish a connection. */
     67 struct nf_conntrack_tuple
     68 {
     69 	struct nf_conntrack_man src;
     70 
     71 	/* These are the parts of the tuple which are fixed. */
     72 	struct {
     73 		union nf_inet_addr u3;
     74 		union {
     75 			/* Add other protocols here. */
     76 			__be16 all;
     77 
     78 			struct {
     79 				__be16 port;
     80 			} tcp;
     81 			struct {
     82 				__be16 port;
     83 			} udp;
     84 			struct {
     85 				u_int8_t type, code;
     86 			} icmp;
     87 			struct {
     88 				__be16 port;
     89 			} dccp;
     90 			struct {
     91 				__be16 port;
     92 			} sctp;
     93 			struct {
     94 				__be16 key;
     95 			} gre;
     96 		} u;
     97 
     98 		/* The protocol. */
     99 		u_int8_t protonum;
    100 
    101 		/* The direction (for tuplehash) */
    102 		u_int8_t dir;
    103 	} dst;
    104 };
    105 
    106 struct nf_conntrack_tuple_mask
    107 {
    108 	struct {
    109 		union nf_inet_addr u3;
    110 		union nf_conntrack_man_proto u;
    111 	} src;
    112 };
    113 
    114 #endif /* _NF_CONNTRACK_TUPLE_H */
    115