PageRenderTime 38ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 1ms

/epan/dissectors/packet-ipv6.c

https://github.com/labx-technologies-llc/wireshark
C | 2899 lines | 2426 code | 305 blank | 168 comment | 169 complexity | 2808ed312cbe5e2ce39bfb3744b7a63c MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /* packet-ipv6.c
  2. * Routines for IPv6 packet disassembly
  3. *
  4. * $Id$
  5. *
  6. * Wireshark - Network traffic analyzer
  7. * By Gerald Combs <gerald@wireshark.org>
  8. * Copyright 1998 Gerald Combs
  9. *
  10. * SHIM6 support added by Matthijs Mekking <matthijs@NLnetLabs.nl>
  11. *
  12. * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  27. */
  28. #include "config.h"
  29. #include <math.h>
  30. #include <glib.h>
  31. #include <epan/packet.h>
  32. #include <epan/expert.h>
  33. #include <epan/ip_opts.h>
  34. #include <epan/addr_resolv.h>
  35. #include <epan/prefs.h>
  36. #include <epan/reassemble.h>
  37. #include <epan/ipproto.h>
  38. #include <epan/ipv6-utils.h>
  39. #include <epan/etypes.h>
  40. #include <epan/ppptypes.h>
  41. #include <epan/aftypes.h>
  42. #include <epan/nlpid.h>
  43. #include <epan/arcnet_pids.h>
  44. #include <epan/in_cksum.h>
  45. #include <epan/expert.h>
  46. #include <epan/emem.h>
  47. #include <epan/tap.h>
  48. #include "packet-ipsec.h"
  49. #include "packet-ipv6.h"
  50. #include "packet-ip.h"
  51. #ifdef HAVE_GEOIP_V6
  52. #include <GeoIP.h>
  53. #include <epan/geoip_db.h>
  54. #endif /* HAVE_GEOIP_V6 */
  55. /* Differentiated Services Field. See RFCs 2474, 2597 and 2598. */
  56. #define IPDSFIELD_DSCP_MASK 0xFC
  57. #define IPDSFIELD_ECN_MASK 0x03
  58. #define IPDSFIELD_DSCP_SHIFT 2
  59. #define IPDSFIELD_DSCP(dsfield) (((dsfield)&IPDSFIELD_DSCP_MASK)>>IPDSFIELD_DSCP_SHIFT)
  60. #define IPDSFIELD_ECN(dsfield) ((dsfield)&IPDSFIELD_ECN_MASK)
  61. #define IPDSFIELD_DSCP_DEFAULT 0x00
  62. #define IPDSFIELD_DSCP_CS1 0x08
  63. #define IPDSFIELD_DSCP_CS2 0x10
  64. #define IPDSFIELD_DSCP_CS3 0x18
  65. #define IPDSFIELD_DSCP_CS4 0x20
  66. #define IPDSFIELD_DSCP_CS5 0x28
  67. #define IPDSFIELD_DSCP_CS6 0x30
  68. #define IPDSFIELD_DSCP_CS7 0x38
  69. #define IPDSFIELD_DSCP_AF11 0x0A
  70. #define IPDSFIELD_DSCP_AF12 0x0C
  71. #define IPDSFIELD_DSCP_AF13 0x0E
  72. #define IPDSFIELD_DSCP_AF21 0x12
  73. #define IPDSFIELD_DSCP_AF22 0x14
  74. #define IPDSFIELD_DSCP_AF23 0x16
  75. #define IPDSFIELD_DSCP_AF31 0x1A
  76. #define IPDSFIELD_DSCP_AF32 0x1C
  77. #define IPDSFIELD_DSCP_AF33 0x1E
  78. #define IPDSFIELD_DSCP_AF41 0x22
  79. #define IPDSFIELD_DSCP_AF42 0x24
  80. #define IPDSFIELD_DSCP_AF43 0x26
  81. #define IPDSFIELD_DSCP_EF 0x2E
  82. #define IPDSFIELD_ECT_MASK 0x02
  83. #define IPDSFIELD_CE_MASK 0x01
  84. /* RPL Routing header */
  85. #define IP6RRPL_BITMASK_CMPRI 0xF0000000
  86. #define IP6RRPL_BITMASK_CMPRE 0x0F000000
  87. #define IP6RRPL_BITMASK_PAD 0x00F00000
  88. #define IP6RRPL_BITMASK_RESERVED 0x000FFFFF
  89. static int ipv6_tap = -1;
  90. static int proto_ipv6 = -1;
  91. static int hf_ipv6_version = -1;
  92. static int hf_ip_version = -1;
  93. static int hf_ipv6_class = -1;
  94. static int hf_ipv6_flow = -1;
  95. static int hf_ipv6_plen = -1;
  96. static int hf_ipv6_nxt = -1;
  97. static int hf_ipv6_hlim = -1;
  98. static int hf_ipv6_src = -1;
  99. static int hf_ipv6_src_host = -1;
  100. static int hf_ipv6_src_sa_mac = -1;
  101. static int hf_ipv6_src_isatap_ipv4 = -1;
  102. static int hf_ipv6_src_6to4_gateway_ipv4 = -1;
  103. static int hf_ipv6_src_6to4_sla_id = -1;
  104. static int hf_ipv6_src_teredo_server_ipv4 = -1;
  105. static int hf_ipv6_src_teredo_port = -1;
  106. static int hf_ipv6_src_teredo_client_ipv4 = -1;
  107. static int hf_ipv6_dst = -1;
  108. static int hf_ipv6_dst_host = -1;
  109. static int hf_ipv6_dst_sa_mac = -1;
  110. static int hf_ipv6_dst_isatap_ipv4 = -1;
  111. static int hf_ipv6_dst_6to4_gateway_ipv4 = -1;
  112. static int hf_ipv6_dst_6to4_sla_id = -1;
  113. static int hf_ipv6_dst_teredo_server_ipv4 = -1;
  114. static int hf_ipv6_dst_teredo_port = -1;
  115. static int hf_ipv6_dst_teredo_client_ipv4 = -1;
  116. static int hf_ipv6_addr = -1;
  117. static int hf_ipv6_host = -1;
  118. static int hf_ipv6_sa_mac = -1;
  119. static int hf_ipv6_isatap_ipv4 = -1;
  120. static int hf_ipv6_6to4_gateway_ipv4 = -1;
  121. static int hf_ipv6_6to4_sla_id = -1;
  122. static int hf_ipv6_teredo_server_ipv4 = -1;
  123. static int hf_ipv6_teredo_port = -1;
  124. static int hf_ipv6_teredo_client_ipv4 = -1;
  125. static int hf_ipv6_opt = -1;
  126. static int hf_ipv6_opt_type = -1;
  127. static int hf_ipv6_opt_length = -1;
  128. static int hf_ipv6_opt_pad1 = -1;
  129. static int hf_ipv6_opt_padn = -1;
  130. static int hf_ipv6_opt_tel = -1;
  131. static int hf_ipv6_opt_rtalert = -1;
  132. static int hf_ipv6_opt_jumbo = -1;
  133. static int hf_ipv6_opt_calipso_doi = -1;
  134. static int hf_ipv6_opt_calipso_cmpt_length = -1;
  135. static int hf_ipv6_opt_calipso_sens_level = -1;
  136. static int hf_ipv6_opt_calipso_checksum = -1;
  137. static int hf_ipv6_opt_calipso_cmpt_bitmap = -1;
  138. static int hf_ipv6_opt_qs_func = -1;
  139. static int hf_ipv6_opt_qs_rate = -1;
  140. static int hf_ipv6_opt_qs_ttl = -1;
  141. static int hf_ipv6_opt_qs_ttl_diff = -1;
  142. static int hf_ipv6_opt_qs_unused = -1;
  143. static int hf_ipv6_opt_qs_nonce = -1;
  144. static int hf_ipv6_opt_qs_reserved = -1;
  145. static int hf_ipv6_opt_rpl_flag = -1;
  146. static int hf_ipv6_opt_rpl_flag_o = -1;
  147. static int hf_ipv6_opt_rpl_flag_r = -1;
  148. static int hf_ipv6_opt_rpl_flag_f = -1;
  149. static int hf_ipv6_opt_rpl_flag_rsv = -1;
  150. static int hf_ipv6_opt_rpl_instance_id = -1;
  151. static int hf_ipv6_opt_rpl_senderrank = -1;
  152. static int hf_ipv6_opt_experimental = -1;
  153. static int hf_ipv6_opt_unknown = -1;
  154. static int hf_ipv6_dst_opt = -1;
  155. static int hf_ipv6_hop_opt = -1;
  156. static int hf_ipv6_unk_hdr = -1;
  157. static int hf_ipv6_routing_hdr_opt = -1;
  158. static int hf_ipv6_routing_hdr_type = -1;
  159. static int hf_ipv6_routing_hdr_left = -1;
  160. static int hf_ipv6_routing_hdr_addr = -1;
  161. static int hf_ipv6_frag_nxt = -1;
  162. static int hf_ipv6_frag_reserved = -1;
  163. static int hf_ipv6_frag_offset = -1;
  164. static int hf_ipv6_frag_reserved_bits = -1;
  165. static int hf_ipv6_frag_more = -1;
  166. static int hf_ipv6_frag_id = -1;
  167. static int hf_ipv6_fragments = -1;
  168. static int hf_ipv6_fragment = -1;
  169. static int hf_ipv6_fragment_overlap = -1;
  170. static int hf_ipv6_fragment_overlap_conflict = -1;
  171. static int hf_ipv6_fragment_multiple_tails = -1;
  172. static int hf_ipv6_fragment_too_long_fragment = -1;
  173. static int hf_ipv6_fragment_error = -1;
  174. static int hf_ipv6_fragment_count = -1;
  175. static int hf_ipv6_reassembled_in = -1;
  176. static int hf_ipv6_reassembled_length = -1;
  177. static int hf_ipv6_reassembled_data = -1;
  178. static int hf_ipv6_mipv6_home_address = -1;
  179. static int hf_ipv6_routing_hdr_rpl_cmprI = -1;
  180. static int hf_ipv6_routing_hdr_rpl_cmprE = -1;
  181. static int hf_ipv6_routing_hdr_rpl_pad = -1;
  182. static int hf_ipv6_routing_hdr_rpl_reserved = -1;
  183. static int hf_ipv6_routing_hdr_rpl_segments = -1;
  184. static int hf_ipv6_routing_hdr_rpl_addr = -1;
  185. static int hf_ipv6_routing_hdr_rpl_fulladdr = -1;
  186. static int hf_ipv6_shim6 = -1;
  187. static int hf_ipv6_shim6_nxt = -1;
  188. static int hf_ipv6_shim6_len = -1;
  189. static int hf_ipv6_shim6_p = -1;
  190. /* context tag is 49 bits, cannot be used for filter yet */
  191. static int hf_ipv6_shim6_ct = -1;
  192. static int hf_ipv6_shim6_type = -1;
  193. static int hf_ipv6_shim6_proto = -1;
  194. static int hf_ipv6_shim6_checksum = -1;
  195. static int hf_ipv6_shim6_checksum_bad = -1;
  196. static int hf_ipv6_shim6_checksum_good = -1;
  197. static int hf_ipv6_shim6_inonce = -1; /* also for request nonce */
  198. static int hf_ipv6_shim6_rnonce = -1;
  199. static int hf_ipv6_shim6_precvd = -1;
  200. static int hf_ipv6_shim6_psent = -1;
  201. static int hf_ipv6_shim6_psrc = -1;
  202. static int hf_ipv6_shim6_pdst = -1;
  203. static int hf_ipv6_shim6_pnonce = -1;
  204. static int hf_ipv6_shim6_pdata = -1;
  205. static int hf_ipv6_shim6_sulid = -1;
  206. static int hf_ipv6_shim6_rulid = -1;
  207. static int hf_ipv6_shim6_reap = -1;
  208. static int hf_ipv6_shim6_opt_type = -1;
  209. static int hf_ipv6_shim6_opt_len = -1;
  210. static int hf_ipv6_shim6_opt_total_len = -1;
  211. static int hf_ipv6_shim6_opt_loc_verif_methods = -1;
  212. static int hf_ipv6_shim6_opt_critical = -1;
  213. static int hf_ipv6_shim6_opt_loclist = -1;
  214. static int hf_ipv6_shim6_locator = -1;
  215. static int hf_ipv6_shim6_loc_flag = -1;
  216. static int hf_ipv6_shim6_loc_prio = -1;
  217. static int hf_ipv6_shim6_loc_weight = -1;
  218. static int hf_ipv6_shim6_opt_locnum = -1;
  219. static int hf_ipv6_shim6_opt_elemlen = -1;
  220. static int hf_ipv6_shim6_opt_fii = -1;
  221. static int hf_ipv6_traffic_class_dscp = -1;
  222. static int hf_ipv6_traffic_class_ect = -1;
  223. static int hf_ipv6_traffic_class_ce = -1;
  224. #ifdef HAVE_GEOIP_V6
  225. static int hf_geoip_country = -1;
  226. static int hf_geoip_city = -1;
  227. static int hf_geoip_org = -1;
  228. static int hf_geoip_isp = -1;
  229. static int hf_geoip_asnum = -1;
  230. static int hf_geoip_lat = -1;
  231. static int hf_geoip_lon = -1;
  232. static int hf_geoip_src_country = -1;
  233. static int hf_geoip_src_city = -1;
  234. static int hf_geoip_src_org = -1;
  235. static int hf_geoip_src_isp = -1;
  236. static int hf_geoip_src_asnum = -1;
  237. static int hf_geoip_src_lat = -1;
  238. static int hf_geoip_src_lon = -1;
  239. static int hf_geoip_dst_country = -1;
  240. static int hf_geoip_dst_city = -1;
  241. static int hf_geoip_dst_org = -1;
  242. static int hf_geoip_dst_isp = -1;
  243. static int hf_geoip_dst_asnum = -1;
  244. static int hf_geoip_dst_lat = -1;
  245. static int hf_geoip_dst_lon = -1;
  246. #endif /* HAVE_GEOIP_V6 */
  247. static gint ett_ipv6 = -1;
  248. static gint ett_ipv6_opt = -1;
  249. static gint ett_ipv6_opt_flag = -1;
  250. static gint ett_ipv6_version = -1;
  251. static gint ett_ipv6_shim6 = -1;
  252. static gint ett_ipv6_shim6_option = -1;
  253. static gint ett_ipv6_shim6_locators = -1;
  254. static gint ett_ipv6_shim6_verif_methods = -1;
  255. static gint ett_ipv6_shim6_loc_pref = -1;
  256. static gint ett_ipv6_shim6_probes_sent = -1;
  257. static gint ett_ipv6_shim6_probe_sent = -1;
  258. static gint ett_ipv6_shim6_probes_rcvd = -1;
  259. static gint ett_ipv6_shim6_probe_rcvd = -1;
  260. static gint ett_ipv6_shim6_cksum = -1;
  261. static gint ett_ipv6_fragments = -1;
  262. static gint ett_ipv6_fragment = -1;
  263. static gint ett_ipv6_traffic_class = -1;
  264. #ifdef HAVE_GEOIP_V6
  265. static gint ett_geoip_info = -1;
  266. #endif /* HAVE_GEOIP_V6 */
  267. static expert_field ei_ipv6_dst_addr_not_multicast = EI_INIT;
  268. static expert_field ei_ipv6_src_route_list_mult_inst_same_addr = EI_INIT;
  269. static expert_field ei_ipv6_src_route_list_src_addr = EI_INIT;
  270. static expert_field ei_ipv6_src_route_list_dst_addr = EI_INIT;
  271. static expert_field ei_ipv6_src_route_list_multicast_addr = EI_INIT;
  272. static expert_field ei_ipv6_cmpri_cmpre_pad = EI_INIT;
  273. static expert_field ei_ipv6_routing_hdr_rpl_reserved = EI_INIT;
  274. static expert_field ei_ipv6_opt_tel_invalid_len = EI_INIT;
  275. static expert_field ei_ipv6_opt_jumbo_invalid_len = EI_INIT;
  276. static expert_field ei_ipv6_opt_rtalert_invalid_len = EI_INIT;
  277. static expert_field ei_ipv6_mipv6_home_address_invalid_len = EI_INIT;
  278. static expert_field ei_ipv6_shim6_opt_elemlen_invalid = EI_INIT;
  279. static expert_field ei_ipv6_shim6_checksum_bad = EI_INIT;
  280. static expert_field ei_ipv6_routing_hdr_rpl_segments_ge0 = EI_INIT;
  281. static const fragment_items ipv6_frag_items = {
  282. &ett_ipv6_fragment,
  283. &ett_ipv6_fragments,
  284. &hf_ipv6_fragments,
  285. &hf_ipv6_fragment,
  286. &hf_ipv6_fragment_overlap,
  287. &hf_ipv6_fragment_overlap_conflict,
  288. &hf_ipv6_fragment_multiple_tails,
  289. &hf_ipv6_fragment_too_long_fragment,
  290. &hf_ipv6_fragment_error,
  291. &hf_ipv6_fragment_count,
  292. &hf_ipv6_reassembled_in,
  293. &hf_ipv6_reassembled_length,
  294. &hf_ipv6_reassembled_data,
  295. "IPv6 fragments"
  296. };
  297. static dissector_handle_t data_handle;
  298. static dissector_table_t ip_dissector_table;
  299. /* Reassemble fragmented datagrams */
  300. static gboolean ipv6_reassemble = TRUE;
  301. /* Place IPv6 summary in proto tree */
  302. static gboolean ipv6_summary_in_tree = TRUE;
  303. #ifdef HAVE_GEOIP_V6
  304. /* Look up addresses in GeoIP */
  305. static gboolean ipv6_use_geoip = TRUE;
  306. #endif /* HAVE_GEOIP_V6 */
  307. /* Perform strict RFC adherence checking */
  308. static gboolean g_ipv6_rpl_srh_strict_rfc_checking = FALSE;
  309. #ifndef offsetof
  310. #define offsetof(type, member) ((size_t)(&((type *)0)->member))
  311. #endif
  312. /*
  313. * defragmentation of IPv6
  314. */
  315. static reassembly_table ipv6_reassembly_table;
  316. /* http://www.iana.org/assignments/icmpv6-parameters (last updated 2012-12-22) */
  317. static const value_string ipv6_opt_vals[] = {
  318. { IP6OPT_PAD1, "Pad1" },
  319. { IP6OPT_PADN, "PadN" },
  320. { IP6OPT_TEL, "Tunnel Encapsulation Limit" },
  321. { IP6OPT_RTALERT, "Router Alert" },
  322. { IP6OPT_CALIPSO, "Calipso" },
  323. { IP6OPT_QUICKSTART, "Quick Start" },
  324. { IP6OPT_ENDI, "Endpoint Identification" },
  325. { IP6OPT_EXP_1E, "Experimental (0x1E)" },
  326. { IP6OPT_EXP_3E, "Experimental (0x3E)" },
  327. { IP6OPT_EXP_5E, "Experimental (0x5E)" },
  328. { IP6OPT_RPL, "RPL Option" },
  329. { IP6OPT_EXP_7E, "Experimental (0x7E)" },
  330. { IP6OPT_EXP_9E, "Experimental (0x9E)" },
  331. { IP6OPT_EXP_BE, "Experimental (0xBE)" },
  332. { IP6OPT_JUMBO, "Jumbo" },
  333. { IP6OPT_HOME_ADDRESS, "Home Address" },
  334. { IP6OPT_EXP_DE, "Experimental (0xDE)" },
  335. { IP6OPT_EXP_FE, "Experimental (0xFE)" },
  336. { 0, NULL }
  337. };
  338. void
  339. capture_ipv6(const guchar *pd, int offset, int len, packet_counts *ld)
  340. {
  341. guint8 nxt;
  342. int advance;
  343. if (!BYTES_ARE_IN_FRAME(offset, len, 4+4+16+16)) {
  344. ld->other++;
  345. return;
  346. }
  347. nxt = pd[offset+6]; /* get the "next header" value */
  348. offset += 4+4+16+16; /* skip past the IPv6 header */
  349. again:
  350. switch (nxt) {
  351. case IP_PROTO_HOPOPTS:
  352. case IP_PROTO_ROUTING:
  353. case IP_PROTO_DSTOPTS:
  354. if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
  355. ld->other++;
  356. return;
  357. }
  358. nxt = pd[offset];
  359. advance = (pd[offset+1] + 1) << 3;
  360. if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
  361. ld->other++;
  362. return;
  363. }
  364. offset += advance;
  365. goto again;
  366. case IP_PROTO_FRAGMENT:
  367. if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
  368. ld->other++;
  369. return;
  370. }
  371. nxt = pd[offset];
  372. advance = 8;
  373. if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
  374. ld->other++;
  375. return;
  376. }
  377. offset += advance;
  378. goto again;
  379. case IP_PROTO_AH:
  380. if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
  381. ld->other++;
  382. return;
  383. }
  384. nxt = pd[offset];
  385. advance = 8 + ((pd[offset+1] - 1) << 2);
  386. if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
  387. ld->other++;
  388. return;
  389. }
  390. offset += advance;
  391. goto again;
  392. case IP_PROTO_SHIM6:
  393. case IP_PROTO_SHIM6_OLD:
  394. if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
  395. ld->other++;
  396. return;
  397. }
  398. nxt = pd[offset];
  399. advance = (pd[offset+1] + 1) << 3;
  400. if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
  401. ld->other++;
  402. return;
  403. }
  404. offset += advance;
  405. goto again;
  406. }
  407. switch(nxt) {
  408. case IP_PROTO_SCTP:
  409. ld->sctp++;
  410. break;
  411. case IP_PROTO_TCP:
  412. ld->tcp++;
  413. break;
  414. case IP_PROTO_UDP:
  415. case IP_PROTO_UDPLITE:
  416. ld->udp++;
  417. break;
  418. case IP_PROTO_ICMP:
  419. case IP_PROTO_ICMPV6: /* XXX - separate counters? */
  420. ld->icmp++;
  421. break;
  422. case IP_PROTO_OSPF:
  423. ld->ospf++;
  424. break;
  425. case IP_PROTO_GRE:
  426. ld->gre++;
  427. break;
  428. case IP_PROTO_VINES:
  429. ld->vines++;
  430. break;
  431. default:
  432. ld->other++;
  433. }
  434. }
  435. #ifdef HAVE_GEOIP_V6
  436. static void
  437. add_geoip_info_entry(proto_tree *geoip_info_item, tvbuff_t *tvb, gint offset, const struct e_in6_addr *ip, int isdst)
  438. {
  439. proto_tree *geoip_info_tree;
  440. guint num_dbs = geoip_db_num_dbs();
  441. guint item_cnt = 0;
  442. guint dbnum;
  443. geoip_info_tree = proto_item_add_subtree(geoip_info_item, ett_geoip_info);
  444. for (dbnum = 0; dbnum < num_dbs; dbnum++) {
  445. const char *geoip_str = geoip_db_lookup_ipv6(dbnum, *ip, NULL);
  446. int db_type = geoip_db_type(dbnum);
  447. int geoip_hf, geoip_local_hf;
  448. switch (db_type) {
  449. case GEOIP_COUNTRY_EDITION_V6:
  450. geoip_hf = hf_geoip_country;
  451. geoip_local_hf = (isdst) ? hf_geoip_dst_country : hf_geoip_src_country;
  452. break;
  453. #if NUM_DB_TYPES > 31
  454. case GEOIP_CITY_EDITION_REV0_V6:
  455. case GEOIP_CITY_EDITION_REV1_V6:
  456. geoip_hf = hf_geoip_city;
  457. geoip_local_hf = (isdst) ? hf_geoip_dst_city : hf_geoip_src_city;
  458. break;
  459. case GEOIP_ORG_EDITION_V6:
  460. geoip_hf = hf_geoip_org;
  461. geoip_local_hf = (isdst) ? hf_geoip_dst_org : hf_geoip_src_org;
  462. break;
  463. case GEOIP_ISP_EDITION_V6:
  464. geoip_hf = hf_geoip_isp;
  465. geoip_local_hf = (isdst) ? hf_geoip_dst_isp : hf_geoip_src_isp;
  466. break;
  467. case GEOIP_ASNUM_EDITION_V6:
  468. geoip_hf = hf_geoip_asnum;
  469. geoip_local_hf = (isdst) ? hf_geoip_dst_asnum : hf_geoip_src_asnum;
  470. break;
  471. #endif /* DB_NUM_TYPES */
  472. case WS_LAT_FAKE_EDITION:
  473. geoip_hf = hf_geoip_lat;
  474. geoip_local_hf = (isdst) ? hf_geoip_dst_lat : hf_geoip_src_lat;
  475. break;
  476. case WS_LON_FAKE_EDITION:
  477. geoip_hf = hf_geoip_lon;
  478. geoip_local_hf = (isdst) ? hf_geoip_dst_lon : hf_geoip_src_lon;
  479. break;
  480. default:
  481. continue;
  482. break;
  483. }
  484. if (geoip_str) {
  485. proto_item *item;
  486. if (db_type == WS_LAT_FAKE_EDITION || db_type == WS_LON_FAKE_EDITION) {
  487. /* Convert latitude, longitude to double. Fix bug #5077 */
  488. item = proto_tree_add_double_format_value(geoip_info_tree, geoip_local_hf, tvb,
  489. offset, 16, g_ascii_strtod(geoip_str, NULL), "%s", geoip_str);
  490. PROTO_ITEM_SET_GENERATED(item);
  491. item = proto_tree_add_double_format_value(geoip_info_tree, geoip_hf, tvb,
  492. offset, 16, g_ascii_strtod(geoip_str, NULL), "%s", geoip_str);
  493. PROTO_ITEM_SET_GENERATED(item);
  494. PROTO_ITEM_SET_HIDDEN(item);
  495. } else {
  496. item = proto_tree_add_unicode_string(geoip_info_tree, geoip_local_hf, tvb,
  497. offset, 16, geoip_str);
  498. PROTO_ITEM_SET_GENERATED(item);
  499. item = proto_tree_add_unicode_string(geoip_info_tree, geoip_hf, tvb,
  500. offset, 16, geoip_str);
  501. PROTO_ITEM_SET_GENERATED(item);
  502. PROTO_ITEM_SET_HIDDEN(item);
  503. }
  504. item_cnt++;
  505. proto_item_append_text(geoip_info_item, "%s%s", plurality(item_cnt, "", ", "), geoip_str);
  506. }
  507. }
  508. if (item_cnt == 0)
  509. proto_item_append_text(geoip_info_item, "Unknown");
  510. }
  511. static void
  512. add_geoip_info(proto_tree *tree, tvbuff_t *tvb, gint offset, const struct e_in6_addr *src, const struct e_in6_addr *dst)
  513. {
  514. guint num_dbs;
  515. proto_item *geoip_info_item;
  516. num_dbs = geoip_db_num_dbs();
  517. if (num_dbs < 1)
  518. return;
  519. geoip_info_item = proto_tree_add_text(tree, tvb, offset + IP6H_SRC, 16, "Source GeoIP: ");
  520. PROTO_ITEM_SET_GENERATED(geoip_info_item);
  521. add_geoip_info_entry(geoip_info_item, tvb, offset + IP6H_SRC, src, 0);
  522. geoip_info_item = proto_tree_add_text(tree, tvb, offset + IP6H_DST, 16, "Destination GeoIP: ");
  523. PROTO_ITEM_SET_GENERATED(geoip_info_item);
  524. add_geoip_info_entry(geoip_info_item, tvb, offset + IP6H_DST, dst, 1);
  525. }
  526. #endif /* HAVE_GEOIP_V6 */
  527. static void
  528. ipv6_reassemble_init(void)
  529. {
  530. reassembly_table_init(&ipv6_reassembly_table,
  531. &addresses_reassembly_table_functions);
  532. }
  533. enum {
  534. IPv6_RT_HEADER_SOURCE_ROUTING=0,
  535. IPv6_RT_HEADER_NIMROD,
  536. IPv6_RT_HEADER_MobileIP,
  537. IPv6_RT_HEADER_RPL
  538. };
  539. /* Routing Header Types */
  540. static const value_string routing_header_type[] = {
  541. { IPv6_RT_HEADER_SOURCE_ROUTING, "IPv6 Source Routing" },
  542. { IPv6_RT_HEADER_NIMROD, "Nimrod" },
  543. { IPv6_RT_HEADER_MobileIP, "Mobile IP" },
  544. { IPv6_RT_HEADER_RPL, "RPL" },
  545. { 0, NULL }
  546. };
  547. static int
  548. dissect_routing6(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo) {
  549. struct ip6_rthdr rt;
  550. guint len, seg_left;
  551. proto_tree *rthdr_tree;
  552. proto_item *ti;
  553. guint8 buf[sizeof(struct ip6_rthdr0) + sizeof(struct e_in6_addr) * 23];
  554. tvb_memcpy(tvb, (guint8 *)&rt, offset, sizeof(rt));
  555. len = (rt.ip6r_len + 1) << 3;
  556. /* Assigning seg_left and the if (seg_left) {} blocks of code that follow,
  557. * along with any expert_add_info() calls, all need to execute when
  558. * appropriate, regardless of whether the tree is NULL or not. */
  559. if (1) {
  560. /* !!! specify length */
  561. ti = proto_tree_add_uint_format(tree, hf_ipv6_routing_hdr_opt, tvb,
  562. offset, len, rt.ip6r_type,
  563. "Routing Header, Type : %s (%u)",
  564. val_to_str_const(rt.ip6r_type, routing_header_type, "Unknown"),
  565. rt.ip6r_type);
  566. rthdr_tree = proto_item_add_subtree(ti, ett_ipv6);
  567. proto_tree_add_text(rthdr_tree, tvb,
  568. offset + (int)offsetof(struct ip6_rthdr, ip6r_nxt), 1,
  569. "Next header: %s (%u)", ipprotostr(rt.ip6r_nxt), rt.ip6r_nxt);
  570. proto_tree_add_text(rthdr_tree, tvb,
  571. offset + (int)offsetof(struct ip6_rthdr, ip6r_len), 1,
  572. "Length: %u (%d bytes)", rt.ip6r_len, len);
  573. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_type, tvb,
  574. offset + (int)offsetof(struct ip6_rthdr, ip6r_type), 1, ENC_BIG_ENDIAN);
  575. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_left, tvb,
  576. offset + (int)offsetof(struct ip6_rthdr, ip6r_segleft), 1, ENC_BIG_ENDIAN);
  577. seg_left = tvb_get_guint8(tvb, offset + (int)offsetof(struct ip6_rthdr, ip6r_segleft));
  578. if (rt.ip6r_type == IPv6_RT_HEADER_SOURCE_ROUTING && len <= sizeof(buf)) {
  579. struct e_in6_addr *a;
  580. int n;
  581. struct ip6_rthdr0 *rt0;
  582. tvb_memcpy(tvb, buf, offset, len);
  583. rt0 = (struct ip6_rthdr0 *)buf;
  584. for (a = rt0->ip6r0_addr, n = 0;
  585. a < (struct e_in6_addr *)(buf + len); a++, n++) {
  586. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_addr, tvb,
  587. offset + (int)(offsetof(struct ip6_rthdr0, ip6r0_addr)
  588. + n * sizeof(struct e_in6_addr)),
  589. (int)sizeof(struct e_in6_addr), ENC_NA);
  590. if (seg_left)
  591. TVB_SET_ADDRESS(&pinfo->dst, AT_IPv6, tvb,
  592. offset + (int)offsetof(struct ip6_rthdr0, ip6r0_addr) + n * (int)sizeof(struct e_in6_addr), 16);
  593. }
  594. }
  595. if (rt.ip6r_type == IPv6_RT_HEADER_MobileIP) {
  596. proto_tree_add_item(rthdr_tree, hf_ipv6_mipv6_home_address, tvb,
  597. offset + 8, 16, ENC_NA);
  598. if (seg_left)
  599. TVB_SET_ADDRESS(&pinfo->dst, AT_IPv6, tvb, offset + 8, 16);
  600. }
  601. if (rt.ip6r_type == IPv6_RT_HEADER_RPL) {
  602. guint8 cmprI;
  603. guint8 cmprE;
  604. guint8 pad;
  605. guint32 reserved;
  606. gint segments;
  607. /* IPv6 destination address used for elided bytes */
  608. struct e_in6_addr dstAddr;
  609. /* IPv6 source address used for strict checking */
  610. struct e_in6_addr srcAddr;
  611. offset += 4;
  612. memcpy((guint8 *)&dstAddr, (guint8 *)pinfo->dst.data, pinfo->dst.len);
  613. memcpy((guint8 *)&srcAddr, (guint8 *)pinfo->src.data, pinfo->src.len);
  614. /* from RFC6554: Multicast addresses MUST NOT appear in the IPv6 Destination Address field */
  615. if(g_ipv6_rpl_srh_strict_rfc_checking && E_IN6_IS_ADDR_MULTICAST(&dstAddr)){
  616. expert_add_info(pinfo, ti, &ei_ipv6_dst_addr_not_multicast);
  617. }
  618. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_cmprI, tvb, offset, 4, ENC_BIG_ENDIAN);
  619. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_cmprE, tvb, offset, 4, ENC_BIG_ENDIAN);
  620. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_pad, tvb, offset, 4, ENC_BIG_ENDIAN);
  621. cmprI = tvb_get_guint8(tvb, offset) & 0xF0;
  622. cmprE = tvb_get_guint8(tvb, offset) & 0x0F;
  623. pad = tvb_get_guint8(tvb, offset + 1) & 0xF0;
  624. /* Shift bytes over */
  625. cmprI >>= 4;
  626. pad >>= 4;
  627. /* from RFC6554: when CmprI and CmprE are both 0, Pad MUST carry a value of 0 */
  628. if(g_ipv6_rpl_srh_strict_rfc_checking && (cmprI == 0 && cmprE == 0 && pad != 0)){
  629. expert_add_info_format_text(pinfo, ti, &ei_ipv6_cmpri_cmpre_pad, "When cmprI equals 0 and cmprE equals 0, pad MUST equal 0 but instead was %d", pad);
  630. }
  631. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
  632. reserved = tvb_get_bits32(tvb, ((offset + 1) * 8) + 4, 20, ENC_BIG_ENDIAN);
  633. if(g_ipv6_rpl_srh_strict_rfc_checking && reserved != 0){
  634. expert_add_info_format_text(pinfo, ti, &ei_ipv6_routing_hdr_rpl_reserved, "Reserved field must equal 0 but instead was %d", reserved);
  635. }
  636. /* from RFC6554:
  637. n = (((Hdr Ext Len * 8) - Pad - (16 - CmprE)) / (16 - CmprI)) + 1 */
  638. segments = (((rt.ip6r_len * 8) - pad - (16 - cmprE)) / (16 - cmprI)) + 1;
  639. ti = proto_tree_add_int(rthdr_tree, hf_ipv6_routing_hdr_rpl_segments, tvb, offset, 2, segments);
  640. PROTO_ITEM_SET_GENERATED(ti);
  641. if (segments < 0) {
  642. /* This error should always be reported */
  643. expert_add_info_format_text(pinfo, ti, &ei_ipv6_routing_hdr_rpl_segments_ge0, "Calculated total segments must be greater than or equal to 0, instead was %d", segments);
  644. } else {
  645. offset += 4;
  646. /* We use cmprI for internal (e.g.: not last) address for how many bytes to elide, so actual bytes present = 16-CmprI */
  647. while(segments > 1) {
  648. struct e_in6_addr addr;
  649. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_addr, tvb, offset, (16-cmprI), ENC_NA);
  650. /* Display Full Address */
  651. memcpy((guint8 *)&addr, (guint8 *)&dstAddr, sizeof(dstAddr));
  652. tvb_memcpy(tvb, (guint8 *)&addr + cmprI, offset, (16-cmprI));
  653. ti = proto_tree_add_ipv6(rthdr_tree, hf_ipv6_routing_hdr_rpl_fulladdr, tvb, offset, (16-cmprI), (guint8 *)&addr);
  654. PROTO_ITEM_SET_GENERATED(ti);
  655. offset += (16-cmprI);
  656. segments--;
  657. if(g_ipv6_rpl_srh_strict_rfc_checking){
  658. /* from RFC6554: */
  659. /* The SRH MUST NOT specify a path that visits a node more than once. */
  660. /* To do this, we will just check the current 'addr' against the next addresses */
  661. gint tempSegments;
  662. gint tempOffset;
  663. tempSegments = segments; /* Has already been decremented above */
  664. tempOffset = offset; /* Has already been moved */
  665. while(tempSegments > 1) {
  666. struct e_in6_addr tempAddr;
  667. memcpy((guint8 *)&tempAddr, (guint8 *)&dstAddr, sizeof(dstAddr));
  668. tvb_memcpy(tvb, (guint8 *)&tempAddr + cmprI, tempOffset, (16-cmprI));
  669. /* Compare the addresses */
  670. if (memcmp(addr.bytes, tempAddr.bytes, 16) == 0) {
  671. /* Found a later address that is the same */
  672. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_mult_inst_same_addr);
  673. break;
  674. }
  675. tempOffset += (16-cmprI);
  676. tempSegments--;
  677. }
  678. if (tempSegments == 1) {
  679. struct e_in6_addr tempAddr;
  680. memcpy((guint8 *)&tempAddr, (guint8 *)&dstAddr, sizeof(dstAddr));
  681. tvb_memcpy(tvb, (guint8 *)&tempAddr + cmprE, tempOffset, (16-cmprE));
  682. /* Compare the addresses */
  683. if (memcmp(addr.bytes, tempAddr.bytes, 16) == 0) {
  684. /* Found a later address that is the same */
  685. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_mult_inst_same_addr);
  686. }
  687. }
  688. /* IPv6 Source and Destination addresses of the encapsulating datagram (MUST) not appear in the SRH*/
  689. if (memcmp(addr.bytes, srcAddr.bytes, 16) == 0) {
  690. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_src_addr);
  691. }
  692. if (memcmp(addr.bytes, dstAddr.bytes, 16) == 0) {
  693. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_dst_addr);
  694. }
  695. /* Multicast addresses MUST NOT appear in the in SRH */
  696. if(E_IN6_IS_ADDR_MULTICAST(&addr)){
  697. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_multicast_addr);
  698. }
  699. }
  700. }
  701. /* We use cmprE for last address for how many bytes to elide, so actual bytes present = 16-CmprE */
  702. if (segments == 1) {
  703. struct e_in6_addr addr;
  704. proto_tree_add_item(rthdr_tree, hf_ipv6_routing_hdr_rpl_addr, tvb, offset, (16-cmprI), ENC_NA);
  705. /* Display Full Address */
  706. memcpy((guint8 *)&addr, (guint8 *)&dstAddr, sizeof(dstAddr));
  707. tvb_memcpy(tvb, (guint8 *)&addr + cmprE, offset, (16-cmprE));
  708. ti = proto_tree_add_ipv6(rthdr_tree, hf_ipv6_routing_hdr_rpl_fulladdr, tvb, offset, (16-cmprE), (guint8 *)&addr);
  709. PROTO_ITEM_SET_GENERATED(ti);
  710. /* offset += (16-cmprE); */
  711. if(g_ipv6_rpl_srh_strict_rfc_checking){
  712. /* IPv6 Source and Destination addresses of the encapsulating datagram (MUST) not appear in the SRH*/
  713. if (memcmp(addr.bytes, srcAddr.bytes, 16) == 0) {
  714. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_src_addr);
  715. }
  716. if (memcmp(addr.bytes, dstAddr.bytes, 16) == 0) {
  717. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_dst_addr);
  718. }
  719. /* Multicast addresses MUST NOT appear in the in SRH */
  720. if(E_IN6_IS_ADDR_MULTICAST(&addr)){
  721. expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_multicast_addr);
  722. }
  723. }
  724. }
  725. }
  726. }
  727. }
  728. return len;
  729. }
  730. static int
  731. dissect_frag6(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
  732. guint16 *offlg, guint32 *ident) {
  733. struct ip6_frag frag;
  734. int len;
  735. proto_item *ti;
  736. proto_tree *rthdr_tree;
  737. tvb_memcpy(tvb, (guint8 *)&frag, offset, sizeof(frag));
  738. len = sizeof(frag);
  739. frag.ip6f_offlg = g_ntohs(frag.ip6f_offlg);
  740. frag.ip6f_ident = g_ntohl(frag.ip6f_ident);
  741. *offlg = frag.ip6f_offlg;
  742. *ident = frag.ip6f_ident;
  743. col_add_fstr(pinfo->cinfo, COL_INFO,
  744. "IPv6 fragment (nxt=%s (%u) off=%u id=0x%x)",
  745. ipprotostr(frag.ip6f_nxt), frag.ip6f_nxt,
  746. (frag.ip6f_offlg & IP6F_OFF_MASK) >> IP6F_OFF_SHIFT, frag.ip6f_ident);
  747. if (tree) {
  748. ti = proto_tree_add_text(tree, tvb, offset, len,
  749. "Fragmentation Header");
  750. rthdr_tree = proto_item_add_subtree(ti, ett_ipv6);
  751. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_nxt, tvb,
  752. offset + (int)offsetof(struct ip6_frag, ip6f_nxt), 1,
  753. ENC_BIG_ENDIAN);
  754. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_reserved, tvb,
  755. offset + (int)offsetof(struct ip6_frag, ip6f_reserved), 1,
  756. ENC_BIG_ENDIAN);
  757. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_offset, tvb,
  758. offset + (int)offsetof(struct ip6_frag, ip6f_offlg), 2, ENC_BIG_ENDIAN);
  759. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_reserved_bits, tvb,
  760. offset + (int)offsetof(struct ip6_frag, ip6f_offlg), 2, ENC_BIG_ENDIAN);
  761. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_more, tvb,
  762. offset + (int)offsetof(struct ip6_frag, ip6f_offlg), 2, ENC_BIG_ENDIAN);
  763. proto_tree_add_item(rthdr_tree, hf_ipv6_frag_id, tvb,
  764. offset + (int)offsetof(struct ip6_frag, ip6f_ident), 4, ENC_BIG_ENDIAN);
  765. }
  766. return len;
  767. }
  768. static const value_string rtalertvals[] = {
  769. { IP6OPT_RTALERT_MLD, "MLD" },
  770. { IP6OPT_RTALERT_RSVP, "RSVP" },
  771. { IP6OPT_RTALERT_ACTNET, "Active Network" },
  772. { 0, NULL }
  773. };
  774. static int
  775. dissect_unknown_option(tvbuff_t *tvb, int offset, proto_tree *tree)
  776. {
  777. int len;
  778. proto_tree *unkopt_tree;
  779. proto_item *ti, *ti_len;
  780. len = (tvb_get_guint8(tvb, offset + 1) + 1) << 3;
  781. if (tree) {
  782. /* !!! specify length */
  783. ti = proto_tree_add_item(tree, hf_ipv6_unk_hdr, tvb, offset, len, ENC_NA);
  784. unkopt_tree = proto_item_add_subtree(ti, ett_ipv6);
  785. proto_tree_add_item(unkopt_tree, hf_ipv6_nxt, tvb, offset, 1, ENC_NA);
  786. offset += 1;
  787. ti_len = proto_tree_add_item(unkopt_tree, hf_ipv6_opt_length, tvb, offset, 1, ENC_NA);
  788. proto_item_append_text(ti_len, " (%d byte%s)", len, plurality(len, "", "s"));
  789. /* offset += 1; */
  790. }
  791. return len;
  792. }
  793. static int
  794. dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo, const int hf_option_item)
  795. {
  796. int len;
  797. int offset_end;
  798. proto_tree *dstopt_tree, *opt_tree;
  799. proto_item *ti, *ti_len, *ti_opt, *ti_opt_len;
  800. guint8 opt_len, opt_type;
  801. len = (tvb_get_guint8(tvb, offset + 1) + 1) << 3;
  802. offset_end = offset + len;
  803. if (tree) {
  804. /* !!! specify length */
  805. ti = proto_tree_add_item(tree, hf_option_item, tvb, offset, len, ENC_NA);
  806. dstopt_tree = proto_item_add_subtree(ti, ett_ipv6);
  807. proto_tree_add_item(dstopt_tree, hf_ipv6_nxt, tvb, offset, 1, ENC_NA);
  808. offset += 1;
  809. ti_len = proto_tree_add_item(dstopt_tree, hf_ipv6_opt_length, tvb, offset, 1, ENC_NA);
  810. proto_item_append_text(ti_len, " (%d byte%s)", len, plurality(len, "", "s"));
  811. offset += 1;
  812. while (offset_end > offset) {
  813. /* there are more options */
  814. /* IPv6 Option */
  815. ti_opt = proto_tree_add_item(dstopt_tree, hf_ipv6_opt, tvb, offset, 1, ENC_NA);
  816. opt_tree = proto_item_add_subtree(ti_opt, ett_ipv6_opt);
  817. /* Option type */
  818. proto_tree_add_item(opt_tree, hf_ipv6_opt_type, tvb, offset, 1, ENC_BIG_ENDIAN);
  819. opt_type = tvb_get_guint8(tvb, offset);
  820. /* Add option name to option root label */
  821. proto_item_append_text(ti_opt, " (%s", val_to_str(opt_type, ipv6_opt_vals, "Unknown %d"));
  822. /* The Pad1 option is a special case, and contains no data. */
  823. if (opt_type == IP6OPT_PAD1) {
  824. proto_tree_add_item(opt_tree, hf_ipv6_opt_pad1, tvb, offset, 1, ENC_NA);
  825. offset += 1;
  826. proto_item_append_text(ti_opt, ")");
  827. continue;
  828. }
  829. offset += 1;
  830. /* Option length */
  831. ti_opt_len = proto_tree_add_item(opt_tree, hf_ipv6_opt_length, tvb, offset, 1, ENC_BIG_ENDIAN);
  832. opt_len = tvb_get_guint8(tvb, offset);
  833. proto_item_set_len(ti_opt, opt_len + 2);
  834. offset += 1;
  835. switch (opt_type) {
  836. case IP6OPT_PADN:
  837. /* RFC 2460 states :
  838. * "The PadN option is used to insert two or more octets of
  839. * padding into the Options area of a header. For N octets of
  840. * padding, the Opt Data Len field contains the value N-2, and
  841. * the Option Data consists of N-2 zero-valued octets."
  842. */
  843. proto_tree_add_item(opt_tree, hf_ipv6_opt_padn, tvb,
  844. offset, opt_len, ENC_NA);
  845. offset += opt_len;
  846. break;
  847. case IP6OPT_TEL:
  848. if (opt_len != 1) {
  849. expert_add_info_format_text(pinfo, ti_opt_len, &ei_ipv6_opt_tel_invalid_len,
  850. "Tunnel Encapsulation Limit: Invalid length (%u bytes)", opt_len);
  851. }
  852. proto_tree_add_item(opt_tree, hf_ipv6_opt_tel, tvb,
  853. offset, 1, ENC_BIG_ENDIAN);
  854. offset += 1;
  855. break;
  856. case IP6OPT_JUMBO:
  857. if (opt_len != 4) {
  858. expert_add_info_format_text(pinfo, ti_opt_len, &ei_ipv6_opt_jumbo_invalid_len,
  859. "Jumbo payload: Invalid length (%u bytes)", opt_len);
  860. }
  861. proto_tree_add_item(opt_tree, hf_ipv6_opt_jumbo, tvb,
  862. offset, 4, ENC_BIG_ENDIAN);
  863. offset += 4;
  864. break;
  865. case IP6OPT_RTALERT:
  866. {
  867. if (opt_len != 2) {
  868. expert_add_info_format_text(pinfo, ti_opt_len, &ei_ipv6_opt_rtalert_invalid_len,
  869. "Router alert: Invalid Length (%u bytes)",
  870. opt_len + 2);
  871. }
  872. proto_tree_add_item(opt_tree, hf_ipv6_opt_rtalert, tvb,
  873. offset, 2, ENC_BIG_ENDIAN);
  874. offset += 2;
  875. break;
  876. }
  877. case IP6OPT_HOME_ADDRESS:
  878. if (opt_len != 16) {
  879. expert_add_info_format_text(pinfo, ti_opt_len, &ei_ipv6_mipv6_home_address_invalid_len,
  880. "Home Address: Invalid length (%u bytes)", opt_len);
  881. }
  882. proto_tree_add_item(opt_tree, hf_ipv6_mipv6_home_address, tvb,
  883. offset, 16, ENC_NA);
  884. TVB_SET_ADDRESS(&pinfo->src, AT_IPv6, tvb, offset, 16);
  885. offset += 16;
  886. break;
  887. case IP6OPT_CALIPSO:
  888. {
  889. guint8 cmpt_length;
  890. proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_doi, tvb,
  891. offset, 4, ENC_BIG_ENDIAN);
  892. offset += 4;
  893. proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_cmpt_length, tvb,
  894. offset, 1, ENC_BIG_ENDIAN);
  895. cmpt_length = tvb_get_guint8(tvb, offset);
  896. offset += 1;
  897. proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_sens_level, tvb,
  898. offset, 1, ENC_BIG_ENDIAN);
  899. offset += 1;
  900. /* Need to add Check Checksum..*/
  901. proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_checksum, tvb,
  902. offset, 2, ENC_BIG_ENDIAN);
  903. offset += 2;
  904. proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_cmpt_bitmap, tvb,
  905. offset, cmpt_length, ENC_NA);
  906. offset += cmpt_length;
  907. break;
  908. }
  909. case IP6OPT_QUICKSTART:
  910. {
  911. guint8 command = tvb_get_guint8(tvb, offset);
  912. guint8 function = command >> 4;
  913. guint8 rate = command & QS_RATE_MASK;
  914. guint8 ttl_diff;
  915. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_func, tvb, offset, 1, ENC_NA);
  916. if (function == QS_RATE_REQUEST) {
  917. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_rate, tvb, offset, 1, ENC_NA);
  918. offset += 1;
  919. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_ttl, tvb, offset, 1, ENC_NA);
  920. ttl_diff = (pinfo->ip_ttl - tvb_get_guint8(tvb, offset) % 256);
  921. offset += 1;
  922. ti = proto_tree_add_uint_format_value(opt_tree, hf_ipv6_opt_qs_ttl_diff,
  923. tvb, offset, 1, ttl_diff,
  924. "%u", ttl_diff);
  925. PROTO_ITEM_SET_GENERATED(ti);
  926. proto_item_append_text(ti_opt, ", %s, QS TTL %u, QS TTL diff %u",
  927. val_to_str_ext(rate, &qs_rate_vals_ext, "Unknown (%u)"),
  928. tvb_get_guint8(tvb, offset), ttl_diff);
  929. offset += 1;
  930. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_nonce, tvb, offset, 4, ENC_NA);
  931. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_reserved, tvb, offset, 4, ENC_NA);
  932. offset += 4;
  933. } else if (function == QS_RATE_REPORT) {
  934. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_rate, tvb, offset, 1, ENC_NA);
  935. offset += 1;
  936. proto_item_append_text(ti_opt, ", %s",
  937. val_to_str_ext(rate, &qs_rate_vals_ext, "Unknown (%u)"));
  938. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_unused, tvb, offset, 1, ENC_NA);
  939. offset += 1;
  940. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_nonce, tvb, offset, 4, ENC_NA);
  941. proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_reserved, tvb, offset, 4, ENC_NA);
  942. offset += 4;
  943. }
  944. }
  945. break;
  946. case IP6OPT_RPL:
  947. {
  948. proto_tree *flag_tree;
  949. proto_item *ti_flag;
  950. ti_flag = proto_tree_add_item(opt_tree, hf_ipv6_opt_rpl_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
  951. flag_tree = proto_item_add_subtree(ti_flag, ett_ipv6_opt_flag);
  952. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_flag_o, tvb, offset, 1, ENC_BIG_ENDIAN);
  953. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_flag_r, tvb, offset, 1, ENC_BIG_ENDIAN);
  954. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_flag_f, tvb, offset, 1, ENC_BIG_ENDIAN);
  955. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_flag_rsv, tvb, offset, 1, ENC_BIG_ENDIAN);
  956. offset +=1;
  957. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_instance_id, tvb, offset, 1, ENC_BIG_ENDIAN);
  958. offset +=1;
  959. proto_tree_add_item(flag_tree, hf_ipv6_opt_rpl_senderrank, tvb, offset, 2, ENC_BIG_ENDIAN);
  960. offset +=2;
  961. /* TODO: Add dissector of sub TLV */
  962. }
  963. break;
  964. case IP6OPT_EXP_1E:
  965. case IP6OPT_EXP_3E:
  966. case IP6OPT_EXP_5E:
  967. case IP6OPT_EXP_7E:
  968. case IP6OPT_EXP_9E:
  969. case IP6OPT_EXP_BE:
  970. case IP6OPT_EXP_DE:
  971. case IP6OPT_EXP_FE:
  972. proto_tree_add_item(opt_tree, hf_ipv6_opt_experimental, tvb,
  973. offset, opt_len, ENC_NA);
  974. offset += opt_len;
  975. break;
  976. default:
  977. proto_tree_add_item(opt_tree, hf_ipv6_opt_unknown, tvb,
  978. offset, opt_len, ENC_NA);
  979. offset += opt_len;
  980. break;
  981. }
  982. /* Close the ) to option root label */
  983. proto_item_append_text(ti_opt, ")");
  984. }
  985. }
  986. return len;
  987. }
  988. static int
  989. dissect_hopopts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo)
  990. {
  991. return dissect_opts(tvb, offset, tree, pinfo, hf_ipv6_hop_opt);
  992. }
  993. static int
  994. dissect_dstopts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo)
  995. {
  996. return dissect_opts(tvb, offset, tree, pinfo, hf_ipv6_dst_opt);
  997. }
  998. /* START SHIM6 PART */
  999. static guint16 shim_checksum(const guint8 *ptr, int len)
  1000. {
  1001. vec_t cksum_vec[1];
  1002. cksum_vec[0].ptr = ptr;
  1003. cksum_vec[0].len = len;
  1004. return in_cksum(&cksum_vec[0], 1);
  1005. }
  1006. static int
  1007. dissect_shim_hex(tvbuff_t *tvb, int offset, int len, const char *itemname, guint8 bitmask, proto_tree *tree)
  1008. {
  1009. proto_item *ti;
  1010. int count;
  1011. gint p;
  1012. p = offset;
  1013. ti = proto_tree_add_text(tree, tvb, offset, len, "%s", itemname);
  1014. proto_item_append_text(ti, " 0x%02x", tvb_get_guint8(tvb, p) & bitmask);
  1015. for (count=1; count<len; count++)
  1016. proto_item_append_text(ti, "%02x", tvb_get_guint8(tvb, p+count));
  1017. return len;
  1018. }
  1019. static const value_string shimoptvals[] = {
  1020. { SHIM6_OPT_RESPVAL, "Responder Validator Option" },
  1021. { SHIM6_OPT_LOCLIST, "Locator List Option" },
  1022. { SHIM6_OPT_LOCPREF, "Locator Preferences Option" },
  1023. { SHIM6_OPT_CGAPDM, "CGA Parameter Data Structure Option" },
  1024. { SHIM6_OPT_CGASIG, "CGA Signature Option" },
  1025. { SHIM6_OPT_ULIDPAIR, "ULID Pair Option" },
  1026. { SHIM6_OPT_FII, "Forked Instance Identifier Option" },
  1027. { 0, NULL }
  1028. };
  1029. static const value_string shimverifmethods[] = {
  1030. { SHIM6_VERIF_HBA, "HBA" },
  1031. { SHIM6_VERIF_CGA, "CGA" },
  1032. { 0, NULL }
  1033. };
  1034. static const value_string shimflags[] _U_ = {
  1035. { SHIM6_FLAG_BROKEN, "BROKEN" },
  1036. { SHIM6_FLAG_TEMPORARY, "TEMPORARY" },
  1037. { 0, NULL }
  1038. };
  1039. static const value_string shimreapstates[] = {
  1040. { SHIM6_REAP_OPERATIONAL, "Operational" },
  1041. { SHIM6_REAP_EXPLORING, "Exploring" },
  1042. { SHIM6_REAP_INBOUNDOK, "InboundOK" },
  1043. { 0, NULL }
  1044. };
  1045. static const value_string shim6_protocol[] = {
  1046. { 0, "SHIM6" },
  1047. { 1, "HIP" },
  1048. { 0, NULL }
  1049. };
  1050. static void
  1051. dissect_shim6_opt_loclist(proto_tree * opt_tree, tvbuff_t * tvb, gint *offset)
  1052. {
  1053. proto_item * it;
  1054. proto_tree * subtree;
  1055. guint count;
  1056. guint optlen;
  1057. int p = *offset;
  1058. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_loclist, tvb, p, 4, ENC_BIG_ENDIAN);
  1059. p += 4;
  1060. optlen = tvb_get_guint8(tvb, p);
  1061. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_locnum, tvb, p, 1, ENC_BIG_ENDIAN);
  1062. p++;
  1063. /* Verification Methods */
  1064. it = proto_tree_add_text(opt_tree, tvb, p, optlen,
  1065. "Locator Verification Methods");
  1066. subtree = proto_item_add_subtree(it, ett_ipv6_shim6_verif_methods);
  1067. for (count=0; count < optlen; count++)
  1068. proto_tree_add_item(subtree, hf_ipv6_shim6_opt_loc_verif_methods, tvb,
  1069. p+count, 1, ENC_BIG_ENDIAN);
  1070. p += optlen;
  1071. /* Padding, included in length field */
  1072. if ((7 - optlen % 8) > 0) {
  1073. proto_tree_add_text(opt_tree, tvb, p, (7 - optlen % 8), "Padding");
  1074. p += (7 - optlen % 8);
  1075. }
  1076. /* Locators */
  1077. it = proto_tree_add_text(opt_tree, tvb, p, 16 * optlen, "Locators");
  1078. subtree = proto_item_add_subtree(it, ett_ipv6_shim6_locators);
  1079. for (count=0; count < optlen; count++) {
  1080. proto_tree_add_item(subtree, hf_ipv6_shim6_locator, tvb, p, 16, ENC_NA);
  1081. p += 16;
  1082. }
  1083. *offset = p;
  1084. }
  1085. static void
  1086. dissect_shim6_opt_loc_pref(proto_tree * opt_tree, tvbuff_t * tvb, gint *offset, gint len, packet_info *pinfo)
  1087. {
  1088. proto_tree * subtree;
  1089. proto_item * it;
  1090. gint p;
  1091. gint optlen;
  1092. gint count;
  1093. p = *offset;
  1094. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_loclist, tvb, p, 4, ENC_BIG_ENDIAN);
  1095. p += 4;
  1096. optlen = tvb_get_guint8(tvb, p);
  1097. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_elemlen, tvb, p, 1, ENC_BIG_ENDIAN);
  1098. if (optlen < 1 || optlen > 3) {
  1099. proto_tree_add_expert_format(opt_tree, pinfo, &ei_ipv6_shim6_opt_elemlen_invalid, tvb, p, 1,
  1100. "Invalid element length: %u", optlen);
  1101. return;
  1102. }
  1103. p++;
  1104. /* Locator Preferences */
  1105. count = 1;
  1106. while (p < len) {
  1107. it = proto_tree_add_text(opt_tree, tvb, p, optlen, "Locator Preferences %u", count);
  1108. subtree = proto_item_add_subtree(it, ett_ipv6_shim6_loc_pref);
  1109. /* Flags */
  1110. if (optlen >= 1)
  1111. proto_tree_add_item(subtree, hf_ipv6_shim6_loc_flag, tvb, p, 1, ENC_BIG_ENDIAN);
  1112. /* Priority */
  1113. if (optlen >= 2)
  1114. proto_tree_add_item(subtree, hf_ipv6_shim6_loc_prio, tvb, p+1, 1, ENC_BIG_ENDIAN);
  1115. /* Weight */
  1116. if (optlen >= 3)
  1117. proto_tree_add_item(subtree, hf_ipv6_shim6_loc_weight, tvb, p+2, 1, ENC_BIG_ENDIAN);
  1118. /*
  1119. * Shim6 Draft 08 doesn't specify the format when the Element length is
  1120. * more than three, except that any such formats MUST be defined so that
  1121. * the first three octets are the same as in the above case, that is, a
  1122. * of a 1 octet flags field followed by a 1 octet priority field, and a
  1123. * 1 octet weight field.
  1124. */
  1125. p += optlen;
  1126. count++;
  1127. }
  1128. *offset = p;
  1129. }
  1130. static int
  1131. dissect_shimopts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo)
  1132. {
  1133. int len, total_len;
  1134. gint p;
  1135. gint padding;
  1136. proto_tree *opt_tree;
  1137. proto_item *ti;
  1138. const gchar *ctype;
  1139. p = offset;
  1140. p += 4;
  1141. len = tvb_get_ntohs(tvb, offset+2);
  1142. padding = 7 - ((len + 3) % 8);
  1143. total_len = 4 + len + padding;
  1144. if (tree)
  1145. {
  1146. /* Option Type */
  1147. ctype = val_to_str_const( (tvb_get_ntohs(tvb, offset) & SHIM6_BITMASK_OPT_TYPE) >> 1, shimoptvals, "Unknown Option Type");
  1148. ti = proto_tree_add_text(tree, tvb, offset, total_len, "%s", ctype);
  1149. opt_tree = proto_item_add_subtree(ti, ett_ipv6_shim6_option);
  1150. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_type, tvb, offset, 2, ENC_BIG_ENDIAN);
  1151. /* Critical */
  1152. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_critical, tvb, offset+1, 1, ENC_BIG_ENDIAN);
  1153. /* Content Length */
  1154. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_len, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
  1155. ti = proto_tree_add_uint_format(opt_tree, hf_ipv6_shim6_opt_total_len, tvb, offset+2, 2,
  1156. total_len, "Total Length: %u", total_len);
  1157. PROTO_ITEM_SET_GENERATED(ti);
  1158. /* Option Type Specific */
  1159. switch (tvb_get_ntohs(tvb, offset) >> 1)
  1160. {
  1161. case SHIM6_OPT_RESPVAL:
  1162. p += dissect_shim_hex(tvb, p, len, "Validator:", 0xff, opt_tree);
  1163. if (total_len-(len+4) > 0)
  1164. proto_tree_add_text(opt_tree, tvb, p, total_len-(len+4), "Padding");
  1165. break;
  1166. case SHIM6_OPT_LOCLIST:
  1167. dissect_shim6_opt_loclist(opt_tree, tvb, &p);
  1168. break;
  1169. case SHIM6_OPT_LOCPREF:
  1170. dissect_shim6_opt_loc_pref(opt_tree, tvb, &p, offset+len+4, pinfo);
  1171. if (total_len-(len+4) > 0)
  1172. proto_tree_add_text(opt_tree, tvb, p, total_len-(len+4), "Padding");
  1173. break;
  1174. case SHIM6_OPT_CGAPDM:
  1175. p += dissect_shim_hex(tvb, p, len, "CGA Parameter Data Structure:", 0xff, opt_tree);
  1176. if (total_len-(len+4) > 0)
  1177. proto_tree_add_text(opt_tree, tvb, p, total_len-(len+4), "Padding");
  1178. break;
  1179. case SHIM6_OPT_CGASIG:
  1180. p += dissect_shim_hex(tvb, p, len, "CGA Signature:", 0xff, opt_tree);
  1181. if (total_len-(len+4) > 0)
  1182. proto_tree_add_text(opt_tree, tvb, p, total_len-(len+4), "Padding");
  1183. break;
  1184. case SHIM6_OPT_ULIDPAIR:
  1185. proto_tree_add_text(opt_tree, tvb, p, 4, "Reserved");
  1186. p += 4;
  1187. proto_tree_add_item(opt_tree, hf_ipv6_shim6_sulid, tvb, p, 16, ENC_NA);
  1188. p += 16;
  1189. proto_tree_add_item(opt_tree, hf_ipv6_shim6_rulid, tvb, p, 16, ENC_NA);
  1190. p += 16;
  1191. break;
  1192. case SHIM6_OPT_FII:
  1193. proto_tree_add_item(opt_tree, hf_ipv6_shim6_opt_fii, tvb, p, 4, ENC_BIG_ENDIAN);
  1194. p += 4;
  1195. break;
  1196. default:
  1197. break;
  1198. }
  1199. }
  1200. return total_len;
  1201. }
  1202. static void
  1203. dissect_shim6_ct(proto_tree * shim_tree, gint hf_item, tvbuff_t * tvb, gint offset, const guchar * label)
  1204. {
  1205. guint8 tmp[6];
  1206. guchar * ct_str;
  1207. tmp[0] = tvb_get_guint8(tvb, offset++);
  1208. tmp[1] = tvb_get_guint8(tvb, offset++);
  1209. tmp[2] = tvb_get_guint8(tvb, offset++);
  1210. tmp[3] = tvb_get_guint8(tvb, offset++);
  1211. tmp[4] = tvb_get_guint8(tvb, offset++);
  1212. tmp[5] = tvb_get_guint8(tvb, offset++);
  1213. ct_str = ep_strdup_printf("%s: %02X %02X %02X %02X %02X %02X", label,
  1214. tmp[0] & SHIM6_BITMASK_CT, tmp[1], tmp[2],
  1215. tmp[3], tmp[4], tmp[5]
  1216. );
  1217. proto_tree_add_none_format(shim_tree, hf_item, tvb, offset - 6, 6, "%s", ct_str);
  1218. }
  1219. static void
  1220. dissect_shim6_probes(proto_tree * shim_tree, tvbuff_t * tvb, gint offset,
  1221. const guchar * label, guint nbr_probe,
  1222. gboolean probes_rcvd)
  1223. {
  1224. proto_tree * probes_tree;
  1225. proto_tree * probe_tree;
  1226. proto_item * it;
  1227. gint ett_probes;
  1228. gint ett_probe;
  1229. guint count;
  1230. if (probes_rcvd) {
  1231. ett_probes = ett_ipv6_shim6_probes_rcvd;
  1232. ett_probe = ett_ipv6_shim6_probe_rcvd;
  1233. } else {
  1234. ett_probes = ett_ipv6_shim6_probes_sent;
  1235. ett_probe = ett_ipv6_shim6_probe_sent;
  1236. }
  1237. it = proto_tree_add_text(shim_tree, tvb, offset, 40 * nbr_probe, "%s", label);
  1238. probes_tree = proto_item_add_subtree(it, ett_probes);
  1239. for (count=0; count < nbr_probe; count++) {
  1240. it = proto_tree_add_text(probes_tree, tvb, offset, 40, "Probe %u", count+1);
  1241. probe_tree = proto_item_add_subtree(it, ett_probe);
  1242. proto_tree_add_item(probe_tree, hf_ipv6_shim6_psrc, tvb, offset, 16, ENC_NA);
  1243. offset += 16;
  1244. proto_tree_add_item(probe_tree, hf_ipv6_shim6_pdst, tvb, offset, 16, ENC_NA);
  1245. offset += 16;
  1246. proto_tree_add_item(probe_tree, hf_ipv6_shim6_pnonce, tvb, offset, 4, ENC_BIG_ENDIAN);
  1247. offset += 4;
  1248. proto_tree_add_item(probe_tree, hf_ipv6_shim6_pdata, tvb, offset, 4, ENC_BIG_ENDIAN);
  1249. offset += 4;
  1250. }
  1251. }
  1252. /* Dissect SHIM6 data: control messages */
  1253. static int
  1254. dissect_shimctrl(tvbuff_t *tvb, gint offset, guint type, proto_tree *shim_tree)
  1255. {
  1256. gint p;
  1257. guint8 tmp;
  1258. const gchar *sta;
  1259. guint probes_sent;
  1260. guint probes_rcvd;
  1261. p = offset;
  1262. switch (type)
  1263. {
  1264. case SHIM6_TYPE_I1:
  1265. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Initiator Context Tag");
  1266. p += 6;
  1267. proto_tree_add_item(shim_tree, hf_ipv6_shim6_inonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1268. p += 4;
  1269. break;
  1270. case SHIM6_TYPE_R1:
  1271. proto_tree_add_text(shim_tree, tvb, p, 2, "Reserved2");
  1272. p += 2;
  1273. proto_tree_add_item(shim_tree, hf_ipv6_shim6_inonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1274. p += 4;
  1275. proto_tree_add_item(shim_tree, hf_ipv6_shim6_rnonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1276. p += 4;
  1277. break;
  1278. case SHIM6_TYPE_I2:
  1279. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Initiator Context Tag");
  1280. p += 6;
  1281. proto_tree_add_item(shim_tree, hf_ipv6_shim6_inonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1282. p += 4;
  1283. proto_tree_add_item(shim_tree, hf_ipv6_shim6_rnonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1284. p += 4;
  1285. proto_tree_add_text(shim_tree, tvb, p, 4, "Reserved2");
  1286. p += 4;
  1287. break;
  1288. case SHIM6_TYPE_R2:
  1289. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Responder Context Tag");
  1290. p += 6;
  1291. proto_tree_add_item(shim_tree, hf_ipv6_shim6_inonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1292. p += 4;
  1293. break;
  1294. case SHIM6_TYPE_R1BIS:
  1295. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Packet Context Tag");
  1296. p += 6;
  1297. proto_tree_add_item(shim_tree, hf_ipv6_shim6_rnonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1298. p += 4;
  1299. break;
  1300. case SHIM6_TYPE_I2BIS:
  1301. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Initiator Context Tag");
  1302. p += 6;
  1303. proto_tree_add_item(shim_tree, hf_ipv6_shim6_inonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1304. p += 4;
  1305. proto_tree_add_item(shim_tree, hf_ipv6_shim6_rnonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1306. p += 4;
  1307. proto_tree_add_text(shim_tree, tvb, p, 6, "Reserved2");
  1308. p += 6;
  1309. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Initiator Context Tag");
  1310. p += 6;
  1311. break;
  1312. case SHIM6_TYPE_UPD_REQ:
  1313. case SHIM6_TYPE_UPD_ACK:
  1314. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Receiver Context Tag");
  1315. p += 6;
  1316. proto_tree_add_item(shim_tree, hf_ipv6_shim6_rnonce, tvb, p, 4, ENC_BIG_ENDIAN);
  1317. p += 4;
  1318. break;
  1319. case SHIM6_TYPE_KEEPALIVE:
  1320. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Receiver Context Tag");
  1321. p += 6;
  1322. proto_tree_add_text(shim_tree, tvb, p, 4, "Reserved2");
  1323. p += 4;
  1324. break;
  1325. case SHIM6_TYPE_PROBE:
  1326. dissect_shim6_ct(shim_tree, hf_ipv6_shim6_ct, tvb, p, "Receiver Context Tag");
  1327. p += 6;
  1328. tmp = tvb_get_guint8(tvb, p);
  1329. probes_sent = tmp & SHIM6_BITMASK_PSENT;
  1330. probes_rcvd = (tmp & SHIM6_BITMASK_PRECVD) >> 4;
  1331. proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_psent, tvb,
  1332. p, 1, probes_sent,
  1333. "Probes Sent: %u", probes_sent);
  1334. proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_precvd, tvb,
  1335. p, 1, probes_rcvd,
  1336. "Probes Received: %u", probes_rcvd);
  1337. p++;
  1338. sta = val_to_str_const((tvb_get_guint8(tvb, p) & SHIM6_BITMASK_STA) >> 6,
  1339. shimreapstates, "Unknown REAP State");
  1340. proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_reap, tvb,
  1341. p, 1, (tvb_get_guint8(tvb, p) & SHIM6_BITMASK_STA) >> 6,
  1342. "REAP State: %s", sta);
  1343. proto_tree_add_text(shim_tree, tvb, p, 3, "Reserved2");
  1344. p += 3;
  1345. /* Probes Sent */
  1346. if (probes_sent) {
  1347. dissect_shim6_probes(shim_tree, tvb, p, "Probes Sent",
  1348. probes_sent, FALSE);
  1349. p += 40 * probes_sent;
  1350. }
  1351. /* Probes Received */
  1352. if (probes_rcvd) {
  1353. dissect_shim6_probes(shim_tree, tvb, p, "Probes Received",
  1354. probes_rcvd, TRUE);
  1355. p += 40 * probes_rcvd;
  1356. }
  1357. break;
  1358. default:
  1359. break;
  1360. }
  1361. return p-offset;
  1362. }
  1363. /* Dissect SHIM6 data: payload, common part, options */
  1364. static const value_string shimctrlvals[] = {
  1365. { SHIM6_TYPE_I1, "I1" },
  1366. { SHIM6_TYPE_R1, "R1" },
  1367. { SHIM6_TYPE_I2, "I2" },
  1368. { SHIM6_TYPE_R2, "R2" },
  1369. { SHIM6_TYPE_R1BIS, "R1bis" },
  1370. { SHIM6_TYPE_I2BIS, "I2bis" },
  1371. { SHIM6_TYPE_UPD_REQ, "Update Request" },
  1372. { SHIM6_TYPE_UPD_ACK, "Update Acknowledgment" },
  1373. { SHIM6_TYPE_KEEPALIVE, "Keepalive" },
  1374. { SHIM6_TYPE_PROBE, "Probe" },
  1375. { 0, NULL }
  1376. };
  1377. static void ipv6_shim6_checkum_additional_info(tvbuff_t * tvb, packet_info * pinfo,
  1378. proto_item * it_cksum, int offset, gboolean is_cksum_correct)
  1379. {
  1380. proto_tree * checksum_tree;
  1381. proto_item * item;
  1382. checksum_tree = proto_item_add_subtree(it_cksum, ett_ipv6_shim6_cksum);
  1383. item = proto_tree_add_boolean(checksum_tree, hf_ipv6_shim6_checksum_good, tvb,
  1384. offset, 2, is_cksum_correct);
  1385. PROTO_ITEM_SET_GENERATED(item);
  1386. item = proto_tree_add_boolean(checksum_tree, hf_ipv6_shim6_checksum_bad, tvb,
  1387. offset, 2, !is_cksum_correct);
  1388. PROTO_ITEM_SET_GENERATED(item);
  1389. if (!is_cksum_correct) {
  1390. expert_add_info(pinfo, item, &ei_ipv6_shim6_checksum_bad);
  1391. col_append_str(pinfo->cinfo, COL_INFO, " [Shim6 CHECKSUM INCORRECT]");
  1392. }
  1393. }
  1394. static int
  1395. dissect_shim6(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info * pinfo)
  1396. {
  1397. struct ip6_shim shim;
  1398. int len;
  1399. gint p;
  1400. proto_tree *shim_tree;
  1401. proto_item *ti;
  1402. guint8 tmp[5];
  1403. tvb_memcpy(tvb, (guint8 *)&shim, offset, sizeof(shim));
  1404. len = (shim.ip6s_len + 1) << 3;
  1405. if (tree)
  1406. {
  1407. ti = proto_tree_add_item(tree, hf_ipv6_shim6, tvb, offset, len, ENC_NA);
  1408. shim_tree = proto_item_add_subtree(ti, ett_ipv6_shim6);
  1409. /* Next Header */
  1410. proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_nxt, tvb,
  1411. offset + (int)offsetof(struct ip6_shim, ip6s_nxt), 1, shim.ip6s_nxt,
  1412. "Next header: %s (%u)", ipprotostr(shim.ip6s_nxt), shim.ip6s_nxt);
  1413. /* Header Extension Length */
  1414. proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_len, tvb,
  1415. offset + (int)offsetof(struct ip6_shim, ip6s_len), 1, shim.ip6s_len,
  1416. "Header Ext Length: %u (%d bytes)", shim.ip6s_len, len);
  1417. /* P Field */
  1418. proto_tree_add_item(shim_tree, hf_ipv6_shim6_p, tvb,
  1419. offset + (int)offsetof(struct ip6_shim, ip6s_p), 1, ENC_BIG_ENDIAN);
  1420. /* skip the first 2 bytes (nxt hdr, hdr ext len, p+7bits) */
  1421. p = offset + 3;
  1422. if (shim.ip6s_p & SHIM6_BITMASK_P)
  1423. {
  1424. tmp[0] = tvb_get_guint8(tvb, p++);
  1425. tmp[1] = tvb_get_guint8(tvb, p++);
  1426. tmp[2] = tvb_get_guint8(tvb, p++);
  1427. tmp[3] = tvb_get_guint8(tvb, p++);
  1428. tmp[4] = tvb_get_guint8(tvb, p++);
  1429. /* Payload Extension Header */
  1430. proto_tree_add_none_format(shim_tree, hf_ipv6_shim6_ct, tvb,
  1431. offset + (int)offsetof(struct ip6_shim, ip6s_p), 6,
  1432. "Receiver Context Tag: %02x %02x %02x %02x %02x %02x",
  1433. shim.ip6s_p & SHIM6_BITMASK_CT, tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]);
  1434. }
  1435. else
  1436. {
  1437. /* Control Message */
  1438. guint16 csum;
  1439. int advance;
  1440. /* Message Type */
  1441. proto_tree_add_item(shim_tree, hf_ipv6_shim6_type, tvb,
  1442. offset + (int)offsetof(struct ip6_shim, ip6s_p), 1,
  1443. ENC_BIG_ENDIAN
  1444. );
  1445. /* Protocol bit (Must be zero for SHIM6) */
  1446. proto_tree_add_item(shim_tree, hf_ipv6_shim6_proto, tvb, p, 1, ENC_BIG_ENDIAN);
  1447. p++;
  1448. /* Checksum */
  1449. csum = shim_checksum(tvb_get_ptr(tvb, offset, len), len);
  1450. if (csum == 0) {
  1451. ti = proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_checksum, tvb, p, 2,
  1452. tvb_get_ntohs(tvb, p), "Checksum: 0x%04x [correct]", tvb_get_ntohs(tvb, p));
  1453. ipv6_shim6_checkum_additional_info(tvb, pinfo, ti, p, TRUE);
  1454. } else {
  1455. ti = proto_tree_add_uint_format(shim_tree, hf_ipv6_shim6_checksum, tvb, p, 2,
  1456. tvb_get_ntohs(tvb, p), "Checksum: 0x%04x [incorrect: should be 0x%04x]",
  1457. tvb_get_ntohs(tvb, p), in_cksum_shouldbe(tvb_get_ntohs(tvb, p), csum));
  1458. ipv6_shim6_checkum_additional_info(tvb, pinfo, ti, p, FALSE);
  1459. }
  1460. p += 2;
  1461. /* Type specific data */
  1462. advance = dissect_shimctrl(tvb, p, shim.ip6s_p & SHIM6_BITMASK_TYPE, shim_tree);
  1463. p += advance;
  1464. /* Options */
  1465. while (p < offset+len) {
  1466. p += dissect_shimopts(tvb, p, shim_tree, pinfo);
  1467. }
  1468. }
  1469. }
  1470. return len;
  1471. }
  1472. /* END SHIM6 PART */
  1473. static void
  1474. dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
  1475. {
  1476. proto_tree *ipv6_tree = NULL;
  1477. proto_item *ipv6_item = NULL, *ti;
  1478. guint8 nxt;
  1479. guint8 stype=0;
  1480. int advance;
  1481. guint16 plen;
  1482. gboolean hopopts, routing, frag, ah, shim6, dstopts;
  1483. guint16 offlg;
  1484. guint32 ident;
  1485. int offset;
  1486. fragment_head *ipfd_head;
  1487. tvbuff_t *next_tvb;
  1488. gboolean update_col_info = TRUE;
  1489. gboolean save_fragmented = FALSE;
  1490. const char *sep = "IPv6 ";
  1491. guint8 *mac_addr;
  1492. struct ip6_hdr ipv6;
  1493. col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPv6");
  1494. col_clear(pinfo->cinfo, COL_INFO);
  1495. offset = 0;
  1496. tvb_memcpy(tvb, (guint8 *)&ipv6, offset, sizeof(ipv6));
  1497. /* Get extension header and payload length */
  1498. plen = g_ntohs(ipv6.ip6_plen);
  1499. /* Adjust the length of this tvbuff to include only the IPv6 datagram. */
  1500. set_actual_length(tvb, plen + (guint)sizeof (struct ip6_hdr));
  1501. TVB_SET_ADDRESS(&pinfo->net_src, AT_IPv6, tvb, offset + IP6H_SRC, 16);
  1502. TVB_SET_ADDRESS(&pinfo->src, AT_IPv6, tvb, offset + IP6H_SRC, 16);
  1503. TVB_SET_ADDRESS(&pinfo->net_dst, AT_IPv6, tvb, offset + IP6H_DST, 16);
  1504. TVB_SET_ADDRESS(&pinfo->dst, AT_IPv6, tvb, offset + IP6H_DST, 16);
  1505. if (tree) {
  1506. proto_tree* pt;
  1507. proto_item* pi;
  1508. proto_tree *ipv6_tc_tree;
  1509. proto_item *ipv6_tc;
  1510. const char *name;
  1511. ipv6_item = proto_tree_add_item(tree, proto_ipv6, tvb, offset, -1, ENC_NA);
  1512. ipv6_tree = proto_item_add_subtree(ipv6_item, ett_ipv6);
  1513. /* !!! warning: (4-bit) version, (6-bit) DSCP, (1-bit) ECN-ECT, (1-bit) ECN-CE and (20-bit) Flow */
  1514. pi = proto_tree_add_item(ipv6_tree, hf_ipv6_version, tvb,
  1515. offset + (int)offsetof(struct ip6_hdr, ip6_vfc), 1, ENC_BIG_ENDIAN);
  1516. pt = proto_item_add_subtree(pi,ett_ipv6_version);
  1517. pi = proto_tree_add_item(pt, hf_ip_version, tvb,
  1518. offset + (int)offsetof(struct ip6_hdr, ip6_vfc), 1, ENC_BIG_ENDIAN);
  1519. PROTO_ITEM_SET_GENERATED(pi);
  1520. ipv6_tc = proto_tree_add_item(ipv6_tree, hf_ipv6_class, tvb,
  1521. offset + (int)offsetof(struct ip6_hdr, ip6_flow), 4, ENC_BIG_ENDIAN);
  1522. ipv6_tc_tree = proto_item_add_subtree(ipv6_tc, ett_ipv6_traffic_class);
  1523. proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_dscp, tvb,
  1524. offset + (int)offsetof(struct ip6_hdr, ip6_flow), 4, ENC_BIG_ENDIAN);
  1525. proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_ect, tvb,
  1526. offset + (int)offsetof(struct ip6_hdr, ip6_flow), 4, ENC_BIG_ENDIAN);
  1527. proto_tree_add_item(ipv6_tc_tree, hf_ipv6_traffic_class_ce, tvb,
  1528. offset + (int)offsetof(struct ip6_hdr, ip6_flow), 4, ENC_BIG_ENDIAN);
  1529. proto_tree_add_item(ipv6_tree, hf_ipv6_flow, tvb,
  1530. offset + (int)offsetof(struct ip6_hdr, ip6_flow), 4, ENC_BIG_ENDIAN);
  1531. proto_tree_add_item(ipv6_tree, hf_ipv6_plen, tvb,
  1532. offset + (int)offsetof(struct ip6_hdr, ip6_plen), 2, ENC_BIG_ENDIAN);
  1533. proto_tree_add_uint_format(ipv6_tree, hf_ipv6_nxt, tvb,
  1534. offset + (int)offsetof(struct ip6_hdr, ip6_nxt), 1,
  1535. ipv6.ip6_nxt,
  1536. "Next header: %s (%u)",
  1537. ipprotostr(ipv6.ip6_nxt), ipv6.ip6_nxt);
  1538. proto_tree_add_item(ipv6_tree, hf_ipv6_hlim, tvb,
  1539. offset + (int)offsetof(struct ip6_hdr, ip6_hlim), 1, ENC_BIG_ENDIAN);
  1540. /* Yes, there is not TTL in IPv6 Header... but it is the same of Hop Limit...*/
  1541. pinfo->ip_ttl = tvb_get_guint8(tvb, offset + (int)offsetof(struct ip6_hdr, ip6_hlim));
  1542. /* Add the different items for the source address */
  1543. proto_tree_add_item(ipv6_tree, hf_ipv6_src, tvb,
  1544. offset + (int)offsetof(struct ip6_hdr, ip6_src), 16, ENC_NA);
  1545. ti = proto_tree_add_ipv6(ipv6_tree, hf_ipv6_addr, tvb,
  1546. offset + (int)offsetof(struct ip6_hdr, ip6_src),
  1547. 16, (guint8 *)&ipv6.ip6_src);
  1548. PROTO_ITEM_SET_HIDDEN(ti);
  1549. name = get_addr_name(&pinfo->src);
  1550. if (ipv6_summary_in_tree) {
  1551. proto_item_append_text(ipv6_item, ", Src: %s (%s)", name, ip6_to_str(&ipv6.ip6_src));
  1552. }
  1553. ti = proto_tree_add_string(ipv6_tree, hf_ipv6_src_host, tvb,
  1554. offset + (int)offsetof(struct ip6_hdr, ip6_src),
  1555. 16, name);
  1556. PROTO_ITEM_SET_GENERATED(ti);
  1557. PROTO_ITEM_SET_HIDDEN(ti);
  1558. ti = proto_tree_add_string(ipv6_tree, hf_ipv6_host, tvb,
  1559. offset + (int)offsetof(struct ip6_hdr, ip6_src),
  1560. 16, name);
  1561. PROTO_ITEM_SET_GENERATED(ti);
  1562. PROTO_ITEM_SET_HIDDEN(ti);
  1563. /* Extract embedded (IPv6 and MAC) address information */
  1564. if (tvb_get_ntohs(tvb, offset + IP6H_SRC) == 0x2002) { /* RFC 3056 section 2 */
  1565. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_src_6to4_gateway_ipv4, tvb,
  1566. offset + IP6H_SRC + 2, 4, ENC_BIG_ENDIAN);
  1567. PROTO_ITEM_SET_GENERATED(ti);
  1568. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_src_6to4_sla_id, tvb,
  1569. offset + IP6H_SRC + 6, 2, ENC_BIG_ENDIAN);
  1570. PROTO_ITEM_SET_GENERATED(ti);
  1571. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_6to4_gateway_ipv4, tvb,
  1572. offset + IP6H_SRC + 2, 4, ENC_BIG_ENDIAN);
  1573. PROTO_ITEM_SET_GENERATED(ti);
  1574. PROTO_ITEM_SET_HIDDEN(ti);
  1575. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_6to4_sla_id, tvb,
  1576. offset + IP6H_SRC + 6, 2, ENC_BIG_ENDIAN);
  1577. PROTO_ITEM_SET_GENERATED(ti);
  1578. PROTO_ITEM_SET_HIDDEN(ti);
  1579. } else if (tvb_get_ntohl(tvb, offset + IP6H_SRC) == 0x20010000) { /* RFC 4380 section 4 */
  1580. guint16 mapped_port = tvb_get_ntohs(tvb, offset + IP6H_SRC + 10) ^ 0xffff;
  1581. guint32 client_v4 = tvb_get_ipv4(tvb, offset + IP6H_SRC + 12) ^ 0xffffffff;
  1582. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_src_teredo_server_ipv4, tvb,
  1583. offset + IP6H_SRC + 4, 4, ENC_BIG_ENDIAN);
  1584. PROTO_ITEM_SET_GENERATED(ti);
  1585. ti = proto_tree_add_uint(ipv6_tree, hf_ipv6_src_teredo_port, tvb,
  1586. offset + IP6H_SRC + 10, 2, mapped_port);
  1587. PROTO_ITEM_SET_GENERATED(ti);
  1588. ti = proto_tree_add_ipv4(ipv6_tree, hf_ipv6_src_teredo_client_ipv4, tvb,
  1589. offset + IP6H_SRC + 12, 4, client_v4);
  1590. PROTO_ITEM_SET_GENERATED(ti);
  1591. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_teredo_server_ipv4, tvb,
  1592. offset + IP6H_SRC + 4, 4, ENC_BIG_ENDIAN);
  1593. PROTO_ITEM_SET_GENERATED(ti);
  1594. PROTO_ITEM_SET_HIDDEN(ti);
  1595. ti = proto_tree_add_uint(ipv6_tree, hf_ipv6_teredo_port, tvb,
  1596. offset + IP6H_SRC + 10, 2, mapped_port);
  1597. PROTO_ITEM_SET_GENERATED(ti);
  1598. PROTO_ITEM_SET_HIDDEN(ti);
  1599. ti = proto_tree_add_ipv4(ipv6_tree, hf_ipv6_teredo_client_ipv4, tvb,
  1600. offset + IP6H_SRC + 12, 4, client_v4);
  1601. PROTO_ITEM_SET_GENERATED(ti);
  1602. PROTO_ITEM_SET_HIDDEN(ti);
  1603. }
  1604. if (tvb_get_guint8(tvb, offset + IP6H_SRC + 8) & 0x02 && tvb_get_ntohs(tvb, offset + IP6H_SRC + 11) == 0xfffe) { /* RFC 4291 appendix A */
  1605. mac_addr = (guint8 *)ep_alloc(6);
  1606. tvb_memcpy(tvb, mac_addr, offset + IP6H_SRC + 8, 3);
  1607. tvb_memcpy(tvb, mac_addr+3, offset+ IP6H_SRC + 13, 3);
  1608. mac_addr[0] &= ~0x02;
  1609. ti = proto_tree_add_ether(ipv6_tree, hf_ipv6_src_sa_mac, tvb,
  1610. offset + IP6H_SRC + 8, 6, mac_addr);
  1611. PROTO_ITEM_SET_GENERATED(ti);
  1612. ti = proto_tree_add_ether(ipv6_tree, hf_ipv6_sa_mac, tvb,
  1613. offset + IP6H_SRC + 8, 6, mac_addr);
  1614. PROTO_ITEM_SET_GENERATED(ti);
  1615. PROTO_ITEM_SET_HIDDEN(ti);
  1616. } else if ((tvb_get_ntohl(tvb, offset + IP6H_SRC + 8) & 0xfcffffff) == 0x00005efe) { /* RFC 5214 section 6.1 */
  1617. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_src_isatap_ipv4, tvb,
  1618. offset + IP6H_SRC + 12, 4, ENC_BIG_ENDIAN);
  1619. PROTO_ITEM_SET_GENERATED(ti);
  1620. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_isatap_ipv4, tvb,
  1621. offset + IP6H_SRC + 12, 4, ENC_BIG_ENDIAN);
  1622. PROTO_ITEM_SET_GENERATED(ti);
  1623. PROTO_ITEM_SET_HIDDEN(ti);
  1624. }
  1625. /* Add different items for the destination address */
  1626. proto_tree_add_item(ipv6_tree, hf_ipv6_dst, tvb,
  1627. offset + (int)offsetof(struct ip6_hdr, ip6_dst), 16, ENC_NA);
  1628. ti = proto_tree_add_ipv6(ipv6_tree, hf_ipv6_addr, tvb,
  1629. offset + (int)offsetof(struct ip6_hdr, ip6_dst),
  1630. 16, (guint8 *)&ipv6.ip6_dst);
  1631. PROTO_ITEM_SET_HIDDEN(ti);
  1632. name = get_addr_name(&pinfo->dst);
  1633. if (ipv6_summary_in_tree) {
  1634. proto_item_append_text(ipv6_item, ", Dst: %s (%s)", name, ip6_to_str(&ipv6.ip6_dst));
  1635. }
  1636. ti = proto_tree_add_string(ipv6_tree, hf_ipv6_dst_host, tvb,
  1637. offset + (int)offsetof(struct ip6_hdr, ip6_dst),
  1638. 16, name);
  1639. PROTO_ITEM_SET_GENERATED(ti);
  1640. PROTO_ITEM_SET_HIDDEN(ti);
  1641. ti = proto_tree_add_string(ipv6_tree, hf_ipv6_host, tvb,
  1642. offset + (int)offsetof(struct ip6_hdr, ip6_dst),
  1643. 16, name);
  1644. PROTO_ITEM_SET_GENERATED(ti);
  1645. PROTO_ITEM_SET_HIDDEN(ti);
  1646. /* Extract embedded (IPv6 and MAC) address information */
  1647. if (tvb_get_ntohs(tvb, offset + IP6H_DST) == 0x2002) { /* RFC 3056 section 2 */
  1648. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_dst_6to4_gateway_ipv4, tvb,
  1649. offset + IP6H_DST + 2, 4, ENC_BIG_ENDIAN);
  1650. PROTO_ITEM_SET_GENERATED(ti);
  1651. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_dst_6to4_sla_id, tvb,
  1652. offset + IP6H_DST + 6, 2, ENC_BIG_ENDIAN);
  1653. PROTO_ITEM_SET_GENERATED(ti);
  1654. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_6to4_gateway_ipv4, tvb,
  1655. offset + IP6H_DST + 2, 4, ENC_BIG_ENDIAN);
  1656. PROTO_ITEM_SET_GENERATED(ti);
  1657. PROTO_ITEM_SET_HIDDEN(ti);
  1658. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_6to4_sla_id, tvb,
  1659. offset + IP6H_DST + 6, 2, ENC_BIG_ENDIAN);
  1660. PROTO_ITEM_SET_GENERATED(ti);
  1661. PROTO_ITEM_SET_HIDDEN(ti);
  1662. } else if (tvb_get_ntohl(tvb, offset + IP6H_DST) == 0x20010000) { /* RFC 4380 section 4 */
  1663. guint16 mapped_port = tvb_get_ntohs(tvb, offset + IP6H_DST + 10) ^ 0xffff;
  1664. guint32 client_v4 = tvb_get_ipv4(tvb, offset + IP6H_DST + 12) ^ 0xffffffff;
  1665. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_dst_teredo_server_ipv4, tvb,
  1666. offset + IP6H_DST + 4, 4, ENC_BIG_ENDIAN);
  1667. PROTO_ITEM_SET_GENERATED(ti);
  1668. ti = proto_tree_add_uint(ipv6_tree, hf_ipv6_dst_teredo_port, tvb,
  1669. offset + IP6H_DST + 10, 2, mapped_port);
  1670. PROTO_ITEM_SET_GENERATED(ti);
  1671. ti = proto_tree_add_ipv4(ipv6_tree, hf_ipv6_dst_teredo_client_ipv4, tvb,
  1672. offset + IP6H_DST + 12, 4, client_v4);
  1673. PROTO_ITEM_SET_GENERATED(ti);
  1674. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_teredo_server_ipv4, tvb,
  1675. offset + IP6H_DST + 4, 4, ENC_BIG_ENDIAN);
  1676. PROTO_ITEM_SET_GENERATED(ti);
  1677. PROTO_ITEM_SET_HIDDEN(ti);
  1678. ti = proto_tree_add_uint(ipv6_tree, hf_ipv6_teredo_port, tvb,
  1679. offset + IP6H_DST + 10, 2, mapped_port);
  1680. PROTO_ITEM_SET_GENERATED(ti);
  1681. PROTO_ITEM_SET_HIDDEN(ti);
  1682. ti = proto_tree_add_ipv4(ipv6_tree, hf_ipv6_teredo_client_ipv4, tvb,
  1683. offset + IP6H_DST + 12, 4, client_v4);
  1684. PROTO_ITEM_SET_GENERATED(ti);
  1685. PROTO_ITEM_SET_HIDDEN(ti);
  1686. }
  1687. if (tvb_get_guint8(tvb, offset + IP6H_DST + 8) & 0x02 && tvb_get_ntohs(tvb, offset + IP6H_DST + 11) == 0xfffe) { /* RFC 4291 appendix A */
  1688. mac_addr = (guint8 *)ep_alloc(6);
  1689. tvb_memcpy(tvb, mac_addr, offset + IP6H_DST + 8, 3);
  1690. tvb_memcpy(tvb, mac_addr+3, offset+ IP6H_DST + 13, 3);
  1691. mac_addr[0] &= ~0x02;
  1692. ti = proto_tree_add_ether(ipv6_tree, hf_ipv6_dst_sa_mac, tvb,
  1693. offset + IP6H_DST + 8, 6, mac_addr);
  1694. PROTO_ITEM_SET_GENERATED(ti);
  1695. ti = proto_tree_add_ether(ipv6_tree, hf_ipv6_sa_mac, tvb,
  1696. offset + IP6H_DST + 8, 6, mac_addr);
  1697. PROTO_ITEM_SET_GENERATED(ti);
  1698. PROTO_ITEM_SET_HIDDEN(ti);
  1699. } else if ((tvb_get_ntohl(tvb, offset + IP6H_DST + 8) & 0xfcffffff) == 0x00005efe) { /* RFC 5214 section 6.1 */
  1700. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_dst_isatap_ipv4, tvb,
  1701. offset + IP6H_DST + 12, 4, ENC_BIG_ENDIAN);
  1702. PROTO_ITEM_SET_GENERATED(ti);
  1703. ti = proto_tree_add_item(ipv6_tree, hf_ipv6_isatap_ipv4, tvb,
  1704. offset + IP6H_DST + 12, 4, ENC_BIG_ENDIAN);
  1705. PROTO_ITEM_SET_GENERATED(ti);
  1706. PROTO_ITEM_SET_HIDDEN(ti);
  1707. }
  1708. }
  1709. #ifdef HAVE_GEOIP_V6
  1710. if (tree && ipv6_use_geoip) {
  1711. add_geoip_info(ipv6_tree, tvb, offset, &ipv6.ip6_src, &ipv6.ip6_dst);
  1712. }
  1713. #endif
  1714. /* start of the new header (could be a extension header) */
  1715. nxt = tvb_get_guint8(tvb, offset + 6);
  1716. offset += (int)sizeof(struct ip6_hdr);
  1717. offlg = 0;
  1718. ident = 0;
  1719. /* start out assuming this isn't fragmented, and has none of the other
  1720. non-final headers */
  1721. hopopts = FALSE;
  1722. routing = FALSE;
  1723. ah = FALSE;
  1724. shim6 = FALSE;
  1725. dstopts = FALSE;
  1726. again:
  1727. switch (nxt) {
  1728. case IP_PROTO_HOPOPTS:
  1729. hopopts = TRUE;
  1730. advance = dissect_hopopts(tvb, offset, ipv6_tree, pinfo);
  1731. nxt = tvb_get_guint8(tvb, offset);
  1732. offset += advance;
  1733. plen -= advance;
  1734. goto again;
  1735. case IP_PROTO_ROUTING:
  1736. routing = TRUE;
  1737. advance = dissect_routing6(tvb, offset, ipv6_tree, pinfo);
  1738. nxt = tvb_get_guint8(tvb, offset);
  1739. offset += advance;
  1740. plen -= advance;
  1741. goto again;
  1742. case IP_PROTO_FRAGMENT:
  1743. advance = dissect_frag6(tvb, offset, pinfo, ipv6_tree,
  1744. &offlg, &ident);
  1745. nxt = tvb_get_guint8(tvb, offset);
  1746. offset += advance;
  1747. plen -= advance;
  1748. frag = offlg & (IP6F_OFF_MASK | IP6F_MORE_FRAG);
  1749. save_fragmented |= frag;
  1750. if (ipv6_reassemble && frag && tvb_bytes_exist(tvb, offset, plen)) {
  1751. ipfd_head = fragment_add_check(&ipv6_reassembly_table,
  1752. tvb, offset, pinfo, ident, NULL,
  1753. offlg & IP6F_OFF_MASK,
  1754. plen,
  1755. offlg & IP6F_MORE_FRAG);
  1756. next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled IPv6",
  1757. ipfd_head, &ipv6_frag_items, &update_col_info, ipv6_tree);
  1758. if (next_tvb) { /* Process post-fragment headers after reassembly... */
  1759. offset= 0;
  1760. offlg = 0;
  1761. tvb = next_tvb;
  1762. goto again;
  1763. }
  1764. }
  1765. if (!(offlg & IP6F_OFF_MASK)) /*...or in the first fragment */
  1766. goto again;
  1767. break;
  1768. case IP_PROTO_AH:
  1769. ah = TRUE;
  1770. advance = dissect_ah_header(tvb_new_subset_remaining(tvb, offset),
  1771. pinfo, ipv6_tree, NULL, NULL);
  1772. nxt = tvb_get_guint8(tvb, offset);
  1773. offset += advance;
  1774. plen -= advance;
  1775. goto again;
  1776. case IP_PROTO_SHIM6:
  1777. case IP_PROTO_SHIM6_OLD:
  1778. shim6 = TRUE;
  1779. advance = dissect_shim6(tvb, offset, ipv6_tree, pinfo);
  1780. nxt = tvb_get_guint8(tvb, offset);
  1781. stype = tvb_get_guint8(tvb, offset+2);
  1782. offset += advance;
  1783. plen -= advance;
  1784. goto again;
  1785. case IP_PROTO_DSTOPTS:
  1786. dstopts = TRUE;
  1787. advance = dissect_dstopts(tvb, offset, ipv6_tree, pinfo);
  1788. nxt = tvb_get_guint8(tvb, offset);
  1789. offset += advance;
  1790. plen -= advance;
  1791. goto again;
  1792. case IP_PROTO_NONE:
  1793. break;
  1794. default:
  1795. /* Since we did not recognize this IPv6 option, check
  1796. * whether it is a known protocol. If not, then it
  1797. * is an unknown IPv6 option
  1798. */
  1799. if (!dissector_get_uint_handle(ip_dissector_table, nxt)) {
  1800. advance = dissect_unknown_option(tvb, offset, ipv6_tree);
  1801. nxt = tvb_get_guint8(tvb, offset);
  1802. offset += advance;
  1803. plen -= advance;
  1804. goto again;
  1805. }
  1806. }
  1807. proto_item_set_len (ipv6_item, offset);
  1808. /* collect packet info */
  1809. pinfo->ipproto = nxt;
  1810. pinfo->iplen = (int)sizeof(ipv6) + plen + offset;
  1811. pinfo->iphdrlen = offset;
  1812. tap_queue_packet(ipv6_tap, pinfo, &ipv6);
  1813. if (offlg & IP6F_OFF_MASK || (ipv6_reassemble && offlg & IP6F_MORE_FRAG)) {
  1814. /* Not the first fragment, or the first when we are reassembling and there are more. */
  1815. /* Don't dissect it; just show this as a fragment. */
  1816. /* COL_INFO was filled in by "dissect_frag6()" */
  1817. call_dissector(data_handle, tvb_new_subset_remaining(tvb, offset), pinfo, tree);
  1818. return;
  1819. } else {
  1820. /* First fragment, not fragmented, or already reassembled. Dissect what we have here. */
  1821. /* Get a tvbuff for the payload. */
  1822. next_tvb = tvb_new_subset_remaining(tvb, offset);
  1823. /*
  1824. * If this is the first fragment, but not the only fragment,
  1825. * tell the next protocol that.
  1826. */
  1827. if (offlg & IP6F_MORE_FRAG)
  1828. pinfo->fragmented = TRUE;
  1829. else
  1830. pinfo->fragmented = FALSE;
  1831. }
  1832. /* do lookup with the subdissector table */
  1833. if (!dissector_try_uint(ip_dissector_table, nxt, next_tvb, pinfo, tree)) {
  1834. /* Unknown protocol.
  1835. Handle "no next header" specially. */
  1836. if (nxt == IP_PROTO_NONE) {
  1837. /* If we had an Authentication Header, the AH dissector already
  1838. put something in the Info column; leave it there. */
  1839. if (!ah) {
  1840. if (hopopts || routing || dstopts || shim6) {
  1841. if (hopopts) {
  1842. col_append_fstr(pinfo->cinfo, COL_INFO, "%shop-by-hop options",
  1843. sep);
  1844. sep = ", ";
  1845. }
  1846. if (routing) {
  1847. col_append_fstr(pinfo->cinfo, COL_INFO, "%srouting", sep);
  1848. sep = ", ";
  1849. }
  1850. if (dstopts) {
  1851. col_append_fstr(pinfo->cinfo, COL_INFO, "%sdestination options",
  1852. sep);
  1853. }
  1854. if (shim6) {
  1855. if (stype & SHIM6_BITMASK_P) {
  1856. col_append_str(pinfo->cinfo, COL_INFO, "Shim6 (Payload)");
  1857. }
  1858. else {
  1859. col_append_fstr(pinfo->cinfo, COL_INFO, "Shim6 (%s)",
  1860. val_to_str_const(stype & SHIM6_BITMASK_TYPE, shimctrlvals, "Unknown"));
  1861. }
  1862. }
  1863. } else
  1864. col_set_str(pinfo->cinfo, COL_INFO, "IPv6 no next header");
  1865. }
  1866. } else {
  1867. col_add_fstr(pinfo->cinfo, COL_INFO, "%s (%u)", ipprotostr(nxt), nxt);
  1868. }
  1869. call_dissector(data_handle, next_tvb, pinfo, tree);
  1870. }
  1871. pinfo->fragmented = save_fragmented;
  1872. }
  1873. void
  1874. proto_register_ipv6(void)
  1875. {
  1876. static hf_register_info hf[] = {
  1877. { &hf_ipv6_version,
  1878. { "Version", "ipv6.version",
  1879. FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
  1880. { &hf_ip_version,
  1881. { "This field makes the filter \"ip.version == 6\" possible", "ip.version",
  1882. FT_UINT8, BASE_DEC, NULL, 0xF0, NULL, HFILL }},
  1883. { &hf_ipv6_class,
  1884. { "Traffic class", "ipv6.class",
  1885. FT_UINT32, BASE_HEX, NULL, 0x0FF00000, NULL, HFILL }},
  1886. { &hf_ipv6_flow,
  1887. { "Flowlabel", "ipv6.flow",
  1888. FT_UINT32, BASE_HEX, NULL, 0x000FFFFF, NULL, HFILL }},
  1889. { &hf_ipv6_plen,
  1890. { "Payload length", "ipv6.plen",
  1891. FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  1892. { &hf_ipv6_nxt,
  1893. { "Next header", "ipv6.nxt",
  1894. FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0, NULL, HFILL }},
  1895. { &hf_ipv6_hlim,
  1896. { "Hop limit", "ipv6.hlim",
  1897. FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }},
  1898. { &hf_ipv6_src,
  1899. { "Source", "ipv6.src",
  1900. FT_IPv6, BASE_NONE, NULL, 0x0,
  1901. "Source IPv6 Address", HFILL }},
  1902. { &hf_ipv6_src_host,
  1903. { "Source Host", "ipv6.src_host",
  1904. FT_STRING, BASE_NONE, NULL, 0x0,
  1905. "Source IPv6 Host", HFILL }},
  1906. { &hf_ipv6_src_sa_mac,
  1907. { "Source SA MAC", "ipv6.src_sa_mac",
  1908. FT_ETHER, BASE_NONE, NULL, 0x0,
  1909. "Source IPv6 Stateless Autoconfiguration MAC Address", HFILL }},
  1910. { &hf_ipv6_src_isatap_ipv4,
  1911. { "Source ISATAP IPv4", "ipv6.src_isatap_ipv4",
  1912. FT_IPv4, BASE_NONE, NULL, 0x0,
  1913. "Source IPv6 ISATAP Encapsulated IPv4 Address", HFILL }},
  1914. { &hf_ipv6_src_6to4_gateway_ipv4,
  1915. { "Source 6to4 Gateway IPv4", "ipv6.src_6to4_gw_ipv4",
  1916. FT_IPv4, BASE_NONE, NULL, 0x0,
  1917. "Source IPv6 6to4 Gateway IPv4 Address", HFILL }},
  1918. { &hf_ipv6_src_6to4_sla_id,
  1919. { "Source 6to4 SLA ID", "ipv6.src_6to4_sla_id",
  1920. FT_UINT16, BASE_DEC, NULL, 0x0,
  1921. "Source IPv6 6to4 SLA ID", HFILL }},
  1922. { &hf_ipv6_src_teredo_server_ipv4,
  1923. { "Source Teredo Server IPv4", "ipv6.src_ts_ipv4",
  1924. FT_IPv4, BASE_NONE, NULL, 0x0,
  1925. "Source IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }},
  1926. { &hf_ipv6_src_teredo_port,
  1927. { "Source Teredo Port", "ipv6.src_tc_port",
  1928. FT_UINT16, BASE_DEC, NULL, 0x0,
  1929. "Source IPv6 Teredo Client Mapped Port", HFILL }},
  1930. { &hf_ipv6_src_teredo_client_ipv4,
  1931. { "Source Teredo Client IPv4", "ipv6.src_tc_ipv4",
  1932. FT_IPv4, BASE_NONE, NULL, 0x0,
  1933. "Source IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }},
  1934. { &hf_ipv6_dst,
  1935. { "Destination", "ipv6.dst",
  1936. FT_IPv6, BASE_NONE, NULL, 0x0,
  1937. "Destination IPv6 Address", HFILL }},
  1938. { &hf_ipv6_dst_host,
  1939. { "Destination Host", "ipv6.dst_host",
  1940. FT_STRING, BASE_NONE, NULL, 0x0,
  1941. "Destination IPv6 Host", HFILL }},
  1942. { &hf_ipv6_dst_sa_mac,
  1943. { "Destination SA MAC", "ipv6.dst_sa_mac",
  1944. FT_ETHER, BASE_NONE, NULL, 0x0,
  1945. "Destination IPv6 Stateless Autoconfiguration MAC Address", HFILL }},
  1946. { &hf_ipv6_dst_isatap_ipv4,
  1947. { "Destination ISATAP IPv4", "ipv6.dst_isatap_ipv4",
  1948. FT_IPv4, BASE_NONE, NULL, 0x0,
  1949. "Destination IPv6 ISATAP Encapsulated IPv4 Address", HFILL }},
  1950. { &hf_ipv6_dst_6to4_gateway_ipv4,
  1951. { "Destination 6to4 Gateway IPv4", "ipv6.dst_6to4_gw_ipv4",
  1952. FT_IPv4, BASE_NONE, NULL, 0x0,
  1953. "Destination IPv6 6to4 Gateway IPv4 Address", HFILL }},
  1954. { &hf_ipv6_dst_6to4_sla_id,
  1955. { "Destination 6to4 SLA ID", "ipv6.dst_6to4_sla_id",
  1956. FT_UINT16, BASE_DEC, NULL, 0x0,
  1957. "Destination IPv6 6to4 SLA ID", HFILL }},
  1958. { &hf_ipv6_dst_teredo_server_ipv4,
  1959. { "Destination Teredo Server IPv4", "ipv6.dst_ts_ipv4",
  1960. FT_IPv4, BASE_NONE, NULL, 0x0,
  1961. "Destination IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }},
  1962. { &hf_ipv6_dst_teredo_port,
  1963. { "Destination Teredo Port", "ipv6.dst_tc_port",
  1964. FT_UINT16, BASE_DEC, NULL, 0x0,
  1965. "Destination IPv6 Teredo Client Mapped Port", HFILL }},
  1966. { &hf_ipv6_dst_teredo_client_ipv4,
  1967. { "Destination Teredo Client IPv4", "ipv6.dst_tc_ipv4",
  1968. FT_IPv4, BASE_NONE, NULL, 0x0,
  1969. "Destination IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }},
  1970. { &hf_ipv6_addr,
  1971. { "Source or Destination Address", "ipv6.addr",
  1972. FT_IPv6, BASE_NONE, NULL, 0x0,
  1973. NULL, HFILL }},
  1974. { &hf_ipv6_host,
  1975. { "Source or Destination Host", "ipv6.host",
  1976. FT_STRING, BASE_NONE, NULL, 0x0,
  1977. NULL, HFILL }},
  1978. { &hf_ipv6_sa_mac,
  1979. { "SA MAC", "ipv6.sa_mac",
  1980. FT_ETHER, BASE_NONE, NULL, 0x0,
  1981. "IPv6 Stateless Autoconfiguration MAC Address", HFILL }},
  1982. { &hf_ipv6_isatap_ipv4,
  1983. { "ISATAP IPv4", "ipv6.isatap_ipv4",
  1984. FT_IPv4, BASE_NONE, NULL, 0x0,
  1985. "IPv6 ISATAP Encapsulated IPv4 Address", HFILL }},
  1986. { &hf_ipv6_6to4_gateway_ipv4,
  1987. { "6to4 Gateway IPv4", "ipv6.6to4_gw_ipv4",
  1988. FT_IPv4, BASE_NONE, NULL, 0x0,
  1989. "IPv6 6to4 Gateway IPv4 Address", HFILL }},
  1990. { &hf_ipv6_6to4_sla_id,
  1991. { "6to4 SLA ID", "ipv6.6to4_sla_id",
  1992. FT_UINT16, BASE_DEC, NULL, 0x0,
  1993. "IPv6 6to4 SLA ID", HFILL }},
  1994. { &hf_ipv6_teredo_server_ipv4,
  1995. { "Teredo Server IPv4", "ipv6.ts_ipv4",
  1996. FT_IPv4, BASE_NONE, NULL, 0x0,
  1997. "IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }},
  1998. { &hf_ipv6_teredo_port,
  1999. { "Teredo Port", "ipv6.tc_port",
  2000. FT_UINT16, BASE_DEC, NULL, 0x0,
  2001. "IPv6 Teredo Client Mapped Port", HFILL }},
  2002. { &hf_ipv6_teredo_client_ipv4,
  2003. { "Teredo Client IPv4", "ipv6.tc_ipv4",
  2004. FT_IPv4, BASE_NONE, NULL, 0x0,
  2005. "IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }},
  2006. #ifdef HAVE_GEOIP_V6
  2007. { &hf_geoip_country,
  2008. { "Source or Destination GeoIP Country", "ipv6.geoip.country",
  2009. FT_STRING, BASE_NONE, NULL, 0x0,
  2010. NULL, HFILL }},
  2011. { &hf_geoip_city,
  2012. { "Source or Destination GeoIP City", "ipv6.geoip.city",
  2013. FT_STRING, BASE_NONE, NULL, 0x0,
  2014. NULL, HFILL }},
  2015. { &hf_geoip_org,
  2016. { "Source or Destination GeoIP Organization", "ipv6.geoip.org",
  2017. FT_STRING, BASE_NONE, NULL, 0x0,
  2018. NULL, HFILL }},
  2019. { &hf_geoip_isp,
  2020. { "Source or Destination GeoIP ISP", "ipv6.geoip.isp",
  2021. FT_STRING, BASE_NONE, NULL, 0x0,
  2022. NULL, HFILL }},
  2023. { &hf_geoip_asnum,
  2024. { "Source or Destination GeoIP AS Number", "ipv6.geoip.asnum",
  2025. FT_STRING, BASE_NONE, NULL, 0x0,
  2026. NULL, HFILL }},
  2027. { &hf_geoip_lat,
  2028. { "Source or Destination GeoIP Latitude", "ipv6.geoip.lat",
  2029. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2030. NULL, HFILL }},
  2031. { &hf_geoip_lon,
  2032. { "Source or Destination GeoIP Longitude", "ipv6.geoip.lon",
  2033. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2034. NULL, HFILL }},
  2035. { &hf_geoip_src_country,
  2036. { "Source GeoIP Country", "ipv6.geoip.src_country",
  2037. FT_STRING, BASE_NONE, NULL, 0x0,
  2038. NULL, HFILL }},
  2039. { &hf_geoip_src_city,
  2040. { "Source GeoIP City", "ipv6.geoip.src_city",
  2041. FT_STRING, BASE_NONE, NULL, 0x0,
  2042. NULL, HFILL }},
  2043. { &hf_geoip_src_org,
  2044. { "Source GeoIP Organization", "ipv6.geoip.src_org",
  2045. FT_STRING, BASE_NONE, NULL, 0x0,
  2046. NULL, HFILL }},
  2047. { &hf_geoip_src_isp,
  2048. { "Source GeoIP ISP", "ipv6.geoip.src_isp",
  2049. FT_STRING, BASE_NONE, NULL, 0x0,
  2050. NULL, HFILL }},
  2051. { &hf_geoip_src_asnum,
  2052. { "Source GeoIP AS Number", "ipv6.geoip.src_asnum",
  2053. FT_STRING, BASE_NONE, NULL, 0x0,
  2054. NULL, HFILL }},
  2055. { &hf_geoip_src_lat,
  2056. { "Source GeoIP Latitude", "ipv6.geoip.src_lat",
  2057. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2058. NULL, HFILL }},
  2059. { &hf_geoip_src_lon,
  2060. { "Source GeoIP Longitude", "ipv6.geoip.src_lon",
  2061. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2062. NULL, HFILL }},
  2063. { &hf_geoip_dst_country,
  2064. { "Destination GeoIP Country", "ipv6.geoip.dst_country",
  2065. FT_STRING, BASE_NONE, NULL, 0x0,
  2066. NULL, HFILL }},
  2067. { &hf_geoip_dst_city,
  2068. { "Destination GeoIP City", "ipv6.geoip.dst_city",
  2069. FT_STRING, BASE_NONE, NULL, 0x0,
  2070. NULL, HFILL }},
  2071. { &hf_geoip_dst_org,
  2072. { "Destination GeoIP Organization", "ipv6.geoip.dst_org",
  2073. FT_STRING, BASE_NONE, NULL, 0x0,
  2074. NULL, HFILL }},
  2075. { &hf_geoip_dst_isp,
  2076. { "Destination GeoIP ISP", "ipv6.geoip.dst_isp",
  2077. FT_STRING, BASE_NONE, NULL, 0x0,
  2078. NULL, HFILL }},
  2079. { &hf_geoip_dst_asnum,
  2080. { "Destination GeoIP AS Number", "ipv6.geoip.dst_asnum",
  2081. FT_STRING, BASE_NONE, NULL, 0x0,
  2082. NULL, HFILL }},
  2083. { &hf_geoip_dst_lat,
  2084. { "Destination GeoIP Latitude", "ipv6.geoip.dst_lat",
  2085. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2086. NULL, HFILL }},
  2087. { &hf_geoip_dst_lon,
  2088. { "Destination GeoIP Longitude", "ipv6.geoip.dst_lon",
  2089. FT_DOUBLE, BASE_NONE, NULL, 0x0,
  2090. NULL, HFILL }},
  2091. #endif /* HAVE_GEOIP_V6 */
  2092. { &hf_ipv6_dst_opt,
  2093. { "Destination Option", "ipv6.dst_opt",
  2094. FT_NONE, BASE_NONE, NULL, 0x0,
  2095. NULL, HFILL }},
  2096. { &hf_ipv6_hop_opt,
  2097. { "Hop-by-Hop Option", "ipv6.hop_opt",
  2098. FT_NONE, BASE_NONE, NULL, 0x0,
  2099. NULL, HFILL }},
  2100. { &hf_ipv6_unk_hdr,
  2101. { "Unknown Extension Header", "ipv6.unknown_hdr",
  2102. FT_NONE, BASE_NONE, NULL, 0x0,
  2103. NULL, HFILL }},
  2104. { &hf_ipv6_opt,
  2105. { "IPv6 Option", "ipv6.opt",
  2106. FT_NONE, BASE_NONE, NULL, 0x0,
  2107. "Option", HFILL }},
  2108. { &hf_ipv6_opt_type,
  2109. { "Type", "ipv6.opt.type",
  2110. FT_UINT8, BASE_DEC, VALS(ipv6_opt_vals), 0x0,
  2111. "Options type", HFILL }},
  2112. { &hf_ipv6_opt_length,
  2113. { "Length", "ipv6.opt.length",
  2114. FT_UINT8, BASE_DEC, NULL, 0x0,
  2115. "Length in units of 8 octets", HFILL }},
  2116. { &hf_ipv6_opt_pad1,
  2117. { "Pad1", "ipv6.opt.pad1",
  2118. FT_NONE, BASE_NONE, NULL, 0x0,
  2119. "Pad1 Option", HFILL }},
  2120. { &hf_ipv6_opt_padn,
  2121. { "PadN", "ipv6.opt.padn",
  2122. FT_BYTES, BASE_NONE, NULL, 0x0,
  2123. "PadN Option", HFILL }},
  2124. { &hf_ipv6_opt_rtalert,
  2125. { "Router Alert", "ipv6.opt.router_alert",
  2126. FT_UINT16, BASE_DEC, VALS(rtalertvals), 0x0,
  2127. NULL, HFILL }},
  2128. { &hf_ipv6_opt_tel,
  2129. { "Tunnel Encapsulation Limit", "ipv6.opt.tel",
  2130. FT_UINT8, BASE_DEC, NULL, 0x0,
  2131. "How many further levels of encapsulation are permitted", HFILL }},
  2132. { &hf_ipv6_opt_jumbo,
  2133. { "Jumbo", "ipv6.opt.jumbo",
  2134. FT_UINT32, BASE_DEC, NULL, 0x0,
  2135. "Length of the IPv6 packet in octets", HFILL }},
  2136. { &hf_ipv6_opt_calipso_doi,
  2137. { "CALIPSO Domain of Interpretation","ipv6.opt.calipso.doi",
  2138. FT_UINT8, BASE_DEC, NULL, 0x0,
  2139. NULL, HFILL }},
  2140. { &hf_ipv6_opt_calipso_cmpt_length,
  2141. { "Compartment Length","ipv6.opt.calipso.cmpt.length",
  2142. FT_UINT8, BASE_DEC, NULL, 0x0,
  2143. NULL, HFILL }},
  2144. { &hf_ipv6_opt_calipso_sens_level,
  2145. { "Sensitivity Level","ipv6.opt.calipso.sens_level",
  2146. FT_UINT8, BASE_DEC, NULL, 0x0,
  2147. NULL, HFILL }},
  2148. { &hf_ipv6_opt_calipso_checksum,
  2149. { "Checksum","ipv6.opt.calipso.checksum",
  2150. FT_UINT16, BASE_HEX, NULL, 0x0,
  2151. NULL, HFILL }},
  2152. { &hf_ipv6_opt_calipso_cmpt_bitmap,
  2153. { "Compartment Bitmap","ipv6.opt.calipso.cmpt_bitmap",
  2154. FT_BYTES, BASE_NONE, NULL, 0x0,
  2155. NULL, HFILL }},
  2156. { &hf_ipv6_opt_qs_func,
  2157. { "Function", "ipv6.opt.qs_func",
  2158. FT_UINT8, BASE_DEC, VALS(qs_func_vals), QS_FUNC_MASK,
  2159. NULL, HFILL }},
  2160. { &hf_ipv6_opt_qs_rate,
  2161. { "Rate", "ipv6.opt.qs_rate",
  2162. FT_UINT8, BASE_DEC | BASE_EXT_STRING, &qs_rate_vals_ext, QS_RATE_MASK,
  2163. NULL, HFILL }},
  2164. { &hf_ipv6_opt_qs_ttl,
  2165. { "QS TTL", "ipv6.opt.qs_ttl",
  2166. FT_UINT8, BASE_DEC, NULL, 0x0,
  2167. NULL, HFILL }},
  2168. { &hf_ipv6_opt_qs_ttl_diff,
  2169. { "TTL Diff", "ipv6.opt.qs_ttl_diff",
  2170. FT_UINT8, BASE_DEC, NULL, 0x0,
  2171. NULL, HFILL }},
  2172. { &hf_ipv6_opt_qs_unused,
  2173. { "Not Used", "ipv6.opt.qs_unused",
  2174. FT_UINT8, BASE_DEC, NULL, 0x0,
  2175. NULL, HFILL }},
  2176. { &hf_ipv6_opt_qs_nonce,
  2177. { "QS Nonce", "ipv6.opt.qs_nonce",
  2178. FT_UINT32, BASE_HEX, NULL, 0xFFFFFFFC,
  2179. NULL, HFILL }},
  2180. { &hf_ipv6_opt_qs_reserved,
  2181. { "Reserved", "ipv6.opt.qs_reserved",
  2182. FT_UINT32, BASE_HEX, NULL, 0x0003,
  2183. NULL, HFILL }},
  2184. { &hf_ipv6_opt_rpl_flag,
  2185. { "Flag", "ipv6.opt.rpl.flag",
  2186. FT_UINT8, BASE_DEC, NULL, 0x0,
  2187. NULL, HFILL }},
  2188. { &hf_ipv6_opt_rpl_flag_o,
  2189. { "Down", "ipv6.opt.rpl.flag.o",
  2190. FT_BOOLEAN, 8, NULL, 0x80,
  2191. "The packet is expected to progress Up or Down", HFILL }},
  2192. { &hf_ipv6_opt_rpl_flag_r,
  2193. { "Rank Error", "ipv6.opt.rpl.flag.r",
  2194. FT_BOOLEAN, 8, NULL, 0x40,
  2195. "Indicating whether a rank error was detected", HFILL }},
  2196. { &hf_ipv6_opt_rpl_flag_f,
  2197. { "Forwarding Error", "ipv6.opt.rpl.flag.f",
  2198. FT_BOOLEAN, 8, NULL, 0x20,
  2199. "Indicating that this node can not forward the packet further towards the destination", HFILL }},
  2200. { &hf_ipv6_opt_rpl_flag_rsv,
  2201. { "Reserved", "ipv6.opt.rpl.flag.rsv",
  2202. FT_UINT8, BASE_HEX, NULL, 0x1F,
  2203. "Reserved (Must Be Zero)", HFILL }},
  2204. { &hf_ipv6_opt_rpl_instance_id,
  2205. { "RPLInstanceID", "ipv6.opt.rpl.instance_id",
  2206. FT_UINT8, BASE_HEX, NULL, 0x0,
  2207. "Indicating the DODAG instance along which the packet is sent", HFILL }},
  2208. { &hf_ipv6_opt_rpl_senderrank,
  2209. { "Sender Rank", "ipv6.opt.rpl.sender_rank",
  2210. FT_UINT16, BASE_HEX, NULL, 0x0,
  2211. "Set to zero by the source and to DAGRank(rank) by a router that forwards inside the RPL network", HFILL }},
  2212. { &hf_ipv6_opt_experimental,
  2213. { "Experimental Option","ipv6.opt.experimental",
  2214. FT_BYTES, BASE_NONE, NULL, 0x0,
  2215. NULL, HFILL }},
  2216. { &hf_ipv6_opt_unknown,
  2217. { "Unknown Option Payload","ipv6.opt.unknown",
  2218. FT_BYTES, BASE_NONE, NULL, 0x0,
  2219. NULL, HFILL }},
  2220. { &hf_ipv6_routing_hdr_opt,
  2221. { "Routing Header, Type","ipv6.routing_hdr",
  2222. FT_UINT8, BASE_DEC, NULL, 0x0,
  2223. "Routing Header Option", HFILL }},
  2224. { &hf_ipv6_routing_hdr_type,
  2225. { "Type", "ipv6.routing_hdr.type",
  2226. FT_UINT8, BASE_DEC, VALS(routing_header_type), 0x0,
  2227. "Routing Header Type", HFILL }},
  2228. { &hf_ipv6_routing_hdr_left,
  2229. { "Segments Left", "ipv6.routing_hdr.left",
  2230. FT_UINT8, BASE_DEC, NULL, 0x0,
  2231. "Routing Header Segments Left", HFILL }},
  2232. { &hf_ipv6_routing_hdr_addr,
  2233. { "Address", "ipv6.routing_hdr.addr",
  2234. FT_IPv6, BASE_NONE, NULL, 0x0,
  2235. "Routing Header Address", HFILL }},
  2236. { &hf_ipv6_frag_nxt,
  2237. { "Next header", "ipv6.fragment.nxt",
  2238. FT_UINT16, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
  2239. "Fragment next header", HFILL }},
  2240. { &hf_ipv6_frag_reserved,
  2241. { "Reserved octet", "ipv6.fragment.reserved_octet",
  2242. FT_UINT16, BASE_HEX, NULL, 0x0,
  2243. "Should always be 0", HFILL }},
  2244. { &hf_ipv6_frag_offset,
  2245. { "Offset", "ipv6.fragment.offset",
  2246. FT_UINT16, BASE_DEC_HEX, NULL, IP6F_OFF_MASK,
  2247. "Fragment Offset", HFILL }},
  2248. { &hf_ipv6_frag_reserved_bits,
  2249. { "Reserved bits", "ipv6.fragment.reserved_bits",
  2250. FT_UINT16, BASE_DEC_HEX, NULL, IP6F_RESERVED_MASK,
  2251. NULL, HFILL }},
  2252. { &hf_ipv6_frag_more,
  2253. { "More Fragment", "ipv6.fragment.more",
  2254. FT_BOOLEAN, 16, TFS(&tfs_yes_no), IP6F_MORE_FRAG,
  2255. "More Fragments", HFILL }},
  2256. { &hf_ipv6_frag_id,
  2257. { "Identification", "ipv6.fragment.id",
  2258. FT_UINT32, BASE_HEX, NULL, 0x0,
  2259. "Fragment Identification", HFILL }},
  2260. { &hf_ipv6_fragment_overlap,
  2261. { "Fragment overlap", "ipv6.fragment.overlap",
  2262. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2263. "Fragment overlaps with other fragments", HFILL }},
  2264. { &hf_ipv6_fragment_overlap_conflict,
  2265. { "Conflicting data in fragment overlap", "ipv6.fragment.overlap.conflict",
  2266. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2267. "Overlapping fragments contained conflicting data", HFILL }},
  2268. { &hf_ipv6_fragment_multiple_tails,
  2269. { "Multiple tail fragments found", "ipv6.fragment.multipletails",
  2270. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2271. "Several tails were found when defragmenting the packet", HFILL }},
  2272. { &hf_ipv6_fragment_too_long_fragment,
  2273. { "Fragment too long", "ipv6.fragment.toolongfragment",
  2274. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2275. "Fragment contained data past end of packet", HFILL }},
  2276. { &hf_ipv6_fragment_error,
  2277. { "Defragmentation error", "ipv6.fragment.error",
  2278. FT_FRAMENUM, BASE_NONE, NULL, 0x0,
  2279. "Defragmentation error due to illegal fragments", HFILL }},
  2280. { &hf_ipv6_fragment_count,
  2281. { "Fragment count", "ipv6.fragment.count",
  2282. FT_UINT32, BASE_DEC, NULL, 0x0,
  2283. NULL, HFILL }},
  2284. { &hf_ipv6_fragment,
  2285. { "IPv6 Fragment", "ipv6.fragment",
  2286. FT_FRAMENUM, BASE_NONE, NULL, 0x0,
  2287. NULL, HFILL }},
  2288. { &hf_ipv6_fragments,
  2289. { "IPv6 Fragments", "ipv6.fragments",
  2290. FT_NONE, BASE_NONE, NULL, 0x0,
  2291. NULL, HFILL }},
  2292. { &hf_ipv6_reassembled_in,
  2293. { "Reassembled IPv6 in frame", "ipv6.reassembled_in",
  2294. FT_FRAMENUM, BASE_NONE, NULL, 0x0,
  2295. "This IPv6 packet is reassembled in this frame", HFILL }},
  2296. { &hf_ipv6_reassembled_length,
  2297. { "Reassembled IPv6 length", "ipv6.reassembled.length",
  2298. FT_UINT32, BASE_DEC, NULL, 0x0,
  2299. "The total length of the reassembled payload", HFILL }},
  2300. { &hf_ipv6_reassembled_data,
  2301. { "Reassembled IPv6 data", "ipv6.reassembled.data",
  2302. FT_BYTES, BASE_NONE, NULL, 0x0,
  2303. "The reassembled payload", HFILL }},
  2304. /* RPL Routing Header */
  2305. { &hf_ipv6_routing_hdr_rpl_cmprI,
  2306. { "Compressed Internal Octets (CmprI)", "ipv6.routing_hdr.rpl.cmprI",
  2307. FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_CMPRI,
  2308. "Elided octets from all but last segment", HFILL }},
  2309. { &hf_ipv6_routing_hdr_rpl_cmprE,
  2310. { "Compressed Final Octets (CmprE)", "ipv6.routing_hdr.rpl.cmprE",
  2311. FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_CMPRE,
  2312. "Elided octets from last segment address", HFILL }},
  2313. { &hf_ipv6_routing_hdr_rpl_pad,
  2314. { "Padding Bytes", "ipv6.routing_hdr.rpl.pad",
  2315. FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_PAD,
  2316. NULL, HFILL }},
  2317. { &hf_ipv6_routing_hdr_rpl_reserved,
  2318. { "Reserved", "ipv6.routing_hdr.rpl.reserved",
  2319. FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_RESERVED,
  2320. "Must be Zero", HFILL }},
  2321. { &hf_ipv6_routing_hdr_rpl_segments,
  2322. { "Total Segments", "ipv6.routing_hdr.rpl.segments",
  2323. FT_INT32, BASE_DEC, NULL, 0,
  2324. NULL, HFILL }},
  2325. { &hf_ipv6_routing_hdr_rpl_addr,
  2326. { "Address", "ipv6.routing_hdr.rpl.address",
  2327. FT_BYTES, BASE_NONE, NULL, 0,
  2328. NULL, HFILL }},
  2329. { &hf_ipv6_routing_hdr_rpl_fulladdr,
  2330. { "Full Address", "ipv6.routing_hdr.rpl.full_address",
  2331. FT_IPv6, BASE_NONE, NULL, 0,
  2332. "Uncompressed IPv6 Address", HFILL }},
  2333. /* Mobile IPv6 */
  2334. { &hf_ipv6_mipv6_home_address,
  2335. { "Home Address", "ipv6.mipv6_home_address",
  2336. FT_IPv6, BASE_NONE, NULL, 0x0,
  2337. NULL, HFILL }},
  2338. /* SHIM6 */
  2339. { &hf_ipv6_shim6,
  2340. { "SHIM6", "ipv6.shim6",
  2341. FT_NONE, BASE_NONE, NULL, 0x0,
  2342. NULL, HFILL }},
  2343. { &hf_ipv6_shim6_nxt,
  2344. { "Next Header", "ipv6.shim6.nxt",
  2345. FT_UINT8, BASE_DEC, NULL, 0x0,
  2346. NULL, HFILL }},
  2347. { &hf_ipv6_shim6_len,
  2348. { "Header Ext Length", "ipv6.shim6.len",
  2349. FT_UINT8, BASE_DEC, NULL, 0x0,
  2350. NULL, HFILL }},
  2351. { &hf_ipv6_shim6_p,
  2352. { "P Bit", "ipv6.shim6.p",
  2353. FT_BOOLEAN, 8, NULL, SHIM6_BITMASK_P,
  2354. NULL, HFILL }},
  2355. { &hf_ipv6_shim6_ct,
  2356. { "Context Tag", "ipv6.shim6.ct",
  2357. FT_NONE, BASE_NONE, NULL, 0x0,
  2358. NULL, HFILL }},
  2359. { &hf_ipv6_shim6_type,
  2360. { "Message Type", "ipv6.shim6.type",
  2361. FT_UINT8, BASE_DEC,
  2362. VALS(shimctrlvals), SHIM6_BITMASK_TYPE,
  2363. NULL, HFILL }},
  2364. { &hf_ipv6_shim6_proto,
  2365. { "Protocol", "ipv6.shim6.proto",
  2366. FT_UINT8, BASE_DEC,
  2367. VALS(shim6_protocol), SHIM6_BITMASK_PROTOCOL,
  2368. NULL, HFILL }},
  2369. { &hf_ipv6_shim6_checksum,
  2370. { "Checksum", "ipv6.shim6.checksum",
  2371. FT_UINT16, BASE_HEX, NULL, 0x0,
  2372. "Shim6 Checksum", HFILL }},
  2373. { &hf_ipv6_shim6_checksum_bad,
  2374. { "Bad Checksum", "ipv6.shim6.checksum_bad",
  2375. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2376. "Shim6 Bad Checksum", HFILL }},
  2377. { &hf_ipv6_shim6_checksum_good,
  2378. { "Good Checksum", "ipv6.shim6.checksum_good",
  2379. FT_BOOLEAN, BASE_NONE, NULL, 0x0,
  2380. NULL, HFILL }},
  2381. { &hf_ipv6_shim6_inonce,
  2382. { "Initiator Nonce", "ipv6.shim6.inonce",
  2383. FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
  2384. NULL, HFILL }},
  2385. { &hf_ipv6_shim6_rnonce,
  2386. { "Responder Nonce", "ipv6.shim6.rnonce",
  2387. FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
  2388. NULL, HFILL }},
  2389. { &hf_ipv6_shim6_precvd,
  2390. { "Probes Received", "ipv6.shim6.precvd",
  2391. FT_UINT8, BASE_DEC, NULL, 0x0,
  2392. NULL, HFILL }},
  2393. { &hf_ipv6_shim6_psent,
  2394. { "Probes Sent", "ipv6.shim6.psent",
  2395. FT_UINT8, BASE_DEC, NULL, 0x0,
  2396. NULL, HFILL }},
  2397. { &hf_ipv6_shim6_psrc,
  2398. { "Source Address", "ipv6.shim6.psrc",
  2399. FT_IPv6, BASE_NONE, NULL, 0x0,
  2400. "Shim6 Probe Source Address", HFILL }},
  2401. { &hf_ipv6_shim6_pdst,
  2402. { "Destination Address", "ipv6.shim6.pdst",
  2403. FT_IPv6, BASE_NONE, NULL, 0x0,
  2404. "Shim6 Probe Destination Address", HFILL }},
  2405. { &hf_ipv6_shim6_pnonce,
  2406. { "Nonce", "ipv6.shim6.pnonce",
  2407. FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
  2408. "Shim6 Probe Nonce", HFILL }},
  2409. { &hf_ipv6_shim6_pdata,
  2410. { "Data", "ipv6.shim6.pdata",
  2411. FT_UINT32, BASE_HEX, NULL, 0x0,
  2412. "Shim6 Probe Data", HFILL }},
  2413. { &hf_ipv6_shim6_sulid,
  2414. { "Sender ULID", "ipv6.shim6.sulid",
  2415. FT_IPv6, BASE_NONE, NULL, 0x0,
  2416. "Shim6 Sender ULID", HFILL }},
  2417. { &hf_ipv6_shim6_rulid,
  2418. { "Receiver ULID", "ipv6.shim6.rulid",
  2419. FT_IPv6, BASE_NONE, NULL, 0x0,
  2420. "Shim6 Receiver ULID", HFILL }},
  2421. { &hf_ipv6_shim6_reap,
  2422. { "REAP State", "ipv6.shim6.reap",
  2423. FT_UINT8, BASE_DEC, NULL, 0x0,
  2424. NULL, HFILL }},
  2425. { &hf_ipv6_shim6_opt_type,
  2426. { "Option Type", "ipv6.shim6.opt.type",
  2427. FT_UINT16, BASE_DEC,
  2428. VALS(shimoptvals), SHIM6_BITMASK_OPT_TYPE,
  2429. "Shim6 Option Type", HFILL }},
  2430. { &hf_ipv6_shim6_opt_critical,
  2431. { "Option Critical Bit", "ipv6.shim6.opt.critical",
  2432. FT_BOOLEAN, 8,
  2433. TFS(&tfs_yes_no),
  2434. SHIM6_BITMASK_CRITICAL,
  2435. "TRUE : option is critical, FALSE: option is not critical",
  2436. HFILL }},
  2437. { &hf_ipv6_shim6_opt_len,
  2438. { "Content Length", "ipv6.shim6.opt.len",
  2439. FT_UINT16, BASE_DEC, NULL, 0x0,
  2440. "Content Length Option", HFILL }},
  2441. { &hf_ipv6_shim6_opt_total_len,
  2442. { "Total Length", "ipv6.shim6.opt.total_len",
  2443. FT_UINT16, BASE_DEC, NULL, 0x0,
  2444. "Total Option Length", HFILL }},
  2445. { &hf_ipv6_shim6_opt_loc_verif_methods,
  2446. { "Verification Method", "ipv6.shim6.opt.verif_method",
  2447. FT_UINT8, BASE_DEC,
  2448. VALS(shimverifmethods), 0x0,
  2449. "Locator Verification Method", HFILL }},
  2450. { &hf_ipv6_shim6_opt_loclist,
  2451. { "Locator List Generation", "ipv6.shim6.opt.loclist",
  2452. FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
  2453. NULL, HFILL }},
  2454. { &hf_ipv6_shim6_locator,
  2455. { "Locator", "ipv6.shim6.locator",
  2456. FT_IPv6, BASE_NONE, NULL, 0x0,
  2457. "Shim6 Locator", HFILL }},
  2458. { &hf_ipv6_shim6_opt_locnum,
  2459. { "Num Locators", "ipv6.shim6.opt.locnum",
  2460. FT_UINT8, BASE_DEC, NULL, 0x0,
  2461. "Number of Locators in Locator List", HFILL }},
  2462. { &hf_ipv6_shim6_opt_elemlen,
  2463. { "Element Length", "ipv6.shim6.opt.elemlen",
  2464. FT_UINT8, BASE_DEC, NULL, 0x0,
  2465. "Length of Elements in Locator Preferences Option", HFILL }},
  2466. { &hf_ipv6_shim6_loc_flag,
  2467. { "Flags", "ipv6.shim6.loc.flags",
  2468. FT_UINT8, BASE_DEC, NULL, 0x0,
  2469. "Locator Preferences Flags", HFILL }},
  2470. { &hf_ipv6_shim6_loc_prio,
  2471. { "Priority", "ipv6.shim6.loc.prio",
  2472. FT_UINT8, BASE_DEC, NULL, 0x0,
  2473. "Locator Preferences Priority", HFILL }},
  2474. { &hf_ipv6_shim6_loc_weight,
  2475. { "Weight", "ipv6.shim6.loc.weight",
  2476. FT_UINT8, BASE_DEC, NULL, 0x0,
  2477. "Locator Preferences Weight", HFILL }},
  2478. { &hf_ipv6_shim6_opt_fii,
  2479. { "Forked Instance Identifier", "ipv6.shim6.opt.fii",
  2480. FT_UINT32, BASE_DEC_HEX, NULL, 0x0,
  2481. NULL, HFILL }},
  2482. { &hf_ipv6_traffic_class_dscp,
  2483. { "Differentiated Services Field", "ipv6.traffic_class.dscp",
  2484. FT_UINT32, BASE_HEX | BASE_EXT_STRING, &dscp_vals_ext, 0x0FC00000, NULL, HFILL }},
  2485. { &hf_ipv6_traffic_class_ect,
  2486. { "ECN-Capable Transport (ECT)", "ipv6.traffic_class.ect",
  2487. FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0200000, NULL, HFILL }},
  2488. { &hf_ipv6_traffic_class_ce,
  2489. { "ECN-CE", "ipv6.traffic_class.ce",
  2490. FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x0100000, NULL, HFILL }},
  2491. };
  2492. static gint *ett[] = {
  2493. &ett_ipv6,
  2494. &ett_ipv6_opt,
  2495. &ett_ipv6_opt_flag,
  2496. &ett_ipv6_version,
  2497. &ett_ipv6_shim6,
  2498. &ett_ipv6_shim6_option,
  2499. &ett_ipv6_shim6_locators,
  2500. &ett_ipv6_shim6_verif_methods,
  2501. &ett_ipv6_shim6_loc_pref,
  2502. &ett_ipv6_shim6_probes_sent,
  2503. &ett_ipv6_shim6_probes_rcvd,
  2504. &ett_ipv6_shim6_probe_sent,
  2505. &ett_ipv6_shim6_probe_rcvd,
  2506. &ett_ipv6_shim6_cksum,
  2507. &ett_ipv6_fragments,
  2508. &ett_ipv6_fragment,
  2509. &ett_ipv6_traffic_class,
  2510. #ifdef HAVE_GEOIP_V6
  2511. &ett_geoip_info
  2512. #endif /* HAVE_GEOIP_V6 */
  2513. };
  2514. static ei_register_info ei[] = {
  2515. { &ei_ipv6_dst_addr_not_multicast, { "ipv6.dst_addr.not_multicast", PI_PROTOCOL, PI_WARN, "Destination address must not be a multicast address", EXPFILL }},
  2516. { &ei_ipv6_src_route_list_mult_inst_same_addr, { "ipv6.src_route_list.mult_inst_same_addr", PI_PROTOCOL, PI_ERROR, "Multiple instances of the same address must not appear in the source route list", EXPFILL }},
  2517. { &ei_ipv6_src_route_list_src_addr, { "ipv6.src_route_list.src_addr", PI_PROTOCOL, PI_ERROR, "Source address must not appear in the source route list", EXPFILL }},
  2518. { &ei_ipv6_src_route_list_dst_addr, { "ipv6.src_route_list.dst_addr", PI_PROTOCOL, PI_ERROR, "Destination address must not appear in the source route list", EXPFILL }},
  2519. { &ei_ipv6_src_route_list_multicast_addr, { "ipv6.src_route_list.multicast_addr", PI_PROTOCOL, PI_ERROR, "Multicast addresses must not appear in the source route list", EXPFILL }},
  2520. { &ei_ipv6_cmpri_cmpre_pad, { "ipv6.routing_hdr.rpl.cmprI.cmprE.pad", PI_PROTOCOL, PI_WARN, "When cmprI equals 0 and cmprE equals 0, pad MUST equal 0 but instead was X", EXPFILL }},
  2521. { &ei_ipv6_routing_hdr_rpl_reserved, { "ipv6.routing_hdr.rpl.reserved.not0", PI_PROTOCOL, PI_WARN, "Reserved field must equal 0 but instead was X", EXPFILL }},
  2522. { &ei_ipv6_opt_tel_invalid_len, { "ipv6.opt.tel.invalid_len", PI_MALFORMED, PI_ERROR, "Tunnel Encapsulation Limit: Invalid length", EXPFILL }},
  2523. { &ei_ipv6_opt_jumbo_invalid_len, { "ipv6.opt.jumbo.invalid_len", PI_MALFORMED, PI_ERROR, "Jumbo payload: Invalid length", EXPFILL }},
  2524. { &ei_ipv6_opt_rtalert_invalid_len, { "ipv6.opt.router_alert.invalid_len", PI_MALFORMED, PI_ERROR, "Router alert: Invalid Length", EXPFILL }},
  2525. { &ei_ipv6_mipv6_home_address_invalid_len, { "ipv6.mipv6_home_address.invalid_len", PI_MALFORMED, PI_ERROR, "Home Address: Invalid length", EXPFILL }},
  2526. { &ei_ipv6_shim6_opt_elemlen_invalid, { "ipv6.shim6.opt.elemlen.invalid", PI_MALFORMED, PI_ERROR, "Invalid element length", EXPFILL }},
  2527. { &ei_ipv6_shim6_checksum_bad, { "ipv6.shim6.checksum_bad.expert", PI_CHECKSUM, PI_ERROR, "Bad checksum", EXPFILL }},
  2528. { &ei_ipv6_routing_hdr_rpl_segments_ge0, { "ipv6.routing_hdr.rpl.segments.ge0", PI_MALFORMED, PI_ERROR, "Calculated total segments must be greater than or equal to 0, instead was X", EXPFILL }},
  2529. };
  2530. module_t *ipv6_module;
  2531. expert_module_t* expert_ipv6;
  2532. proto_ipv6 = proto_register_protocol("Internet Protocol Version 6", "IPv6", "ipv6");
  2533. proto_register_field_array(proto_ipv6, hf, array_length(hf));
  2534. proto_register_subtree_array(ett, array_length(ett));
  2535. expert_ipv6 = expert_register_protocol(proto_ipv6);
  2536. expert_register_field_array(expert_ipv6, ei, array_length(ei));
  2537. /* Register configuration options */
  2538. ipv6_module = prefs_register_protocol(proto_ipv6, NULL);
  2539. prefs_register_bool_preference(ipv6_module, "defragment",
  2540. "Reassemble fragmented IPv6 datagrams",
  2541. "Whether fragmented IPv6 datagrams should be reassembled",
  2542. &ipv6_reassemble);
  2543. prefs_register_bool_preference(ipv6_module, "summary_in_tree",
  2544. "Show IPv6 summary in protocol tree",
  2545. "Whether the IPv6 summary line should be shown in the protocol tree",
  2546. &ipv6_summary_in_tree);
  2547. #ifdef HAVE_GEOIP_V6
  2548. prefs_register_bool_preference(ipv6_module, "use_geoip" ,
  2549. "Enable GeoIP lookups",
  2550. "Whether to look up IPv6 addresses in each GeoIP database we have loaded",
  2551. &ipv6_use_geoip);
  2552. #endif /* HAVE_GEOIP_V6 */
  2553. /* RPL Strict Header Checking */
  2554. prefs_register_bool_preference(ipv6_module, "perform_strict_rpl_srh_rfc_checking",
  2555. "Perform strict checking for adherence to the RFC for RPL Source Routing Headers (RFC 6554)",
  2556. "Whether to check that all RPL Source Routing Headers adhere to RFC 6554",
  2557. &g_ipv6_rpl_srh_strict_rfc_checking);
  2558. register_dissector("ipv6", dissect_ipv6, proto_ipv6);
  2559. register_init_routine(ipv6_reassemble_init);
  2560. ipv6_tap = register_tap("ipv6");
  2561. }
  2562. void
  2563. proto_reg_handoff_ipv6(void)
  2564. {
  2565. dissector_handle_t ipv6_handle;
  2566. data_handle = find_dissector("data");
  2567. ipv6_handle = find_dissector("ipv6");
  2568. dissector_add_uint("ethertype", ETHERTYPE_IPv6, ipv6_handle);
  2569. dissector_add_uint("ppp.protocol", PPP_IPV6, ipv6_handle);
  2570. dissector_add_uint("ppp.protocol", ETHERTYPE_IPv6, ipv6_handle);
  2571. dissector_add_uint("gre.proto", ETHERTYPE_IPv6, ipv6_handle);
  2572. dissector_add_uint("ip.proto", IP_PROTO_IPV6, ipv6_handle);
  2573. dissector_add_uint("null.type", BSD_AF_INET6_BSD, ipv6_handle);
  2574. dissector_add_uint("null.type", BSD_AF_INET6_FREEBSD, ipv6_handle);
  2575. dissector_add_uint("null.type", BSD_AF_INET6_DARWIN, ipv6_handle);
  2576. dissector_add_uint("chdlctype", ETHERTYPE_IPv6, ipv6_handle);
  2577. dissector_add_uint("fr.ietf", NLPID_IP6, ipv6_handle);
  2578. dissector_add_uint("osinl.excl", NLPID_IP6, ipv6_handle);
  2579. dissector_add_uint("x.25.spi", NLPID_IP6, ipv6_handle);
  2580. dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_IPv6, ipv6_handle);
  2581. ip_dissector_table = find_dissector_table("ip.proto");
  2582. }
  2583. /*
  2584. * Editor modelines
  2585. *
  2586. * Local Variables:
  2587. * c-basic-offset: 2
  2588. * tab-width: 8
  2589. * indent-tabs-mode: nil
  2590. * End:
  2591. *
  2592. * ex: set shiftwidth=2 tabstop=8 expandtab:
  2593. * :indentSize=2:tabSize=8:noTabs=true:
  2594. */