Coverage Report

Created: 2026-05-14 06:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ax4000.c
Line
Count
Source
1
/* packet-ax4000.c
2
 * Routines for Spirent AX/4000 Test Block dissection
3
 * Copyright 2004, SEKINE Hideki <sekineh@gf7.so-net.ne.jp>
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
#include "config.h"
13
14
#include <epan/packet.h>
15
16
void proto_register_ax4000(void);
17
void proto_reg_handoff_ax4000(void);
18
19
static dissector_handle_t ax4000_handle;
20
21
/* Initialize the protocol and registered fields */
22
static int proto_ax4000;
23
static int hf_ax4000_port;
24
static int hf_ax4000_chassis;
25
static int hf_ax4000_fill;
26
static int hf_ax4000_index;
27
static int hf_ax4000_timestamp;
28
static int hf_ax4000_seq;
29
static int hf_ax4000_crc;
30
31
/* Initialize the subtree pointers */
32
static int ett_ax4000;
33
34
/* Code to actually dissect the packets */
35
static int
36
dissect_ax4000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
37
5
{
38
5
  proto_item *ti;
39
5
  proto_tree *ax4000_tree;
40
41
5
  uint32_t ax_port, ax_chassis, ax_index, ax_seq, ax_timestamp;
42
43
  /* Make entries in Protocol column and Info column on summary display */
44
5
  col_set_str(pinfo->cinfo, COL_PROTOCOL, "AX4000");
45
5
  col_clear(pinfo->cinfo, COL_INFO);
46
47
  /* create display subtree for the protocol */
48
5
  ti = proto_tree_add_item(tree, proto_ax4000, tvb, 0, -1, ENC_NA);
49
50
5
  ax4000_tree = proto_item_add_subtree(ti, ett_ax4000);
51
52
5
  proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_port, tvb, 0, 1, ENC_LITTLE_ENDIAN, &ax_port);
53
5
  proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_chassis, tvb, 1, 1, ENC_LITTLE_ENDIAN, &ax_chassis);
54
5
  proto_tree_add_item(ax4000_tree, hf_ax4000_fill, tvb, 2, 1, ENC_BIG_ENDIAN);
55
5
  proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_index, tvb, 2, 2, ENC_BIG_ENDIAN, &ax_index);
56
5
  proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_timestamp, tvb, 6, 4, ENC_LITTLE_ENDIAN, &ax_timestamp);
57
5
  proto_tree_add_item_ret_uint(ax4000_tree, hf_ax4000_seq, tvb, 10, 4, ENC_LITTLE_ENDIAN, &ax_seq);
58
5
  proto_tree_add_item(ax4000_tree, hf_ax4000_crc, tvb, 14, 2, ENC_LITTLE_ENDIAN);
59
60
5
  col_append_fstr(pinfo->cinfo, COL_INFO,
61
5
      "Chss:%u Prt:%u Idx:%u Seq:0x%08x TS:%.6f[msec]",
62
5
      ax_chassis, ax_port, ax_index, ax_seq, ax_timestamp*1e-5);
63
64
5
  return tvb_captured_length(tvb);
65
5
}
66
67
/* Register the protocol with Wireshark */
68
69
/* this format is require because a script is used to build the C function
70
   that calls all the protocol registration.
71
*/
72
73
void
74
proto_register_ax4000(void)
75
15
{
76
15
  static hf_register_info hf[] = {
77
15
    { &hf_ax4000_port,
78
15
      { "Port Number", "ax4000.port",
79
15
        FT_UINT8, BASE_DEC, NULL, 0x0,
80
15
        NULL, HFILL }
81
15
    },
82
15
    { &hf_ax4000_chassis,
83
15
      { "Chassis Number", "ax4000.chassis",
84
15
        FT_UINT8, BASE_DEC, NULL, 0x0,
85
15
        NULL, HFILL }
86
15
    },
87
15
    { &hf_ax4000_fill,
88
15
      { "Fill Type", "ax4000.fill",
89
15
        FT_UINT8, BASE_DEC, NULL, 0xc0,
90
15
        NULL, HFILL }
91
15
    },
92
15
    { &hf_ax4000_index,
93
15
      { "Index", "ax4000.index",
94
15
        FT_UINT16, BASE_DEC, NULL, 0x0FFF,
95
15
        NULL, HFILL }
96
15
    },
97
15
    { &hf_ax4000_timestamp,
98
15
      { "Timestamp", "ax4000.timestamp",
99
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
100
15
        NULL, HFILL }
101
15
    },
102
15
    { &hf_ax4000_seq,
103
15
      { "Sequence Number", "ax4000.seq",
104
15
        FT_UINT32, BASE_HEX, NULL, 0x0,
105
15
        NULL, HFILL }
106
15
    },
107
15
    { &hf_ax4000_crc,
108
15
      { "CRC (unchecked)", "ax4000.crc",
109
15
        FT_UINT16, BASE_HEX, NULL, 0x0,
110
15
        NULL, HFILL }
111
15
    }
112
15
  };
113
114
  /* Setup protocol subtree array */
115
15
  static int *ett[] = {
116
15
    &ett_ax4000
117
15
  };
118
119
  /* Register the protocol name and description */
120
15
  proto_ax4000 = proto_register_protocol("AX/4000 Test Block",
121
15
                 "AX4000", "ax4000");
122
123
  /* Required function calls to register the header fields and subtrees used */
124
15
  proto_register_field_array(proto_ax4000, hf, array_length(hf));
125
15
  proto_register_subtree_array(ett, array_length(ett));
126
127
15
  ax4000_handle = register_dissector("ax4000", dissect_ax4000, proto_ax4000);
128
15
}
129
130
15
#define AX4000_TCP_PORT 3357 /* assigned by IANA */
131
15
#define AX4000_UDP_PORT 3357 /* assigned by IANA */
132
133
void
134
proto_reg_handoff_ax4000(void)
135
15
{
136
15
#define IP_PROTO_AX4000         173     /* AX/4000 Testblock - non IANA */
137
138
15
  dissector_add_uint("ip.proto", IP_PROTO_AX4000, ax4000_handle);
139
15
  dissector_add_uint_with_preference("tcp.port", AX4000_TCP_PORT, ax4000_handle);
140
15
  dissector_add_uint_with_preference("udp.port", AX4000_UDP_PORT, ax4000_handle);
141
15
}
142
143
/*
144
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
145
 *
146
 * Local variables:
147
 * c-basic-offset: 8
148
 * tab-width: 8
149
 * indent-tabs-mode: t
150
 * End:
151
 *
152
 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
153
 * :indentSize=8:tabSize=8:noTabs=false:
154
 */