39 #include <netinet/if_ether.h>
43 #define DBG(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
45 #define DBG(format, ...) ;
53 #define COUNTRY_CODE_LEN 4
56 #define EXIT_TEREDO_TRAILER 66
59 #define IP6TUN_RECORD_INVALID 0x00000000
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
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
85 #define TEREDO_TRL_NONCE 0x01
86 #define TEREDO_TRL_AADDR 0x02
87 #define TEREDO_TRL_NDISC 0x04
88 #define TEREDO_TRL_RPORT 0x08
90 #define TEREDO_HDR_ORIG 0x01
91 #define TEREDO_HDR_AUTH 0x02
93 #define PCAP_SIZE 1500
98 #define ETH_P_8021Q 0x8100
101 #define ETH_P_ISMP 0x81FD
103 #ifndef ETH_P_MPLS_UC
104 #define ETH_P_MPLS_UC 0x8847
107 #ifndef ETH_P_MPLS_MC
108 #define ETH_P_MPLS_MC 0x8848
111 #define ETH_P_LLDP 0x88CC
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
119 #define VLAN_ID_MASK 0xFF0F
122 #define MPLS_LABEL_SHIFT 12
123 #define MPLS_STACK_MASK 0xFF7F
125 #define AYIYA_PORT 5072
126 #define AYIYA_BASE_HLEN 8
127 #define AYIYA_TIME_TOL 120
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
139 #define ISATAP_MARK 0x5EFE
140 #define ISATAP_MARK_NO 0xFE5E
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
147 #define _6OVER4_PREFIX 0xFE80
148 #define _6OVER4_PREFIX_NO 0x80FE
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
156 #define IP_HLEN_MASK 0x0F
157 #define IP_TTL_OFFSET 0x08
160 #define IPV6_HOP_OFFSET 0x07
162 #define IPV6_LL_MASK 0xFE80
163 #define IPV6_LL_MASK_NO 0x80FE
168 #define UDP_DNS_PORT 53
174 #define PARSE_FAILED 0
175 #define PARSE_SUCCESS 1
177 #define INIT_FAILED 0
178 #define INIT_SUCCESS 1
180 #define VALIDITE_FAILED 0
181 #define VALIDITE_SUCCESS 1
184 #define NSEC_IN_SEC 1000000000
185 #define NSEC_IN_USEC 1000
193 uint8_t idlen_idtype;
194 uint8_t siglen_hshmeth;
195 uint8_t autmeth_opcode;
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