Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 1 | /* packet-vpp.c |
| 2 | * |
| 3 | * Routines for the disassembly of fd.io vpp project |
| 4 | * dispatch captures |
| 5 | * |
| 6 | * Copyright (c) 2018 Cisco and/or its affiliates. |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at: |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | * |
| 19 | * This version is not to be upstreamed as-is, since it hooks up the |
| 20 | * vpp dissector to WTAP_ENCAP_USER13, a test encap type. |
| 21 | */ |
| 22 | |
| 23 | #include "config.h" |
| 24 | |
| 25 | #include <epan/packet.h> |
| 26 | #include <epan/expert.h> |
| 27 | #include <epan/to_str.h> |
| 28 | #include <epan/in_cksum.h> |
| 29 | #include <epan/nlpid.h> |
| 30 | #include <epan/etypes.h> |
| 31 | #include <stdio.h> |
| 32 | #include <wsutil/ws_printf.h> |
| 33 | |
| 34 | void proto_register_vpp(void); |
| 35 | void proto_reg_handoff_vpp(void); |
| 36 | |
| 37 | static int proto_vpp = -1; |
| 38 | static int proto_vpp_opaque = -1; |
| 39 | static int proto_vpp_trace = -1; |
| 40 | static int hf_vpp_nodename = -1; |
| 41 | static int hf_vpp_buffer_index = -1; |
| 42 | |
| 43 | static int hf_vpp_buffer_current_data = -1; |
| 44 | static int hf_vpp_buffer_current_length = -1; |
| 45 | |
| 46 | static int hf_vpp_buffer_flags = -1; |
| 47 | static int hf_vpp_buffer_flag_non_default_freelist = -1; |
| 48 | static int hf_vpp_buffer_flag_traced = -1; |
| 49 | static int hf_vpp_buffer_flag_next_present = -1; |
| 50 | static int hf_vpp_buffer_flag_total_length_valid = -1; |
| 51 | static int hf_vpp_buffer_flag_ext_hdr_valid = -1; |
| 52 | static int hf_vpp_buffer_flag_l4_checksum_computed = -1; |
| 53 | static int hf_vpp_buffer_flag_l4_checksum_correct = -1; |
| 54 | static int hf_vpp_buffer_flag_vlan_2_deep = -1; |
| 55 | static int hf_vpp_buffer_flag_vlan_1_deep = -1; |
| 56 | static int hf_vpp_buffer_flag_span_clone = -1; |
| 57 | static int hf_vpp_buffer_flag_loop_counter_valid = -1; |
| 58 | static int hf_vpp_buffer_flag_locally_originated = -1; |
| 59 | static int hf_vpp_buffer_flag_is_ip4 = -1; |
| 60 | static int hf_vpp_buffer_flag_is_ip6 = -1; |
| 61 | static int hf_vpp_buffer_flag_offload_ip_checksum = -1; |
| 62 | static int hf_vpp_buffer_flag_offload_tcp_checksum = -1; |
| 63 | static int hf_vpp_buffer_flag_offload_udp_checksum = -1; |
| 64 | static int hf_vpp_buffer_flag_is_natted = -1; |
| 65 | static int hf_vpp_buffer_flag_l2_hdr_offset_valid = -1; |
| 66 | static int hf_vpp_buffer_flag_l3_hdr_offset_valid = -1; |
| 67 | static int hf_vpp_buffer_flag_l4_hdr_offset_valid = -1; |
| 68 | static int hf_vpp_buffer_flag_flow_report = -1; |
| 69 | static int hf_vpp_buffer_flag_is_dvr = -1; |
| 70 | static int hf_vpp_buffer_flag_qos_data_valid = -1; |
| 71 | static int hf_vpp_buffer_flow_id = -1; |
| 72 | static int hf_vpp_buffer_next_buffer = -1; |
| 73 | static int hf_vpp_buffer_current_config_index = -1; |
| 74 | static int hf_vpp_buffer_error_index = -1; |
| 75 | static int hf_vpp_buffer_n_add_refs = -1; |
| 76 | static int hf_vpp_buffer_buffer_pool_index = -1; |
| 77 | |
| 78 | static int hf_vpp_buffer_opaque_raw = -1; |
| 79 | static int hf_vpp_buffer_opaque_opaque = -1; |
| 80 | |
| 81 | static int hf_vpp_buffer_trace = -1; |
| 82 | |
| 83 | static gint ett_vpp = -1; |
| 84 | static gint ett_vpp_opaque = -1; |
| 85 | static gint ett_vpp_trace = -1; |
| 86 | |
| 87 | static dissector_handle_t vpp_dissector_handle; |
| 88 | static dissector_handle_t vpp_opaque_dissector_handle; |
| 89 | static dissector_handle_t vpp_trace_dissector_handle; |
| 90 | |
Dave Barach | c2b4dc5 | 2018-11-24 18:29:26 -0500 | [diff] [blame] | 91 | static dissector_table_t vpp_subdissector_table; |
Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 92 | |
Dave Barach | c2b4dc5 | 2018-11-24 18:29:26 -0500 | [diff] [blame] | 93 | /* List of next dissector names that we know about */ |
| 94 | #define foreach_next_dissector \ |
| 95 | _(eth_maybefcs) \ |
| 96 | _(ip) \ |
| 97 | _(ipv6) \ |
| 98 | _(udp) |
| 99 | |
| 100 | #define _(a) static dissector_handle_t a##_dissector_handle; |
| 101 | foreach_next_dissector; |
| 102 | #undef _ |
| 103 | |
| 104 | /* |
| 105 | * node-name, next dissector name pairs |
| 106 | * |
| 107 | * Unfortunately, -Werror=c++-compat causes |
| 108 | * the node names "ipX-not-enabled" to throw a shoe if |
| 109 | * not explicitly quoted. Never mind that the first macro |
| 110 | * arg is [only] used as a string (#xxx). |
| 111 | */ |
| 112 | |
| 113 | #define foreach_node_to_dissector_pair \ |
| 114 | _("ip6-lookup", ipv6) \ |
| 115 | _("ip4-input", ip) \ |
| 116 | _("ip4-not-enabled", ip) \ |
| 117 | _("ip4-input-no-checksum", ip) \ |
| 118 | _("ip4-lookup", ip) \ |
| 119 | _("ip4-local", ip) \ |
| 120 | _("ip4-udp-lookup", udp) \ |
| 121 | _("ip4-icmp-error", ip) \ |
| 122 | _("ip4-glean", ip) \ |
| 123 | _("ethernet-input", eth_maybefcs) |
Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 124 | |
| 125 | static void |
| 126 | add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start, |
| 127 | gint len, int hf) |
| 128 | { |
| 129 | gint next; |
| 130 | int line_len; |
| 131 | int data_len; |
| 132 | |
| 133 | while (len > 0) { |
| 134 | line_len = tvb_find_line_end(tvb, start, len, &next, FALSE); |
| 135 | data_len = next - start; |
| 136 | proto_tree_add_string(tree, hf, tvb, start, data_len, |
| 137 | tvb_format_stringzpad(tvb, start, line_len)); |
| 138 | start += data_len; |
| 139 | len -= data_len; |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | static int |
| 144 | dissect_vpp_trace (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, |
| 145 | void* data _U_) |
| 146 | { |
| 147 | int offset = 0; |
| 148 | proto_item *ti; |
| 149 | proto_tree *trace_tree; |
| 150 | gint trace_string_length; |
| 151 | |
| 152 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "VPP-Trace"); |
| 153 | col_clear(pinfo->cinfo, COL_INFO); |
| 154 | |
| 155 | ti = proto_tree_add_item(tree, proto_vpp_trace, tvb, offset, -1, ENC_NA); |
| 156 | trace_tree = proto_item_add_subtree(ti, ett_vpp_trace); |
| 157 | |
| 158 | /* How long is the trace string? */ |
| 159 | (void ) tvb_get_stringz_enc (wmem_packet_scope(), tvb, 0, |
| 160 | &trace_string_length, ENC_ASCII); |
| 161 | |
| 162 | add_multi_line_string_to_tree (trace_tree, tvb, 0, |
| 163 | trace_string_length, |
| 164 | hf_vpp_buffer_trace); |
| 165 | return tvb_captured_length(tvb); |
| 166 | } |
| 167 | |
| 168 | /* |
| 169 | * BIG FAT WARNING: it's impossible to #include the vpp header files, |
| 170 | * so this is a private copy of .../src/vnet/buffer.h, with |
| 171 | * some vpp typedefs thrown in for good measure. |
| 172 | */ |
| 173 | |
| 174 | typedef unsigned int u32; |
| 175 | typedef unsigned short int u16; |
| 176 | typedef short int i16; |
| 177 | typedef unsigned char u8; |
| 178 | typedef unsigned long long u64; |
| 179 | |
| 180 | typedef struct |
| 181 | { |
| 182 | u32 sw_if_index[2]; |
| 183 | i16 l2_hdr_offset; |
| 184 | i16 l3_hdr_offset; |
| 185 | i16 l4_hdr_offset; |
| 186 | u8 feature_arc_index; |
| 187 | u8 dont_waste_me; |
| 188 | |
| 189 | union |
| 190 | { |
| 191 | /* IP4/6 buffer opaque. */ |
| 192 | struct |
| 193 | { |
| 194 | /* Adjacency from destination IP address lookup [VLIB_TX]. |
| 195 | Adjacency from source IP address lookup [VLIB_RX]. |
| 196 | This gets set to ~0 until source lookup is performed. */ |
| 197 | u32 adj_index[2]; |
| 198 | |
| 199 | union |
| 200 | { |
| 201 | struct |
| 202 | { |
| 203 | /* Flow hash value for this packet computed from IP src/dst address |
| 204 | protocol and ports. */ |
| 205 | u32 flow_hash; |
| 206 | |
| 207 | union |
| 208 | { |
| 209 | /* next protocol */ |
| 210 | u32 save_protocol; |
| 211 | |
| 212 | /* Hint for transport protocols */ |
| 213 | u32 fib_index; |
| 214 | }; |
| 215 | |
| 216 | /* Rewrite length */ |
| 217 | u32 save_rewrite_length; |
| 218 | |
| 219 | /* MFIB RPF ID */ |
| 220 | u32 rpf_id; |
| 221 | }; |
| 222 | |
| 223 | /* ICMP */ |
| 224 | struct |
| 225 | { |
| 226 | u8 type; |
| 227 | u8 code; |
| 228 | u32 data; |
| 229 | } icmp; |
| 230 | |
| 231 | /* reassembly */ |
| 232 | union |
| 233 | { |
| 234 | /* in/out variables */ |
| 235 | struct |
| 236 | { |
| 237 | u32 next_index; /* index of next node - ignored if "feature" node */ |
| 238 | u16 estimated_mtu; /* estimated MTU calculated during reassembly */ |
| 239 | }; |
| 240 | /* internal variables used during reassembly */ |
| 241 | struct |
| 242 | { |
| 243 | u16 fragment_first; |
| 244 | u16 fragment_last; |
| 245 | u16 range_first; |
| 246 | u16 range_last; |
| 247 | u32 next_range_bi; |
| 248 | u16 ip6_frag_hdr_offset; |
| 249 | }; |
| 250 | } reass; |
| 251 | }; |
| 252 | |
| 253 | } ip; |
| 254 | |
| 255 | /* |
| 256 | * MPLS: |
| 257 | * data copied from the MPLS header that was popped from the packet |
| 258 | * during the look-up. |
| 259 | */ |
| 260 | struct |
| 261 | { |
| 262 | /* do not overlay w/ ip.adj_index[0,1] nor flow hash */ |
| 263 | u32 pad[3]; |
| 264 | u8 ttl; |
| 265 | u8 exp; |
| 266 | u8 first; |
| 267 | /* Rewrite length */ |
| 268 | u32 save_rewrite_length; |
| 269 | /* |
| 270 | * BIER - the number of bytes in the header. |
| 271 | * the len field in the header is not authoritative. It's the |
| 272 | * value in the table that counts. |
| 273 | */ |
| 274 | struct |
| 275 | { |
| 276 | u8 n_bytes; |
| 277 | } bier; |
| 278 | } mpls; |
| 279 | |
| 280 | /* l2 bridging path, only valid there */ |
| 281 | struct opaque_l2 |
| 282 | { |
| 283 | u32 feature_bitmap; |
| 284 | u16 bd_index; /* bridge-domain index */ |
| 285 | u8 l2_len; /* ethernet header length */ |
| 286 | u8 shg; /* split-horizon group */ |
| 287 | u16 l2fib_sn; /* l2fib bd/int seq_num */ |
| 288 | u8 bd_age; /* aging enabled */ |
| 289 | } l2; |
| 290 | |
| 291 | /* l2tpv3 softwire encap, only valid there */ |
| 292 | struct |
| 293 | { |
| 294 | u32 pad[4]; /* do not overlay w/ ip.adj_index[0,1] */ |
| 295 | u8 next_index; |
| 296 | u32 session_index; |
| 297 | } l2t; |
| 298 | |
| 299 | /* L2 classify */ |
| 300 | struct |
| 301 | { |
| 302 | struct opaque_l2 pad; |
| 303 | union |
| 304 | { |
| 305 | u32 table_index; |
| 306 | u32 opaque_index; |
| 307 | }; |
| 308 | u64 hash; |
| 309 | } l2_classify; |
| 310 | |
| 311 | /* vnet policer */ |
| 312 | struct |
| 313 | { |
| 314 | u32 pad[8 - 2 - 1]; /* to end of opaque */ |
| 315 | u32 index; |
| 316 | } policer; |
| 317 | |
| 318 | /* interface output features */ |
| 319 | struct |
| 320 | { |
| 321 | u32 flags; |
| 322 | u32 sad_index; |
| 323 | } ipsec; |
| 324 | |
| 325 | /* MAP */ |
| 326 | struct |
| 327 | { |
| 328 | u16 mtu; |
| 329 | } map; |
| 330 | |
| 331 | /* MAP-T */ |
| 332 | struct |
| 333 | { |
| 334 | u32 map_domain_index; |
| 335 | struct |
| 336 | { |
| 337 | u32 saddr, daddr; |
| 338 | u16 frag_offset; //Fragmentation header offset |
| 339 | u16 l4_offset; //L4 header overall offset |
| 340 | u8 l4_protocol; //The final protocol number |
| 341 | } v6; //Used by ip6_map_t only |
| 342 | u16 checksum_offset; //L4 checksum overall offset |
| 343 | u16 mtu; //Exit MTU |
| 344 | } map_t; |
| 345 | |
| 346 | /* IP Fragmentation */ |
| 347 | struct |
| 348 | { |
| 349 | u32 pad[2]; /* do not overlay w/ ip.adj_index[0,1] */ |
| 350 | u16 mtu; |
| 351 | u8 next_index; |
| 352 | u8 flags; //See ip_frag.h |
| 353 | } ip_frag; |
| 354 | |
| 355 | /* COP - configurable junk filter(s) */ |
| 356 | struct |
| 357 | { |
| 358 | /* Current configuration index. */ |
| 359 | u32 current_config_index; |
| 360 | } cop; |
| 361 | |
| 362 | /* LISP */ |
| 363 | struct |
| 364 | { |
| 365 | /* overlay address family */ |
| 366 | u16 overlay_afi; |
| 367 | } lisp; |
| 368 | |
| 369 | /* TCP */ |
| 370 | struct |
| 371 | { |
| 372 | u32 connection_index; |
| 373 | u32 seq_number; |
| 374 | u32 seq_end; |
| 375 | u32 ack_number; |
| 376 | u16 hdr_offset; /**< offset relative to ip hdr */ |
| 377 | u16 data_offset; /**< offset relative to ip hdr */ |
| 378 | u16 data_len; /**< data len */ |
| 379 | u8 flags; |
| 380 | } tcp; |
| 381 | |
| 382 | /* SCTP */ |
| 383 | struct |
| 384 | { |
| 385 | u32 connection_index; |
| 386 | u16 sid; /**< Stream ID */ |
| 387 | u16 ssn; /**< Stream Sequence Number */ |
| 388 | u32 tsn; /**< Transmission Sequence Number */ |
| 389 | u16 hdr_offset; /**< offset relative to ip hdr */ |
| 390 | u16 data_offset; /**< offset relative to ip hdr */ |
| 391 | u16 data_len; /**< data len */ |
| 392 | u8 subconn_idx; /**< index of the sub_connection being used */ |
| 393 | u8 flags; |
| 394 | } sctp; |
| 395 | |
| 396 | /* SNAT */ |
| 397 | struct |
| 398 | { |
| 399 | u32 flags; |
| 400 | } snat; |
| 401 | |
| 402 | u32 unused[6]; |
| 403 | }; |
| 404 | } vnet_buffer_opaque_t; |
| 405 | |
| 406 | |
| 407 | #define PTAS proto_tree_add_string(opaque_tree, \ |
| 408 | hf_vpp_buffer_opaque_opaque, \ |
| 409 | tvb, 0, strlen(tmpbuf), tmpbuf) |
| 410 | |
| 411 | static int |
| 412 | dissect_vpp_opaque (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, |
| 413 | void* data _U_) |
| 414 | { |
| 415 | int offset = 0; |
| 416 | proto_item *ti; |
| 417 | proto_tree *opaque_tree; |
| 418 | char tmpbuf [512]; |
| 419 | int print_offset; |
| 420 | guint32 opaque[10]; |
| 421 | vnet_buffer_opaque_t _o, *o = &_o; |
| 422 | |
| 423 | int i; |
| 424 | |
| 425 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "VPP-Opaque"); |
| 426 | col_clear(pinfo->cinfo, COL_INFO); |
| 427 | |
| 428 | ti = proto_tree_add_item(tree, proto_vpp_opaque, tvb, offset, -1, ENC_NA); |
| 429 | opaque_tree = proto_item_add_subtree(ti, ett_vpp_opaque); |
| 430 | |
| 431 | print_offset = 0; |
| 432 | for (i = 0; i < 10; i++) { |
| 433 | opaque[i] = tvb_get_guint32 (tvb, offset + 4*i, ENC_LITTLE_ENDIAN); |
| 434 | snprintf (tmpbuf + print_offset, sizeof(tmpbuf) - print_offset, |
| 435 | "%08x ", opaque[i]); |
| 436 | print_offset = strlen (tmpbuf); |
| 437 | } |
| 438 | offset += 40; |
| 439 | |
| 440 | proto_tree_add_string (opaque_tree, hf_vpp_buffer_opaque_raw, tvb, 0, |
| 441 | strlen(tmpbuf), tmpbuf); |
| 442 | |
| 443 | memset (o, 0, sizeof (*o)); |
| 444 | memcpy (o, opaque, sizeof (opaque)); |
| 445 | |
| 446 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 447 | "sw_if_index[VLIB_RX]: %d, sw_if_index[VLIB_TX]: %d", |
| 448 | o->sw_if_index[0], o->sw_if_index[1]); |
| 449 | PTAS; |
| 450 | |
| 451 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 452 | "L2 offset %d, L3 offset %d, L4 offset %d, feature arc index %d", |
| 453 | (u32)(o->l2_hdr_offset), |
| 454 | (u32)(o->l3_hdr_offset), |
| 455 | (u32)(o->l4_hdr_offset), |
| 456 | (u32)(o->feature_arc_index)); |
| 457 | PTAS; |
| 458 | |
| 459 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 460 | "ip.adj_index[VLIB_RX]: %d, ip.adj_index[VLIB_TX]: %d", |
| 461 | (u32)(o->ip.adj_index[0]), |
| 462 | (u32)(o->ip.adj_index[1])); |
| 463 | PTAS; |
| 464 | |
| 465 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 466 | "ip.flow_hash: 0x%x, ip.save_protocol: 0x%x, ip.fib_index: %d", |
| 467 | o->ip.flow_hash, o->ip.save_protocol, o->ip.fib_index); |
| 468 | PTAS; |
| 469 | |
| 470 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 471 | "ip.save_rewrite_length: %d, ip.rpf_id: %d", |
| 472 | o->ip.save_rewrite_length, o->ip.rpf_id); |
| 473 | PTAS; |
| 474 | |
| 475 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 476 | "ip.icmp.type: %d ip.icmp.code: %d, ip.icmp.data: 0x%x", |
| 477 | (u32)(o->ip.icmp.type), |
| 478 | (u32)(o->ip.icmp.code), |
| 479 | o->ip.icmp.data); |
| 480 | PTAS; |
| 481 | |
| 482 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 483 | "ip.reass.next_index: %d, ip.reass.estimated_mtu: %d", |
| 484 | o->ip.reass.next_index, (u32)(o->ip.reass.estimated_mtu)); |
| 485 | PTAS; |
| 486 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 487 | "ip.reass.fragment_first: %d ip.reass.fragment_last: %d", |
| 488 | (u32)(o->ip.reass.fragment_first), |
| 489 | (u32)(o->ip.reass.fragment_last)); |
| 490 | PTAS; |
| 491 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 492 | "ip.reass.range_first: %d ip.reass.range_last: %d", |
| 493 | (u32)(o->ip.reass.range_first), |
| 494 | (u32)(o->ip.reass.range_last)); |
| 495 | PTAS; |
| 496 | |
| 497 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 498 | "ip.reass.next_range_bi: 0x%x, ip.reass.ip6_frag_hdr_offset: %d", |
| 499 | o->ip.reass.next_range_bi, |
| 500 | (u32)(o->ip.reass.ip6_frag_hdr_offset)); |
| 501 | PTAS; |
| 502 | |
| 503 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 504 | "mpls.ttl: %d, mpls.exp: %d, mpls.first: %d, " |
| 505 | "mpls.save_rewrite_length: %d, mpls.bier.n_bytes: %d", |
| 506 | (u32)(o->mpls.ttl), (u32)(o->mpls.exp), (u32)(o->mpls.first), |
| 507 | o->mpls.save_rewrite_length, (u32)(o->mpls.bier.n_bytes)); |
| 508 | PTAS; |
| 509 | |
| 510 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 511 | "l2.feature_bitmap: %08x, l2.bd_index: %d, l2.l2_len: %d, " |
| 512 | "l2.shg: %d, l2.l2fib_sn: %d, l2.bd_age: %d", |
| 513 | o->l2.feature_bitmap, (u32)(o->l2.bd_index), |
| 514 | (u32)(o->l2.l2_len), (u32)(o->l2.shg), (u32)(o->l2.l2fib_sn), |
| 515 | (u32)(o->l2.bd_age)); |
| 516 | PTAS; |
| 517 | |
| 518 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 519 | "l2t.next_index: %d, l2t.session_index: %d", |
| 520 | (u32)(o->l2t.next_index), o->l2t.session_index); |
| 521 | PTAS; |
| 522 | |
| 523 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 524 | "l2_classify.table_index: %d, l2_classify.opaque_index: %d, " |
| 525 | "l2_classify.hash: 0x%llx", |
| 526 | o->l2_classify.table_index, |
| 527 | o->l2_classify.opaque_index, |
| 528 | o->l2_classify.hash); |
| 529 | PTAS; |
| 530 | |
| 531 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 532 | "policer.index: %d", o->policer.index); |
| 533 | PTAS; |
| 534 | |
| 535 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 536 | "ipsec.flags: 0x%x, ipsec.sad_index: %d", |
| 537 | o->ipsec.flags, o->ipsec.sad_index); |
| 538 | PTAS; |
| 539 | |
| 540 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 541 | "map.mtu: %d", (u32)(o->map.mtu)); |
| 542 | PTAS; |
| 543 | |
| 544 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 545 | "map_t.v6.saddr: 0x%x, map_t.v6.daddr: 0x%x, " |
| 546 | "map_t.v6.frag_offset: %d, map_t.v6.l4_offset: %d", |
| 547 | o->map_t.v6.saddr, |
| 548 | o->map_t.v6.daddr, |
| 549 | (u32)(o->map_t.v6.frag_offset), |
| 550 | (u32)(o->map_t.v6.l4_offset)); |
| 551 | PTAS; |
| 552 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 553 | "map_t.v6.l4_protocol: %d, map_t.checksum_offset: %d, " |
| 554 | "map_t.mtu: %d", |
| 555 | (u32)(o->map_t.v6.l4_protocol), |
| 556 | (u32)(o->map_t.checksum_offset), |
| 557 | (u32)(o->map_t.mtu)); |
| 558 | PTAS; |
| 559 | |
| 560 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 561 | "ip_frag.mtu: %d, ip_frag.next_index: %d, ip_frag.flags: 0x%x", |
| 562 | (u32)(o->ip_frag.mtu), |
| 563 | (u32)(o->ip_frag.next_index), |
| 564 | (u32)(o->ip_frag.flags)); |
| 565 | PTAS; |
| 566 | |
| 567 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 568 | "cop.current_config_index: %d", |
| 569 | o->cop.current_config_index); |
| 570 | PTAS; |
| 571 | |
| 572 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 573 | "lisp.overlay_afi: %d", |
| 574 | (u32)(o->lisp.overlay_afi)); |
| 575 | PTAS; |
| 576 | |
| 577 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 578 | "tcp.connection_index: %d, tcp.seq_number: %d, tcp.seq_end: %d, " |
| 579 | "tcp.ack_number: %d, tcp.hdr_offset: %d, tcp.data_offset: %d", |
| 580 | o->tcp.connection_index, |
| 581 | o->tcp.seq_number, |
| 582 | o->tcp.seq_end, |
| 583 | o->tcp.ack_number, |
| 584 | (u32)(o->tcp.hdr_offset), |
| 585 | (u32)(o->tcp.data_offset)); |
| 586 | PTAS; |
| 587 | |
| 588 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 589 | "tcp.data_len: %d, tcp.flags: 0x%x", |
| 590 | (u32)(o->tcp.data_len), |
| 591 | (u32)(o->tcp.flags)); |
| 592 | PTAS; |
| 593 | |
| 594 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 595 | "sctp.connection_index: %d, sctp.sid: %d, sctp.ssn: %d, " |
| 596 | "sctp.tsn: %d, sctp.hdr_offset: %d", |
| 597 | o->sctp.connection_index, |
| 598 | (u32)(o->sctp.sid), |
| 599 | (u32)(o->sctp.ssn), |
| 600 | (u32)(o->sctp.tsn), |
| 601 | (u32)(o->sctp.hdr_offset)); |
| 602 | PTAS; |
| 603 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 604 | "sctp.data_offset: %d, sctp.data_len: %d, sctp.subconn_idx: %d, " |
| 605 | "sctp.flags: 0x%x", |
| 606 | (u32)(o->sctp.data_offset), |
| 607 | (u32)(o->sctp.data_len), |
| 608 | (u32)(o->sctp.subconn_idx), |
| 609 | (u32)(o->sctp.flags)); |
| 610 | PTAS; |
| 611 | |
| 612 | snprintf (tmpbuf, sizeof(tmpbuf), |
| 613 | "snat.flags: 0x%x", |
| 614 | o->snat.flags); |
| 615 | PTAS; |
| 616 | |
| 617 | return tvb_captured_length(tvb); |
| 618 | } |
| 619 | |
| 620 | |
| 621 | static int |
| 622 | dissect_vpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
| 623 | { |
| 624 | proto_item *ti; |
| 625 | proto_tree *vpp_tree; |
| 626 | tvbuff_t *opaque_tvb, *eth_tvb, *trace_tvb; |
| 627 | int offset = 0; |
| 628 | guint8 major_version, minor_version; |
| 629 | guint8 name_length; |
| 630 | guint8 *name; |
| 631 | guint16 trace_length; |
Dave Barach | c2b4dc5 | 2018-11-24 18:29:26 -0500 | [diff] [blame] | 632 | int i; |
Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 633 | static const int *buffer_flags[] = { |
| 634 | &hf_vpp_buffer_flag_non_default_freelist, |
| 635 | &hf_vpp_buffer_flag_traced, |
| 636 | &hf_vpp_buffer_flag_next_present, |
| 637 | &hf_vpp_buffer_flag_total_length_valid, |
| 638 | &hf_vpp_buffer_flag_ext_hdr_valid, |
| 639 | &hf_vpp_buffer_flag_l4_checksum_computed, |
| 640 | &hf_vpp_buffer_flag_l4_checksum_correct, |
| 641 | &hf_vpp_buffer_flag_vlan_2_deep, |
| 642 | &hf_vpp_buffer_flag_vlan_1_deep, |
| 643 | &hf_vpp_buffer_flag_span_clone, |
| 644 | &hf_vpp_buffer_flag_loop_counter_valid, |
| 645 | &hf_vpp_buffer_flag_locally_originated, |
| 646 | &hf_vpp_buffer_flag_is_ip4, |
| 647 | &hf_vpp_buffer_flag_is_ip6, |
| 648 | &hf_vpp_buffer_flag_offload_ip_checksum, |
| 649 | &hf_vpp_buffer_flag_offload_tcp_checksum, |
| 650 | &hf_vpp_buffer_flag_offload_udp_checksum, |
| 651 | &hf_vpp_buffer_flag_is_natted, |
| 652 | &hf_vpp_buffer_flag_l2_hdr_offset_valid, |
| 653 | &hf_vpp_buffer_flag_l3_hdr_offset_valid, |
| 654 | &hf_vpp_buffer_flag_l4_hdr_offset_valid, |
| 655 | &hf_vpp_buffer_flag_flow_report, |
| 656 | &hf_vpp_buffer_flag_is_dvr, |
| 657 | &hf_vpp_buffer_flag_qos_data_valid, |
| 658 | NULL |
| 659 | }; |
| 660 | |
| 661 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "VPP"); |
| 662 | col_clear(pinfo->cinfo, COL_INFO); |
| 663 | |
| 664 | ti = proto_tree_add_item(tree, proto_vpp, tvb, offset, -1, ENC_NA); |
| 665 | vpp_tree = proto_item_add_subtree(ti, ett_vpp); |
| 666 | |
| 667 | major_version = tvb_get_guint8 (tvb, offset); |
| 668 | offset++; |
| 669 | |
| 670 | minor_version = tvb_get_guint8 (tvb, offset); |
| 671 | offset++; |
| 672 | |
| 673 | if (major_version != 1 || minor_version != 0) |
| 674 | ws_debug_printf ("WARNING: version mismatch (%d, %d)", |
| 675 | major_version, minor_version); |
| 676 | |
| 677 | /* Skip the buffer index */ |
| 678 | offset += 4; |
| 679 | |
| 680 | /* Recover the node name */ |
| 681 | name_length = tvb_get_guint8 (tvb, offset); |
| 682 | offset++; |
| 683 | |
| 684 | name = (guint8 *) g_malloc (name_length + 1); |
| 685 | for (i = 0; i < name_length; i++, offset++) { |
| 686 | name[i] = tvb_get_guint8 (tvb, offset); |
| 687 | } |
| 688 | name[i] = 0; |
| 689 | offset++; |
| 690 | |
| 691 | proto_tree_add_string(vpp_tree, hf_vpp_nodename, tvb, 5, name_length, |
| 692 | name); |
| 693 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_index, tvb, |
| 694 | 0 /* bi at offset 0 */, 4, ENC_LITTLE_ENDIAN); |
| 695 | |
| 696 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_current_data, tvb, |
| 697 | offset, 2, ENC_LITTLE_ENDIAN); |
| 698 | offset += 2; |
| 699 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_current_length, tvb, |
| 700 | offset, 2, ENC_LITTLE_ENDIAN); |
| 701 | offset += 2; |
| 702 | |
| 703 | proto_tree_add_bitmask(vpp_tree, tvb, offset, |
| 704 | hf_vpp_buffer_flags, ett_vpp, |
| 705 | buffer_flags, ENC_LITTLE_ENDIAN); |
| 706 | offset += 4; |
| 707 | |
| 708 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_flow_id, tvb, |
| 709 | offset, 4, ENC_LITTLE_ENDIAN); |
| 710 | offset += 4; |
| 711 | |
| 712 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_next_buffer, tvb, |
| 713 | offset, 4, ENC_LITTLE_ENDIAN); |
| 714 | offset += 4; |
| 715 | |
| 716 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_current_config_index, tvb, |
| 717 | offset, 4, ENC_LITTLE_ENDIAN); |
| 718 | offset += 4; |
| 719 | |
| 720 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_error_index, tvb, |
| 721 | offset, 2, ENC_LITTLE_ENDIAN); |
| 722 | offset += 2; |
| 723 | |
| 724 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_n_add_refs, tvb, |
| 725 | offset, 1, ENC_LITTLE_ENDIAN); |
| 726 | offset += 1; |
| 727 | |
| 728 | proto_tree_add_item(vpp_tree, hf_vpp_buffer_buffer_pool_index, tvb, |
| 729 | offset, 1, ENC_LITTLE_ENDIAN); |
| 730 | offset += 1; |
| 731 | |
| 732 | opaque_tvb = tvb_new_subset_remaining (tvb, offset); |
| 733 | call_dissector (vpp_opaque_dissector_handle, opaque_tvb, pinfo, tree); |
| 734 | |
| 735 | /* Skip opaque */ |
| 736 | offset += 40; |
| 737 | /* skip second opaque line */ |
| 738 | offset += 64; |
| 739 | |
| 740 | trace_length = tvb_get_guint16 (tvb, offset, ENC_LITTLE_ENDIAN); |
| 741 | offset += 2; |
| 742 | |
| 743 | if (trace_length > 0) { |
| 744 | trace_tvb = tvb_new_subset_remaining (tvb, offset); |
| 745 | offset += trace_length; |
| 746 | |
| 747 | call_dissector (vpp_trace_dissector_handle, trace_tvb, pinfo, tree); |
| 748 | } |
| 749 | |
| 750 | eth_tvb = tvb_new_subset_remaining (tvb, offset); |
| 751 | |
Dave Barach | c2b4dc5 | 2018-11-24 18:29:26 -0500 | [diff] [blame] | 752 | /* |
| 753 | * Delegate the rest of the packet dissection to the per-node |
| 754 | * next dissector in the foreach_node_to_dissector_pair list |
| 755 | * |
| 756 | * Failing that, pretend its an ethernet packet |
| 757 | */ |
| 758 | if (!dissector_try_string (vpp_subdissector_table, name, eth_tvb, |
| 759 | pinfo, tree, NULL)) |
| 760 | call_dissector (eth_maybefcs_dissector_handle, eth_tvb, pinfo, tree); |
Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 761 | |
| 762 | g_free (name); |
| 763 | return tvb_captured_length(tvb); |
| 764 | } |
| 765 | |
| 766 | void |
| 767 | proto_register_vpp(void) |
| 768 | { |
| 769 | static hf_register_info hf[] = { |
| 770 | { &hf_vpp_buffer_index, |
| 771 | { "BufferIndex", "vpp.bufferindex", FT_UINT32, BASE_HEX, NULL, 0x0, |
| 772 | NULL, HFILL }, |
| 773 | }, |
| 774 | { &hf_vpp_nodename, |
| 775 | { "NodeName", "vpp.nodename", FT_STRINGZ, BASE_NONE, NULL, 0x0, |
| 776 | NULL, HFILL }, |
| 777 | }, |
| 778 | { &hf_vpp_buffer_current_data, |
| 779 | { "CurrentData", "vpp.current_data", FT_INT16, BASE_DEC, NULL, 0x0, |
| 780 | NULL, HFILL }, |
| 781 | }, |
| 782 | { &hf_vpp_buffer_current_length, |
| 783 | { "CurrentLength", "vpp.current_length", FT_UINT16, BASE_DEC, NULL, 0x0, |
| 784 | NULL, HFILL }, |
| 785 | }, |
| 786 | |
| 787 | /* |
| 788 | * Warning: buffer flag bits are not cast in concrete, and it's |
| 789 | * impossible to imagine trying to compile WS with even a subset |
| 790 | * of the actual header files. |
| 791 | * |
| 792 | * See .../src/vlib/buffer.h, .../src/vnet/buffer.h in |
| 793 | * the fd.io vpp source tree. |
| 794 | */ |
| 795 | |
| 796 | { &hf_vpp_buffer_flags, |
| 797 | { "BufferFlags", "vpp.flags", FT_UINT32, BASE_HEX, NULL, 0x0, |
| 798 | NULL, HFILL }, |
| 799 | }, |
| 800 | |
| 801 | { &hf_vpp_buffer_flag_non_default_freelist, |
| 802 | { "NonDefaultFreelist", "vpp.flags.non_default_freelist", |
| 803 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x1, NULL, HFILL }, |
| 804 | }, |
| 805 | { &hf_vpp_buffer_flag_traced, |
| 806 | { "Traced", "vpp.flags.traced", |
| 807 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x2, NULL, HFILL }, |
| 808 | }, |
| 809 | { &hf_vpp_buffer_flag_next_present, |
| 810 | { "NextPresent", "vpp.flags.next_present", |
| 811 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x4, NULL, HFILL }, |
| 812 | }, |
| 813 | { &hf_vpp_buffer_flag_total_length_valid, |
| 814 | { "TotalLengthValid", "vpp.flags.total_length_valid", |
| 815 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x8, NULL, HFILL }, |
| 816 | }, |
| 817 | { &hf_vpp_buffer_flag_ext_hdr_valid, |
| 818 | { "ExtHeaderValid", "vpp.flags.ext_hdr_valid", |
| 819 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x10, NULL, HFILL }, |
| 820 | }, |
| 821 | |
| 822 | { &hf_vpp_buffer_flag_l4_checksum_computed, |
| 823 | { "L4ChecksumComputed", "vpp.flags.l4_checksum_computed", |
| 824 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x80000000, NULL, HFILL }, |
| 825 | }, |
| 826 | { &hf_vpp_buffer_flag_l4_checksum_correct, |
| 827 | { "L4ChecksumCorrect", "vpp.flags.l4_checksum_correct", |
| 828 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x40000000, NULL, HFILL }, |
| 829 | }, |
| 830 | { &hf_vpp_buffer_flag_vlan_2_deep, |
| 831 | { "Vlan2Deep", "vpp.flags.vlan_2_deep", |
| 832 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x20000000, NULL, HFILL }, |
| 833 | }, |
| 834 | { &hf_vpp_buffer_flag_vlan_1_deep, |
| 835 | { "Vlan1Deep", "vpp.flags.vlan_1_deep", |
| 836 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x10000000, NULL, HFILL }, |
| 837 | }, |
| 838 | { &hf_vpp_buffer_flag_span_clone, |
| 839 | { "SpanClone", "vpp.flags.span_clone", |
| 840 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x08000000, NULL, HFILL }, |
| 841 | }, |
| 842 | { &hf_vpp_buffer_flag_loop_counter_valid, |
| 843 | { "LoopCounterValid", "vpp.flags.loop_counter_valid", |
| 844 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x04000000, NULL, HFILL }, |
| 845 | }, |
| 846 | { &hf_vpp_buffer_flag_locally_originated, |
| 847 | { "LocallyOriginated", "vpp.flags.locally_originated", |
| 848 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x02000000, NULL, HFILL }, |
| 849 | }, |
| 850 | { &hf_vpp_buffer_flag_is_ip4, |
| 851 | { "IsIP4", "vpp.flags.is_ip4", |
| 852 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x01000000, NULL, HFILL }, |
| 853 | }, |
| 854 | { &hf_vpp_buffer_flag_is_ip6, |
| 855 | { "IsIP4", "vpp.flags.is_ip6", |
| 856 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00800000, NULL, HFILL }, |
| 857 | }, |
| 858 | { &hf_vpp_buffer_flag_offload_ip_checksum, |
| 859 | { "OffloadIPChecksum", "vpp.flags.offload_ip_checksum", |
| 860 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00400000, NULL, HFILL }, |
| 861 | }, |
| 862 | { &hf_vpp_buffer_flag_offload_tcp_checksum, |
| 863 | { "OffloadTCPChecksum", "vpp.flags.offload_tcp_checksum", |
| 864 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00200000, NULL, HFILL }, |
| 865 | }, |
| 866 | { &hf_vpp_buffer_flag_offload_udp_checksum, |
| 867 | { "OffloadUDPChecksum", "vpp.flags.offload_udp_checksum", |
| 868 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00100000, NULL, HFILL }, |
| 869 | }, |
| 870 | { &hf_vpp_buffer_flag_is_natted, |
| 871 | { "IsNATted", "vpp.flags.is_natted", |
| 872 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00080000, NULL, HFILL }, |
| 873 | }, |
| 874 | { &hf_vpp_buffer_flag_l2_hdr_offset_valid, |
| 875 | { "L2HdrOffsetValid", "vpp.flags.l2_hdr_offset_valid", |
| 876 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00040000, NULL, HFILL }, |
| 877 | }, |
| 878 | { &hf_vpp_buffer_flag_l3_hdr_offset_valid, |
| 879 | { "L3HdrOffsetValid", "vpp.flags.l3_hdr_offset_valid", |
| 880 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00020000, NULL, HFILL }, |
| 881 | }, |
| 882 | { &hf_vpp_buffer_flag_l4_hdr_offset_valid, |
| 883 | { "L4HdrOffsetValid", "vpp.flags.l4_hdr_offset_valid", |
| 884 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00010000, NULL, HFILL }, |
| 885 | }, |
| 886 | { &hf_vpp_buffer_flag_flow_report, |
| 887 | { "FlowReport", "vpp.flags.flow_report", |
| 888 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00008000, NULL, HFILL }, |
| 889 | }, |
| 890 | { &hf_vpp_buffer_flag_is_dvr, |
| 891 | { "IsDVR", "vpp.flags.is_dvr", |
| 892 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00004000, NULL, HFILL }, |
| 893 | }, |
| 894 | { &hf_vpp_buffer_flag_qos_data_valid, |
| 895 | { "QOSDataValid", "vpp.flags.qos_data_valid", |
| 896 | FT_BOOLEAN, 32, TFS(&tfs_true_false), 0x00002000, NULL, HFILL }, |
| 897 | }, |
| 898 | |
| 899 | { &hf_vpp_buffer_flow_id, |
| 900 | { "FlowID", "vpp.flow_id", FT_UINT32, BASE_DEC, NULL, 0x0, |
| 901 | NULL, HFILL }, |
| 902 | }, |
| 903 | { &hf_vpp_buffer_next_buffer, |
| 904 | { "NextBuffer", "vpp.next_buffer", FT_UINT32, BASE_DEC, NULL, 0x0, |
| 905 | NULL, HFILL }, |
| 906 | }, |
| 907 | { &hf_vpp_buffer_current_config_index, |
| 908 | { "CurrentConfigIndex", "vpp.current_config_index", |
| 909 | FT_UINT32, BASE_DEC, NULL, 0x0, |
| 910 | NULL, HFILL }, |
| 911 | }, |
| 912 | { &hf_vpp_buffer_error_index, |
| 913 | { "ErrorIndex", "vpp.error_index", |
| 914 | FT_UINT16, BASE_DEC, NULL, 0x0, |
| 915 | NULL, HFILL }, |
| 916 | }, |
| 917 | { &hf_vpp_buffer_n_add_refs, |
| 918 | { "AddRefs", "vpp.n_add_refs_index", |
| 919 | FT_UINT8, BASE_DEC, NULL, 0x0, |
| 920 | NULL, HFILL }, |
| 921 | }, |
| 922 | { &hf_vpp_buffer_buffer_pool_index, |
| 923 | { "BufferPoolIndex", "vpp.buffer_pool_index", |
| 924 | FT_UINT8, BASE_DEC, NULL, 0x0, |
| 925 | NULL, HFILL }, |
| 926 | }, |
| 927 | }; |
| 928 | |
| 929 | static hf_register_info opaque_hf[] = { |
| 930 | { &hf_vpp_buffer_opaque_raw, |
| 931 | { "Raw ", "vppMetadata.opaque_raw", FT_STRINGZ, BASE_NONE, NULL, 0x0, |
| 932 | NULL, HFILL }, |
| 933 | }, |
| 934 | { &hf_vpp_buffer_opaque_opaque, |
| 935 | { "Opaque", "vppMetadata.opaque", |
| 936 | FT_STRINGZ, BASE_NONE, NULL, 0x0, NULL, HFILL }, |
| 937 | }, |
| 938 | }; |
| 939 | |
| 940 | static hf_register_info trace_hf[] = { |
| 941 | { &hf_vpp_buffer_trace, |
| 942 | { "Trace", "vppTrace.trace", FT_STRINGZ, BASE_NONE, NULL, 0x0, |
| 943 | NULL, HFILL }, |
| 944 | }, |
| 945 | }; |
| 946 | |
| 947 | static gint *ett[] = { |
| 948 | &ett_vpp, |
| 949 | }; |
| 950 | static gint *ett_opaque[] = { |
| 951 | &ett_vpp_opaque, |
| 952 | }; |
| 953 | static gint *ett_trace[] = { |
| 954 | &ett_vpp_trace, |
| 955 | }; |
| 956 | |
| 957 | proto_vpp = proto_register_protocol("VPP Buffer Metadata", "VPP", "vpp"); |
| 958 | proto_register_field_array(proto_vpp, hf, array_length(hf)); |
| 959 | proto_register_subtree_array (ett, array_length(ett)); |
| 960 | register_dissector("vpp", dissect_vpp, proto_vpp); |
| 961 | |
| 962 | proto_vpp_opaque = proto_register_protocol("VPP Buffer Opaque", "VPP-Opaque", |
| 963 | "vpp-opaque"); |
| 964 | proto_register_field_array(proto_vpp_opaque, opaque_hf, |
| 965 | array_length(opaque_hf)); |
| 966 | proto_register_subtree_array (ett_opaque, array_length(ett_opaque)); |
| 967 | register_dissector("vppOpaque", dissect_vpp_opaque, proto_vpp_opaque); |
| 968 | |
| 969 | proto_vpp_trace = proto_register_protocol("VPP Buffer Trace", "VPP-Trace", |
| 970 | "vpp-trace"); |
| 971 | proto_register_field_array(proto_vpp_trace, trace_hf, |
| 972 | array_length(trace_hf)); |
| 973 | proto_register_subtree_array (ett_trace, array_length(ett_trace)); |
| 974 | register_dissector("vppTrace", dissect_vpp_trace, proto_vpp_trace); |
| 975 | |
Dave Barach | c2b4dc5 | 2018-11-24 18:29:26 -0500 | [diff] [blame] | 976 | vpp_subdissector_table = register_dissector_table |
| 977 | ("vpp", "VPP per-node next dissector table", proto_vpp, |
| 978 | FT_STRING, BASE_NONE); |
| 979 | |
| 980 | #define _(n,d) \ |
| 981 | d##_dissector_handle = find_dissector(#d); \ |
| 982 | dissector_add_string ("vpp", n, d##_dissector_handle); |
| 983 | foreach_node_to_dissector_pair; |
Dave Barach | 1dda386 | 2018-11-20 20:15:37 -0500 | [diff] [blame] | 984 | #undef _ |
| 985 | } |
| 986 | |
| 987 | void |
| 988 | proto_reg_handoff_vpp(void) |
| 989 | { |
| 990 | vpp_dissector_handle = find_dissector("vpp"); |
| 991 | vpp_opaque_dissector_handle = find_dissector("vppOpaque"); |
| 992 | vpp_trace_dissector_handle = find_dissector("vppTrace"); |
| 993 | dissector_add_uint("wtap_encap", WTAP_ENCAP_USER13, vpp_dissector_handle); |
| 994 | } |
| 995 | |
| 996 | /* |
| 997 | * Editor modelines - http://www.wireshark.org/tools/modelines.html |
| 998 | * |
| 999 | * Local variables: |
| 1000 | * c-basic-offset: 4 |
| 1001 | * tab-width: 8 |
| 1002 | * indent-tabs-mode: nil |
| 1003 | * End: |
| 1004 | * |
| 1005 | * vi: set shiftwidth=4 tabstop=8 expandtab: |
| 1006 | * :indentSize=4:tabSize=8:noTabs=true: |
| 1007 | */ |