Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-lanforge.c
blobf8ccee5ad8f275a211df270defd38a71e7a1b3d6
1 /* packet-lanforge.c
2 * Routines for "LANforge traffic generator IP protocol" dissection
3 * Copyright 2008
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.
20 #include "config.h"
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;
33 /* lanforge header */
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;
50 /* entry point */
51 static bool dissect_lanforge(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
53 proto_item *ti;
54 proto_tree *lanforge_tree;
55 uint32_t offset = 0;
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. */
60 return false;
63 /* check for magic number */
64 magic = tvb_get_ntohl(tvb, 4);
65 if(magic != LANFORGE_MAGIC){
66 /* Not a LANforge packet. */
67 return false;
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);
85 offset+=4;
87 proto_tree_add_item(lanforge_tree, hf_lanforge_magic, tvb, offset, 4, ENC_BIG_ENDIAN);
88 offset+=4;
90 proto_tree_add_item(lanforge_tree, hf_lanforge_src_session, tvb, offset, 2, ENC_BIG_ENDIAN);
91 offset+=2;
93 proto_tree_add_item(lanforge_tree, hf_lanforge_dst_session, tvb, offset, 2, ENC_BIG_ENDIAN);
94 offset+=2;
96 proto_tree_add_item_ret_uint(lanforge_tree, hf_lanforge_pld_len_l,
97 tvb, offset, 2, ENC_BIG_ENDIAN, &pld_len);
98 offset+=2;
99 proto_tree_add_item_ret_uint(lanforge_tree, hf_lanforge_pld_len_h,
100 tvb, offset, 1, ENC_BIG_ENDIAN, &pld_len_h);
101 offset+=1;
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);
106 offset+=1;
108 proto_tree_add_item(lanforge_tree, hf_lanforge_seq, tvb, offset, 4, ENC_BIG_ENDIAN);
109 offset+=4;
111 proto_tree_add_item(lanforge_tree, hf_lanforge_tx_time_s, tvb, offset, 4, ENC_BIG_ENDIAN);
112 offset+=4;
113 proto_tree_add_item(lanforge_tree, hf_lanforge_tx_time_ns, tvb, offset, 4, ENC_BIG_ENDIAN);
114 offset+=4;
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,
120 lanforge_tree);
122 return true;
126 /* Register the protocol with Wireshark */
127 void proto_register_lanforge(void)
129 /* Setup list of header fields */
131 static hf_register_info hf[] = {
133 { &hf_lanforge_crc,
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
197 { &hf_lanforge_seq,
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,
209 NULL, HFILL
213 { &hf_lanforge_tx_time_ns,
215 "Timestamp nsecs", "lanforge.ts-nsecs",
216 FT_UINT32, BASE_DEC, NULL, 0x0,
217 NULL, HFILL
221 { &hf_lanforge_timestamp,
223 "Timestamp", "lanforge.timestamp",
224 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
225 NULL, HFILL
230 /* Setup protocol subtree array */
232 static int *ett[] = {
233 &ett_lanforge
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
257 * Local variables:
258 * c-basic-offset: 4
259 * tab-width: 8
260 * indent-tabs-mode: nil
261 * End:
263 * vi: set shiftwidth=4 tabstop=8 expandtab:
264 * :indentSize=4:tabSize=8:noTabs=true: