2 * Routines for Spirent AX/4000 Test Block dissection
3 * Copyright 2004, SEKINE Hideki <sekineh@gf7.so-net.ne.jp>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include <epan/ipproto.h>
17 void proto_register_ax4000(void);
18 void proto_reg_handoff_ax4000(void);
20 static dissector_handle_t ax4000_handle
;
22 /* Initialize the protocol and registered fields */
23 static int proto_ax4000
;
24 static int hf_ax4000_port
;
25 static int hf_ax4000_chassis
;
26 static int hf_ax4000_fill
;
27 static int hf_ax4000_index
;
28 static int hf_ax4000_timestamp
;
29 static int hf_ax4000_seq
;
30 static int hf_ax4000_crc
;
32 /* Initialize the subtree pointers */
33 static int ett_ax4000
;
35 /* Code to actually dissect the packets */
37 dissect_ax4000(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
40 proto_tree
*ax4000_tree
;
42 uint32_t ax_port
, ax_chassis
, ax_index
, ax_seq
, ax_timestamp
;
44 /* Make entries in Protocol column and Info column on summary display */
45 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "AX4000");
46 col_clear(pinfo
->cinfo
, COL_INFO
);
48 /* create display subtree for the protocol */
49 ti
= proto_tree_add_item(tree
, proto_ax4000
, tvb
, 0, -1, ENC_NA
);
51 ax4000_tree
= proto_item_add_subtree(ti
, ett_ax4000
);
53 proto_tree_add_item_ret_uint(ax4000_tree
, hf_ax4000_port
, tvb
, 0, 1, ENC_LITTLE_ENDIAN
, &ax_port
);
54 proto_tree_add_item_ret_uint(ax4000_tree
, hf_ax4000_chassis
, tvb
, 1, 1, ENC_LITTLE_ENDIAN
, &ax_chassis
);
55 proto_tree_add_item(ax4000_tree
, hf_ax4000_fill
, tvb
, 2, 1, ENC_BIG_ENDIAN
);
56 proto_tree_add_item_ret_uint(ax4000_tree
, hf_ax4000_index
, tvb
, 2, 2, ENC_BIG_ENDIAN
, &ax_index
);
57 proto_tree_add_item_ret_uint(ax4000_tree
, hf_ax4000_timestamp
, tvb
, 6, 4, ENC_LITTLE_ENDIAN
, &ax_timestamp
);
58 proto_tree_add_item_ret_uint(ax4000_tree
, hf_ax4000_seq
, tvb
, 10, 4, ENC_LITTLE_ENDIAN
, &ax_seq
);
59 proto_tree_add_item(ax4000_tree
, hf_ax4000_crc
, tvb
, 14, 2, ENC_LITTLE_ENDIAN
);
61 col_append_fstr(pinfo
->cinfo
, COL_INFO
,
62 "Chss:%u Prt:%u Idx:%u Seq:0x%08x TS:%.6f[msec]",
63 ax_chassis
, ax_port
, ax_index
, ax_seq
, ax_timestamp
*1e-5);
65 return tvb_captured_length(tvb
);
68 /* Register the protocol with Wireshark */
70 /* this format is require because a script is used to build the C function
71 that calls all the protocol registration.
75 proto_register_ax4000(void)
77 static hf_register_info hf
[] = {
79 { "Port Number", "ax4000.port",
80 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
84 { "Chassis Number", "ax4000.chassis",
85 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
89 { "Fill Type", "ax4000.fill",
90 FT_UINT8
, BASE_DEC
, NULL
, 0xc0,
94 { "Index", "ax4000.index",
95 FT_UINT16
, BASE_DEC
, NULL
, 0x0FFF,
98 { &hf_ax4000_timestamp
,
99 { "Timestamp", "ax4000.timestamp",
100 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
104 { "Sequence Number", "ax4000.seq",
105 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
109 { "CRC (unchecked)", "ax4000.crc",
110 FT_UINT16
, BASE_HEX
, NULL
, 0x0,
115 /* Setup protocol subtree array */
116 static int *ett
[] = {
120 /* Register the protocol name and description */
121 proto_ax4000
= proto_register_protocol("AX/4000 Test Block",
124 /* Required function calls to register the header fields and subtrees used */
125 proto_register_field_array(proto_ax4000
, hf
, array_length(hf
));
126 proto_register_subtree_array(ett
, array_length(ett
));
128 ax4000_handle
= register_dissector("ax4000", dissect_ax4000
, proto_ax4000
);
131 #define AX4000_TCP_PORT 3357 /* assigned by IANA */
132 #define AX4000_UDP_PORT 3357 /* assigned by IANA */
135 proto_reg_handoff_ax4000(void)
137 dissector_add_uint("ip.proto", IP_PROTO_AX4000
, ax4000_handle
);
138 dissector_add_uint_with_preference("tcp.port", AX4000_TCP_PORT
, ax4000_handle
);
139 dissector_add_uint_with_preference("udp.port", AX4000_UDP_PORT
, ax4000_handle
);
143 * Editor modelines - https://www.wireshark.org/tools/modelines.html
148 * indent-tabs-mode: t
151 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
152 * :indentSize=8:tabSize=8:noTabs=false: