2 * Routines for "LANforge traffic generator IP protocol" dissection
4 * Ben Greear <greearb@candelatech.com>
6 * Based on pktgen dissectory by:
7 * Francesco Fondelli <francesco dot fondelli, gmail dot com>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
16 /* LANforge generates network traffic for load & performance testing.
17 * See http://www.candelatech.com for more info.
22 #include <epan/packet.h>
24 void proto_register_lanforge(void);
25 void proto_reg_handoff_lanforge(void);
27 /* magic num used for heuristic */
28 #define LANFORGE_MAGIC 0x1a2b3c4d
30 /* Initialize the protocol and registered fields */
31 static int proto_lanforge
;
34 static int hf_lanforge_crc
;
35 static int hf_lanforge_magic
;
36 static int hf_lanforge_src_session
;
37 static int hf_lanforge_dst_session
;
38 static int hf_lanforge_pld_len_l
;
39 static int hf_lanforge_pld_len_h
;
40 static int hf_lanforge_pld_len
;
41 static int hf_lanforge_pld_pattern
;
42 static int hf_lanforge_seq
;
43 static int hf_lanforge_tx_time_s
;
44 static int hf_lanforge_tx_time_ns
;
45 static int hf_lanforge_timestamp
;
47 /* Initialize the subtree pointer */
48 static int ett_lanforge
;
51 static bool dissect_lanforge(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
54 proto_tree
*lanforge_tree
;
56 uint32_t magic
, pld_len
, pld_len_h
;
58 /* check for min size */
59 if(tvb_captured_length(tvb
) < 28) { /* Not a LANforge packet. */
63 /* check for magic number */
64 magic
= tvb_get_ntohl(tvb
, 4);
65 if(magic
!= LANFORGE_MAGIC
){
66 /* Not a LANforge packet. */
70 /* Make entries in Protocol column and Info column on summary display */
72 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "LANforge");
74 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Seq: %u", tvb_get_ntohl(tvb
, 16));
76 /* create display subtree for the protocol */
78 ti
= proto_tree_add_item(tree
, proto_lanforge
, tvb
, 0, -1, ENC_NA
);
80 lanforge_tree
= proto_item_add_subtree(ti
, ett_lanforge
);
82 /* add items to the subtree */
84 proto_tree_add_item(lanforge_tree
, hf_lanforge_crc
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
87 proto_tree_add_item(lanforge_tree
, hf_lanforge_magic
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
90 proto_tree_add_item(lanforge_tree
, hf_lanforge_src_session
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
93 proto_tree_add_item(lanforge_tree
, hf_lanforge_dst_session
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
96 proto_tree_add_item_ret_uint(lanforge_tree
, hf_lanforge_pld_len_l
,
97 tvb
, offset
, 2, ENC_BIG_ENDIAN
, &pld_len
);
99 proto_tree_add_item_ret_uint(lanforge_tree
, hf_lanforge_pld_len_h
,
100 tvb
, offset
, 1, ENC_BIG_ENDIAN
, &pld_len_h
);
102 pld_len
|= (pld_len_h
<< 16);
103 proto_tree_add_uint(lanforge_tree
, hf_lanforge_pld_len
, tvb
, offset
-3, 3, pld_len
);
105 proto_tree_add_item(lanforge_tree
, hf_lanforge_pld_pattern
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
108 proto_tree_add_item(lanforge_tree
, hf_lanforge_seq
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
111 proto_tree_add_item(lanforge_tree
, hf_lanforge_tx_time_s
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
113 proto_tree_add_item(lanforge_tree
, hf_lanforge_tx_time_ns
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
115 proto_tree_add_item(lanforge_tree
, hf_lanforge_timestamp
,
116 tvb
, offset
- 8, 8, ENC_TIME_SECS_NSECS
|ENC_BIG_ENDIAN
);
118 if(tvb_reported_length_remaining(tvb
, offset
) > 0) /* random data */
119 call_data_dissector(tvb_new_subset_remaining(tvb
, offset
), pinfo
,
126 /* Register the protocol with Wireshark */
127 void proto_register_lanforge(void)
129 /* Setup list of header fields */
131 static hf_register_info hf
[] = {
135 "CRC", "lanforge.CRC",
136 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
137 "The LANforge CRC number", HFILL
141 { &hf_lanforge_magic
,
143 "Magic number", "lanforge.magic",
144 FT_UINT32
, BASE_HEX
, NULL
, 0x0,
145 "The LANforge magic number", HFILL
149 { &hf_lanforge_src_session
,
151 "Source session ID", "lanforge.source-session-id",
152 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
153 "The LANforge source session ID", HFILL
157 { &hf_lanforge_dst_session
,
159 "Dest session ID", "lanforge.dest-session-id",
160 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
161 "The LANforge dest session ID", HFILL
165 { &hf_lanforge_pld_len_l
,
167 "Payload Length(L)", "lanforge.pld-len-L",
168 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
169 "The LANforge payload length (low bytes)", HFILL
173 { &hf_lanforge_pld_len_h
,
175 "Payload Length(H)", "lanforge.pld-len-H",
176 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
177 "The LANforge payload length (high byte)", HFILL
181 { &hf_lanforge_pld_len
,
183 "Payload Length", "lanforge.pld-length",
184 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
185 "The LANforge payload length", HFILL
189 { &hf_lanforge_pld_pattern
,
191 "Payload Pattern", "lanforge.pld-pattern",
192 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
193 "The LANforge payload pattern", HFILL
199 "Sequence Number", "lanforge.seqno",
200 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
201 "The LANforge Sequence Number", HFILL
205 { &hf_lanforge_tx_time_s
,
207 "Timestamp Secs", "lanforge.ts-secs",
208 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
213 { &hf_lanforge_tx_time_ns
,
215 "Timestamp nsecs", "lanforge.ts-nsecs",
216 FT_UINT32
, BASE_DEC
, NULL
, 0x0,
221 { &hf_lanforge_timestamp
,
223 "Timestamp", "lanforge.timestamp",
224 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0x0,
230 /* Setup protocol subtree array */
232 static int *ett
[] = {
236 /* Register the protocol name and description */
238 proto_lanforge
= proto_register_protocol("LANforge Traffic Generator", "LANforge", "lanforge");
240 /* Required function calls to register the header fields and subtrees used */
242 proto_register_field_array(proto_lanforge
, hf
, array_length(hf
));
243 proto_register_subtree_array(ett
, array_length(ett
));
247 void proto_reg_handoff_lanforge(void)
249 /* Register as a heuristic UDP dissector */
250 heur_dissector_add("udp", dissect_lanforge
, "LANforge over UDP", "lanforge_udp", proto_lanforge
, HEURISTIC_ENABLE
);
251 heur_dissector_add("tcp", dissect_lanforge
, "LANforge over TCP", "lanforge_tcp", proto_lanforge
, HEURISTIC_ENABLE
);
255 * Editor modelines - https://www.wireshark.org/tools/modelines.html
260 * indent-tabs-mode: nil
263 * vi: set shiftwidth=4 tabstop=8 expandtab:
264 * :indentSize=4:tabSize=8:noTabs=true: