2 * Routines for ISC DHCP Server failover protocol dissection
3 * Copyright 2004, M. Ortega y Strupp <moys@loplof.de>
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
13 * This implementation is loosely based on draft-ietf-dhc-failover-07.txt.
14 * As this document does not represent the actual implementation, the
15 * source code of ISC DHCPD 3.0 was used too.
19 * https://tools.ietf.org/html/draft-ietf-dhc-failover-10
21 * upon which the handling of the message-digest option is based.
23 * Updated to https://tools.ietf.org/html/draft-ietf-dhc-failover-12, July 2020
25 * Updated with Microsoft DHCP Failover Protocol Extension in August 2023:
26 * https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-dhcpf/380744f9-17ed-4aef-8810-ef08d1e70932
31 #include <epan/packet.h>
32 #include <epan/strutil.h>
33 #include <epan/prefs.h>
34 #include <epan/expert.h>
35 #include <epan/to_str.h>
37 #include <epan/unit_strings.h>
39 #include "packet-arp.h"
40 #include "packet-tcp.h"
42 #define TCP_PORT_DHCPFO 647 /* Not IANA registered */
44 void proto_register_dhcpfo(void);
45 void proto_reg_handoff_dhcpfo(void);
47 static dissector_handle_t dhcpfo_handle
;
49 /* desegmentation of DHCP failover over TCP */
50 static bool dhcpfo_desegment
= true;
52 /* enum preference to interpret Microsoft-formatted fields correctly */
53 #define AUTODETECT_MS_DHCP 0
54 #define DISSECT_IEFT_DRAFT 1
55 #define DISSECT_MS_DHCP 2
56 static const enum_val_t microsoft_compatibility
[] = {
57 { "autodetect_ms_dhcp", "Autodetect Microsoft Windows DHCP server", AUTODETECT_MS_DHCP
},
58 { "dissect_ietf_draft", "Dissect using IETF draft 12 specifications", DISSECT_IEFT_DRAFT
},
59 { "dissect_ms_dhcp", "Dissect using Microsoft-style formatting", DISSECT_MS_DHCP
},
62 static int dhcpfo_microsoft_compatibility
= AUTODETECT_MS_DHCP
;
64 /* Initialize the protocol and registered fields */
65 static int proto_dhcpfo
;
66 static int hf_dhcpfo_length
;
67 static int hf_dhcpfo_type
;
68 static int hf_dhcpfo_poffset
;
69 static int hf_dhcpfo_time
;
70 static int hf_dhcpfo_xid
;
71 static int hf_dhcpfo_additional_HB
;
72 static int hf_dhcpfo_payload_data
;
73 static int hf_dhcpfo_option_code
;
74 static int hf_dhcpfo_dhcp_style_option
;
75 static int hf_dhcpfo_option_length
;
76 static int hf_dhcpfo_binding_status
;
77 static int hf_dhcpfo_server_state
;
78 static int hf_dhcpfo_assigned_ip_address
;
79 static int hf_dhcpfo_delayed_service_parameter
;
80 static int hf_dhcpfo_addresses_transferred
;
81 static int hf_dhcpfo_client_identifier
;
82 static int hf_dhcpfo_client_hw_type
;
83 static int hf_dhcpfo_client_hardware_address
;
84 static int hf_dhcpfo_ftddns
;
85 static int hf_dhcpfo_reject_reason
;
86 static int hf_dhcpfo_relationship_name
;
87 static int hf_dhcpfo_message
;
88 static int hf_dhcpfo_mclt
;
89 static int hf_dhcpfo_vendor_class
;
90 static int hf_dhcpfo_lease_expiration_time
;
91 static int hf_dhcpfo_potential_expiration_time
;
92 static int hf_dhcpfo_client_last_transaction_time
;
93 static int hf_dhcpfo_start_time_of_state
;
94 static int hf_dhcpfo_vendor_option
;
95 static int hf_dhcpfo_max_unacked_bndupd
;
96 static int hf_dhcpfo_protocol_version
;
97 static int hf_dhcpfo_receive_timer
;
98 static int hf_dhcpfo_message_digest
;
99 static int hf_dhcpfo_ipflags
;
100 static int hf_dhcpfo_ipflags_reserved
;
101 static int hf_dhcpfo_ipflags_bootp
;
102 static int hf_dhcpfo_ipflags_mbz
;
103 static int hf_dhcpfo_hash_bucket_assignment
;
104 static int hf_dhcpfo_message_digest_type
;
105 static int hf_dhcpfo_tls_request
;
106 static int hf_dhcpfo_tls_reply
;
107 static int hf_dhcpfo_serverflag
;
108 static int hf_dhcpfo_options
;
109 static int hf_dhcpfo_ms_client_name
;
110 static int hf_dhcpfo_ms_client_description
;
111 static int hf_dhcpfo_ms_client_type
;
112 static int hf_dhcpfo_ms_client_nap_status
;
113 static int hf_dhcpfo_ms_client_nap_capable
;
114 static int hf_dhcpfo_ms_client_nap_probation
;
115 static int hf_dhcpfo_ms_client_matched_policy
;
116 static int hf_dhcpfo_ms_server_name
;
117 static int hf_dhcpfo_ms_server_ip
;
118 static int hf_dhcpfo_ms_client_scope
;
119 static int hf_dhcpfo_ms_client_subnet_mask
;
120 static int hf_dhcpfo_ms_scope_id
;
121 static int hf_dhcpfo_ms_ipflags
;
122 static int hf_dhcpfo_ms_extended_address_state
;
123 static int hf_dhcpfo_infoblox_client_hostname
;
124 static int hf_dhcpfo_unknown_data
;
126 /* Initialize the subtree pointers */
127 static int ett_dhcpfo
;
128 static int ett_fo_payload
;
129 static int ett_fo_option
;
130 static int ett_fo_payload_data
;
132 static expert_field ei_dhcpfo_bad_length
;
133 static expert_field ei_dhcpfo_message_digest_type_not_allowed
;
136 /* Length of fixed-length portion of header */
137 #define DHCPFO_FL_HDR_LEN 12
139 /* message-types of failover */
141 static const value_string failover_vals
[] =
144 {2, "Pool response"},
145 {3, "Binding update"},
146 {4, "Binding acknowledge"},
148 {6, "Connect acknowledge"},
149 {7, "Update request"},
151 {9, "Update request all"},
158 /*options of payload-data*/
159 #define DHCP_FO_PD_ADDRESSES_TRANSFERRED 1
160 #define DHCP_FO_PD_ASSIGNED_IP_ADDRESS 2
161 #define DHCP_FO_PD_BINDING_STATUS 3
162 #define DHCP_FO_PD_CLIENT_IDENTIFIER 4
163 #define DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS 5
164 #define DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME 6
165 #define DHCP_FO_PD_REPLY_OPTION 7
166 #define DHCP_FO_PD_REQUEST_OPTION 8
167 #define DHCP_FO_PD_FTDDNS 9
168 #define DHCP_FO_PD_DELAYED_SERVICE_PARAMETER 10
169 #define DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT 11
170 #define DHCP_FO_PD_IP_FLAGS 12
171 #define DHCP_FO_PD_LEASE_EXPIRATION_TIME 13
172 #define DHCP_FO_PD_MAX_UNACKED_BNDUPD 14
173 #define DHCP_FO_PD_MCLT 15
174 #define DHCP_FO_PD_MESSAGE 16
175 #define DHCP_FO_PD_MESSAGE_DIGEST 17
176 #define DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME 18
177 #define DHCP_FO_PD_RECEIVE_TIMER 19
178 #define DHCP_FO_PD_PROTOCOL_VERSION 20
179 #define DHCP_FO_PD_REJECT_REASON 21
180 #define DHCP_FO_PD_RELATIONSHIP_NAME 22
181 #define DHCP_FO_PD_SERVERFLAG 23
182 #define DHCP_FO_PD_SERVERSTATE 24
183 #define DHCP_FO_PD_START_TIME_OF_STATE 25
184 #define DHCP_FO_PD_TLS_REPLY 26
185 #define DHCP_FO_PD_TLS_REQUEST 27
186 #define DHCP_FO_PD_VENDOR_CLASS 28
187 #define DHCP_FO_PD_VENDOR_OPTION 29
188 /* Options not defined in the draft */
189 #define DHCP_FO_PD_OPTION_30 30
190 #define DHCP_FO_PD_OPTION_31 31
191 #define DHCP_FO_PD_OPTION_32 32
192 #define DHCP_FO_PD_OPTION_33 33
193 #define DHCP_FO_PD_OPTION_34 34
194 #define DHCP_FO_PD_OPTION_35 35
195 #define DHCP_FO_PD_OPTION_36 36
196 #define DHCP_FO_PD_OPTION_37 37
197 #define DHCP_FO_PD_OPTION_38 38
198 #define DHCP_FO_PD_OPTION_39 39
199 #define DHCP_FO_PD_OPTION_40 40
200 #define DHCP_FO_PD_OPTION_41 41
203 static const char VENDOR_SPECIFIC
[] = "(vendor-specific)";
204 static const char UNKNOWN_OPTION
[] = "Unknown Option";
206 static const value_string option_code_vals
[] =
208 {DHCP_FO_PD_ADDRESSES_TRANSFERRED
, "addresses-transferred"},
209 {DHCP_FO_PD_ASSIGNED_IP_ADDRESS
, "assigned-IP-address"},
210 {DHCP_FO_PD_BINDING_STATUS
, "binding-status"},
211 {DHCP_FO_PD_CLIENT_IDENTIFIER
, "client-identifier"},
212 {DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS
, "client-hardware-address"},
213 {DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME
, "client-last-transaction-time"},
214 {DHCP_FO_PD_REPLY_OPTION
, "reply-option"},
215 {DHCP_FO_PD_REQUEST_OPTION
, "request-option"},
216 {DHCP_FO_PD_FTDDNS
, "FTDDNS"},
217 {DHCP_FO_PD_DELAYED_SERVICE_PARAMETER
, "delayed-service-parameter"},
218 {DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT
, "hash-bucket-assignment"},
219 {DHCP_FO_PD_IP_FLAGS
, "IP-flags"},
220 {DHCP_FO_PD_LEASE_EXPIRATION_TIME
, "lease-expiration-time"},
221 {DHCP_FO_PD_MAX_UNACKED_BNDUPD
, "max-unacked-BNDUPD"},
222 {DHCP_FO_PD_MCLT
, "MCLT"},
223 {DHCP_FO_PD_MESSAGE
, "message"},
224 {DHCP_FO_PD_MESSAGE_DIGEST
, "message-digest"},
225 {DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME
, "potential-expiration-time"},
226 {DHCP_FO_PD_RECEIVE_TIMER
, "receive-timer"},
227 {DHCP_FO_PD_PROTOCOL_VERSION
, "protocol-version"},
228 {DHCP_FO_PD_REJECT_REASON
, "reject-reason"},
229 {DHCP_FO_PD_RELATIONSHIP_NAME
, "relationship-name"},
230 {DHCP_FO_PD_SERVERFLAG
, "server-flag"},
231 {DHCP_FO_PD_SERVERSTATE
, "server-state"},
232 {DHCP_FO_PD_START_TIME_OF_STATE
, "start-time-of-state"},
233 {DHCP_FO_PD_TLS_REPLY
, "TLS-reply"},
234 {DHCP_FO_PD_TLS_REQUEST
, "TLS-request"},
235 {DHCP_FO_PD_VENDOR_CLASS
, "vendor-class"},
236 {DHCP_FO_PD_VENDOR_OPTION
, "vendor-option"},
237 /* Not specified in the draft, further defined in the following arrays: */
238 {DHCP_FO_PD_OPTION_30
, VENDOR_SPECIFIC
},
239 {DHCP_FO_PD_OPTION_31
, VENDOR_SPECIFIC
},
240 {DHCP_FO_PD_OPTION_32
, VENDOR_SPECIFIC
},
241 {DHCP_FO_PD_OPTION_33
, VENDOR_SPECIFIC
},
242 {DHCP_FO_PD_OPTION_34
, VENDOR_SPECIFIC
},
243 {DHCP_FO_PD_OPTION_35
, VENDOR_SPECIFIC
},
244 {DHCP_FO_PD_OPTION_36
, VENDOR_SPECIFIC
},
245 {DHCP_FO_PD_OPTION_37
, VENDOR_SPECIFIC
},
246 {DHCP_FO_PD_OPTION_38
, VENDOR_SPECIFIC
},
247 {DHCP_FO_PD_OPTION_39
, VENDOR_SPECIFIC
},
248 {DHCP_FO_PD_OPTION_40
, VENDOR_SPECIFIC
},
249 {DHCP_FO_PD_OPTION_41
, VENDOR_SPECIFIC
},
253 /* Used when Microsoft-compatibility is detected/enabled */
254 static const value_string microsoft_option_code_vals
[] =
256 {DHCP_FO_PD_OPTION_30
, "microsoft-scope-ID-list"},
257 {DHCP_FO_PD_OPTION_31
, "microsoft-client-name"},
258 {DHCP_FO_PD_OPTION_32
, "microsoft-client-description"},
259 {DHCP_FO_PD_OPTION_33
, "microsoft-client-subnet-mask"},
260 {DHCP_FO_PD_OPTION_34
, "microsoft-server-IP"},
261 {DHCP_FO_PD_OPTION_35
, "microsoft-server-name"},
262 {DHCP_FO_PD_OPTION_36
, "microsoft-client-type"},
263 {DHCP_FO_PD_OPTION_37
, "microsoft-client-NAP-status"},
264 {DHCP_FO_PD_OPTION_38
, "microsoft-client-NAP-probation"},
265 {DHCP_FO_PD_OPTION_39
, "microsoft-client-NAP-capable"},
266 {DHCP_FO_PD_OPTION_40
, "microsoft-client-matched-policy"},
267 {DHCP_FO_PD_OPTION_41
, "microsoft-extended-address-state"},
271 /* Used when Microsoft-compatibility is NOT detected/enabled */
272 static const value_string others_option_code_vals
[] =
274 {DHCP_FO_PD_OPTION_30
, "infoblox-client-hostname"},
278 /* Microsoft client types (option 36) */
280 static const value_string ms_client_type_vals
[] =
282 {0x00, "CLIENT_TYPE_UNSPECIFIED"},
283 {0x01, "CLIENT_TYPE_DHCP"},
284 {0x02, "CLIENT_TYPE_BOOTP"},
285 {0x03, "CLIENT_TYPE_BOTH"},
286 {0x04, "CLIENT_TYPE_RESERVATION_FLAG"},
287 {0x64, "CLIENT_TYPE_NONE"},
291 /* Microsoft client NAP status codes (option 37) */
293 static const value_string ms_client_nap_status_vals
[] =
295 {0x00, "NOQUARANTINE"},
296 {0x01, "RESTRICTEDACCESS"},
297 {0x02, "DROPPACKET"},
304 static const value_string binding_status_vals
[] =
319 static const value_string server_state_vals
[] =
323 {3, "communication interrupted"},
325 {5, "potential conflict"},
330 {10, "resolution interrupted"},
331 {11, "conflict done"},
336 static const value_string reject_reason_vals
[] =
339 {1, "Illegal IP address (not part of any address pool)"},
340 {2, "Fatal conflict exists: address in use by other client"},
341 {3, "Missing binding information"},
342 {4, "Connection rejected, time mismatch too great"},
343 {5, "Connection rejected, invalid MCLT"},
344 {6, "Connection rejected, unknown reason"},
345 {7, "Connection rejected, duplicate connection"},
346 {8, "Connection rejected, invalid failover partner"},
347 {9, "TLS not supported"},
348 {10, "TLS supported but not configured"},
349 {11, "TLS required but not supported by partner"},
350 {12, "Message digest not supported"},
351 {13, "Message digest not configured"},
352 {14, "Protocol version mismatch"},
353 {15, "Outdated binding information"},
354 {16, "Less critical binding information"},
355 {17, "No traffic within sufficient time"},
356 {18, "Hash bucket assignment conflict"},
357 {19, "IP not reserved on this server"},
358 {20, "Message digest failed to compare"},
359 {21, "Missing message digest."},
360 {254, "Unknown: Error occurred but does not match any reason"},
364 static const value_string tls_request_vals
[] =
366 {0, "No TLS operation"},
367 {1, "TLS operation desired but not required"},
368 {2, "TLS operation is required"},
372 static const value_string tls_reply_vals
[] =
374 {0, "No TLS operation"},
375 {1, "TLS operation is required"},
379 static const value_string message_digest_type_vals
[] =
382 {2, "Microsoft-specific"},
386 static const value_string serverflag_vals
[] =
393 /* Code to actually dissect the packets */
395 get_dhcpfo_pdu_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
, void *data _U_
)
398 * Return the length of the DHCP failover packet.
400 return tvb_get_ntohs(tvb
, offset
);
404 dissect_dhcpfo_pdu(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
407 proto_item
*ti
, *pi
, *oi
;
408 proto_tree
*dhcpfo_tree
= NULL
, *payload_tree
, *option_tree
;
409 uint8_t tls_request
, tls_reply
;
411 unsigned type
, serverflag
;
415 uint32_t lease_expiration_time
,
416 potential_expiration_time
, client_last_transaction_time
,
418 bool bogus_poffset
, microsoft_style
;
419 uint16_t opcode
, option_length
;
420 uint8_t htype
, reject_reason
, message_digest_type
, binding_status
;
421 const uint8_t *vendor_class_str
, *relationship_name_str
;
422 const char *htype_str
, *option_name
;
423 char *lease_expiration_time_str
, *potential_expiration_time_str
,
424 *client_last_transaction_time_str
, *start_time_of_state_str
;
426 uint8_t server_state
, ms_client_type
, ms_client_nap_status
, ms_client_nap_capable
;
427 uint32_t max_unacked_bndupd
, receive_timer
,
428 ms_client_nap_probation
, ms_extended_address_state
;
429 const uint8_t *client_hostname_str
, *ms_server_name_str
, *ms_client_description_str
,
430 *ms_client_matched_policy_str
;
432 /* Make entries in Protocol column and Info column on summary display */
433 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DHCPFO");
434 col_clear(pinfo
->cinfo
, COL_INFO
);
436 length
= tvb_get_ntohs(tvb
, offset
);
438 /* create display subtree for the protocol */
439 ti
= proto_tree_add_item(tree
, proto_dhcpfo
, tvb
, 0, -1, ENC_NA
);
441 dhcpfo_tree
= proto_item_add_subtree(ti
, ett_dhcpfo
);
443 if (length
>= DHCPFO_FL_HDR_LEN
) {
444 proto_tree_add_uint(dhcpfo_tree
,
445 hf_dhcpfo_length
, tvb
, offset
, 2, length
);
447 proto_tree_add_uint_format_value(dhcpfo_tree
,
448 hf_dhcpfo_length
, tvb
, offset
, 2, length
,
449 "%u (bogus, must be >= %u)",
450 length
, DHCPFO_FL_HDR_LEN
);
455 type
= tvb_get_uint8(tvb
, offset
);
457 proto_tree_add_uint(dhcpfo_tree
,
458 hf_dhcpfo_type
, tvb
, offset
, 1, type
);
460 col_set_str(pinfo
->cinfo
, COL_INFO
,
461 val_to_str_const(type
, failover_vals
, "Unknown Packet"));
464 if (dhcpfo_microsoft_compatibility
== DISSECT_MS_DHCP
) {
465 microsoft_style
= true;
467 /* Set to false, changed to true later if autodetected */
468 microsoft_style
= false;
470 poffset
= tvb_get_uint8(tvb
, offset
);
472 if (dhcpfo_microsoft_compatibility
== AUTODETECT_MS_DHCP
) {
473 microsoft_style
= true;
475 bogus_poffset
= false;
476 proto_tree_add_uint_format_value(dhcpfo_tree
,
477 hf_dhcpfo_poffset
, tvb
, offset
, 1, poffset
,
478 "%u (as per Draft, now treated as being %u)",
479 poffset
, DHCPFO_FL_HDR_LEN
);
480 poffset
= DHCPFO_FL_HDR_LEN
;
481 } else if (poffset
< DHCPFO_FL_HDR_LEN
) {
482 bogus_poffset
= true;
484 proto_tree_add_uint_format_value(dhcpfo_tree
,
485 hf_dhcpfo_poffset
, tvb
, offset
, 1, poffset
,
486 "%u (bogus, must be >= %u)",
487 poffset
, DHCPFO_FL_HDR_LEN
);
489 } else if (poffset
> length
) {
490 bogus_poffset
= true;
492 proto_tree_add_uint_format_value(dhcpfo_tree
,
493 hf_dhcpfo_poffset
, tvb
, offset
, 1, poffset
,
494 "%u (bogus, must be <= length of message)",
498 bogus_poffset
= false;
500 proto_tree_add_uint(dhcpfo_tree
,
501 hf_dhcpfo_poffset
, tvb
, offset
, 1, poffset
);
508 * XXX - this is *almost* like a time_t, but it's unsigned.
509 * Also, we need a way to keep from displaying nanoseconds,
510 * so as not to make it look as if it has higher
512 timex
.secs
= tvb_get_ntohl(tvb
, offset
);
514 proto_tree_add_time_format_value(dhcpfo_tree
, hf_dhcpfo_time
, tvb
,
515 offset
, 4, &timex
, "%s",
516 abs_time_secs_to_str(pinfo
->pool
, timex
.secs
, ABSOLUTE_TIME_LOCAL
, true));
520 xid
= tvb_get_ntohl(tvb
, offset
);
522 proto_tree_add_item(dhcpfo_tree
,
523 hf_dhcpfo_xid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
525 col_append_fstr(pinfo
->cinfo
, COL_INFO
," xid: %x", xid
);
529 return offset
; /* payload offset was bogus */
531 /* if there are any additional header bytes */
532 if (poffset
!= offset
) {
533 proto_tree_add_item(dhcpfo_tree
, hf_dhcpfo_additional_HB
, tvb
,
534 offset
, poffset
-offset
, ENC_NA
);
539 if (poffset
== length
)
540 return length
; /* no payload */
541 /* create display subtree for the payload */
542 pi
= proto_tree_add_item(dhcpfo_tree
, hf_dhcpfo_payload_data
,
543 tvb
, poffset
, length
-poffset
, ENC_NA
);
544 payload_tree
= proto_item_add_subtree(pi
, ett_fo_payload
);
545 while (offset
< length
) {
546 opcode
= tvb_get_ntohs(tvb
, offset
);
547 option_length
= tvb_get_ntohs(tvb
, offset
+2);
549 oi
= proto_tree_add_item(payload_tree
,
550 hf_dhcpfo_dhcp_style_option
, tvb
, offset
,
551 option_length
+4, ENC_NA
);
552 option_tree
= proto_item_add_subtree(oi
, ett_fo_option
);
554 /*** DHCP-Style-Options ****/
556 option_name
= val_to_str_const(opcode
, option_code_vals
, UNKNOWN_OPTION
);
557 if (strcmp(option_name
, VENDOR_SPECIFIC
) == 0) {
558 /* Get the option name based on current setting */
559 if (microsoft_style
) {
560 option_name
= val_to_str_const(opcode
, microsoft_option_code_vals
, UNKNOWN_OPTION
);
562 option_name
= val_to_str_const(opcode
, others_option_code_vals
, UNKNOWN_OPTION
);
565 proto_item_append_text(oi
, ", %s (%u)", option_name
, opcode
);
567 proto_tree_add_uint(option_tree
, hf_dhcpfo_option_code
, tvb
,
570 proto_tree_add_uint(option_tree
, hf_dhcpfo_option_length
, tvb
,
571 offset
+2, 2, option_length
);
575 /** opcode dependent format **/
579 case DHCP_FO_PD_BINDING_STATUS
:
580 binding_status
= tvb_get_uint8(tvb
, offset
);
581 proto_item_append_text(oi
, ", %s (%d)",
582 val_to_str_const(binding_status
,
587 proto_tree_add_item(option_tree
,
588 hf_dhcpfo_binding_status
, tvb
,
589 offset
, 1, ENC_BIG_ENDIAN
);
592 case DHCP_FO_PD_ASSIGNED_IP_ADDRESS
:
593 if (option_length
!= 4) {
594 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "assigned ip address is not 4 bytes long");
597 proto_item_append_text(oi
, ", %s ", tvb_ip_to_str(pinfo
->pool
, tvb
, offset
));
599 proto_tree_add_item(option_tree
,
600 hf_dhcpfo_assigned_ip_address
, tvb
, offset
,
601 option_length
, ENC_BIG_ENDIAN
);
604 case DHCP_FO_PD_DELAYED_SERVICE_PARAMETER
:
605 if (option_length
!= 1) {
606 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "delayed service parameter is not 1 bytes long");
610 proto_item_append_text(oi
, ", %d ", tvb_get_uint8(tvb
, offset
));
612 proto_tree_add_item(option_tree
,
613 hf_dhcpfo_delayed_service_parameter
, tvb
,
614 offset
, option_length
, ENC_NA
);
617 case DHCP_FO_PD_ADDRESSES_TRANSFERRED
:
618 if (option_length
!= 4) {
619 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "addresses transferred is not 4 bytes long");
623 proto_item_append_text(oi
,", %u", tvb_get_ntohl(tvb
, offset
));
625 proto_tree_add_item(option_tree
,
626 hf_dhcpfo_addresses_transferred
, tvb
, offset
,
627 option_length
, ENC_BIG_ENDIAN
);
630 case DHCP_FO_PD_CLIENT_IDENTIFIER
:
632 const uint8_t* identifier
;
634 * XXX - if this is truly like DHCP option 81,
635 * we need to dissect it as such.
637 proto_tree_add_item_ret_string(option_tree
,
638 hf_dhcpfo_client_identifier
, tvb
, offset
,
639 option_length
, ENC_ASCII
|ENC_NA
, pinfo
->pool
, &identifier
);
641 proto_item_append_text(oi
,", \"%s\"", identifier
);
645 case DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS
:
646 if (microsoft_style
== false) {
647 /* As specified in the draft: hardware type + hardware address */
648 if (option_length
< 2) {
649 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "hardware address is too short");
652 htype
= tvb_get_uint8(tvb
, offset
);
653 htype_str
= tvb_arphrdaddr_to_str(pinfo
->pool
, tvb
, offset
+1, option_length
-1,
655 proto_item_append_text(oi
, ", %s", htype_str
);
657 proto_tree_add_item(option_tree
, hf_dhcpfo_client_hw_type
, tvb
,
658 offset
, 1, ENC_BIG_ENDIAN
);
659 proto_tree_add_string(option_tree
, hf_dhcpfo_client_hardware_address
, tvb
,
660 offset
+1, option_length
-1, htype_str
);
662 /* Microsoft-style: DHCP scope (reversed) + hardware type + hardware address */
663 if (option_length
< 6) {
664 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "hardware address is too short");
667 proto_tree_add_item(option_tree
,
668 hf_dhcpfo_ms_client_scope
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
669 uint32_t scope
= tvb_get_uint32(tvb
, offset
, ENC_LITTLE_ENDIAN
);
670 htype
= tvb_get_uint8(tvb
, offset
+4);
671 htype_str
= tvb_arphrdaddr_to_str(pinfo
->pool
, tvb
, offset
+1+4, option_length
-1-4,
673 proto_item_append_text(oi
, ", %s, client DHCP scope: %s",
674 htype_str
, ip_num_to_str(pinfo
->pool
, scope
));
676 proto_tree_add_item(option_tree
, hf_dhcpfo_client_hw_type
, tvb
,
677 offset
+4, 1, ENC_BIG_ENDIAN
);
678 proto_tree_add_string(option_tree
, hf_dhcpfo_client_hardware_address
, tvb
,
679 offset
+1+4, option_length
-1-4, htype_str
);
683 case DHCP_FO_PD_FTDDNS
:
684 proto_tree_add_item(option_tree
, hf_dhcpfo_ftddns
, tvb
,
685 offset
, option_length
, ENC_ASCII
);
688 case DHCP_FO_PD_REJECT_REASON
:
689 if (option_length
!= 1) {
690 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Reject reason is not 1 byte long");
693 reject_reason
= tvb_get_uint8(tvb
, offset
);
695 proto_item_append_text(oi
, ", %s (%d)",
696 val_to_str_const(reject_reason
, reject_reason_vals
,
700 proto_tree_add_uint(option_tree
,
701 hf_dhcpfo_reject_reason
, tvb
, offset
,
702 option_length
, reject_reason
);
705 case DHCP_FO_PD_RELATIONSHIP_NAME
:
706 if (microsoft_style
== false) {
708 proto_tree_add_item_ret_string(option_tree
,
709 hf_dhcpfo_relationship_name
, tvb
, offset
,
710 option_length
, ENC_ASCII
, pinfo
->pool
, &relationship_name_str
);
711 proto_item_append_text(oi
,", \"%s\"",
712 format_text(pinfo
->pool
, relationship_name_str
, option_length
));
714 /* Microsoft-style: Parse as UTF-16-LE */
715 proto_tree_add_item_ret_string(option_tree
,
716 hf_dhcpfo_relationship_name
, tvb
, offset
,
717 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &relationship_name_str
);
718 /* String length is half the data length */
719 proto_item_append_text(oi
,", \"%s\"",
720 format_text(pinfo
->pool
, relationship_name_str
, option_length
/2));
724 case DHCP_FO_PD_MESSAGE
:
725 proto_tree_add_item(option_tree
, hf_dhcpfo_message
, tvb
,
726 offset
, option_length
, ENC_ASCII
);
729 case DHCP_FO_PD_MCLT
:
730 if (option_length
!= 4) {
731 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "MCLT is not 4 bytes long");
734 mclt
= tvb_get_ntohl(tvb
, offset
);
735 proto_item_append_text(oi
,", %u seconds", mclt
);
736 proto_tree_add_uint(option_tree
, hf_dhcpfo_mclt
, tvb
,
737 offset
, option_length
, mclt
);
740 case DHCP_FO_PD_VENDOR_CLASS
:
741 if (microsoft_style
== false) {
743 proto_tree_add_item_ret_string(option_tree
,
744 hf_dhcpfo_vendor_class
, tvb
, offset
,
745 option_length
, ENC_ASCII
, pinfo
->pool
, &vendor_class_str
);
746 proto_item_append_text(oi
,", \"%s\"",
747 format_text(pinfo
->pool
, vendor_class_str
, option_length
));
749 /* Microsoft-style: Parse as UTF-16-LE */
750 proto_tree_add_item_ret_string(option_tree
,
751 hf_dhcpfo_vendor_class
, tvb
, offset
,
752 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &vendor_class_str
);
753 /* String length is half the data length */
754 proto_item_append_text(oi
,", \"%s\"",
755 format_text(pinfo
->pool
, vendor_class_str
, option_length
/2));
759 case DHCP_FO_PD_LEASE_EXPIRATION_TIME
:
760 if (option_length
!= 4) {
761 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Lease expiration time is not 4 bytes long");
764 lease_expiration_time
=
765 tvb_get_ntohl(tvb
, offset
);
766 lease_expiration_time_str
=
767 abs_time_secs_to_str(pinfo
->pool
, lease_expiration_time
, ABSOLUTE_TIME_LOCAL
, true);
769 proto_item_append_text(oi
, ", %s",
770 lease_expiration_time_str
);
772 proto_tree_add_uint_format_value(option_tree
,
773 hf_dhcpfo_lease_expiration_time
, tvb
,
774 offset
, option_length
,
775 lease_expiration_time
,
777 lease_expiration_time_str
);
780 case DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME
:
781 if (option_length
!= 4) {
782 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Potential expiration time is not 4 bytes long");
785 potential_expiration_time
=
786 tvb_get_ntohl(tvb
, offset
);
788 potential_expiration_time_str
=
789 abs_time_secs_to_str(pinfo
->pool
, potential_expiration_time
, ABSOLUTE_TIME_LOCAL
, true);
791 proto_item_append_text(oi
, ", %s",
792 potential_expiration_time_str
);
794 proto_tree_add_uint_format_value(option_tree
,
795 hf_dhcpfo_potential_expiration_time
, tvb
,
796 offset
, option_length
,
797 potential_expiration_time
,
799 potential_expiration_time_str
);
802 case DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME
:
803 if (option_length
!= 4) {
804 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Last transaction time is not 4 bytes long");
807 client_last_transaction_time
=
808 tvb_get_ntohl(tvb
, offset
);
809 client_last_transaction_time_str
=
810 abs_time_secs_to_str(pinfo
->pool
, client_last_transaction_time
, ABSOLUTE_TIME_LOCAL
, true);
812 proto_item_append_text(oi
, ", %s",
813 client_last_transaction_time_str
);
815 proto_tree_add_uint_format_value(option_tree
,
816 hf_dhcpfo_client_last_transaction_time
, tvb
,
817 offset
, option_length
,
818 client_last_transaction_time
,
820 abs_time_secs_to_str(pinfo
->pool
, client_last_transaction_time
, ABSOLUTE_TIME_LOCAL
, true));
823 case DHCP_FO_PD_START_TIME_OF_STATE
:
824 if (option_length
!= 4) {
825 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Start time of state is not 4 bytes long");
828 start_time_of_state
=
829 tvb_get_ntohl(tvb
, offset
);
830 start_time_of_state_str
=
831 abs_time_secs_to_str(pinfo
->pool
, start_time_of_state
, ABSOLUTE_TIME_LOCAL
, true);
833 proto_item_append_text(oi
, ", %s",
834 start_time_of_state_str
);
836 proto_tree_add_uint_format_value(option_tree
,
837 hf_dhcpfo_start_time_of_state
, tvb
,
838 offset
, option_length
,
841 abs_time_secs_to_str(pinfo
->pool
, start_time_of_state
, ABSOLUTE_TIME_LOCAL
, true));
844 case DHCP_FO_PD_SERVERSTATE
:
845 if (option_length
!= 1) {
846 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "server status is not 1 byte long");
849 server_state
= tvb_get_uint8(tvb
, offset
);
851 proto_item_append_text(oi
, ", %s (%u)",
852 val_to_str_const(server_state
, server_state_vals
,
856 proto_tree_add_uint(option_tree
,
857 hf_dhcpfo_server_state
, tvb
, offset
, 1,
861 case DHCP_FO_PD_SERVERFLAG
:
862 if (option_length
!= 1) {
863 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Serverflag is not 1 byte long");
866 serverflag
= tvb_get_uint8(tvb
, offset
);
867 proto_item_append_text(oi
, ", %s (%d)",
868 val_to_str_const(serverflag
, serverflag_vals
, "UNKNOWN FLAGS"),
870 proto_tree_add_item(option_tree
, hf_dhcpfo_serverflag
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
873 case DHCP_FO_PD_VENDOR_OPTION
:
874 proto_tree_add_item(option_tree
,
875 hf_dhcpfo_vendor_option
, tvb
, offset
,
876 option_length
, ENC_NA
);
879 case DHCP_FO_PD_MAX_UNACKED_BNDUPD
:
880 if (option_length
!= 4) {
881 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Max unacked BNDUPD is not 4 bytes long");
884 max_unacked_bndupd
= tvb_get_ntohl(tvb
, offset
);
885 proto_item_append_text(oi
, ", %u", max_unacked_bndupd
);
887 proto_tree_add_uint(option_tree
,
888 hf_dhcpfo_max_unacked_bndupd
, tvb
, offset
,
889 option_length
, max_unacked_bndupd
);
892 case DHCP_FO_PD_RECEIVE_TIMER
:
893 if (option_length
!= 4) {
894 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Receive timer is not 4 bytes long");
897 receive_timer
= tvb_get_ntohl(tvb
, offset
);
898 proto_item_append_text(oi
,", %u seconds",
901 proto_tree_add_uint(option_tree
,
902 hf_dhcpfo_receive_timer
, tvb
, offset
,
903 option_length
, receive_timer
);
906 case DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT
:
907 proto_tree_add_item(option_tree
,
908 hf_dhcpfo_hash_bucket_assignment
, tvb
,
909 offset
, option_length
, ENC_NA
);
912 case DHCP_FO_PD_IP_FLAGS
: {
913 if (microsoft_style
== false) {
914 /* As specified in the draft: 16-bit flags */
915 static int * const ipflags
[] = {
916 &hf_dhcpfo_ipflags_reserved
,
917 &hf_dhcpfo_ipflags_bootp
,
918 &hf_dhcpfo_ipflags_mbz
,
921 if (option_length
!= 2) {
922 /* Draft-12 shows Len=1 with 16-bit field though */
923 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "IP flags is not 2 bytes long");
926 proto_tree_add_bitmask(option_tree
, tvb
, offset
, hf_dhcpfo_ipflags
,
927 ett_fo_payload_data
, ipflags
, ENC_BIG_ENDIAN
);
929 /* Microsoft-style: one byte only, usage unknown */
930 if (option_length
!= 1) {
931 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "IP flags is not 1 bytes long");
934 proto_item_append_text(oi
, ", flags (Microsoft-specific): 0x%02x", tvb_get_uint8(tvb
, offset
));
935 proto_tree_add_item(option_tree
, hf_dhcpfo_ms_ipflags
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
940 case DHCP_FO_PD_MESSAGE_DIGEST
:
941 if (option_length
< 1) {
942 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Message digest option is too short");
946 message_digest_type
= tvb_get_uint8(tvb
, offset
);
947 ti
= proto_tree_add_item(option_tree
, hf_dhcpfo_message_digest_type
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
949 if (message_digest_type
>= 1 && message_digest_type
<= 2) {
950 proto_item_append_text(oi
, ", %s", val_to_str_const(message_digest_type
, message_digest_type_vals
, "Unknown value"));
952 proto_item_append_text(oi
, ", type not allowed");
953 expert_add_info_format(pinfo
, ti
, &ei_dhcpfo_message_digest_type_not_allowed
, "Message digest type: %u, not allowed", message_digest_type
);
956 proto_tree_add_item(option_tree
,
957 hf_dhcpfo_message_digest
, tvb
, offset
+1,
958 option_length
-1, ENC_ASCII
);
961 case DHCP_FO_PD_PROTOCOL_VERSION
:
962 if (option_length
!= 1) {
963 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Protocol version is not 1 byte long");
966 proto_item_append_text(oi
, ", version: %u", tvb_get_uint8(tvb
, offset
));
967 proto_tree_add_item(option_tree
, hf_dhcpfo_protocol_version
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
970 case DHCP_FO_PD_TLS_REQUEST
:
971 if (option_length
!= 1) {
972 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "TLS request is not 1 bytes long");
975 tls_request
= tvb_get_uint8(tvb
, offset
);
976 proto_item_append_text(oi
, ", %s", val_to_str(tls_request
, tls_request_vals
, "Unknown (%u)"));
977 proto_tree_add_item(option_tree
, hf_dhcpfo_tls_request
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
980 case DHCP_FO_PD_TLS_REPLY
:
981 if (option_length
!= 1) {
982 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "TLS reply is not 1 bytes long");
985 tls_reply
= tvb_get_uint8(tvb
, offset
);
986 proto_item_append_text(oi
, ", %s", val_to_str(tls_reply
, tls_reply_vals
, "Unknown (%u)"));
987 proto_tree_add_item(option_tree
, hf_dhcpfo_tls_reply
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
990 case DHCP_FO_PD_REQUEST_OPTION
:
991 case DHCP_FO_PD_REPLY_OPTION
:
992 proto_tree_add_item(option_tree
, hf_dhcpfo_options
, tvb
, offset
, option_length
, ENC_NA
);
995 case DHCP_FO_PD_OPTION_30
:
996 if (microsoft_style
) {
997 /* Microsoft: Scope ID List */
998 uint16_t local_offset
= 0;
999 while (local_offset
< option_length
) {
1000 proto_tree_add_item(option_tree
,
1001 hf_dhcpfo_ms_scope_id
, tvb
, offset
+local_offset
, 4, ENC_LITTLE_ENDIAN
);
1005 /* In Infoblox this is client hostname */
1006 proto_tree_add_item_ret_string(option_tree
,
1007 hf_dhcpfo_infoblox_client_hostname
, tvb
, offset
,
1008 option_length
, ENC_UTF_8
, pinfo
->pool
, &client_hostname_str
);
1009 proto_item_append_text(oi
,", \"%s\"",
1010 format_text(pinfo
->pool
, client_hostname_str
, option_length
));
1014 case DHCP_FO_PD_OPTION_31
:
1015 /* Microsoft: Client Name */
1016 proto_tree_add_item_ret_string(option_tree
,
1017 hf_dhcpfo_ms_client_name
, tvb
, offset
,
1018 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &client_hostname_str
);
1019 /* With UTF-16 the string length is half the data length, minus the zero-termination */
1020 proto_item_append_text(oi
,", \"%s\"",
1021 format_text(pinfo
->pool
, client_hostname_str
, option_length
/2-1));
1024 case DHCP_FO_PD_OPTION_32
:
1025 /* Microsoft: Client Description */
1026 proto_tree_add_item_ret_string(option_tree
,
1027 hf_dhcpfo_ms_client_description
, tvb
, offset
,
1028 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &ms_client_description_str
);
1029 /* With UTF-16 the string length is half the data length, minus the zero-termination */
1030 proto_item_append_text(oi
,", \"%s\"",
1031 format_text(pinfo
->pool
, ms_client_description_str
, option_length
/2-1));
1034 case DHCP_FO_PD_OPTION_33
:
1035 /* Microsoft: Client Subnet Mask */
1036 if (option_length
!= 4) {
1037 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "netmask is not 4 bytes long");
1040 proto_item_append_text(oi
, ", %s", tvb_ip_to_str(pinfo
->pool
, tvb
, offset
));
1041 proto_tree_add_item(option_tree
,
1042 hf_dhcpfo_ms_client_subnet_mask
, tvb
, offset
,
1043 option_length
, ENC_BIG_ENDIAN
);
1046 case DHCP_FO_PD_OPTION_34
:
1047 /* Microsoft: Server IP */
1048 if (option_length
!= 4) {
1049 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "server IP address is not 4 bytes long");
1052 proto_item_append_text(oi
, ", %s", tvb_ip_to_str(pinfo
->pool
, tvb
, offset
));
1053 proto_tree_add_item(option_tree
,
1054 hf_dhcpfo_ms_server_ip
, tvb
, offset
,
1055 option_length
, ENC_BIG_ENDIAN
);
1058 case DHCP_FO_PD_OPTION_35
:
1059 /* Microsoft: Server Name */
1060 proto_tree_add_item_ret_string(option_tree
,
1061 hf_dhcpfo_ms_server_name
, tvb
, offset
,
1062 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &ms_server_name_str
);
1063 /* With UTF-16 the string length is half the data length, minus the zero-termination */
1064 proto_item_append_text(oi
,", \"%s\"",
1065 format_text(pinfo
->pool
, ms_server_name_str
, option_length
/2-1));
1068 case DHCP_FO_PD_OPTION_36
:
1069 /* Microsoft: Client Type */
1070 if (option_length
!= 1) {
1071 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "client type is not 1 byte long");
1074 ms_client_type
= tvb_get_uint8(tvb
, offset
);
1075 proto_item_append_text(oi
, ", %s (%d)",
1076 val_to_str_const(ms_client_type
, ms_client_type_vals
, "(undefined)"),
1078 proto_tree_add_item(option_tree
, hf_dhcpfo_ms_client_type
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
1081 case DHCP_FO_PD_OPTION_37
:
1082 /* Microsoft: Client NAP Status */
1083 if (option_length
!= 1) {
1084 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "client NAP status is not 1 byte long");
1087 ms_client_nap_status
= tvb_get_uint8(tvb
, offset
);
1088 proto_item_append_text(oi
, ", %s (%d)",
1089 val_to_str_const(ms_client_nap_status
, ms_client_nap_status_vals
, "(undefined)"),
1090 ms_client_nap_status
);
1091 proto_tree_add_item(option_tree
, hf_dhcpfo_ms_client_nap_status
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
1094 case DHCP_FO_PD_OPTION_38
:
1095 /* Microsoft: Client NAP Probation */
1096 if (option_length
!= 4) {
1097 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "client NAP probation is not 4 bytes long");
1100 ms_client_nap_probation
= tvb_get_ntohl(tvb
, offset
);
1101 /* The option value is specified:
1102 * "The value is specified as an absolute time and represents the
1103 * number of 100-nanosecond intervals since January 1, 1601 (UTC)"
1104 * But obviously that large values won't fit into a 4-byte variable.
1105 * So showing as uint32 for now.
1107 proto_item_append_text(oi
,", %u", ms_client_nap_probation
);
1108 proto_tree_add_uint(option_tree
,
1109 hf_dhcpfo_ms_client_nap_probation
, tvb
, offset
,
1110 option_length
, ms_client_nap_probation
);
1113 case DHCP_FO_PD_OPTION_39
:
1114 /* Microsoft: Client NAP Capable */
1115 if (option_length
!= 1) {
1116 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "client NAP capable option is not 1 byte long");
1119 ms_client_nap_capable
= tvb_get_uint8(tvb
, offset
);
1120 proto_item_append_text(oi
, ", %s (%d)",
1121 tfs_get_true_false(ms_client_nap_capable
),
1122 ms_client_nap_capable
);
1123 proto_tree_add_item(option_tree
, hf_dhcpfo_ms_client_nap_capable
, tvb
, offset
, option_length
, ENC_BIG_ENDIAN
);
1126 case DHCP_FO_PD_OPTION_40
:
1127 /* Microsoft: Client Matched Policy */
1128 proto_tree_add_item_ret_string(option_tree
,
1129 hf_dhcpfo_ms_client_matched_policy
, tvb
, offset
,
1130 option_length
, ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &ms_client_matched_policy_str
);
1131 /* With UTF-16 the string length is half the data length, minus the zero-termination */
1132 proto_item_append_text(oi
,", \"%s\"",
1133 format_text(pinfo
->pool
, ms_client_matched_policy_str
, option_length
/2-1));
1136 case DHCP_FO_PD_OPTION_41
:
1137 /* Microsoft: Extended Address State */
1138 if (option_length
!= 4) {
1139 expert_add_info_format(pinfo
, oi
, &ei_dhcpfo_bad_length
, "Extended address state is not 4 bytes long");
1142 ms_extended_address_state
= tvb_get_ntohl(tvb
, offset
);
1143 proto_item_append_text(oi
,", 0x%08x", ms_extended_address_state
);
1145 proto_tree_add_uint(option_tree
,
1146 hf_dhcpfo_ms_extended_address_state
, tvb
, offset
,
1147 option_length
, ms_extended_address_state
);
1151 proto_tree_add_item(option_tree
,
1152 hf_dhcpfo_unknown_data
, tvb
, offset
,
1153 option_length
, ENC_ASCII
);
1157 offset
+= option_length
;
1160 return tvb_reported_length(tvb
);
1164 dissect_dhcpfo(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data
)
1166 tcp_dissect_pdus(tvb
, pinfo
, tree
, dhcpfo_desegment
, 2,
1167 get_dhcpfo_pdu_len
, dissect_dhcpfo_pdu
, data
);
1168 return tvb_reported_length(tvb
);
1171 /* Register the protocol with Wireshark */
1174 proto_register_dhcpfo(void)
1177 /* Setup list of header fields See Section 1.6.1 for details*/
1178 static hf_register_info hf
[] = {
1179 { &hf_dhcpfo_length
,
1180 { "Message length", "dhcpfo.length",
1181 FT_UINT16
, BASE_DEC
, NULL
, 0,
1185 { "Message Type", "dhcpfo.type",
1186 FT_UINT8
, BASE_DEC
, VALS(failover_vals
), 0,
1189 { &hf_dhcpfo_poffset
,
1190 { "Payload Offset", "dhcpfo.poffset",
1191 FT_UINT8
, BASE_DEC
, NULL
, 0,
1195 { "Time", "dhcpfo.time",
1196 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
, NULL
, 0,
1200 { "Xid", "dhcpfo.xid",
1201 FT_UINT32
, BASE_HEX
, NULL
, 0,
1204 { &hf_dhcpfo_additional_HB
,
1205 {"Additional Header Bytes", "dhcpfo.additionalheaderbytes",
1206 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1209 { &hf_dhcpfo_payload_data
,
1210 {"Payload Data", "dhcpfo.payloaddata",
1211 FT_NONE
, BASE_NONE
, NULL
, 0,
1214 { &hf_dhcpfo_dhcp_style_option
,
1215 {"DHCP Style Option", "dhcpfo.dhcpstyleoption",
1216 FT_NONE
, BASE_NONE
, NULL
, 0,
1219 { &hf_dhcpfo_option_code
,
1220 {"Option Code", "dhcpfo.optioncode",
1221 FT_UINT16
, BASE_DEC
, VALS(option_code_vals
), 0,
1224 {&hf_dhcpfo_option_length
,
1225 {"Length", "dhcpfo.optionlength",
1226 FT_UINT16
, BASE_DEC
, NULL
, 0,
1229 {&hf_dhcpfo_binding_status
,
1230 {"Status", "dhcpfo.bindingstatus",
1231 FT_UINT32
, BASE_DEC
, VALS(binding_status_vals
), 0,
1234 {&hf_dhcpfo_server_state
,
1235 {"server status", "dhcpfo.serverstatus",
1236 FT_UINT8
, BASE_DEC
, VALS(server_state_vals
), 0,
1239 {&hf_dhcpfo_assigned_ip_address
,
1240 {"assigned ip address", "dhcpfo.assignedipaddress",
1241 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1244 {&hf_dhcpfo_delayed_service_parameter
,
1245 {"delayed service parameter", "dhcpfo.delayedserviceparameter",
1246 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1249 {&hf_dhcpfo_addresses_transferred
,
1250 {"addresses transferred", "dhcpfo.addressestransferred",
1251 FT_UINT32
, BASE_DEC
, NULL
, 0,
1254 {&hf_dhcpfo_client_identifier
,
1255 {"Client Identifier", "dhcpfo.clientidentifier",
1256 FT_STRING
, BASE_NONE
, NULL
, 0,
1259 {&hf_dhcpfo_client_hw_type
,
1260 {"Client Hardware Type", "dhcpfo.clienthardwaretype",
1261 FT_UINT8
, BASE_HEX
, VALS(arp_hrd_vals
), 0x0,
1264 {&hf_dhcpfo_client_hardware_address
,
1265 {"Client Hardware Address", "dhcpfo.clienthardwareaddress",
1266 FT_STRING
, BASE_NONE
, NULL
, 0,
1270 {"FTDDNS", "dhcpfo.ftddns",
1271 FT_STRING
, BASE_NONE
, NULL
, 0,
1274 {&hf_dhcpfo_reject_reason
,
1275 {"Reject reason", "dhcpfo.rejectreason",
1276 FT_UINT8
, BASE_DEC
, VALS(reject_reason_vals
), 0,
1279 {&hf_dhcpfo_relationship_name
,
1280 {"Relationship name", "dhcpfo.relationshipname",
1281 FT_STRING
, BASE_NONE
, NULL
, 0,
1284 {&hf_dhcpfo_message
,
1285 {"Message", "dhcpfo.message",
1286 FT_STRING
, BASE_NONE
, NULL
, 0,
1290 {"MCLT", "dhcpfo.mclt",
1291 FT_UINT32
, BASE_DEC
, NULL
, 0,
1294 {&hf_dhcpfo_vendor_class
,
1295 {"Vendor class", "dhcpfo.vendorclass",
1296 FT_STRING
, BASE_NONE
, NULL
, 0,
1299 {&hf_dhcpfo_lease_expiration_time
,
1300 {"Lease expiration time", "dhcpfo.leaseexpirationtime",
1301 FT_UINT32
, BASE_DEC
, NULL
, 0,
1304 {&hf_dhcpfo_potential_expiration_time
,
1305 {"Potential expiration time", "dhcpfo.potentialexpirationtime",
1306 FT_UINT32
, BASE_DEC
, NULL
, 0,
1309 {&hf_dhcpfo_client_last_transaction_time
,
1310 {"Client last transaction time", "dhcpfo.clientlasttransactiontime",
1311 FT_UINT32
, BASE_DEC
, NULL
, 0,
1314 {&hf_dhcpfo_start_time_of_state
,
1315 {"Start time of state", "dhcpfo.starttimeofstate",
1316 FT_UINT32
, BASE_DEC
, NULL
, 0,
1319 {&hf_dhcpfo_vendor_option
,
1320 {"Vendor option", "dhcpfo.vendoroption",
1321 FT_NONE
, BASE_NONE
, NULL
, 0x0,
1324 {&hf_dhcpfo_max_unacked_bndupd
,
1325 {"Max unacked BNDUPD", "dhcpfo.maxunackedbndupd",
1326 FT_UINT32
, BASE_DEC
, NULL
, 0,
1329 {&hf_dhcpfo_protocol_version
,
1330 {"Protocol version", "dhcpfo.protocolversion",
1331 FT_UINT8
, BASE_DEC
, NULL
, 0,
1334 {&hf_dhcpfo_receive_timer
,
1335 {"Receive timer", "dhcpfo.receivetimer",
1336 FT_UINT32
, BASE_DEC
|BASE_UNIT_STRING
, UNS(&units_second_seconds
), 0,
1339 {&hf_dhcpfo_message_digest
,
1340 {"Message digest", "dhcpfo.messagedigest",
1341 FT_BYTES
, BASE_NONE
|BASE_ALLOW_ZERO
, NULL
, 0,
1344 {&hf_dhcpfo_hash_bucket_assignment
,
1345 {"Hash bucket assignment", "dhcpfo.hashbucketassignment",
1346 FT_BYTES
, BASE_NONE
, NULL
, 0,
1349 {&hf_dhcpfo_ipflags
,
1350 {"IP Flags", "dhcpfo.ipflags",
1351 FT_UINT16
, BASE_HEX
, NULL
, 0,
1354 {&hf_dhcpfo_ipflags_reserved
,
1355 {"Reserved", "dhcpfo.ipflags.reserved",
1356 FT_BOOLEAN
, 8, NULL
, 0x80,
1359 {&hf_dhcpfo_ipflags_bootp
,
1360 {"BOOTP", "dhcpfo.ipflags.bootp",
1361 FT_BOOLEAN
, 8, NULL
, 0x40,
1364 {&hf_dhcpfo_ipflags_mbz
,
1365 {"MBZ", "dhcpfo.ipflags.mbz",
1366 FT_UINT8
, BASE_HEX
, NULL
, 0x3F,
1369 {&hf_dhcpfo_message_digest_type
,
1370 {"Message digest type", "dhcpfo.message_digest_type",
1371 FT_UINT8
, BASE_DEC
, VALS(message_digest_type_vals
), 0,
1374 {&hf_dhcpfo_tls_request
,
1375 {"TLS Request", "dhcpfo.tls_request",
1376 FT_UINT8
, BASE_DEC
, VALS(tls_request_vals
), 0,
1379 {&hf_dhcpfo_tls_reply
,
1380 {"TLS Reply", "dhcpfo.tls_reply",
1381 FT_UINT8
, BASE_DEC
, VALS(tls_reply_vals
), 0,
1384 {&hf_dhcpfo_serverflag
,
1385 {"Serverflag", "dhcpfo.serverflag",
1386 FT_UINT8
, BASE_DEC
, VALS(serverflag_vals
), 0,
1389 {&hf_dhcpfo_options
,
1390 {"Options", "dhcpfo.options",
1391 FT_BYTES
, BASE_NONE
, NULL
, 0,
1394 {&hf_dhcpfo_ms_client_name
,
1395 {"Client name (Microsoft-specific)", "dhcpfo.microsoft.clientname",
1396 FT_STRING
, BASE_NONE
, NULL
, 0,
1399 {&hf_dhcpfo_ms_client_description
,
1400 {"Client description (Microsoft-specific)", "dhcpfo.microsoft.clientdescription",
1401 FT_STRING
, BASE_NONE
, NULL
, 0,
1404 {&hf_dhcpfo_ms_client_type
,
1405 {"Client type (Microsoft-specific)", "dhcpfo.microsoft.clienttype",
1406 FT_UINT8
, BASE_NONE
, VALS(ms_client_type_vals
), 0,
1409 {&hf_dhcpfo_ms_client_nap_status
,
1410 {"Client NAP status (Microsoft-specific)", "dhcpfo.microsoft.clientnapstatus",
1411 FT_UINT8
, BASE_NONE
, VALS(ms_client_nap_status_vals
), 0,
1414 {&hf_dhcpfo_ms_client_nap_capable
,
1415 {"Client NAP capable (Microsoft-specific)", "dhcpfo.microsoft.clientnapcapable",
1416 FT_BOOLEAN
, BASE_NONE
, NULL
, 0,
1419 {&hf_dhcpfo_ms_client_nap_probation
,
1420 {"Client NAP probation (Microsoft-specific)", "dhcpfo.microsoft.clientnapprobation",
1421 FT_UINT32
, BASE_DEC
, NULL
, 0,
1424 {&hf_dhcpfo_ms_client_matched_policy
,
1425 {"Client matched policy (Microsoft-specific)", "dhcpfo.microsoft.clientmatchedpolicy",
1426 FT_STRING
, BASE_NONE
, NULL
, 0,
1429 {&hf_dhcpfo_ms_server_name
,
1430 {"Server name (Microsoft-specific)", "dhcpfo.microsoft.servername",
1431 FT_STRING
, BASE_NONE
, NULL
, 0,
1434 {&hf_dhcpfo_ms_client_scope
,
1435 {"Client DHCP scope (Microsoft-specific)", "dhcpfo.microsoft.clientscope",
1436 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1439 {&hf_dhcpfo_ms_client_subnet_mask
,
1440 {"Client subnet mask (Microsoft-specific)", "dhcpfo.microsoft.clientsubnetmask",
1441 FT_IPv4
, BASE_NETMASK
, NULL
, 0x0,
1444 {&hf_dhcpfo_ms_scope_id
,
1445 {"Scope ID (Microsoft-specific)", "dhcpfo.microsoft.scopeid",
1446 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1449 {&hf_dhcpfo_ms_server_ip
,
1450 {"Server IP (Microsoft-specific)", "dhcpfo.microsoft.serverip",
1451 FT_IPv4
, BASE_NONE
, NULL
, 0x0,
1454 {&hf_dhcpfo_ms_ipflags
,
1455 {"IP flags (Microsoft-specific)", "dhcpfo.microsoft.ipflags",
1456 FT_UINT8
, BASE_HEX
, NULL
, 0,
1459 {&hf_dhcpfo_ms_extended_address_state
,
1460 {"Extended address state (Microsoft-specific)", "dhcpfo.microsoft.extendedaddressstate",
1461 FT_UINT32
, BASE_HEX
, NULL
, 0,
1464 {&hf_dhcpfo_infoblox_client_hostname
,
1465 {"Client hostname (Infoblox-specific)", "dhcpfo.infoblox.clienthostname",
1466 FT_STRING
, BASE_NONE
, NULL
, 0,
1469 {&hf_dhcpfo_unknown_data
,
1470 {"Unknown data", "dhcpfo.unknowndata",
1471 FT_BYTES
, BASE_NONE
, NULL
, 0,
1476 /* Setup protocol subtree array */
1477 static int *ett
[] = {
1481 &ett_fo_payload_data
,
1484 static ei_register_info ei
[] = {
1485 { &ei_dhcpfo_bad_length
, { "dhcpfo.bad_length", PI_PROTOCOL
, PI_WARN
, "Bad length", EXPFILL
}},
1486 { &ei_dhcpfo_message_digest_type_not_allowed
, { "dhcpfo.message_digest_type_not_allowed", PI_PROTOCOL
, PI_WARN
, "Message digest type not allowed", EXPFILL
}},
1489 module_t
*dhcpfo_module
;
1490 expert_module_t
* expert_dhcpfo
;
1492 /* Register the protocol name and description */
1493 proto_dhcpfo
= proto_register_protocol("DHCP Failover", "DHCPFO", "dhcpfo");
1495 /* Required function calls to register the header fields and subtrees used */
1496 proto_register_field_array(proto_dhcpfo
, hf
, array_length(hf
));
1497 proto_register_subtree_array(ett
, array_length(ett
));
1498 expert_dhcpfo
= expert_register_protocol(proto_dhcpfo
);
1499 expert_register_field_array(expert_dhcpfo
, ei
, array_length(ei
));
1501 dhcpfo_module
= prefs_register_protocol(proto_dhcpfo
, NULL
);
1503 prefs_register_bool_preference(dhcpfo_module
, "desegment",
1504 "Reassemble DHCP failover messages spanning multiple TCP segments",
1505 "Whether the DHCP failover dissector should reassemble messages spanning multiple TCP segments."
1506 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
1508 prefs_register_enum_preference(dhcpfo_module
, "microsoft_compatibility",
1509 "Microsoft Windows DHCP server compatibility",
1510 "Enables the dissector to show Microsoft-formatted option fields correctly",
1511 &dhcpfo_microsoft_compatibility
,
1512 microsoft_compatibility
, false);
1514 dhcpfo_handle
= register_dissector("dhcpfo", dissect_dhcpfo
, proto_dhcpfo
);
1518 proto_reg_handoff_dhcpfo(void)
1520 dissector_add_uint_with_preference("tcp.port", TCP_PORT_DHCPFO
, dhcpfo_handle
);
1524 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1529 * indent-tabs-mode: t
1532 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
1533 * :indentSize=8:tabSize=8:noTabs=false: