1/* 2 * Definitions and Declarations for tuple. 3 * 4 * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> 5 * - generalize L3 protocol dependent part. 6 * 7 * Derived from include/linux/netfiter_ipv4/ip_conntrack_tuple.h 8 */ 9 10#ifndef _NF_CONNTRACK_TUPLE_H 11#define _NF_CONNTRACK_TUPLE_H 12 13#include <linux/netfilter/nf_conntrack_tuple_common.h> 14 15/* A `tuple' is a structure containing the information to uniquely 16 identify a connection. ie. if two packets have the same tuple, they 17 are in the same connection; if not, they are not. 18 19 We divide the structure along "manipulatable" and 20 "non-manipulatable" lines, for the benefit of the NAT code. 21*/ 22 23#define NF_CT_TUPLE_L3SIZE 4 24 25/* The l3 protocol-specific manipulable parts of the tuple: always in 26 network order! */ 27union nf_conntrack_address { 28 u_int32_t all[NF_CT_TUPLE_L3SIZE]; 29 __be32 ip; 30 __be32 ip6[4]; 31}; 32 33/* The protocol-specific manipulable parts of the tuple: always in 34 network order! */ 35union nf_conntrack_man_proto 36{ 37 /* Add other protocols here. */ 38 u_int16_t all; 39 40 struct { 41 __be16 port; 42 } tcp; 43 struct { 44 __be16 port; 45 } udp; 46 struct { 47 __be16 id; 48 } icmp; 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. */ 58struct nf_conntrack_man 59{ 60 union nf_conntrack_address 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. */ 67struct 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_conntrack_address u3; 74 union { 75 /* Add other protocols here. */ 76 u_int16_t 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 } sctp; 90 struct { 91 __be16 key; 92 } gre; 93 } u; 94 95 /* The protocol. */ 96 u_int8_t protonum; 97 98 /* The direction (for tuplehash) */ 99 u_int8_t dir; 100 } dst; 101}; 102 103#endif /* _NF_CONNTRACK_TUPLE_H */ 104