FlowMon IPv6 Tunnel Monitoring Plugin
FlowMon IPv6 Tunnel Monitoring Plugin
 All Data Structures Files Functions Variables Macros Pages
input-ip6tun.h
Go to the documentation of this file.
1 
36 #ifndef _IP6TUN_H_
37 #define _IP6TUN_H_
38 
39 #include <netinet/if_ether.h>
40 
41 
42 #ifdef DEBUG
43 #define DBG(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
44 #else
45 #define DBG(format, ...) ;
46 #endif
47 
48 #ifdef HANIC
49 #define BUFSIZE 2000
50 #endif
51 
52 #ifdef IP6TUN_GEOIP
53 #define COUNTRY_CODE_LEN 4
54 #endif
55 
56 #define EXIT_TEREDO_TRAILER 66
57 
58 // value
59 #define IP6TUN_RECORD_INVALID 0x00000000
60 
61 // mask
62 #define IP6TUN_RECORD_L3_PROTO 0x00000001
63 #define IP6TUN_RECORD_IPV6 0x00000002
64 #define IP6TUN_RECORD_IPV4 0x00000004
65 #define IP6TUN_RECORD_L4_PROTO 0x00000008
66 #define IP6TUN_RECORD_PORTS 0x00000010
67 #define IP6TUN_RECORD_FLAGS 0x00000020
68 #define IP6TUN_RECORD_ICMP 0x00000040
69 #define IP6TUN_RECORD_TMECH 0x00000080
70 #define IP6TUN_RECORD_TEREDO_HDR 0x00000100
71 #define IP6TUN_RECORD_TEREDO_TRL 0x00000200
72 #define IP6TUN_RECORD_GEOIP_REG 0x00000400
73 #define IP6TUN_RECORD_GEOIP_IP6TUN 0x00000800
74 #define IP6TUN_RECORD_TTL_HOP 0x00001000
75 #define IP6TUN_RECORD_HOP 0x00002000
76 
77 #define IP6TUN_TMECH_NONE 0x00
78 #define IP6TUN_TMECH_TEREDO 0x01
79 #define IP6TUN_TMECH_ISATAP 0x02
80 #define IP6TUN_TMECH_6TO4 0x04
81 #define IP6TUN_TMECH_AYIYA 0x08
82 #define IP6TUN_TMECH_OTHER41 0x10
83 #define IP6TUN_TMECH_6OVER4 0x20
84 
85 #define TEREDO_TRL_NONCE 0x01
86 #define TEREDO_TRL_AADDR 0x02
87 #define TEREDO_TRL_NDISC 0x04
88 #define TEREDO_TRL_RPORT 0x08
89 
90 #define TEREDO_HDR_ORIG 0x01
91 #define TEREDO_HDR_AUTH 0x02
92 
93 #define PCAP_SIZE 1500
94 
95 #define IPPROTO_41 41
96 
97 #ifndef ETH_P_8021Q
98 #define ETH_P_8021Q 0x8100
99 #endif
100 
101 #define ETH_P_ISMP 0x81FD
102 
103 #ifndef ETH_P_MPLS_UC
104 #define ETH_P_MPLS_UC 0x8847
105 #endif
106 
107 #ifndef ETH_P_MPLS_MC
108 #define ETH_P_MPLS_MC 0x8848
109 #endif
110 
111 #define ETH_P_LLDP 0x88CC
112 
113 #define _ETH_P_8021AD 0x88A8
114 #define _ETH_P_8021QINQ 0x9100
115 #define _ETH_P_8021QINQ_DOUBLE 0x9200
116 #define _ETH_P_8021QINQ_TRIPPLE 0x9300
117 
118 #define VLAN_HLEN 4
119 #define VLAN_ID_MASK 0xFF0F
120 
121 #define MPLS_HLEN 4
122 #define MPLS_LABEL_SHIFT 12
123 #define MPLS_STACK_MASK 0xFF7F
124 
125 #define AYIYA_PORT 5072
126 #define AYIYA_BASE_HLEN 8
127 #define AYIYA_TIME_TOL 120
128 
129 #define TEREDO_AUTH_BASIC_HLEN 13
130 #define TEREDO_TRAILER_BASIC_LEN 2
131 #define TEREDO_ORIG_HLEN 8
132 #define TEREDO_ORIG_PRE 0x0000
133 #define TEREDO_ORIG_PRE_NO 0x0000
134 #define TEREDO_AUTH_PRE 0x0001
135 #define TEREDO_AUTH_PRE_NO 0x0100
136 #define TEREDO_PREFIX 0x2001
137 #define TEREDO_PREFIX_NO 0x0120
138 
139 #define ISATAP_MARK 0x5EFE
140 #define ISATAP_MARK_NO 0xFE5E
141 
142 #define _6TO4_RELAY 0xC0586301 // 192.88.99.1 anycast, relay router
143 #define _6TO4_RELAY_NO 0x58C00163
144 #define _6TO4_PREFIX 0x2002
145 #define _6TO4_PREFIX_NO 0x0220
146 
147 #define _6OVER4_PREFIX 0xFE80
148 #define _6OVER4_PREFIX_NO 0x80FE
149 
150 #define TCP_SPORT_OFFSET 0
151 #define TCP_DPORT_OFFSET 2
152 #define TCP_FLAGS_OFFSET 13
153 #define TCP_DATA_OFFSET_OFFSET 12
154 #define TCP_DATA_OFFSET_SHIFT 4
155 
156 #define IP_HLEN_MASK 0x0F
157 #define IP_TTL_OFFSET 0x08
158 
159 #define IPV6_HLEN 40
160 #define IPV6_HOP_OFFSET 0x07
161 
162 #define IPV6_LL_MASK 0xFE80
163 #define IPV6_LL_MASK_NO 0x80FE
164 
165 
166 
167 #define UDP_HLEN 8
168 #define UDP_DNS_PORT 53
169 
170 
171 /* return values */
172 #define GET_FAILED 1
173 
174 #define PARSE_FAILED 0
175 #define PARSE_SUCCESS 1
176 
177 #define INIT_FAILED 0
178 #define INIT_SUCCESS 1
179 
180 #define VALIDITE_FAILED 0
181 #define VALIDITE_SUCCESS 1
182 
183 /* time correction */
184 #define NSEC_IN_SEC 1000000000
185 #define NSEC_IN_USEC 1000
186 
187 /* struct definitions */
188 
192 struct __attribute__ ((packed)) ayiya_hdr {
193  uint8_t idlen_idtype;
194  uint8_t siglen_hshmeth;
195  uint8_t autmeth_opcode;
196  uint8_t next_header;
197  uint32_t timestamp;
198 #define getidlen idlen_idtype >> 4
199 #define getidtype idlen_idtype & 0xF0
200 #define getsiglen siglen_hshmeth >> 4
201 #define gethshmeth siglen_hshmeth & 0xF0
202 #define getautmeth autmeth_opcode >> 4
203 #define getopcode autmeth_opcode & 0xF0
204 };
205 
209 struct __attribute__ ((packed)) teredo_orig_hdr {
210  uint16_t preamble;
211  uint16_t port;
212  uint32_t address;
213 };
214 
218 struct __attribute__ ((packed)) teredo_basic_auth_hdr {
219  uint16_t preamble;
220  uint8_t idlen;
221  uint8_t aulen;
222 };
223 
227 struct __attribute__ ((packed)) teredo_trailer_hdr {
228  uint8_t type;
229  uint8_t len;
230 };
231 
232 #endif /* _IP6TUN_H_ */
233 

© 2012 Masaryk University - Institute of Computer Science - visit http://www.muni.cz/ics/