2 * Routines for ISC DHCP Server failover protocol dissection
3 * Copyright 2004, M. Ortega y Strupp <moys@loplof.de>
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * This implementation is loosely based on draft-ietf-dhc-failover-07.txt.
28 * As this document does not represent the actual implementation, the
29 * source code of ISC DHCPD 3.0 was used too.
33 * http://community.roxen.com/developers/idocs/drafts/draft-ietf-dhc-failover-10.html
35 * upon which the handling of the message-digest option is based.
48 #include <epan/packet.h>
50 #include "packet-arp.h"
52 #define TCP_PORT_DHCPFO 519
54 static unsigned int tcp_port_pref = TCP_PORT_DHCPFO;
56 static dissector_handle_t dhcpfo_handle;
58 /* Initialize the protocol and registered fields */
59 static int proto_dhcpfo = -1;
60 static int hf_dhcpfo_length = -1;
61 static int hf_dhcpfo_type = -1;
62 static int hf_dhcpfo_poffset = -1;
63 static int hf_dhcpfo_time = -1;
64 static int hf_dhcpfo_xid = -1;
65 static int hf_dhcpfo_additional_HB = -1;
66 static int hf_dhcpfo_payload_data = -1;
67 static int hf_dhcpfo_option_code = -1;
68 static int hf_dhcpfo_dhcp_style_option = -1;
69 static int hf_dhcpfo_option_length = -1;
70 static int hf_dhcpfo_binding_status = -1;
71 static int hf_dhcpfo_server_state = -1;
72 static int hf_dhcpfo_assigned_ip_address = -1;
73 static int hf_dhcpfo_sending_server_ip_address = -1;
74 static int hf_dhcpfo_addresses_transfered = -1;
75 static int hf_dhcpfo_client_identifier = -1;
76 static int hf_dhcpfo_client_hw_type = -1;
77 static int hf_dhcpfo_client_hardware_address = -1;
78 static int hf_dhcpfo_ftddns = -1;
79 static int hf_dhcpfo_reject_reason = -1;
80 static int hf_dhcpfo_message = -1;
81 static int hf_dhcpfo_mclt = -1;
82 static int hf_dhcpfo_vendor_class = -1;
83 static int hf_dhcpfo_lease_expiration_time = -1;
84 static int hf_dhcpfo_grace_expiration_time = -1;
85 static int hf_dhcpfo_potential_expiration_time = -1;
86 static int hf_dhcpfo_client_last_transaction_time = -1;
87 static int hf_dhcpfo_start_time_of_state = -1;
88 static int hf_dhcpfo_vendor_option = -1;
89 static int hf_dhcpfo_max_unacked_bndupd = -1;
90 static int hf_dhcpfo_protocol_version = -1;
91 static int hf_dhcpfo_receive_timer = -1;
92 static int hf_dhcpfo_message_digest = -1;
93 static int hf_dhcpfo_hash_bucket_assignment = -1;
95 /* Initialize the subtree pointers */
96 static gint ett_dhcpfo = -1;
97 static gint ett_fo_payload = -1;
98 static gint ett_fo_option = -1;
100 /* structure for payload data */
101 struct payloadMessage {
102 struct payloadMessage *next;
108 struct payloadMessage *liste;
110 /* message-types of failover */
127 static const value_string failover_vals[] =
129 {DHCP_FO_RESERVED, "Reserved"},
130 {DHCP_FO_POOLREQ, "Pool request"},
131 {DHCP_FO_POOLRESP, "Pool response"},
132 {DHCP_FO_BNDUPD, "Binding update"},
133 {DHCP_FO_BNDACK, "Binding acknowledge"},
134 {DHCP_FO_CONNECT, "Connect"},
135 {DHCP_FO_CONNECTACK, "Connect acknowledge"},
136 {DHCP_FO_UPDREQ, "Update request all"},
137 {DHCP_FO_UPDDONE, "Update done"},
138 {DHCP_FO_UPDREQALL, "Update request"},
139 {DHCP_FO_STATE, "State"},
140 {DHCP_FO_CONTACT, "Contact"},
141 {DHCP_FO_DISCONNECT, "Disconnect"},
145 /*options of payload-data*/
147 DHCP_FO_PD_UNKNOWN_PACKET0,
148 DHCP_FO_PD_BINDING_STATUS,
149 DHCP_FO_PD_ASSIGNED_IP_ADDRESS,
150 DHCP_FO_PD_SENDING_SERVER_IP_ADDRESS,
151 DHCP_FO_PD_ADDRESSES_TRANSFERED,
152 DHCP_FO_PD_CLIENT_IDENTIFIER,
153 DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS,
155 DHCP_FO_PD_REJECT_REASON,
158 DHCP_FO_PD_VENDOR_CLASS,
159 DHCP_FO_PD_UNKNOWN_PACKET12,
160 DHCP_FO_PD_LEASE_EXPIRATION_TIME,
161 DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME,
162 DHCP_FO_PD_GRACE_EXPIRATION_TIME,
163 DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME,
164 DHCP_FO_PD_START_TIME_OF_STATE,
165 DHCP_FO_PD_SERVERSTATE,
166 DHCP_FO_PD_SERVERFLAG,
167 DHCP_FO_PD_VENDOR_OPTION,
168 DHCP_FO_PD_MAX_UNACKED_BNDUPD,
169 DHCP_FO_PD_UNKNOWN_PACKET22,
170 DHCP_FO_PD_RECEIVE_TIMER,
171 DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT,
172 DHCP_FO_PD_MESSAGE_DIGEST,
173 DHCP_FO_PD_PROTOCOL_VERSION,
174 DHCP_FO_PD_TLS_REQUEST,
175 DHCP_FO_PD_TLS_REPLY,
176 DHCP_FO_PD_REQUEST_OPTION,
177 DHCP_FO_PD_REPLY_OPTION
180 static const value_string option_code_vals[] =
182 {DHCP_FO_PD_UNKNOWN_PACKET0, "Unknown Packet"},
183 {DHCP_FO_PD_BINDING_STATUS, "binding-status"},
184 {DHCP_FO_PD_ASSIGNED_IP_ADDRESS, "assigned-IP-address"},
185 {DHCP_FO_PD_SENDING_SERVER_IP_ADDRESS, "sending-server-IP-address"},
186 {DHCP_FO_PD_ADDRESSES_TRANSFERED, "addresses-transfered"},
187 {DHCP_FO_PD_CLIENT_IDENTIFIER, "client-identifier"},
188 {DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS, "client-hardware-address"},
189 {DHCP_FO_PD_FTDDNS, "FTDDNS"},
190 {DHCP_FO_PD_REJECT_REASON, "reject-reason"},
191 {DHCP_FO_PD_MESSAGE, "message"},
192 {DHCP_FO_PD_MCLT, "MCLT"},
193 {DHCP_FO_PD_VENDOR_CLASS, "vendor-class"},
194 {DHCP_FO_PD_UNKNOWN_PACKET12, "Unknown Packet"},
195 {DHCP_FO_PD_LEASE_EXPIRATION_TIME, "lease-expiration-time"},
196 {DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME, "potential-expiration-time"},
197 {DHCP_FO_PD_GRACE_EXPIRATION_TIME, "grace-expiration-time"},
198 {DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME, "client-last-transaction-time"},
199 {DHCP_FO_PD_START_TIME_OF_STATE, "start-time-of-state"},
200 {DHCP_FO_PD_SERVERSTATE, "server-state"},
201 {DHCP_FO_PD_SERVERFLAG, "server-flag"},
202 {DHCP_FO_PD_VENDOR_OPTION, "vendor-option"},
203 {DHCP_FO_PD_MAX_UNACKED_BNDUPD, "max-unacked-BNDUPD"},
204 {DHCP_FO_PD_UNKNOWN_PACKET22, "Unknown Packet"},
205 {DHCP_FO_PD_RECEIVE_TIMER, "receive-timer"},
206 {DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT, "hash-bucket-assignment"},
207 {DHCP_FO_PD_MESSAGE_DIGEST, "message-digest"},
208 {DHCP_FO_PD_PROTOCOL_VERSION, "protocol-version"},
209 {DHCP_FO_PD_TLS_REQUEST, "TLS-request"},
210 {DHCP_FO_PD_TLS_REPLY, "TLS-reply"},
211 {DHCP_FO_PD_REQUEST_OPTION, "request-option"},
212 {DHCP_FO_PD_REPLY_OPTION, "reply-option"},
219 DHCP_FO_BS_UNKNOWN_PACKET,
224 DHCP_FO_BS_ABANDONED,
229 static const value_string binding_status_vals[] =
231 {DHCP_FO_BS_UNKNOWN_PACKET, "Unknown Packet"},
232 {DHCP_FO_BS_FREE, "FREE"},
233 {DHCP_FO_BS_ACTIVE, "ACTIVE"},
234 {DHCP_FO_BS_EXPIRED, "EXPIRED"},
235 {DHCP_FO_BS_RELEASED, "RELEASED"},
236 {DHCP_FO_BS_ABANDONED, "ABANDONED"},
237 {DHCP_FO_BS_RESET, "RESET"},
238 {DHCP_FO_BS_BACKUP, "BACKUP"},
245 DHCP_FO_SS_UNKNOWN_PACKET,
246 DHCP_FO_SS_PARTNER_DOWN,
248 DHCP_FO_SS_COMMUNICATION_INTERRUPTED,
249 DHCP_FO_SS_RESOLUTION_INTERRUPTED,
250 DHCP_FO_SS_POTENTIAL_CONFLICT,
252 DHCP_FO_SS_RECOVER_DONE,
256 DHCP_FO_SS_RECOVER_WAIT
260 static const value_string server_state_vals[] =
262 {DHCP_FO_SS_UNKNOWN_PACKET, "Unknown Packet"},
263 {DHCP_FO_SS_PARTNER_DOWN, "partner down"},
264 {DHCP_FO_SS_NORMAL, "normal"},
265 {DHCP_FO_SS_COMMUNICATION_INTERRUPTED, "communication interrupted"},
266 {DHCP_FO_SS_RESOLUTION_INTERRUPTED, "resolution interrupted"},
267 {DHCP_FO_SS_POTENTIAL_CONFLICT, "potential conflict"},
268 {DHCP_FO_SS_RECOVER, "recover"},
269 {DHCP_FO_SS_RECOVER_DONE, "recover done"},
270 {DHCP_FO_SS_SHUTDOWN, "shutdown"},
271 {DHCP_FO_SS_PAUSED, "paused"},
272 {DHCP_FO_SS_STARTUP, "startup"},
273 {DHCP_FO_SS_RECOVER_WAIT, "recover wait"},
306 static const value_string reject_reason_vals[] =
308 {DHCP_FO_RR_0, "Reserved"},
309 {DHCP_FO_RR_1, "Illegal IP address (not part of any address pool)"},
310 {DHCP_FO_RR_2, "Fatal conflict exists: address in use by other client"},
311 {DHCP_FO_RR_3, "Missing binding information"},
312 {DHCP_FO_RR_4, "Connection rejected, time mismatch too great"},
313 {DHCP_FO_RR_5, "Connection rejected, invalid MCLT"},
314 {DHCP_FO_RR_6, "Connection rejected, unknown reason"},
315 {DHCP_FO_RR_7, "Connection rejected, duplicate connection"},
316 {DHCP_FO_RR_8, "Connection rejected, invalid failover partner"},
317 {DHCP_FO_RR_9, "TLS not supported"},
318 {DHCP_FO_RR_10, "TLS supported but not configured"},
319 {DHCP_FO_RR_11, "TLS required but not supported by partner"},
320 {DHCP_FO_RR_12, "Message digest not supported"},
321 {DHCP_FO_RR_13, "Message digest not configured"},
322 {DHCP_FO_RR_14, "Protocol version mismatch"},
323 {DHCP_FO_RR_15, "Missing binding information"},
324 {DHCP_FO_RR_16, "Outdated binding information"},
325 {DHCP_FO_RR_17, "Less critical binding information"},
326 {DHCP_FO_RR_18, "No traffic within sufficient time"},
327 {DHCP_FO_RR_19, "Hash bucket assignment conflict"},
328 {DHCP_FO_RR_254, "Unknown: Error occurred but does not match any reason"},
332 /* Code to actually dissect the packets */
334 dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
337 /* Set up structures needed to add the protocol subtree and manage it */
338 proto_item *ti, *pi, *oi, *receive_timer_item;
339 proto_tree *dhcpfo_tree, *payload_tree, *option_tree;
340 guint16 length, tls_request;
341 guint type, serverflag;
344 gchar *typestrval, *optionstrval, *tls_request_string;
345 guint32 time, lease_expiration_time, grace_expiration_time;
346 guint32 potential_expiration_time, client_last_transaction_time;
347 guint32 start_time_of_state;
348 enum DHCPFOBoolean { false, true } additionalHB, more_payload;
349 guint additionalHBlength;
350 struct payloadMessage *helpliste;
352 guint8 htype, reject_reason, message_digest_type;
353 const guint8 *chaddr;
354 guint8 binding_status;
355 gchar *binding_status_str, *reject_reason_str;
356 gchar *assigned_ip_address_str, *sending_server_ip_address_str;
357 guint32 addresses_transfered;
358 const guint8 *client_identifier_str, *vendor_class_str;
359 gchar *htype_str, *chaddr_str;
360 gchar *lease_expiration_time_str;
361 gchar *grace_expiration_time_str, *potential_expiration_time_str;
362 gchar *client_last_transaction_time_str, *start_time_of_state_str;
363 gchar *server_state_str;
365 guint8 server_state, protocol_version;
366 guint32 max_unacked_bndupd, receive_timer;
368 /* Make entries in Protocol column and Info column on summary display */
369 if (check_col(pinfo->cinfo, COL_PROTOCOL))
370 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DHCPFO");
372 length = tvb_get_ntohs(tvb, 0);
373 type = tvb_get_guint8(tvb, 2);
374 typestrval= match_strval(type,failover_vals);
375 if (typestrval==NULL) {
376 typestrval="Unknown Packet";
378 poffset = tvb_get_guint8(tvb, 3);
383 additionalHBlength = poffset-12;
387 additionalHB = false;
388 additionalHBlength = 0;
390 xid = tvb_get_ntohl(tvb, 8);
392 if (check_col(pinfo->cinfo, COL_INFO)){
393 col_add_fstr(pinfo->cinfo,
394 COL_INFO,"%s xid: %x", typestrval,xid);
397 actualoffset = poffset;
401 if(length-poffset != 0)
404 /*liste->next = NULL;*/
405 liste = (struct payloadMessage*)g_malloc(sizeof(struct payloadMessage));
407 actualoffset = poffset;
409 while(more_payload == true)
412 helpliste->opcode = tvb_get_ntohs(tvb, actualoffset);
413 helpliste->length = tvb_get_ntohs(tvb, actualoffset+2);
414 helpliste->next = NULL;
415 helpliste->actualpoffset = actualoffset;
416 actualoffset = actualoffset + helpliste->length + 4;
417 if(actualoffset>=length)
419 more_payload = false;
423 helpliste->next = (struct payloadMessage*)g_malloc(sizeof(struct payloadMessage));
425 helpliste = helpliste->next;
433 /* create display subtree for the protocol */
434 ti = proto_tree_add_item(tree, proto_dhcpfo, tvb, 0, -1, FALSE);
436 dhcpfo_tree = proto_item_add_subtree(ti, ett_dhcpfo);
438 proto_tree_add_item(dhcpfo_tree,
439 hf_dhcpfo_length, tvb, 0, 2, FALSE);
441 proto_tree_add_item(dhcpfo_tree,
442 hf_dhcpfo_type, tvb, 2, 1, FALSE);
444 proto_tree_add_item(dhcpfo_tree,
445 hf_dhcpfo_poffset, tvb, 3, 1, FALSE);
447 time = tvb_get_ntohl(tvb, 4);
448 proto_tree_add_uint_format(dhcpfo_tree, hf_dhcpfo_time, tvb, 4, 4,time,"%s", abs_time_secs_to_str(time));
451 proto_tree_add_item(dhcpfo_tree,
452 hf_dhcpfo_xid, tvb, 8, 4, FALSE);
454 /* if there are any additional header bytes */
455 if(additionalHB==true)
457 proto_tree_add_item(dhcpfo_tree,
458 hf_dhcpfo_additional_HB, tvb, 12, additionalHBlength, FALSE);
462 if(length-poffset != 0)
465 /* create display subtree for the protocol */
466 pi = proto_tree_add_item(dhcpfo_tree, hf_dhcpfo_payload_data, tvb, poffset, length-poffset, FALSE);
467 payload_tree = proto_item_add_subtree(pi, ett_fo_payload);
472 while(helpliste!=NULL)
474 oi = proto_tree_add_item(payload_tree, hf_dhcpfo_dhcp_style_option, tvb, helpliste->actualpoffset, helpliste->length+4, FALSE);
475 option_tree = proto_item_add_subtree(oi, ett_fo_option);
477 /*** DHCP-Style-Options ****/
479 optionstrval= match_strval(helpliste->opcode,option_code_vals);
480 if (optionstrval==NULL) {
481 optionstrval="Unknown Packet";
485 proto_item_append_text(oi, ", %s (%d)",
486 optionstrval, helpliste->opcode);
488 proto_tree_add_item(option_tree,
489 hf_dhcpfo_option_code, tvb,
490 helpliste->actualpoffset, 2, FALSE);
493 proto_tree_add_item(option_tree,
494 hf_dhcpfo_option_length, tvb,
495 helpliste->actualpoffset+2, 2, FALSE);
498 /** opcode dependent format **/
500 switch(helpliste->opcode){
502 case DHCP_FO_PD_BINDING_STATUS:
504 binding_status = tvb_get_guint8(tvb,
505 helpliste->actualpoffset+4);
507 match_strval(binding_status,
508 binding_status_vals);
509 if(binding_status_str == NULL)
511 binding_status_str = "Unknown Packet";
513 proto_item_append_text(oi, ", %s (%d)",
517 proto_tree_add_item(option_tree,
518 hf_dhcpfo_binding_status, tvb,
519 helpliste->actualpoffset + 4, 1, FALSE);
522 case DHCP_FO_PD_ASSIGNED_IP_ADDRESS:
524 assigned_ip_address_str = ip_to_str(
526 helpliste->actualpoffset+4,
529 proto_item_append_text(oi, ", %s ",
530 assigned_ip_address_str);
532 proto_tree_add_item(option_tree,
533 hf_dhcpfo_assigned_ip_address, tvb,
534 helpliste->actualpoffset + 4,
535 helpliste->length , FALSE);
538 case DHCP_FO_PD_SENDING_SERVER_IP_ADDRESS:
540 sending_server_ip_address_str = ip_to_str(tvb_get_ptr(tvb,helpliste->actualpoffset+4,helpliste->length));
542 proto_item_append_text(oi, ", %s ",
543 sending_server_ip_address_str);
544 proto_tree_add_item(option_tree,
545 hf_dhcpfo_sending_server_ip_address, tvb,
546 helpliste->actualpoffset + 4,
547 helpliste->length , FALSE);
550 case DHCP_FO_PD_ADDRESSES_TRANSFERED:
552 addresses_transfered = tvb_get_ntohl(tvb,
553 helpliste->actualpoffset+4);
555 proto_item_append_text(oi,", %d",addresses_transfered);
556 proto_tree_add_item(option_tree,
557 hf_dhcpfo_addresses_transfered, tvb,
558 helpliste->actualpoffset + 4,
559 helpliste->length , FALSE);
562 case DHCP_FO_PD_CLIENT_IDENTIFIER:
564 client_identifier_str = tvb_get_ptr(tvb,
565 helpliste->actualpoffset+4,
567 proto_item_append_text(oi,", \"%s\"",client_identifier_str);
568 proto_tree_add_item(option_tree,
569 hf_dhcpfo_client_identifier, tvb,
570 helpliste->actualpoffset + 4,
571 helpliste->length , FALSE);
574 case DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS:
576 htype = tvb_get_guint8(tvb,helpliste->actualpoffset+4);
577 chaddr = tvb_get_ptr(tvb, helpliste->actualpoffset+5,
578 helpliste->length-1);
579 htype_str = arphrdtype_to_str(htype, "Unknown (0x%02x)");
580 chaddr_str = arphrdaddr_to_str(tvb_get_ptr(tvb,
581 helpliste->actualpoffset+5, 6),6,htype);
583 proto_item_append_text(oi, ", %s, %s",
584 htype_str, chaddr_str);
586 proto_tree_add_text(option_tree, tvb,
587 helpliste->actualpoffset+4, 1,
591 proto_tree_add_text(option_tree, tvb,
592 helpliste->actualpoffset+5, 6,
593 "Client hardware address: %s",
597 case DHCP_FO_PD_FTDDNS:
599 proto_tree_add_item(option_tree,
600 hf_dhcpfo_ftddns, tvb,
601 helpliste->actualpoffset + 4,
602 helpliste->length , FALSE);
605 case DHCP_FO_PD_REJECT_REASON:
607 reject_reason = tvb_get_guint8(tvb,
608 helpliste->actualpoffset +4);
609 reject_reason_str = match_strval(reject_reason,
611 if (reject_reason_str==NULL) {
612 reject_reason_str="Unknown Packet";
615 proto_item_append_text(oi, ", %s (%d)",
619 proto_tree_add_item(option_tree,
620 hf_dhcpfo_reject_reason, tvb,
621 helpliste->actualpoffset +4,
622 helpliste->length, FALSE);
625 case DHCP_FO_PD_MESSAGE:
627 proto_tree_add_item(option_tree,
628 hf_dhcpfo_message, tvb,
629 helpliste->actualpoffset + 4,
630 helpliste->length , FALSE);
633 case DHCP_FO_PD_MCLT:
635 mclt = tvb_get_ntohl(tvb, helpliste->actualpoffset+4);
636 proto_item_append_text(oi,", %d seconds",mclt);
637 proto_tree_add_item(option_tree,
639 helpliste->actualpoffset +4,
640 helpliste->length, FALSE);
643 case DHCP_FO_PD_VENDOR_CLASS:
645 vendor_class_str = tvb_get_ptr(tvb,
646 helpliste->actualpoffset+4,helpliste->length);
647 proto_item_append_text(oi,", \"%s\"",vendor_class_str);
648 proto_tree_add_item(option_tree,
649 hf_dhcpfo_vendor_class, tvb,
650 helpliste->actualpoffset +4,
651 helpliste->length, FALSE);
654 case DHCP_FO_PD_LEASE_EXPIRATION_TIME:
656 lease_expiration_time = tvb_get_ntohl(tvb,
657 helpliste->actualpoffset+4);
658 lease_expiration_time_str =
659 abs_time_secs_to_str(lease_expiration_time);
661 proto_item_append_text(oi, ", %s",
662 lease_expiration_time_str);
664 proto_tree_add_uint_format(option_tree,
665 hf_dhcpfo_lease_expiration_time, tvb,
666 helpliste->actualpoffset +4,
668 lease_expiration_time,
669 "Lease expiration time: %s",
670 lease_expiration_time_str);
673 case DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME:
675 potential_expiration_time = tvb_get_ntohl(tvb,
676 helpliste->actualpoffset+4);
678 potential_expiration_time_str =
679 abs_time_secs_to_str(potential_expiration_time);
681 proto_item_append_text(oi, ", %s",
682 potential_expiration_time_str);
684 proto_tree_add_uint_format(option_tree,
685 hf_dhcpfo_potential_expiration_time, tvb,
686 helpliste->actualpoffset +4,
688 potential_expiration_time,
689 "Potential expiration time: %s",
690 potential_expiration_time_str);
693 case DHCP_FO_PD_GRACE_EXPIRATION_TIME:
695 grace_expiration_time = tvb_get_ntohl(tvb,
696 helpliste->actualpoffset+4);
698 grace_expiration_time_str =
699 abs_time_secs_to_str(grace_expiration_time);
701 proto_item_append_text(oi, ", %s",
702 grace_expiration_time_str);
704 proto_tree_add_uint_format(option_tree,
705 hf_dhcpfo_grace_expiration_time, tvb,
706 helpliste->actualpoffset +4,
708 grace_expiration_time,
709 "Grace expiration time: %s",
710 grace_expiration_time_str);
714 case DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME:
716 client_last_transaction_time = tvb_get_ntohl(tvb,
717 helpliste->actualpoffset+4);
718 client_last_transaction_time_str =
719 abs_time_secs_to_str(client_last_transaction_time);
721 proto_item_append_text(oi, ", %s",
722 client_last_transaction_time_str);
724 proto_tree_add_uint_format(option_tree,
725 hf_dhcpfo_client_last_transaction_time, tvb,
726 helpliste->actualpoffset +4,
728 client_last_transaction_time,
729 "Last transaction time: %s", abs_time_secs_to_str(client_last_transaction_time));
732 case DHCP_FO_PD_START_TIME_OF_STATE:
733 start_time_of_state = tvb_get_ntohl(tvb,
734 helpliste->actualpoffset+4);
735 start_time_of_state_str =
736 abs_time_secs_to_str(start_time_of_state);
738 proto_item_append_text(oi, ", %s",
739 start_time_of_state_str);
741 proto_tree_add_uint_format(option_tree,
742 hf_dhcpfo_start_time_of_state, tvb,
743 helpliste->actualpoffset +4,
746 "Start time of state: %s", abs_time_secs_to_str(start_time_of_state));
749 case DHCP_FO_PD_SERVERSTATE:
751 server_state = tvb_get_guint8(tvb, helpliste->actualpoffset+4);
753 server_state_str = match_strval(server_state,server_state_vals);
754 if (server_state_str==NULL) {
755 server_state_str="Unknown Packet";
757 proto_item_append_text(oi, ", %s (%d)",
758 server_state_str, server_state);
760 proto_tree_add_item(option_tree,
761 hf_dhcpfo_server_state, tvb,
762 helpliste->actualpoffset + 4, 1, FALSE);
765 case DHCP_FO_PD_SERVERFLAG:
767 serverflag = tvb_get_guint8(tvb,
768 helpliste->actualpoffset+4);
772 proto_item_append_text(oi, ", STARTUP (1)");
773 proto_tree_add_text(option_tree,tvb,
774 helpliste->actualpoffset +4,
776 "Serverflag: STARTUP");
779 else if(serverflag == 0)
781 proto_item_append_text(oi, ", NONE (%d)",
783 proto_tree_add_text(option_tree,tvb,
784 helpliste->actualpoffset +4,
790 proto_item_append_text(oi,
791 "UNKNOWN FLAGS (%d)", serverflag);
793 proto_tree_add_text(option_tree,tvb,
794 helpliste->actualpoffset +4,
796 "Serverflag: UNKNOWN FLAGS");
800 case DHCP_FO_PD_VENDOR_OPTION:
802 proto_tree_add_item(option_tree,
803 hf_dhcpfo_vendor_option, tvb,
804 helpliste->actualpoffset + 4,
805 helpliste->length , FALSE);
809 case DHCP_FO_PD_MAX_UNACKED_BNDUPD:
812 tvb_get_ntohl(tvb,helpliste->actualpoffset+4);
813 proto_item_append_text(oi,", %d", max_unacked_bndupd);
815 proto_tree_add_item(option_tree,
816 hf_dhcpfo_max_unacked_bndupd, tvb,
817 helpliste->actualpoffset + 4,
818 helpliste->length , FALSE);
821 case DHCP_FO_PD_RECEIVE_TIMER:
824 tvb_get_ntohl(tvb,helpliste->actualpoffset+4);
825 proto_item_append_text(oi,", %d seconds", receive_timer);
827 receive_timer_item = proto_tree_add_item(option_tree,
828 hf_dhcpfo_receive_timer, tvb,
829 helpliste->actualpoffset + 4,
830 helpliste->length , FALSE);
831 proto_item_append_text(receive_timer_item, " seconds");
834 case DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT:
836 proto_tree_add_item(option_tree,
837 hf_dhcpfo_hash_bucket_assignment, tvb,
838 helpliste->actualpoffset +4,
839 helpliste->length, FALSE);
842 case DHCP_FO_PD_MESSAGE_DIGEST:
844 message_digest_type = tvb_get_guint8(tvb,helpliste->actualpoffset+4);
845 if(message_digest_type == 1)
847 proto_item_append_text(oi, ", HMAC-MD5");
848 proto_tree_add_text(option_tree, tvb, helpliste->actualpoffset+4, 1, "Message digest type: HMAC-MD5");
852 proto_item_append_text(oi, ", type not allowed");
853 proto_tree_add_text(option_tree, tvb, helpliste->actualpoffset+4, 1, "Message digest type: not allowed");
856 proto_tree_add_item(option_tree,
857 hf_dhcpfo_message_digest, tvb,
858 helpliste->actualpoffset+5,
859 helpliste->length-1,FALSE);
862 case DHCP_FO_PD_PROTOCOL_VERSION:
865 tvb_get_guint8(tvb, helpliste->actualpoffset+4);
867 proto_item_append_text(oi, ", version: %d",
869 proto_tree_add_item(option_tree,
870 hf_dhcpfo_protocol_version, tvb,
871 helpliste->actualpoffset + 4,
872 helpliste->length , FALSE);
875 case DHCP_FO_PD_TLS_REQUEST:
877 tls_request = tvb_get_ntohs(tvb,helpliste->actualpoffset+4);
880 tls_request_string = "No TLS operation";
882 else if(tls_request == 1)
884 tls_request_string = "TLS operation desired but not required";
886 else if(tls_request == 2)
888 tls_request_string = "TLS operation is required";
892 tls_request_string = "Unknown value";
894 proto_item_append_text(oi, ", %s", tls_request_string);
896 proto_tree_add_text(option_tree, tvb,
897 helpliste->actualpoffset+4,
899 "TLS request: %s", tls_request_string);
902 case DHCP_FO_PD_TLS_REPLY:
904 case DHCP_FO_PD_REQUEST_OPTION:
906 case DHCP_FO_PD_REPLY_OPTION:
912 helpliste=helpliste->next;
924 proto_reg_handoff_dhcpfo(void)
926 static gboolean initialized = FALSE;
927 static unsigned int port = 0;
930 dissector_delete("tcp.port", port, dhcpfo_handle);
934 port = tcp_port_pref;
935 dissector_add("tcp.port", tcp_port_pref, dhcpfo_handle);
938 /* Register the protocol with Ethereal */
940 proto_register_dhcpfo(void)
943 /* Setup list of header fields See Section 1.6.1 for details*/
944 static hf_register_info hf[] = {
946 { "Message length", "dhcpfo.length",
947 FT_UINT16, BASE_DEC, NULL, 0,
951 { "Message Type", "dhcpfo.type",
952 FT_UINT8, BASE_DEC, VALS(failover_vals), 0,
956 { &hf_dhcpfo_poffset,
957 { "Payload Offset", "dhcpfo.poffset",
958 FT_UINT8, BASE_DEC, NULL, 0,
963 { "Time", "dhcpfo.time",
964 FT_UINT32, BASE_DEC, NULL, 0,
969 { "Xid", "dhcpfo.xid",
970 FT_UINT32, BASE_HEX, NULL, 0,
974 { &hf_dhcpfo_additional_HB,
975 {"Additional Header Bytes", "dhcpfo.additionalheaderbytes",
976 FT_BYTES, BASE_NONE, NULL, 0x0,
980 { &hf_dhcpfo_payload_data,
981 {"Payload Data", "dhcpfo.payloaddata",
982 FT_NONE, BASE_NONE, NULL, 0,
986 { &hf_dhcpfo_dhcp_style_option,
987 {"DHCP Style Option", "dhcpfo.dhcpstyleoption",
988 FT_NONE, BASE_NONE, NULL, 0,
992 { &hf_dhcpfo_option_code,
993 {"Option Code", "dhcpfo.optioncode",
994 FT_UINT16, BASE_DEC, VALS(option_code_vals), 0,
998 {&hf_dhcpfo_option_length,
999 {"Length", "dhcpfo.optionlength",
1000 FT_UINT16, BASE_DEC, NULL, 0,
1004 {&hf_dhcpfo_binding_status,
1005 {"Type", "dhcpfo.bindingstatus",
1006 FT_UINT32, BASE_DEC, VALS(binding_status_vals), 0,
1011 {&hf_dhcpfo_server_state,
1012 {"server status", "dhcpfo.serverstatus",
1013 FT_UINT8, BASE_DEC, VALS(server_state_vals), 0,
1018 {&hf_dhcpfo_assigned_ip_address,
1019 {"assigned ip address", "dhcpfo.assignedipaddress",
1020 FT_IPv4, BASE_NONE, NULL, 0x0,
1024 {&hf_dhcpfo_sending_server_ip_address,
1025 {"sending server ip-address", "dhcpfo.sendingserveripaddress",
1026 FT_IPv4, BASE_NONE, NULL, 0x0,
1031 {&hf_dhcpfo_addresses_transfered,
1032 {"addresses transfered", "dhcpfo.addressestransfered",
1033 FT_UINT8, BASE_DEC, NULL, 0,
1038 {&hf_dhcpfo_client_identifier,
1039 {"Client Identifier", "dhcpfo.clientidentifier",
1040 FT_STRING, BASE_NONE, NULL, 0,
1044 {&hf_dhcpfo_client_hw_type,
1045 {"Client Hardware Type", "dhcpfo.clienthardwaretype",
1046 FT_UINT8, BASE_HEX, NULL, 0x0,
1049 {&hf_dhcpfo_client_hardware_address,
1050 {"Client Hardware Address", "dhcpfo.clienthardwareaddress",
1051 FT_BYTES, BASE_NONE, NULL, 0,
1056 {"FTDDNS", "dhcpfo.ftddns",
1057 FT_STRING, BASE_NONE, NULL, 0,
1061 {&hf_dhcpfo_reject_reason,
1062 {"Reject reason", "dhcpfo.rejectreason",
1063 FT_UINT8, BASE_DEC, VALS(reject_reason_vals), 0,
1067 {&hf_dhcpfo_message,
1068 {"Message", "dhcpfo.message",
1069 FT_STRING, BASE_NONE, NULL, 0,
1075 {"MCLT", "dhcpfo.mclt",
1076 FT_UINT32, BASE_DEC, NULL, 0,
1080 {&hf_dhcpfo_vendor_class,
1081 {"Vendor class", "dhcpfo.vendorclass",
1082 FT_STRING, BASE_NONE, NULL, 0,
1086 {&hf_dhcpfo_lease_expiration_time,
1087 {"Lease expiration time", "dhcpfo.leaseexpirationtime",
1088 FT_UINT32, BASE_DEC, NULL, 0,
1092 {&hf_dhcpfo_grace_expiration_time,
1093 {"Grace expiration time", "dhcpfo.graceexpirationtime",
1094 FT_UINT32, BASE_DEC, NULL, 0,
1098 {&hf_dhcpfo_potential_expiration_time,
1099 {"Potential expiration time", "dhcpfo.potentialexpirationtime",
1100 FT_UINT32, BASE_DEC, NULL, 0,
1104 {&hf_dhcpfo_client_last_transaction_time,
1105 {"Client last transaction time", "dhcpfo.clientlasttransactiontime",
1106 FT_UINT32, BASE_DEC, NULL, 0,
1110 {&hf_dhcpfo_start_time_of_state,
1111 {"Start time of state", "dhcpfo.starttimeofstate",
1112 FT_UINT32, BASE_DEC, NULL, 0,
1116 {&hf_dhcpfo_vendor_option,
1117 {"Vendor option", "dhcpfo.vendoroption",
1118 FT_NONE, BASE_NONE, NULL, 0x0,
1122 {&hf_dhcpfo_max_unacked_bndupd,
1123 {"Max unacked BNDUPD", "dhcpfo.maxunackedbndupd",
1124 FT_UINT8, BASE_DEC, NULL, 0,
1128 {&hf_dhcpfo_protocol_version,
1129 {"Protocol version", "dhcpfo.protocolversion",
1130 FT_UINT8, BASE_DEC, NULL, 0,
1134 {&hf_dhcpfo_receive_timer,
1135 {"Receive timer", "dhcpfo.receivetimer",
1136 FT_UINT8, BASE_DEC, NULL, 0,
1140 {&hf_dhcpfo_message_digest,
1141 {"Message digest", "dhcpfo.messagedigest",
1142 FT_STRING, BASE_NONE, NULL, 0,
1146 {&hf_dhcpfo_hash_bucket_assignment,
1147 {"Hash bucket assignment", "dhcpfo.hashbucketassignment",
1148 FT_BYTES, BASE_HEX, NULL, 0,
1153 /* Setup protocol subtree array */
1154 static gint *ett[] = {
1160 module_t *dhcpfo_module;
1162 /* Register the protocol name and description */
1163 proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO",
1166 /* Required function calls to register the header fields and subtrees used */
1167 proto_register_field_array(proto_dhcpfo, hf, array_length(hf));
1168 proto_register_subtree_array(ett, array_length(ett));
1170 dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo);
1172 dhcpfo_module = prefs_register_protocol(proto_dhcpfo, proto_reg_handoff_dhcpfo);
1173 prefs_register_uint_preference(dhcpfo_module, "tcp_port",
1174 "DHCP failover TCP Port", "Set the port for DHCP failover communications",
1175 10, &tcp_port_pref);