Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-dlep.c
blob045e7e93cbcda532eb18960d2961ab69ad33caaf
1 /* packet-dlep.c
2 * Routines for DLEP protocol packet disassembly
4 * Copyright (C) 2019 Massachusetts Institute of Technology
6 * Original code from https://github.com/mit-ll/dlep-wireshark-dissector
7 * Original Author: Jeffrey Wildman <jeffrey.wildman@ll.mit.edu>
9 * Extended and supplemented by Uli Heilmeier <uh@heilmeier.eu>, 2020
10 * Extended by:
11 * RFC 8757 Latency Range Extension
12 * RFC 8629 Multi-Hop Forwarding Extension
13 * RFC 8703 Link Identifier Extension
14 * TODO: Decoding of RFC 8651 Control-Plane-Based Pause Extension needs to be implemented
16 * SPDX-License-Identifier: MIT
20 #include "config.h"
22 #include <epan/ftypes/ftypes.h> /* for fieldtype lengths */
23 #include <epan/exceptions.h>
24 #include <epan/expert.h>
25 #include <epan/ipproto.h> /* for IP_PROTO_TCP and IP_PROTO_UDP */
26 #include <epan/packet.h>
27 #include <epan/packet_info.h> /* for struct packet_info */
28 #include <epan/prefs.h>
29 #include <epan/tvbuff.h>
30 #include <epan/to_str.h>
31 #include <epan/tfs.h>
33 #include "packet-tcp.h"
35 /* Section 13: DLEP Data Items */
37 /* DLEP Data Item Lengths (bytes) */
38 #define DLEP_DIT_STATUS_MINLEN 1 /* variable length */
39 #define DLEP_DIT_V4CONN_LEN 5
40 #define DLEP_DIT_V4CONN_WPORT_LEN 7
41 #define DLEP_DIT_V6CONN_LEN 17
42 #define DLEP_DIT_V6CONN_WPORT_LEN 19
43 #define DLEP_DIT_PEERTYPE_MINLEN 1 /* variable length */
44 #define DLEP_DIT_HEARTBEAT_LEN 4
45 /* EXTSUPP has variable, non-negative length */
46 #define DLEP_DIT_MACADDR_EUI48_LEN 6
47 #define DLEP_DIT_MACADDR_EUI64_LEN 8
48 #define DLEP_DIT_V4ADDR_LEN 5
49 #define DLEP_DIT_V6ADDR_LEN 17
50 #define DLEP_DIT_V4SUBNET_LEN 6
51 #define DLEP_DIT_V6SUBNET_LEN 18
52 #define DLEP_DIT_MDRR_LEN 8
53 #define DLEP_DIT_MDRT_LEN 8
54 #define DLEP_DIT_CDRR_LEN 8
55 #define DLEP_DIT_CDRT_LEN 8
56 #define DLEP_DIT_LAT_LEN 8
57 #define DLEP_DIT_RES_LEN 1
58 #define DLEP_DIT_RLQR_LEN 1
59 #define DLEP_DIT_RLQT_LEN 1
60 #define DLEP_DIT_MTU_LEN 2
61 #define DLEP_DIT_HOP_CNT_LEN 2
62 #define DLEP_DIT_HOP_CNTRL_LEN 2
63 #define DLEP_DIT_LI_LENGTH_LEN 2
64 #define DLEP_DIT_LAT_RANGE_LEN 16
66 /* DLEP Data Item Flags Lengths (bytes) */
67 #define DLEP_DIT_V4CONN_FLAGS_LEN 1
68 #define DLEP_DIT_V6CONN_FLAGS_LEN 1
69 #define DLEP_DIT_V4ADDR_FLAGS_LEN 1
70 #define DLEP_DIT_V6ADDR_FLAGS_LEN 1
71 #define DLEP_DIT_PEERTYPE_FLAGS_LEN 1
72 #define DLEP_DIT_V4SUBNET_FLAGS_LEN 1
73 #define DLEP_DIT_V6SUBNET_FLAGS_LEN 1
76 /* Section 15: IANA Considerations */
78 /* Section 15.2: DLEP Signal Type Codes */
79 #define DLEP_SIG_RESERVED 0
80 #define DLEP_SIG_PEERDISC 1
81 #define DLEP_SIG_PEEROFFR 2
83 /* Section 15.3: DLEP Message Type Codes */
84 #define DLEP_MSG_RESERVED 0
85 #define DLEP_MSG_SESSINIT 1
86 #define DLEP_MSG_SESSINITRESP 2
87 #define DLEP_MSG_SESSUPDATE 3
88 #define DLEP_MSG_SESSUPDATERESP 4
89 #define DLEP_MSG_SESSTERM 5
90 #define DLEP_MSG_SESSTERMRESP 6
91 #define DLEP_MSG_DESTUP 7
92 #define DLEP_MSG_DESTUPRESP 8
93 #define DLEP_MSG_DESTANN 9
94 #define DLEP_MSG_DESTANNRESP 10
95 #define DLEP_MSG_DESTDOWN 11
96 #define DLEP_MSG_DESTDOWNRESP 12
97 #define DLEP_MSG_DESTUPDATE 13
98 #define DLEP_MSG_LINKCHARRQST 14
99 #define DLEP_MSG_LINKCHARRESP 15
100 #define DLEP_MSG_HEARTBEAT 16
102 /* Section 15.4: DLEP Data Item Type Codes */
103 #define DLEP_DIT_RESERVED 0
104 #define DLEP_DIT_STATUS 1
105 #define DLEP_DIT_V4CONN 2
106 #define DLEP_DIT_V6CONN 3
107 #define DLEP_DIT_PEERTYPE 4
108 #define DLEP_DIT_HEARTBEAT 5
109 #define DLEP_DIT_EXTSUPP 6
110 #define DLEP_DIT_MACADDR 7
111 #define DLEP_DIT_V4ADDR 8
112 #define DLEP_DIT_V6ADDR 9
113 #define DLEP_DIT_V4SUBNET 10
114 #define DLEP_DIT_V6SUBNET 11
115 #define DLEP_DIT_MDRR 12
116 #define DLEP_DIT_MDRT 13
117 #define DLEP_DIT_CDRR 14
118 #define DLEP_DIT_CDRT 15
119 #define DLEP_DIT_LAT 16
120 #define DLEP_DIT_RES 17
121 #define DLEP_DIT_RLQR 18
122 #define DLEP_DIT_RLQT 19
123 #define DLEP_DIT_MTU 20
124 #define DLEP_DIT_HOP_CNT 21
125 #define DLEP_DIT_HOP_CNTRL 22
126 #define DLEP_DIT_QUEUE_PARA 23
127 #define DLEP_DIT_PAUSE 24
128 #define DLEP_DIT_RESTART 25
129 #define DLEP_DIT_LI_LENGTH 26
130 #define DLEP_DIT_LI 27
131 #define DLEP_DIT_LAT_RANGE 28
133 /* Section 15.5: DLEP Status Codes */
134 #define DLEP_SC_CONT_SUCCESS 0
135 #define DLEP_SC_CONT_NOTINT 1
136 #define DLEP_SC_CONT_RQSTDENIED 2
137 #define DLEP_SC_CONT_INCONSIST 3
138 #define DLEP_SC_TERM_UNKWNMSG 128
139 #define DLEP_SC_TERM_UNEXPMSG 129
140 #define DLEP_SC_TERM_INVDATA 130
141 #define DLEP_SC_TERM_INVDEST 131
142 #define DLEP_SC_TERM_TIMEDOUT 132
143 #define DLEP_SC_TERM_SHUTDOWN 255
145 /* Section 15.6: DLEP Extension Type Codes */
146 #define DLEP_EXT_RESERVED 0
147 #define DLEP_EXT_MULTIHOP 1
148 #define DLEP_EXT_CPB_PAUSE 2
149 #define DLEP_EXT_LI 3
150 #define DLEP_EXT_LR 4
152 /* Section 15.7: DLEP IPv4 Connection Point Flags */
153 #define DLEP_DIT_V4CONN_FLAGMASK_BITLEN DLEP_DIT_V4CONN_FLAGS_LEN * 8
154 #define DLEP_DIT_V4CONN_FLAGMASK_TLS 0x01
156 /* Section 15.8: DLEP IPv6 Connection Point Flags */
157 #define DLEP_DIT_V6CONN_FLAGMASK_BITLEN DLEP_DIT_V6CONN_FLAGS_LEN * 8
158 #define DLEP_DIT_V6CONN_FLAGMASK_TLS 0x01
160 /* Section 15.9: DLEP Peer Type Flags */
161 #define DLEP_DIT_PEERTYPE_FLAGMASK_BITLEN DLEP_DIT_PEERTYPE_FLAGS_LEN * 8
162 #define DLEP_DIT_PEERTYPE_FLAGMASK_SMI 0x01
164 /* Section 15.10: DLEP IPv4 Address Flags */
165 #define DLEP_DIT_V4ADDR_FLAGMASK_BITLEN DLEP_DIT_V4ADDR_FLAGS_LEN * 8
166 #define DLEP_DIT_V4ADDR_FLAGMASK_ADDDROP 0x01
168 /* Section 15.11: DLEP IPv6 Address Flags */
169 #define DLEP_DIT_V6ADDR_FLAGMASK_BITLEN DLEP_DIT_V6ADDR_FLAGS_LEN * 8
170 #define DLEP_DIT_V6ADDR_FLAGMASK_ADDDROP 0x01
172 /* Section 15.12: DLEP IPv4 Attached Subnet Flags */
173 #define DLEP_DIT_V4SUBNET_FLAGMASK_BITLEN DLEP_DIT_V4SUBNET_FLAGS_LEN * 8
174 #define DLEP_DIT_V4SUBNET_FLAGMASK_ADDDROP 0x01
176 /* Section 15.13: DLEP IPv6 Attached Subnet Flags */
177 #define DLEP_DIT_V6SUBNET_FLAGMASK_BITLEN DLEP_DIT_V6SUBNET_FLAGS_LEN * 8
178 #define DLEP_DIT_V6SUBNET_FLAGMASK_ADDDROP 0x01
180 /* RFC 8629 Hop Count Flags */
181 #define DLEP_DIT_HOP_CNT_FLAGMASK_P 0x80
182 #define DLEP_DIT_HOP_CNT_FLAGMASK_RESERVED 0x7F
184 /* Section 15.14: DLEP Well-known Port */
185 #define DLEP_UDP_PORT "854"
186 #define DLEP_TCP_PORT "854"
188 /* Section 15.15: DLEP IPv4 Link-Local Multicast Address */
189 #define DLEP_IPV4_ADDR "224.0.0.117"
191 /* Section 15.16: DLEP IPv6 Link-Local Multicast Address */
192 #define DLEP_IPV6_ADDR "FF02:0:0:0:0:0:1:7"
194 #define DLEP_MSG_HEADER_LEN 4
196 static bool dlep_desegment = true;
198 static dissector_handle_t dlep_msg_handle;
199 static dissector_handle_t dlep_sig_handle;
200 static dissector_table_t dlep_dataitem_table;
202 void proto_register_dlep(void);
203 void proto_reg_handoff_dlep(void);
205 static int proto_dlep;
206 static int proto_dataitem;
208 static int ett_dlep;
209 static int ett_dlep_dataitem;
210 static int ett_dlep_flags;
212 static int hf_dlep_signal;
213 static int hf_dlep_signal_signature;
214 static int hf_dlep_signal_type;
215 static int hf_dlep_signal_length;
216 static int hf_dlep_message;
217 static int hf_dlep_message_type;
218 static int hf_dlep_message_length;
219 static int hf_dlep_dataitem;
220 static int hf_dlep_dataitem_type;
221 static int hf_dlep_dataitem_length;
222 static int hf_dlep_dataitem_value;
223 static int hf_dlep_dataitem_status;
224 static int hf_dlep_dataitem_status_code;
225 static int hf_dlep_dataitem_status_text;
226 static int hf_dlep_dataitem_v4conn;
227 static int hf_dlep_dataitem_v4conn_flags;
228 static int hf_dlep_dataitem_v4conn_flags_tls;
229 static int hf_dlep_dataitem_v4conn_addr;
230 static int hf_dlep_dataitem_v4conn_port;
231 static int hf_dlep_dataitem_v6conn;
232 static int hf_dlep_dataitem_v6conn_flags;
233 static int hf_dlep_dataitem_v6conn_flags_tls;
234 static int hf_dlep_dataitem_v6conn_addr;
235 static int hf_dlep_dataitem_v6conn_port;
236 static int hf_dlep_dataitem_peertype;
237 static int hf_dlep_dataitem_peertype_flags;
238 static int hf_dlep_dataitem_peertype_flags_smi;
239 static int hf_dlep_dataitem_peertype_description;
240 static int hf_dlep_dataitem_heartbeat;
241 static int hf_dlep_dataitem_extsupp;
242 static int hf_dlep_dataitem_extsupp_code;
243 static int hf_dlep_dataitem_macaddr_eui48;
244 static int hf_dlep_dataitem_macaddr_eui64;
245 static int hf_dlep_dataitem_v4addr;
246 static int hf_dlep_dataitem_v4addr_flags;
247 static int hf_dlep_dataitem_v4addr_flags_adddrop;
248 static int hf_dlep_dataitem_v4addr_addr;
249 static int hf_dlep_dataitem_v6addr;
250 static int hf_dlep_dataitem_v6addr_flags;
251 static int hf_dlep_dataitem_v6addr_flags_adddrop;
252 static int hf_dlep_dataitem_v6addr_addr;
253 static int hf_dlep_dataitem_v4subnet;
254 static int hf_dlep_dataitem_v4subnet_flags;
255 static int hf_dlep_dataitem_v4subnet_flags_adddrop;
256 static int hf_dlep_dataitem_v4subnet_subnet;
257 static int hf_dlep_dataitem_v4subnet_prefixlen;
258 static int hf_dlep_dataitem_v6subnet;
259 static int hf_dlep_dataitem_v6subnet_flags;
260 static int hf_dlep_dataitem_v6subnet_flags_adddrop;
261 static int hf_dlep_dataitem_v6subnet_subnet;
262 static int hf_dlep_dataitem_v6subnet_prefixlen;
263 static int hf_dlep_dataitem_mdrr;
264 static int hf_dlep_dataitem_mdrt;
265 static int hf_dlep_dataitem_cdrr;
266 static int hf_dlep_dataitem_cdrt;
267 static int hf_dlep_dataitem_latency;
268 static int hf_dlep_dataitem_resources;
269 static int hf_dlep_dataitem_rlqr;
270 static int hf_dlep_dataitem_rlqt;
271 static int hf_dlep_dataitem_mtu;
272 static int hf_dlep_dataitem_hop_count_flags;
273 static int hf_dlep_dataitem_hop_count_flags_p;
274 static int hf_dlep_dataitem_hop_count_flags_reserved;
275 static int hf_dlep_dataitem_hop_count;
276 static int hf_dlep_dataitem_hop_control;
277 static int hf_dlep_dataitem_li_length;
278 static int hf_dlep_dataitem_li;
279 static int hf_dlep_dataitem_max_lat;
280 static int hf_dlep_dataitem_min_lat;
282 static const value_string signal_type_vals[] = {
283 { DLEP_SIG_RESERVED, "Reserved" },
284 { DLEP_SIG_PEERDISC, "Peer Discovery" },
285 { DLEP_SIG_PEEROFFR, "Peer Offer" },
286 { 0, NULL }
289 static const value_string message_type_vals[] = {
290 { DLEP_MSG_RESERVED, "Reserved" },
291 { DLEP_MSG_SESSINIT, "Session Initialization" },
292 { DLEP_MSG_SESSINITRESP, "Session Initialization Response" },
293 { DLEP_MSG_SESSUPDATE, "Session Update" },
294 { DLEP_MSG_SESSUPDATERESP, "Session Update Response" },
295 { DLEP_MSG_SESSTERM, "Session Termination" },
296 { DLEP_MSG_SESSTERMRESP, "Session Termination Response" },
297 { DLEP_MSG_DESTUP, "Destination Up" },
298 { DLEP_MSG_DESTUPRESP, "Destination Up Response" },
299 { DLEP_MSG_DESTANN, "Destination Announce" },
300 { DLEP_MSG_DESTANNRESP, "Destination Announce Response" },
301 { DLEP_MSG_DESTDOWN, "Destination Down" },
302 { DLEP_MSG_DESTDOWNRESP, "Destination Down Response" },
303 { DLEP_MSG_DESTUPDATE, "Destination Update" },
304 { DLEP_MSG_LINKCHARRQST, "Link Characteristics Request" },
305 { DLEP_MSG_LINKCHARRESP, "Link Characteristics Response" },
306 { DLEP_MSG_HEARTBEAT, "Heartbeat" },
307 { 0, NULL }
310 static const value_string dataitem_type_vals[] = {
311 { DLEP_DIT_RESERVED, "Reserved" },
312 { DLEP_DIT_STATUS, "Status" },
313 { DLEP_DIT_V4CONN, "IPv4 Connection Point" },
314 { DLEP_DIT_V6CONN, "IPv6 Connection Point" },
315 { DLEP_DIT_PEERTYPE, "Peer Type" },
316 { DLEP_DIT_HEARTBEAT, "Heartbeat Interval" },
317 { DLEP_DIT_EXTSUPP, "Extensions Supported" },
318 { DLEP_DIT_MACADDR, "MAC Address" },
319 { DLEP_DIT_V4ADDR, "IPv4 Address" },
320 { DLEP_DIT_V6ADDR, "IPv6 Address" },
321 { DLEP_DIT_V4SUBNET, "IPv4 Attached Subnet" },
322 { DLEP_DIT_V6SUBNET, "IPv6 Attached Subnet" },
323 { DLEP_DIT_MDRR, "Maximum Data Rate (Receive) (MDRR)" },
324 { DLEP_DIT_MDRT, "Maximum Data Rate (Transmit) (MDRT)" },
325 { DLEP_DIT_CDRR, "Current Data Rate (Receive) (CDRR)" },
326 { DLEP_DIT_CDRT, "Current Data Rate (Transmit) (CDRT)" },
327 { DLEP_DIT_LAT, "Latency" },
328 { DLEP_DIT_RES, "Resources (RES)" },
329 { DLEP_DIT_RLQR, "Relative Link Quality (Receive) (RLQR)" },
330 { DLEP_DIT_RLQT, "Relative Link Quality (Transmit) (RLQT)" },
331 { DLEP_DIT_MTU, "Maximum Transmission Unit (MTU)" },
332 { DLEP_DIT_HOP_CNT, "Hop Count" },
333 { DLEP_DIT_HOP_CNTRL, "Hop Control" },
334 { DLEP_DIT_QUEUE_PARA,"Queue Parameters" },
335 { DLEP_DIT_PAUSE, "Pause" },
336 { DLEP_DIT_RESTART, "Restart" },
337 { DLEP_DIT_LI_LENGTH, "Link Identifier Length" },
338 { DLEP_DIT_LI, "Link Identifier" },
339 { DLEP_DIT_LAT_RANGE, "Latency Range" },
340 { 0, NULL }
343 static const value_string status_code_vals[] = {
344 { DLEP_SC_CONT_SUCCESS, "Success" },
345 { DLEP_SC_CONT_NOTINT, "Not Interested" },
346 { DLEP_SC_CONT_RQSTDENIED, "Request Denied" },
347 { DLEP_SC_CONT_INCONSIST, "Inconsistent Data" },
348 { DLEP_SC_TERM_UNKWNMSG, "Unknown Message" },
349 { DLEP_SC_TERM_UNEXPMSG, "Unexpected Message" },
350 { DLEP_SC_TERM_INVDATA, "Invalid Data" },
351 { DLEP_SC_TERM_INVDEST, "Invalid Destination" },
352 { DLEP_SC_TERM_TIMEDOUT, "Timed Out" },
353 { DLEP_SC_TERM_SHUTDOWN, "Shutting Down" },
354 { 0, NULL }
357 static const range_string extension_code_vals[] = {
358 { DLEP_EXT_RESERVED, DLEP_EXT_RESERVED, "Reserved" },
359 { DLEP_EXT_MULTIHOP, DLEP_EXT_MULTIHOP, "Multi-Hop Forwarding" },
360 { DLEP_EXT_CPB_PAUSE, DLEP_EXT_CPB_PAUSE, "Control-Plane-Based Pause" },
361 { DLEP_EXT_LI, DLEP_EXT_LI, "Link Identifiers" },
362 { DLEP_EXT_LR, DLEP_EXT_LR, "Latency Range" },
363 { 5, 65519, "Unassigned" },
364 { 65520, 65534, "Reserved for Private Use" },
365 { 0, 0, NULL }
368 static const range_string hop_cntrl_action_vals[] = {
369 { 0, 0, "Reset" },
370 { 1, 1, "Terminate" },
371 { 2, 2, "Direct Connection" },
372 { 3, 3, "Suppress Forwarding" },
373 { 4, 65519, "Specification Required" },
374 { 65520, 65534, "Private Use" },
375 { 65535, 65535, "Reserved" },
376 { 0, 0, NULL }
379 static expert_field ei_dlep_signal_unexpected_length;
380 static expert_field ei_dlep_message_unexpected_length;
381 static expert_field ei_dlep_dataitem_unexpected_length;
382 static expert_field ei_dlep_dataitem_macaddr_unexpected_length;
384 /* Section 13.1: Status */
385 static int
386 decode_dataitem_status(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
388 proto_item *pi = proto_tree_get_parent(pt);
389 const int len = tvb_captured_length(tvb);
390 int offset = 0;
391 proto_item *tmp_pi = NULL;
392 uint32_t status_code;
394 /* Add and hide the specific dataitem protocol item */
395 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_status, tvb, offset, len, ENC_NA);
396 proto_item_set_hidden(tmp_pi);
398 if (len < DLEP_DIT_STATUS_MINLEN) {
399 return offset;
402 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_status_code, tvb, offset, 1, ENC_NA, &status_code);
403 proto_item_append_text(pi, ", Code: %s (%u)", val_to_str_const(status_code, status_code_vals, "Unknown"), status_code);
404 offset+=1;
406 proto_tree_add_item(pt, hf_dlep_dataitem_status_text, tvb, offset, len-1, ENC_UTF_8);
407 proto_item_append_text(pi, ", Text: %s", tvb_get_string_enc(pinfo->pool, tvb, offset, len-1, ENC_UTF_8));
408 offset+=len-1;
410 return offset;
413 /* Section 13.2: IPv4 Connection Point */
414 static int
415 decode_dataitem_v4conn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
417 proto_item *pi = proto_tree_get_parent(pt);
418 const int len = tvb_captured_length(tvb);
419 int offset = 0;
420 proto_item* tmp_pi = NULL;
421 proto_tree* flags_pt = NULL;
422 uint32_t v4conn_port;
424 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4conn, tvb, offset, len, ENC_NA);
425 proto_item_set_hidden(tmp_pi);
427 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4conn_flags, tvb, offset, DLEP_DIT_V4CONN_FLAGS_LEN, ENC_NA);
428 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
429 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v4conn_flags_tls, tvb, offset, DLEP_DIT_V4CONN_FLAGS_LEN, ENC_NA);
430 offset+=DLEP_DIT_V4CONN_FLAGS_LEN;
432 proto_tree_add_item(pt, hf_dlep_dataitem_v4conn_addr, tvb, offset, FT_IPv4_LEN, ENC_BIG_ENDIAN);
433 proto_item_append_text(pi, ", Addr: %s", tvb_ip_to_str(pinfo->pool, tvb, offset));
434 offset+=FT_IPv4_LEN;
436 if (len == DLEP_DIT_V4CONN_WPORT_LEN) {
437 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_v4conn_port, tvb, offset, 2, ENC_BIG_ENDIAN, &v4conn_port);
438 proto_item_append_text(pi, ", Port: %u", v4conn_port);
439 offset+=2;
442 return offset;
445 /* Section 13.3: IPv6 Connection Point */
446 static int
447 decode_dataitem_v6conn(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
449 proto_item *pi = proto_tree_get_parent(pt);
450 const int len = tvb_captured_length(tvb);
451 int offset = 0;
452 proto_item* tmp_pi = NULL;
453 proto_tree* flags_pt = NULL;
454 uint32_t v6conn_port;
456 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6conn, tvb, offset, len, ENC_NA);
457 proto_item_set_hidden(tmp_pi);
459 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6conn_flags, tvb, offset, DLEP_DIT_V6CONN_FLAGS_LEN, ENC_NA);
460 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
461 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v6conn_flags_tls, tvb, offset, DLEP_DIT_V6CONN_FLAGS_LEN, ENC_NA);
462 offset+=DLEP_DIT_V6CONN_FLAGS_LEN;
464 proto_tree_add_item(pt, hf_dlep_dataitem_v6conn_addr, tvb, offset, FT_IPv6_LEN, ENC_NA);
465 proto_item_append_text(pi, ", Addr: %s", tvb_ip6_to_str(pinfo->pool, tvb, offset));
466 offset+=FT_IPv6_LEN;
468 if (len == DLEP_DIT_V6CONN_WPORT_LEN) {
469 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_v6conn_port, tvb, offset, 2, ENC_BIG_ENDIAN, &v6conn_port);
470 proto_item_append_text(pi, ", Port: %u", v6conn_port);
471 offset+=2;
474 return offset;
477 /* Section 13.4: Peer Type */
478 static int
479 decode_dataitem_peertype(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
481 proto_item *pi = proto_tree_get_parent(pt);
482 const int len = tvb_captured_length(tvb);
483 int offset = 0;
484 proto_item *tmp_pi = NULL;
485 proto_tree * flags_pt = NULL;
487 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_peertype, tvb, offset, len, ENC_NA);
488 proto_item_set_hidden(tmp_pi);
490 if (len < DLEP_DIT_PEERTYPE_MINLEN) {
491 return offset;
494 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_peertype_flags, tvb, offset, DLEP_DIT_PEERTYPE_FLAGS_LEN, ENC_NA);
495 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
496 proto_tree_add_item(flags_pt, hf_dlep_dataitem_peertype_flags_smi, tvb, offset, DLEP_DIT_PEERTYPE_FLAGS_LEN, ENC_NA);
497 offset+=DLEP_DIT_PEERTYPE_FLAGS_LEN;
499 proto_tree_add_item(pt, hf_dlep_dataitem_peertype_description, tvb, offset, len-DLEP_DIT_PEERTYPE_FLAGS_LEN, ENC_UTF_8);
500 proto_item_append_text(pi, ", Description: %s", tvb_get_string_enc(pinfo->pool, tvb, offset, len-DLEP_DIT_PEERTYPE_FLAGS_LEN, ENC_UTF_8));
501 offset+=len-DLEP_DIT_PEERTYPE_FLAGS_LEN;
503 return offset;
506 /* Section 13.5: Heartbeat Interval */
507 static int
508 decode_dataitem_heartbeat(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
510 proto_item *pi = proto_tree_get_parent(pt);
511 int offset = 0;
512 uint32_t heartbeat;
514 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_heartbeat, tvb, offset, DLEP_DIT_HEARTBEAT_LEN, ENC_BIG_ENDIAN, &heartbeat);
515 proto_item_append_text(pi, ": %u (ms)", heartbeat);
516 offset+=DLEP_DIT_HEARTBEAT_LEN;
518 return offset;
521 /* Section 13.6: Extensions Supported */
522 static int
523 decode_dataitem_extsupp(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
525 proto_item *pi = proto_tree_get_parent(pt);
526 const int len = tvb_captured_length(tvb);
527 int offset = 0;
528 uint32_t extension_code;
530 proto_item* tmp_pi = NULL;
532 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_extsupp, tvb, offset, len, ENC_NA);
533 proto_item_set_hidden(tmp_pi);
535 while(offset < len) {
536 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_extsupp_code, tvb, offset, 2, ENC_BIG_ENDIAN, &extension_code);
537 proto_item_append_text(pi, ", Ext: %s (%u)", rval_to_str_const(extension_code, extension_code_vals, "Unknown"), extension_code);
538 offset+=2;
541 return offset;
544 /* Section 13.7: MAC Address */
545 static int
546 decode_dataitem_macaddr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
548 proto_item *pi = proto_tree_get_parent(pt);
549 const int len = tvb_captured_length(tvb);
550 int offset = 0;
551 switch(len) {
552 case FT_ETHER_LEN:
553 proto_tree_add_item(pt, hf_dlep_dataitem_macaddr_eui48, tvb, offset, len, ENC_NA);
554 proto_item_append_text(pi, ": %s", tvb_ether_to_str(pinfo->pool, tvb, offset));
555 break;
556 case FT_EUI64_LEN:
557 proto_tree_add_item(pt, hf_dlep_dataitem_macaddr_eui64, tvb, offset, len, ENC_BIG_ENDIAN);
558 proto_item_append_text(pi, ": %s", tvb_eui64_to_str(pinfo->pool, tvb, offset));
559 break;
560 default:
561 proto_tree_add_expert(pt, NULL, &ei_dlep_dataitem_macaddr_unexpected_length, tvb, offset, len);
562 break;
564 offset+=len;
566 return offset;
569 /* Section 13.8: IPv4 Address */
570 static int
571 decode_dataitem_v4addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
573 proto_item *pi = proto_tree_get_parent(pt);
574 int offset = 0;
575 proto_item* tmp_pi = NULL;
576 proto_tree* flags_pt = NULL;
578 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4addr, tvb, offset, DLEP_DIT_V4ADDR_LEN, ENC_NA);
579 proto_item_set_hidden(tmp_pi);
581 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4addr_flags, tvb, offset, DLEP_DIT_V4ADDR_FLAGS_LEN, ENC_NA);
582 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
583 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v4addr_flags_adddrop, tvb, offset, DLEP_DIT_V4ADDR_FLAGS_LEN, ENC_BIG_ENDIAN);
584 proto_item_append_text(pi, ", %s:", tfs_get_string(tvb_get_uint8(tvb, offset) & DLEP_DIT_V4ADDR_FLAGMASK_ADDDROP, &tfs_add_drop));
585 offset+=DLEP_DIT_V4ADDR_FLAGS_LEN;
587 proto_tree_add_item(pt, hf_dlep_dataitem_v4addr_addr, tvb, offset, FT_IPv4_LEN, ENC_BIG_ENDIAN);
588 proto_item_append_text(pi, " %s", tvb_ip_to_str(pinfo->pool, tvb, offset));
589 offset+=FT_IPv4_LEN;
591 return offset;
594 /* Section 13.9: IPv6 Address */
595 static int
596 decode_dataitem_v6addr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
598 proto_item *pi = proto_tree_get_parent(pt);
599 int offset = 0;
600 proto_item* tmp_pi = NULL;
601 proto_tree* flags_pt = NULL;
603 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6addr, tvb, offset, DLEP_DIT_V6ADDR_LEN, ENC_NA);
604 proto_item_set_hidden(tmp_pi);
606 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6addr_flags, tvb, offset, DLEP_DIT_V6ADDR_FLAGS_LEN, ENC_NA);
607 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
608 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v6addr_flags_adddrop, tvb, offset, DLEP_DIT_V6ADDR_FLAGS_LEN, ENC_BIG_ENDIAN);
609 proto_item_append_text(pi, ", %s:", tfs_get_string(tvb_get_uint8(tvb, offset) & DLEP_DIT_V6ADDR_FLAGMASK_ADDDROP, &tfs_add_drop));
610 offset+=DLEP_DIT_V6ADDR_FLAGS_LEN;
612 proto_tree_add_item(pt, hf_dlep_dataitem_v6addr_addr, tvb, offset, FT_IPv6_LEN, ENC_NA);
613 proto_item_append_text(pi, " %s", tvb_ip6_to_str(pinfo->pool, tvb, offset));
614 offset+=FT_IPv6_LEN;
616 return offset;
619 /* Section 13.10: IPv4 Attached Subnet */
620 static int
621 decode_dataitem_v4subnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
623 proto_item *pi = proto_tree_get_parent(pt);
624 int offset = 0;
625 proto_item* tmp_pi = NULL;
626 proto_tree* flags_pt = NULL;
627 uint32_t prefixlen;
629 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4subnet, tvb, offset, DLEP_DIT_V4SUBNET_LEN, ENC_NA);
630 proto_item_set_hidden(tmp_pi);
632 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v4subnet_flags, tvb, offset, DLEP_DIT_V4SUBNET_FLAGS_LEN, ENC_NA);
633 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
634 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v4subnet_flags_adddrop, tvb, offset, DLEP_DIT_V4SUBNET_FLAGS_LEN, ENC_BIG_ENDIAN);
635 proto_item_append_text(pi, ", %s:", tfs_get_string(tvb_get_uint8(tvb, offset) & DLEP_DIT_V4SUBNET_FLAGMASK_ADDDROP, &tfs_add_drop));
636 offset+=DLEP_DIT_V4SUBNET_FLAGS_LEN;
638 proto_tree_add_item(pt, hf_dlep_dataitem_v4subnet_subnet, tvb, offset, FT_IPv4_LEN, ENC_BIG_ENDIAN);
639 proto_item_append_text(pi, " %s", tvb_ip_to_str(pinfo->pool, tvb, offset));
640 offset+=FT_IPv4_LEN;
642 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_v4subnet_prefixlen, tvb, offset, 1, ENC_BIG_ENDIAN, &prefixlen);
643 proto_item_append_text(pi, "/%u", prefixlen);
644 offset+=1;
646 return offset;
649 /* Section 13.11: IPv6 Attached Subnet */
650 static int
651 decode_dataitem_v6subnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
653 proto_item *pi = proto_tree_get_parent(pt);
654 int offset = 0;
655 proto_item* tmp_pi = NULL;
656 proto_tree* flags_pt = NULL;
657 uint32_t prefixlen;
659 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6subnet, tvb, offset, DLEP_DIT_V6SUBNET_LEN, ENC_NA);
660 proto_item_set_hidden(tmp_pi);
662 tmp_pi = proto_tree_add_item(pt, hf_dlep_dataitem_v6subnet_flags, tvb, offset, DLEP_DIT_V6SUBNET_FLAGS_LEN, ENC_NA);
663 flags_pt = proto_item_add_subtree(tmp_pi, ett_dlep_flags);
664 proto_tree_add_item(flags_pt, hf_dlep_dataitem_v6subnet_flags_adddrop, tvb, offset, DLEP_DIT_V6SUBNET_FLAGS_LEN, ENC_BIG_ENDIAN);
665 proto_item_append_text(pi, ", %s:", tfs_get_string(tvb_get_uint8(tvb, offset) & DLEP_DIT_V6SUBNET_FLAGMASK_ADDDROP, &tfs_add_drop));
666 offset+=DLEP_DIT_V6SUBNET_FLAGS_LEN;
668 proto_tree_add_item(pt, hf_dlep_dataitem_v6subnet_subnet, tvb, offset, FT_IPv6_LEN, ENC_NA);
669 proto_item_append_text(pi, " %s", tvb_ip6_to_str(pinfo->pool, tvb, offset));
670 offset+=FT_IPv6_LEN;
672 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_v6subnet_prefixlen, tvb, offset, 1, ENC_BIG_ENDIAN, &prefixlen);
673 proto_item_append_text(pi, "/%u", prefixlen);
674 offset+=1;
676 return offset;
679 /* Section 13.12: Maximum Data Rate (Receive) */
680 static int
681 decode_dataitem_mdrr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
683 proto_item *pi = proto_tree_get_parent(pt);
684 int offset = 0;
685 uint64_t mdrr;
687 proto_tree_add_item_ret_uint64(pt, hf_dlep_dataitem_mdrr, tvb, offset, DLEP_DIT_MDRR_LEN, ENC_BIG_ENDIAN, &mdrr);
688 proto_item_append_text(pi, ": %" PRIu64 " (bps)", mdrr);
689 offset+=DLEP_DIT_MDRR_LEN;
691 return offset;
694 /* Section 13.13: Maximum Data Rate (Transmit) */
695 static int
696 decode_dataitem_mdrt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
698 proto_item *pi = proto_tree_get_parent(pt);
699 int offset = 0;
700 uint64_t mdrt;
702 proto_tree_add_item_ret_uint64(pt, hf_dlep_dataitem_mdrt, tvb, offset, DLEP_DIT_MDRT_LEN, ENC_BIG_ENDIAN, &mdrt);
703 proto_item_append_text(pi, ": %" PRIu64 " (bps)", mdrt);
704 offset+=DLEP_DIT_MDRT_LEN;
706 return offset;
709 /* Section 13.14: Current Data Rate (Receive) */
710 static int
711 decode_dataitem_cdrr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
713 proto_item *pi = proto_tree_get_parent(pt);
714 int offset = 0;
715 uint64_t cdrr;
717 proto_tree_add_item_ret_uint64(pt, hf_dlep_dataitem_cdrr, tvb, offset, DLEP_DIT_CDRR_LEN, ENC_BIG_ENDIAN, &cdrr);
718 proto_item_append_text(pi, ": %" PRIu64 " (bps)", cdrr);
719 offset+=DLEP_DIT_CDRR_LEN;
721 return offset;
724 /* Section 13.15: Current Data Rate (Transmit) */
725 static int
726 decode_dataitem_cdrt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
728 proto_item *pi = proto_tree_get_parent(pt);
729 int offset = 0;
730 uint64_t cdrt;
732 proto_tree_add_item_ret_uint64(pt, hf_dlep_dataitem_cdrt, tvb, offset, DLEP_DIT_CDRT_LEN, ENC_BIG_ENDIAN, &cdrt);
733 proto_item_append_text(pi, ": %" PRIu64 " (bps)", cdrt);
734 offset+=DLEP_DIT_CDRT_LEN;
736 return offset;
739 /* Section 13.16: Latency */
740 static int
741 decode_dataitem_latency(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
743 proto_item *pi = proto_tree_get_parent(pt);
744 int offset = 0;
745 uint64_t latency;
747 proto_tree_add_item_ret_uint64(pt, hf_dlep_dataitem_latency, tvb, offset, DLEP_DIT_LAT_LEN, ENC_BIG_ENDIAN, &latency);
748 proto_item_append_text(pi, ": %" PRIu64 " (us)", latency);
749 offset+=DLEP_DIT_LAT_LEN;
751 return offset;
754 /* Section 13.17: Resources */
755 static int
756 decode_dataitem_resources(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
758 proto_item *pi = proto_tree_get_parent(pt);
759 int offset = 0;
760 uint32_t resources;
762 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_resources, tvb, offset, DLEP_DIT_RES_LEN, ENC_BIG_ENDIAN, &resources);
763 proto_item_append_text(pi, ": %u (%%)", resources);
764 offset+=DLEP_DIT_RES_LEN;
766 return offset;
769 /* Section 13.18: Relative Link Quality (Receive) */
770 static int
771 decode_dataitem_rlqr(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
773 proto_item *pi = proto_tree_get_parent(pt);
774 int offset = 0;
775 uint32_t rlqr;
777 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_rlqr, tvb, offset, DLEP_DIT_RLQR_LEN, ENC_BIG_ENDIAN, &rlqr);
778 proto_item_append_text(pi, ": %u (%%)", rlqr);
779 offset+=DLEP_DIT_RLQR_LEN;
781 return offset;
784 /* Section 13.19: Relative Link Quality (Transmit) */
785 static int
786 decode_dataitem_rlqt(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
788 proto_item *pi = proto_tree_get_parent(pt);
789 int offset = 0;
790 uint32_t rlqt;
792 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_rlqt, tvb, offset, DLEP_DIT_RLQT_LEN, ENC_BIG_ENDIAN, &rlqt);
793 proto_item_append_text(pi, ": %u (%%)", rlqt);
794 offset+=DLEP_DIT_RLQT_LEN;
796 return offset;
799 /* Section 11.20: Maximum Transmission Unit (MTU) */
800 static int
801 decode_dataitem_mtu(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *pt, void *data _U_)
803 proto_item *pi = proto_tree_get_parent(pt);
804 int offset = 0;
805 uint32_t mtu;
807 proto_tree_add_item_ret_uint(pt, hf_dlep_dataitem_mtu, tvb, offset, DLEP_DIT_MTU_LEN, ENC_BIG_ENDIAN, &mtu);
808 proto_item_append_text(pi, ": %u (bytes)", mtu);
809 offset+=DLEP_DIT_MTU_LEN;
811 return offset;
814 /* RFC 8629 Multi-Hop Extension Hop Count*/
815 static int
816 decode_dataitem_hop_cnt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
818 proto_item *pi = proto_tree_get_parent(pt);
819 int offset = 0;
820 proto_item *pi_field = NULL;
821 static int * const hop_cnt_flags[] = {
822 &hf_dlep_dataitem_hop_count_flags_p,
823 &hf_dlep_dataitem_hop_count_flags_reserved,
824 NULL
827 proto_tree_add_bitmask(pt, tvb, offset, hf_dlep_dataitem_hop_count_flags, ett_dlep_flags, hop_cnt_flags, ENC_BIG_ENDIAN);
828 offset+=1;
829 pi_field = proto_tree_add_item(pt, hf_dlep_dataitem_hop_count, tvb, offset, 1, ENC_NA);
830 proto_item_append_text(pi, ": %s Hops", proto_item_get_display_repr(pinfo->pool, pi_field));
831 offset+=1;
833 return offset;
836 /* RFC 8629 Multi-Hop Extension Hop Control*/
837 static int
838 decode_dataitem_hop_cntrl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
840 proto_item *pi = proto_tree_get_parent(pt);
841 int offset = 0;
842 proto_item *pi_field = NULL;
844 pi_field = proto_tree_add_item(pt, hf_dlep_dataitem_hop_control, tvb, offset, DLEP_DIT_HOP_CNTRL_LEN, ENC_BIG_ENDIAN);
845 proto_item_append_text(pi, ": %s", proto_item_get_display_repr(pinfo->pool, pi_field));
846 offset+=DLEP_DIT_HOP_CNTRL_LEN;
848 return offset;
851 /* RFC 8703 Link Identifier Extension Length */
852 static int
853 decode_dataitem_li_length(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
855 proto_item *pi = proto_tree_get_parent(pt);
856 int offset = 0;
857 proto_item *pi_field = NULL;
859 pi_field = proto_tree_add_item(pt, hf_dlep_dataitem_li_length, tvb, offset, DLEP_DIT_LI_LENGTH_LEN, ENC_BIG_ENDIAN);
860 proto_item_append_text(pi, ": %s Bytes", proto_item_get_display_repr(pinfo->pool, pi_field));
861 offset+=DLEP_DIT_LI_LENGTH_LEN;
863 return offset;
866 /* RFC 8703 Link Identifier Extension Data */
867 static int
868 decode_dataitem_li(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
870 proto_item *pi = proto_tree_get_parent(pt);
871 const int len = tvb_captured_length(tvb);
872 int offset = 0;
874 proto_tree_add_item(pt, hf_dlep_dataitem_li, tvb, offset, len, ENC_NA);
875 proto_item_append_text(pi, ": %s", tvb_bytes_to_str(pinfo->pool, tvb, offset, len));
876 offset+=len;
878 return offset;
881 /* RFC 8757 Latency Range Extension */
882 static int
883 decode_dataitem_lat_range(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
885 proto_item *pi = proto_tree_get_parent(pt);
886 int offset = 0;
887 proto_item *max_lat = NULL;
888 proto_item *min_lat = NULL;
890 max_lat = proto_tree_add_item(pt, hf_dlep_dataitem_max_lat, tvb, offset, 8, ENC_BIG_ENDIAN);
891 offset+=8;
892 min_lat = proto_tree_add_item(pt, hf_dlep_dataitem_min_lat, tvb, offset, 8, ENC_BIG_ENDIAN);
893 proto_item_append_text(pi, ": %s - %s (us)", proto_item_get_display_repr(pinfo->pool, min_lat), proto_item_get_display_repr(pinfo->pool, max_lat));
894 offset+=8;
896 return offset;
900 * Section 11.3: DLEP Generic Data Item
902 * A note on dataitem decoding:
904 * When decoding a specific dataitem, we append information to the generic
905 * dataitem's protocol display line using proto_item_append_text. This is
906 * intended to provide a one-line summary of the specific dataitem without
907 * needing to open the corresponding subtree. The pattern is to typically
908 * augment the one-line summary as each piece of the specific dataitem is
909 * decoded.
911 * Additionally, we often create a hidden proto_item under the generic
912 * dataitem tree that can be used for filtering on the specific dataitem name.
913 * Subfields of the specific dataitem are then placed under the generic
914 * dataitem tree. For example, the following filter 'dlep.dataitem.status' is
915 * valid, but the protocol tree display places 'dlep.dataitem.status.code'
916 * under 'dlep.dataitem'. For very simple dataitems (e.g., Heartbeat Interval),
917 * there is only one subfield, and this step is skipped.
919 static int
920 decode_dataitem(tvbuff_t *tvb, volatile int offset, proto_tree *pt, packet_info *pinfo)
922 proto_item *dataitem_pi = NULL;
923 proto_tree *dataitem_pt = NULL;
924 int dataitem_type = 0;
925 int dataitem_length = 0;
926 tvbuff_t *dataitem_tvb = NULL;
927 volatile int used_length = 0;
929 dataitem_type = tvb_get_ntohs(tvb, offset);
930 dataitem_length = tvb_get_ntohs(tvb, offset+2);
932 dataitem_pi = proto_tree_add_item(pt, hf_dlep_dataitem, tvb, offset, 2+2+dataitem_length, ENC_NA);
933 dataitem_pt = proto_item_add_subtree(dataitem_pi, ett_dlep_dataitem);
935 /* Start the one-line description of the data item */
936 proto_item_set_text(dataitem_pi, "%s Data Item", val_to_str_const(dataitem_type, dataitem_type_vals, "Unknown"));
938 /* Add supporting fields underneath */
939 proto_tree_add_item(dataitem_pt, hf_dlep_dataitem_type, tvb, offset, 2, ENC_BIG_ENDIAN);
940 offset+=2;
942 proto_tree_add_item(dataitem_pt, hf_dlep_dataitem_length, tvb, offset, 2, ENC_BIG_ENDIAN);
943 offset+=2;
945 dataitem_tvb = tvb_new_subset_length(tvb, offset, dataitem_length);
946 TRY {
947 used_length = dissector_try_uint(dlep_dataitem_table, dataitem_type, dataitem_tvb, pinfo, dataitem_pt);
949 CATCH_BOUNDS_ERRORS {
950 expert_add_info(pinfo, dataitem_pi, &ei_dlep_dataitem_unexpected_length);
951 used_length = dataitem_length;
953 ENDTRY;
954 if (used_length == 0) {
955 proto_tree_add_item(dataitem_pt, hf_dlep_dataitem_value, dataitem_tvb, 0, dataitem_length, ENC_NA);
957 else if (used_length != dataitem_length) {
958 expert_add_info(pinfo, dataitem_pi, &ei_dlep_dataitem_unexpected_length);
960 offset+=dataitem_length;
962 return offset;
965 /* Section 11.1: DLEP Signal Header */
966 static int
967 decode_signal_header(tvbuff_t *tvb, int offset, proto_item* pi, proto_tree *pt, packet_info *pinfo)
969 proto_item *tmp_pi = NULL;
970 uint32_t signal_type;
971 uint32_t signal_length;
973 tmp_pi = proto_tree_add_item(pt, hf_dlep_signal, tvb, offset, 0, ENC_NA);
974 proto_item_set_hidden(tmp_pi);
976 proto_tree_add_item(pt, hf_dlep_signal_signature, tvb, offset, 4, ENC_ASCII);
977 offset+=4;
979 proto_tree_add_item_ret_uint(pt, hf_dlep_signal_type, tvb, offset, 2, ENC_BIG_ENDIAN, &signal_type);
980 proto_item_append_text(pi, ", Signal: %s (%u)", val_to_str_const(signal_type, signal_type_vals, "Unknown"), signal_type);
981 col_add_fstr(pinfo->cinfo, COL_INFO, "Signal: %s (%u)", val_to_str_const(signal_type, signal_type_vals, "Unknown"), signal_type);
982 offset+=2;
984 tmp_pi = proto_tree_add_item_ret_uint(pt, hf_dlep_signal_length, tvb, offset, 2, ENC_BIG_ENDIAN, &signal_length);
985 offset+=2;
987 if (signal_length != (uint32_t)tvb_reported_length_remaining(tvb, offset))
988 expert_add_info(pinfo, tmp_pi, &ei_dlep_signal_unexpected_length);
990 return offset;
993 /* Section 11.2: DLEP Message Header */
994 static unsigned
995 get_dlep_message_header_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
997 unsigned message_length;
999 message_length = tvb_get_uint16(tvb, offset+2, ENC_BIG_ENDIAN);
1001 return message_length + DLEP_MSG_HEADER_LEN;
1004 static int
1005 decode_message_header(tvbuff_t *tvb, int offset, proto_item* pi, proto_tree *pt, packet_info *pinfo)
1007 proto_item *tmp_pi = NULL;
1008 uint32_t message_type;
1009 uint32_t message_length;
1011 tmp_pi = proto_tree_add_item(pt, hf_dlep_message, tvb, offset, 0, ENC_NA);
1012 proto_item_set_hidden(tmp_pi);
1014 proto_tree_add_item_ret_uint(pt, hf_dlep_message_type, tvb, offset, 2, ENC_BIG_ENDIAN, &message_type);
1015 proto_item_append_text(pi, ", Message: %s (%u)", val_to_str_const(message_type, message_type_vals, "Unknown"), message_type);
1016 col_add_fstr(pinfo->cinfo, COL_INFO, "Message: %s (%u)", val_to_str_const(message_type, message_type_vals, "Unknown"), message_type);
1017 offset+=2;
1019 tmp_pi = proto_tree_add_item_ret_uint(pt, hf_dlep_message_length, tvb, offset, 2, ENC_BIG_ENDIAN, &message_length);
1020 offset+=2;
1022 if (message_length != (uint32_t)tvb_reported_length_remaining(tvb, offset))
1023 expert_add_info(pinfo, tmp_pi, &ei_dlep_message_unexpected_length);
1025 return offset;
1028 static int
1029 dissect_dlep_sig(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
1031 int offset = 0;
1032 proto_item *dlep_pi = NULL;
1033 proto_tree *dlep_pt = NULL;
1035 /* init column strings */
1036 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DLEP");
1037 col_clear(pinfo->cinfo, COL_INFO);
1039 dlep_pi = proto_tree_add_item(pt, proto_dlep, tvb, 0, -1, ENC_NA);
1040 dlep_pt = proto_item_add_subtree(dlep_pi, ett_dlep);
1042 /* decode dlep header */
1043 offset = decode_signal_header(tvb, offset, dlep_pi, dlep_pt, pinfo);
1045 /* decode dlep dataitems */
1046 while (tvb_reported_length_remaining(tvb, offset) > 0) {
1047 offset = decode_dataitem(tvb, offset, dlep_pt, pinfo);
1050 return tvb_captured_length(tvb);
1053 static int
1054 dissect_dlep_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *pt, void *data _U_)
1056 int offset = 0;
1057 proto_item *dlep_pi = NULL;
1058 proto_tree *dlep_pt = NULL;
1060 /* init column strings */
1061 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DLEP");
1062 col_clear(pinfo->cinfo, COL_INFO);
1064 dlep_pi = proto_tree_add_item(pt, proto_dlep, tvb, 0, -1, ENC_NA);
1065 dlep_pt = proto_item_add_subtree(dlep_pi, ett_dlep);
1067 /* decode dlep header */
1068 offset = decode_message_header(tvb, offset, dlep_pi, dlep_pt, pinfo);
1070 /* decode dlep dataitems */
1071 while (tvb_reported_length_remaining(tvb, offset) > 0) {
1072 offset = decode_dataitem(tvb, offset, dlep_pt, pinfo);
1075 return tvb_captured_length(tvb);
1078 static int
1079 dissect_dlep_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1081 tcp_dissect_pdus(tvb, pinfo, tree, dlep_desegment, DLEP_MSG_HEADER_LEN, get_dlep_message_header_len, dissect_dlep_msg, data);
1082 return tvb_reported_length(tvb);
1085 void
1086 proto_register_dlep(void)
1088 module_t* dlep_module;
1089 expert_module_t* dlep_expert_module;
1091 static hf_register_info hf[] = {
1092 /* name, abbrev, type, display, strings, bitmask, blurb */
1093 { &hf_dlep_signal,
1094 { "Signal", "dlep.signal", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1096 { &hf_dlep_signal_signature,
1097 { "Signature", "dlep.signal.signature", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
1099 { &hf_dlep_signal_type,
1100 { "Signal Type", "dlep.signal.type", FT_UINT16, BASE_DEC, VALS(signal_type_vals), 0x0, NULL, HFILL }
1102 { &hf_dlep_signal_length,
1103 { "Signal Length (bytes)", "dlep.signal.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1105 { &hf_dlep_message,
1106 { "Message", "dlep.message", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1108 { &hf_dlep_message_type,
1109 { "Message Type", "dlep.message.type", FT_UINT16, BASE_DEC, VALS(message_type_vals), 0x0, NULL, HFILL }
1111 { &hf_dlep_message_length,
1112 { "Message Length (bytes)", "dlep.message.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1114 { &hf_dlep_dataitem,
1115 { "Data Item", "dlep.dataitem", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1117 { &hf_dlep_dataitem_type,
1118 { "Type", "dlep.dataitem.type", FT_UINT16, BASE_DEC, VALS(dataitem_type_vals), 0x0, NULL, HFILL }
1120 { &hf_dlep_dataitem_length,
1121 { "Length (bytes)", "dlep.dataitem.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1123 { &hf_dlep_dataitem_value,
1124 { "Value", "dlep.dataitem.value", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1126 { &hf_dlep_dataitem_status,
1127 { "Status", "dlep.dataitem.status", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1129 { &hf_dlep_dataitem_status_code,
1130 { "Code", "dlep.dataitem.status.code", FT_UINT8, BASE_DEC, VALS(status_code_vals), 0x0, NULL, HFILL }
1132 { &hf_dlep_dataitem_status_text,
1133 { "Text", "dlep.dataitem.status.text", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
1135 { &hf_dlep_dataitem_v4conn,
1136 { "IPv4 Connection Point", "dlep.dataitem.v4conn", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1138 { &hf_dlep_dataitem_v4conn_flags,
1139 { "Flags", "dlep.dataitem.v4conn.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1141 { &hf_dlep_dataitem_v4conn_flags_tls,
1142 { "Use TLS Indicator", "dlep.dataitem.v4conn.flags.tls", FT_BOOLEAN, DLEP_DIT_V4CONN_FLAGMASK_BITLEN, TFS(&tfs_set_notset), DLEP_DIT_V4CONN_FLAGMASK_TLS, NULL, HFILL }
1144 { &hf_dlep_dataitem_v4conn_addr,
1145 { "Address", "dlep.dataitem.v4conn.addr", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1147 { &hf_dlep_dataitem_v4conn_port,
1148 { "Port", "dlep.dataitem.v4conn.port", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1150 { &hf_dlep_dataitem_v6conn,
1151 { "IPv6 Connection Point", "dlep.dataitem.v6conn", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1153 { &hf_dlep_dataitem_v6conn_flags,
1154 { "Flags", "dlep.dataitem.v6conn.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1156 { &hf_dlep_dataitem_v6conn_flags_tls,
1157 { "Use TLS Indicator", "dlep.dataitem.v6conn.flags.tls", FT_BOOLEAN, DLEP_DIT_V6CONN_FLAGMASK_BITLEN, TFS(&tfs_set_notset), DLEP_DIT_V6CONN_FLAGMASK_TLS, NULL, HFILL }
1159 { &hf_dlep_dataitem_v6conn_addr,
1160 { "Address", "dlep.dataitem.v6conn.addr", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }
1162 { &hf_dlep_dataitem_v6conn_port,
1163 { "Port", "dlep.dataitem.v6conn.port", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1165 { &hf_dlep_dataitem_peertype,
1166 { "Peer Type", "dlep.dataitem.peertype", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1168 { &hf_dlep_dataitem_peertype_flags,
1169 { "Flags", "dlep.dataitem.peertype.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1171 { &hf_dlep_dataitem_peertype_flags_smi,
1172 { "Secure Medium Indicator", "dlep.dataitem.peertype.flags.smi", FT_BOOLEAN, DLEP_DIT_PEERTYPE_FLAGMASK_BITLEN, TFS(&tfs_set_notset), DLEP_DIT_PEERTYPE_FLAGMASK_SMI, NULL, HFILL }
1174 { &hf_dlep_dataitem_peertype_description,
1175 { "Text", "dlep.dataitem.peertype.description", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }
1177 { &hf_dlep_dataitem_heartbeat,
1178 { "Heartbeat Interval (ms)", "dlep.dataitem.heartbeat", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }
1180 { &hf_dlep_dataitem_extsupp,
1181 { "Extensions Supported", "dlep.dataitem.extsupp", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1183 { &hf_dlep_dataitem_extsupp_code,
1184 { "Code", "dlep.dataitem.extsupp.code", FT_UINT32, BASE_DEC|BASE_RANGE_STRING, RVALS(extension_code_vals), 0x0, NULL, HFILL }
1186 { &hf_dlep_dataitem_macaddr_eui48,
1187 { "MAC Address", "dlep.dataitem.macaddr_eui48", FT_ETHER, BASE_NONE, NULL, 0x0, NULL, HFILL }
1189 { &hf_dlep_dataitem_macaddr_eui64,
1190 { "MAC Address", "dlep.dataitem.macaddr_eui64", FT_EUI64, BASE_NONE, NULL, 0x0, NULL, HFILL }
1192 { &hf_dlep_dataitem_v4addr,
1193 { "IPv4 Address", "dlep.dataitem.v4addr", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1195 { &hf_dlep_dataitem_v4addr_flags,
1196 { "Flags", "dlep.dataitem.v4addr.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1198 { &hf_dlep_dataitem_v4addr_flags_adddrop,
1199 { "Add/Drop Indicator", "dlep.dataitem.v4addr.flags.adddrop", FT_BOOLEAN, DLEP_DIT_V4ADDR_FLAGMASK_BITLEN, TFS(&tfs_add_drop), DLEP_DIT_V4ADDR_FLAGMASK_ADDDROP, NULL, HFILL }
1201 { &hf_dlep_dataitem_v4addr_addr,
1202 { "Address", "dlep.dataitem.v4addr.addr", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1204 { &hf_dlep_dataitem_v6addr,
1205 { "IPv6 Address", "dlep.dataitem.v6addr", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1207 { &hf_dlep_dataitem_v6addr_flags,
1208 { "Flags", "dlep.dataitem.v6addr.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1210 { &hf_dlep_dataitem_v6addr_flags_adddrop,
1211 { "Add/Drop Indicator", "dlep.dataitem.v6addr.flags.adddrop", FT_BOOLEAN, DLEP_DIT_V6ADDR_FLAGMASK_BITLEN, TFS(&tfs_add_drop), DLEP_DIT_V6ADDR_FLAGMASK_ADDDROP, NULL, HFILL }
1213 { &hf_dlep_dataitem_v6addr_addr,
1214 { "Address", "dlep.dataitem.v6addr.addr", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }
1216 { &hf_dlep_dataitem_v4subnet,
1217 { "IPv4 Attached Subnet", "dlep.dataitem.v4subnet", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1219 { &hf_dlep_dataitem_v4subnet_flags,
1220 { "Flags", "dlep.dataitem.v4subnet.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1222 { &hf_dlep_dataitem_v4subnet_flags_adddrop,
1223 { "Add/Drop Indicator", "dlep.dataitem.v4subnet.flags.adddrop", FT_BOOLEAN, DLEP_DIT_V4SUBNET_FLAGMASK_BITLEN, TFS(&tfs_add_drop), DLEP_DIT_V4SUBNET_FLAGMASK_ADDDROP, NULL, HFILL }
1225 { &hf_dlep_dataitem_v4subnet_subnet,
1226 { "Subnet", "dlep.dataitem.v4subnet.subnet", FT_IPv4, BASE_NONE, NULL, 0x0, NULL, HFILL }
1228 { &hf_dlep_dataitem_v4subnet_prefixlen,
1229 { "Prefix Length", "dlep.dataitem.v4subnet.prefixlen", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1231 { &hf_dlep_dataitem_v6subnet,
1232 { "IPv6 Attached Subnet", "dlep.dataitem.v6subnet", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL }
1234 { &hf_dlep_dataitem_v6subnet_flags,
1235 { "Flags", "dlep.dataitem.v6subnet.flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1237 { &hf_dlep_dataitem_v6subnet_flags_adddrop,
1238 { "Add/Drop Indicator", "dlep.dataitem.v6subnet.flags.adddrop", FT_BOOLEAN, DLEP_DIT_V6SUBNET_FLAGMASK_BITLEN, TFS(&tfs_add_drop), DLEP_DIT_V6SUBNET_FLAGMASK_ADDDROP, NULL, HFILL }
1240 { &hf_dlep_dataitem_v6subnet_subnet,
1241 { "Subnet", "dlep.dataitem.v6subnet.subnet", FT_IPv6, BASE_NONE, NULL, 0x0, NULL, HFILL }
1243 { &hf_dlep_dataitem_v6subnet_prefixlen,
1244 { "Prefix Length", "dlep.dataitem.v6subnet.prefixlen", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1246 { &hf_dlep_dataitem_mdrr,
1247 { "Maximum Data Rate (Receive) (bps)", "dlep.dataitem.mdrr", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1249 { &hf_dlep_dataitem_mdrt,
1250 { "Maximum Data Rate (Transmit) (bps)", "dlep.dataitem.mdrt", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1252 { &hf_dlep_dataitem_cdrr,
1253 { "Current Data Rate (Receive) (bps)", "dlep.dataitem.cdrr", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1255 { &hf_dlep_dataitem_cdrt,
1256 { "Current Data Rate (Transmit) (bps)", "dlep.dataitem.cdrt", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1258 { &hf_dlep_dataitem_latency,
1259 { "Latency (us)", "dlep.dataitem.latency", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1261 { &hf_dlep_dataitem_resources,
1262 { "Resources (%)", "dlep.dataitem.resources", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1264 { &hf_dlep_dataitem_rlqr,
1265 { "Relative Link Quality (Receive) (%)", "dlep.dataitem.rlqr", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1267 { &hf_dlep_dataitem_rlqt,
1268 { "Relative Link Quality (Transmit) (%)", "dlep.dataitem.rlqt", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1270 { &hf_dlep_dataitem_mtu,
1271 { "Maximum Transmission Unit (bytes)", "dlep.dataitem.mtu", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1273 { &hf_dlep_dataitem_hop_count_flags,
1274 { "Flags", "dlep.dataitem.hop_count_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL }
1276 { &hf_dlep_dataitem_hop_count_flags_p,
1277 { "P-Bit", "dlep.dataitem.hop_count_flags.p", FT_BOOLEAN, 8, TFS(&tfs_set_notset), DLEP_DIT_HOP_CNT_FLAGMASK_P, "Destination is potentially directly reachable", HFILL }
1279 { &hf_dlep_dataitem_hop_count_flags_reserved,
1280 { "Reserved", "dlep.dataitem.hop_count_flags.reserved", FT_UINT8, BASE_HEX, NULL, DLEP_DIT_HOP_CNT_FLAGMASK_RESERVED, NULL, HFILL }
1282 { &hf_dlep_dataitem_hop_count,
1283 { "Hop Count", "dlep.dataitem.hop_count", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }
1285 { &hf_dlep_dataitem_hop_control,
1286 { "Hop Control", "dlep.dataitem.hop_control", FT_UINT16, BASE_DEC|BASE_RANGE_STRING, RVALS(hop_cntrl_action_vals), 0x0, NULL, HFILL }
1288 { &hf_dlep_dataitem_li_length,
1289 { "Link Identifier Length", "dlep.dataitem.link_identifier_length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }
1291 { &hf_dlep_dataitem_li,
1292 { "Link Identifier", "dlep.dataitem.link_identifier", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL }
1294 { &hf_dlep_dataitem_max_lat,
1295 { "Maximum Latency (us)", "dlep.dataitem.max_latency", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1297 { &hf_dlep_dataitem_min_lat,
1298 { "Minimum Latency (us)", "dlep.dataitem.min_latency", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL }
1302 static int *ett[] = {
1303 &ett_dlep,
1304 &ett_dlep_dataitem,
1305 &ett_dlep_flags
1308 static ei_register_info ei[] = {
1309 { &ei_dlep_signal_unexpected_length, { "dlep.signal.unexpected_length", PI_PROTOCOL, PI_WARN, "Message length does not match reported length remaining", EXPFILL }},
1310 { &ei_dlep_message_unexpected_length, { "dlep.message.unexpected_length", PI_PROTOCOL, PI_WARN, "Signal length does not match reported length remaining", EXPFILL }},
1311 { &ei_dlep_dataitem_unexpected_length, { "dlep.dataitem.unexpected_length", PI_PROTOCOL, PI_WARN, "Unexpected Data Item length", EXPFILL }},
1312 { &ei_dlep_dataitem_macaddr_unexpected_length, { "dlep.dataitem.macaddr.unexpected_length", PI_PROTOCOL, PI_WARN, "Unexpected MAC Address length", EXPFILL }},
1315 proto_dlep = proto_register_protocol("Dynamic Link Exchange Protocol", "DLEP", "dlep");
1316 dlep_msg_handle = register_dissector ("dlep.tcp", dissect_dlep_tcp, proto_dlep);
1317 dlep_sig_handle = register_dissector ("dlep.udp", dissect_dlep_sig, proto_dlep);
1319 dlep_dataitem_table = register_dissector_table("dlep.dataitem", "DLEP Data Item Type", proto_dlep, FT_UINT16, BASE_DEC);
1320 proto_dataitem = proto_register_protocol_in_name_only("DLEP Data Item Dissector", "DLEP Data Item", "dlep.dataitem", proto_dlep, FT_BYTES);
1321 dissector_add_uint("dlep.dataitem", DLEP_DIT_STATUS, create_dissector_handle(decode_dataitem_status, proto_dataitem));
1322 dissector_add_uint("dlep.dataitem", DLEP_DIT_V4CONN, create_dissector_handle(decode_dataitem_v4conn, proto_dataitem));
1323 dissector_add_uint("dlep.dataitem", DLEP_DIT_V6CONN, create_dissector_handle(decode_dataitem_v6conn, proto_dataitem));
1324 dissector_add_uint("dlep.dataitem", DLEP_DIT_PEERTYPE, create_dissector_handle(decode_dataitem_peertype, proto_dataitem));
1325 dissector_add_uint("dlep.dataitem", DLEP_DIT_HEARTBEAT, create_dissector_handle(decode_dataitem_heartbeat, proto_dataitem));
1326 dissector_add_uint("dlep.dataitem", DLEP_DIT_EXTSUPP, create_dissector_handle(decode_dataitem_extsupp, proto_dataitem));
1327 dissector_add_uint("dlep.dataitem", DLEP_DIT_MACADDR, create_dissector_handle(decode_dataitem_macaddr, proto_dataitem));
1328 dissector_add_uint("dlep.dataitem", DLEP_DIT_V4ADDR, create_dissector_handle(decode_dataitem_v4addr, proto_dataitem));
1329 dissector_add_uint("dlep.dataitem", DLEP_DIT_V6ADDR, create_dissector_handle(decode_dataitem_v6addr, proto_dataitem));
1330 dissector_add_uint("dlep.dataitem", DLEP_DIT_V4SUBNET, create_dissector_handle(decode_dataitem_v4subnet, proto_dataitem));
1331 dissector_add_uint("dlep.dataitem", DLEP_DIT_V6SUBNET, create_dissector_handle(decode_dataitem_v6subnet, proto_dataitem));
1332 dissector_add_uint("dlep.dataitem", DLEP_DIT_MDRR, create_dissector_handle(decode_dataitem_mdrr, proto_dataitem));
1333 dissector_add_uint("dlep.dataitem", DLEP_DIT_MDRT, create_dissector_handle(decode_dataitem_mdrt, proto_dataitem));
1334 dissector_add_uint("dlep.dataitem", DLEP_DIT_CDRR, create_dissector_handle(decode_dataitem_cdrr, proto_dataitem));
1335 dissector_add_uint("dlep.dataitem", DLEP_DIT_CDRT, create_dissector_handle(decode_dataitem_cdrt, proto_dataitem));
1336 dissector_add_uint("dlep.dataitem", DLEP_DIT_LAT, create_dissector_handle(decode_dataitem_latency, proto_dataitem));
1337 dissector_add_uint("dlep.dataitem", DLEP_DIT_RES, create_dissector_handle(decode_dataitem_resources, proto_dataitem));
1338 dissector_add_uint("dlep.dataitem", DLEP_DIT_RLQR, create_dissector_handle(decode_dataitem_rlqr, proto_dataitem));
1339 dissector_add_uint("dlep.dataitem", DLEP_DIT_RLQT, create_dissector_handle(decode_dataitem_rlqt, proto_dataitem));
1340 dissector_add_uint("dlep.dataitem", DLEP_DIT_MTU, create_dissector_handle(decode_dataitem_mtu, proto_dataitem));
1341 dissector_add_uint("dlep.dataitem", DLEP_DIT_HOP_CNT, create_dissector_handle(decode_dataitem_hop_cnt, proto_dataitem));
1342 dissector_add_uint("dlep.dataitem", DLEP_DIT_HOP_CNTRL, create_dissector_handle(decode_dataitem_hop_cntrl, proto_dataitem));
1343 dissector_add_uint("dlep.dataitem", DLEP_DIT_LI_LENGTH, create_dissector_handle(decode_dataitem_li_length, proto_dataitem));
1344 dissector_add_uint("dlep.dataitem", DLEP_DIT_LI, create_dissector_handle(decode_dataitem_li, proto_dataitem));
1345 dissector_add_uint("dlep.dataitem", DLEP_DIT_LAT_RANGE, create_dissector_handle(decode_dataitem_lat_range, proto_dataitem));
1347 proto_register_field_array(proto_dlep, hf, array_length(hf));
1348 proto_register_subtree_array(ett, array_length(ett));
1350 dlep_module = prefs_register_protocol(proto_dlep, NULL);
1351 prefs_register_bool_preference(dlep_module, "desegment",
1352 "Reassemble DLEP messages spanning multiple TCP segments",
1353 "Whether the DLEP dissector should reassemble messages spanning multiple TCP segments."
1354 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
1355 &dlep_desegment);
1357 dlep_expert_module = expert_register_protocol(proto_dlep);
1358 expert_register_field_array(dlep_expert_module, ei, array_length(ei));
1361 void
1362 proto_reg_handoff_dlep(void)
1364 dissector_add_uint_range_with_preference("tcp.port", DLEP_TCP_PORT, dlep_msg_handle);
1365 dissector_add_uint_range_with_preference("udp.port", DLEP_UDP_PORT, dlep_sig_handle);