fix usage of "if(tree) {" to display the right things, even if no coloring rule is set
[obnox/wireshark/wip.git] / epan / dissectors / packet-dhcp-failover.c
1 /* packet-dhcpfo.c
2  * Routines for ISC DHCP Server failover protocol dissection
3  * Copyright 2004, M. Ortega y Strupp <moys@loplof.de>
4  *
5  * $Id$
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
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.
15  *
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.
20  *
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.
24  */
25
26 /*
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.
30  *
31  * See also
32  *
33  *      http://community.roxen.com/developers/idocs/drafts/draft-ietf-dhc-failover-10.html
34  *
35  * upon which the handling of the message-digest option is based.
36  */
37
38 #ifdef HAVE_CONFIG_H
39 # include "config.h"
40 #endif
41
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <string.h>
45
46 #include <glib.h>
47
48 #include <epan/packet.h>
49 #include <prefs.h>
50 #include "packet-arp.h"
51
52 #define TCP_PORT_DHCPFO 519
53
54 static unsigned int tcp_port_pref = TCP_PORT_DHCPFO;
55
56 static dissector_handle_t dhcpfo_handle;
57
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;
94
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;
99
100 /* structure for payload data */
101 struct payloadMessage {
102         struct payloadMessage *next;
103         int opcode;
104         int length;
105         /*guint data;*/
106         int actualpoffset;
107 };
108 struct payloadMessage *liste;
109
110 /* message-types of failover */
111 enum {
112         DHCP_FO_RESERVED,
113         DHCP_FO_POOLREQ,
114         DHCP_FO_POOLRESP,
115         DHCP_FO_BNDUPD,
116         DHCP_FO_BNDACK,
117         DHCP_FO_CONNECT,
118         DHCP_FO_CONNECTACK,
119         DHCP_FO_UPDREQ,
120         DHCP_FO_UPDDONE,
121         DHCP_FO_UPDREQALL,
122         DHCP_FO_STATE,
123         DHCP_FO_CONTACT,
124         DHCP_FO_DISCONNECT
125 };
126
127 static const value_string failover_vals[] =
128 {
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"},
142         {0, NULL}
143 };
144
145 /*options of payload-data*/
146 enum {
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,
154         DHCP_FO_PD_FTDDNS,
155         DHCP_FO_PD_REJECT_REASON,
156         DHCP_FO_PD_MESSAGE,
157         DHCP_FO_PD_MCLT,
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
178 };
179
180 static const value_string option_code_vals[] =
181 {
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"},
213         {0, NULL}
214
215 };
216
217 /* Binding-status */
218 enum {
219         DHCP_FO_BS_UNKNOWN_PACKET,
220         DHCP_FO_BS_FREE,
221         DHCP_FO_BS_ACTIVE,
222         DHCP_FO_BS_EXPIRED,
223         DHCP_FO_BS_RELEASED,
224         DHCP_FO_BS_ABANDONED,
225         DHCP_FO_BS_RESET,
226         DHCP_FO_BS_BACKUP
227 };
228
229 static const value_string binding_status_vals[] =
230 {
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"},
239         {0, NULL}
240
241 };
242
243 /* Server-status */
244 enum {
245         DHCP_FO_SS_UNKNOWN_PACKET,
246         DHCP_FO_SS_PARTNER_DOWN,
247         DHCP_FO_SS_NORMAL,
248         DHCP_FO_SS_COMMUNICATION_INTERRUPTED,
249         DHCP_FO_SS_RESOLUTION_INTERRUPTED,
250         DHCP_FO_SS_POTENTIAL_CONFLICT,
251         DHCP_FO_SS_RECOVER,
252         DHCP_FO_SS_RECOVER_DONE,
253         DHCP_FO_SS_SHUTDOWN,
254         DHCP_FO_SS_PAUSED,
255         DHCP_FO_SS_STARTUP,
256         DHCP_FO_SS_RECOVER_WAIT
257 };
258
259
260 static const value_string server_state_vals[] =
261 {
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"},
274         {0, NULL}
275 };
276
277 /* reject reasons */
278
279
280 enum {
281         DHCP_FO_RR_0,
282         DHCP_FO_RR_1,
283         DHCP_FO_RR_2,
284         DHCP_FO_RR_3,
285         DHCP_FO_RR_4,
286         DHCP_FO_RR_5,
287         DHCP_FO_RR_6,
288         DHCP_FO_RR_7,
289         DHCP_FO_RR_8,
290         DHCP_FO_RR_9,
291         DHCP_FO_RR_10,
292         DHCP_FO_RR_11,
293         DHCP_FO_RR_12,
294         DHCP_FO_RR_13,
295         DHCP_FO_RR_14,
296         DHCP_FO_RR_15,
297         DHCP_FO_RR_16,
298         DHCP_FO_RR_17,
299         DHCP_FO_RR_18,
300         DHCP_FO_RR_19,
301         DHCP_FO_RR_254 = 254 
302         
303 };
304
305
306 static const value_string reject_reason_vals[] =
307 {
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"}, 
329         {0, NULL}
330 };
331
332 /* Code to actually dissect the packets */
333 static void
334 dissect_dhcpfo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
335 {
336
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;
342         guint poffset;
343         guint32 xid;
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;
351         int actualoffset;
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;
364         guint32 mclt;
365         guint8 server_state, protocol_version;
366         guint32 max_unacked_bndupd, receive_timer;
367
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");
371     
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";
377         }
378         poffset = tvb_get_guint8(tvb, 3);
379         
380         if(poffset > 12)
381         {
382                 additionalHB = true;
383                 additionalHBlength = poffset-12;
384         }
385         else
386         {
387                 additionalHB = false;
388                 additionalHBlength = 0;
389         }
390         xid = tvb_get_ntohl(tvb, 8);
391
392         if (check_col(pinfo->cinfo, COL_INFO)){ 
393                 col_add_fstr(pinfo->cinfo, 
394                                 COL_INFO,"%s xid: %x", typestrval,xid);
395         }
396         
397         actualoffset = poffset;
398         liste = NULL;
399
400         /* payload-data */
401         if(length-poffset != 0)
402         {
403                 more_payload = true;
404                 /*liste->next = NULL;*/
405                 liste = (struct payloadMessage*)g_malloc(sizeof(struct payloadMessage));
406                 helpliste = liste;
407                 actualoffset = poffset;
408
409                 while(more_payload == true)
410                 {
411                         
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)
418                         {
419                                 more_payload = false;
420                         }
421                         else
422                         {
423                                 helpliste->next = (struct payloadMessage*)g_malloc(sizeof(struct payloadMessage));
424                         }
425                         helpliste = helpliste->next;
426                 }
427                 
428         }
429         
430         if (tree) {
431
432
433                 /* create display subtree for the protocol */
434                 ti = proto_tree_add_item(tree, proto_dhcpfo, tvb, 0, -1, FALSE);
435
436                 dhcpfo_tree = proto_item_add_subtree(ti, ett_dhcpfo);
437
438                 proto_tree_add_item(dhcpfo_tree,
439                     hf_dhcpfo_length, tvb, 0, 2, FALSE);
440
441                 proto_tree_add_item(dhcpfo_tree,
442                     hf_dhcpfo_type, tvb, 2, 1, FALSE);
443
444                 proto_tree_add_item(dhcpfo_tree,
445                     hf_dhcpfo_poffset, tvb, 3, 1, FALSE);
446
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)); 
449                 
450
451                 proto_tree_add_item(dhcpfo_tree,
452                     hf_dhcpfo_xid, tvb, 8, 4, FALSE);
453
454                 /* if there are any additional header bytes */
455                 if(additionalHB==true)
456                 {
457                         proto_tree_add_item(dhcpfo_tree,
458                                 hf_dhcpfo_additional_HB, tvb, 12, additionalHBlength, FALSE);
459                 } 
460                 
461
462                 if(length-poffset != 0)
463                 {
464
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);
468
469                         
470                         
471                         helpliste = liste;      
472                         while(helpliste!=NULL)
473                         {
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);
476                                 
477                                 /*** DHCP-Style-Options ****/
478
479                                 optionstrval=  match_strval(helpliste->opcode,option_code_vals);
480                                 if (optionstrval==NULL) {
481                                         optionstrval="Unknown Packet";
482                                 }
483
484
485                                 proto_item_append_text(oi, ", %s (%d)", 
486                                         optionstrval, helpliste->opcode);
487
488                                 proto_tree_add_item(option_tree,
489                                         hf_dhcpfo_option_code, tvb, 
490                                         helpliste->actualpoffset, 2, FALSE);
491                 
492
493                                 proto_tree_add_item(option_tree,
494                                         hf_dhcpfo_option_length, tvb,
495                                         helpliste->actualpoffset+2, 2, FALSE); 
496
497                                 
498                                 /** opcode dependent format **/
499
500                                 switch(helpliste->opcode){
501                                 
502                                 case DHCP_FO_PD_BINDING_STATUS:
503
504                                         binding_status = tvb_get_guint8(tvb,
505                                                 helpliste->actualpoffset+4);
506                                         binding_status_str = 
507                                                 match_strval(binding_status,
508                                                         binding_status_vals);
509                                         if(binding_status_str == NULL)
510                                         {
511                                                 binding_status_str = "Unknown Packet";
512                                         }
513                                         proto_item_append_text(oi, ", %s (%d)",
514                                                         binding_status_str, 
515                                                         binding_status);
516
517                                         proto_tree_add_item(option_tree,
518                                                 hf_dhcpfo_binding_status, tvb,
519                                                 helpliste->actualpoffset + 4, 1, FALSE);
520                                         break;   
521
522                                 case DHCP_FO_PD_ASSIGNED_IP_ADDRESS:
523
524                                         assigned_ip_address_str = ip_to_str(
525                                                 tvb_get_ptr(tvb,
526                                                         helpliste->actualpoffset+4,
527                                                         helpliste->length));
528
529                                         proto_item_append_text(oi, ", %s ",
530                                                 assigned_ip_address_str);
531
532                                         proto_tree_add_item(option_tree,
533                                                 hf_dhcpfo_assigned_ip_address, tvb,
534                                                 helpliste->actualpoffset + 4, 
535                                                 helpliste->length , FALSE); 
536                                         break;
537
538                                 case DHCP_FO_PD_SENDING_SERVER_IP_ADDRESS:
539
540                                         sending_server_ip_address_str = ip_to_str(tvb_get_ptr(tvb,helpliste->actualpoffset+4,helpliste->length));
541                                         
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); 
548                                         break;
549
550                                 case DHCP_FO_PD_ADDRESSES_TRANSFERED:
551
552                                         addresses_transfered = tvb_get_ntohl(tvb,
553                                                                 helpliste->actualpoffset+4);
554
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); 
560                                         break; 
561
562                                 case DHCP_FO_PD_CLIENT_IDENTIFIER:
563
564                                         client_identifier_str = tvb_get_ptr(tvb,
565                                                                         helpliste->actualpoffset+4,
566                                                                         helpliste->length);
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); 
572                                         break;  
573
574                                 case DHCP_FO_PD_CLIENT_HARDWARE_ADDRESS:
575
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);
582
583                                         proto_item_append_text(oi, ", %s, %s",
584                                                 htype_str, chaddr_str);
585
586                                         proto_tree_add_text(option_tree, tvb, 
587                                                 helpliste->actualpoffset+4, 1,
588                                                 "Hardware type: %s",
589                                                 htype_str);
590
591                                         proto_tree_add_text(option_tree, tvb, 
592                                                 helpliste->actualpoffset+5, 6,
593                                                 "Client hardware address: %s",
594                                                 chaddr_str);
595                                         break;    
596
597                                 case DHCP_FO_PD_FTDDNS:
598
599                                         proto_tree_add_item(option_tree,
600                                                 hf_dhcpfo_ftddns, tvb,
601                                                 helpliste->actualpoffset + 4,
602                                                 helpliste->length , FALSE);
603                                         break;        
604
605                                 case DHCP_FO_PD_REJECT_REASON:
606
607                                         reject_reason = tvb_get_guint8(tvb, 
608                                                                 helpliste->actualpoffset +4);
609                                         reject_reason_str = match_strval(reject_reason,
610                                                         reject_reason_vals);
611                                         if (reject_reason_str==NULL) {
612                                                 reject_reason_str="Unknown Packet";
613                                         }
614                                          
615                                         proto_item_append_text(oi, ", %s (%d)",
616                                                         reject_reason_str, 
617                                                         reject_reason);
618
619                                         proto_tree_add_item(option_tree,
620                                                 hf_dhcpfo_reject_reason, tvb,
621                                                 helpliste->actualpoffset +4,
622                                                 helpliste->length, FALSE);
623                                         break;            
624
625                                 case DHCP_FO_PD_MESSAGE:
626
627                                         proto_tree_add_item(option_tree,
628                                                 hf_dhcpfo_message, tvb,
629                                                 helpliste->actualpoffset + 4, 
630                                                 helpliste->length , FALSE); 
631                                         break;            
632
633                                 case DHCP_FO_PD_MCLT:
634
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,
638                                                 hf_dhcpfo_mclt, tvb,
639                                                 helpliste->actualpoffset +4,
640                                                 helpliste->length, FALSE);
641                                         break;    
642
643                                 case DHCP_FO_PD_VENDOR_CLASS:
644
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);
652                                         break;                    
653
654                                 case DHCP_FO_PD_LEASE_EXPIRATION_TIME:
655
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);
660         
661                                         proto_item_append_text(oi, ", %s", 
662                                                                 lease_expiration_time_str);
663
664                                         proto_tree_add_uint_format(option_tree, 
665                                                 hf_dhcpfo_lease_expiration_time, tvb, 
666                                                 helpliste->actualpoffset +4, 
667                                                 helpliste->length,
668                                                 lease_expiration_time,
669                                                 "Lease expiration time: %s", 
670                                                 lease_expiration_time_str); 
671                                         break;        
672
673                                 case DHCP_FO_PD_POTENTIAL_EXPIRATION_TIME:
674
675                                         potential_expiration_time = tvb_get_ntohl(tvb,
676                                                                 helpliste->actualpoffset+4);
677
678                                         potential_expiration_time_str = 
679                                                 abs_time_secs_to_str(potential_expiration_time);
680                                         
681                                         proto_item_append_text(oi, ", %s", 
682                                                                 potential_expiration_time_str); 
683
684                                         proto_tree_add_uint_format(option_tree, 
685                                                 hf_dhcpfo_potential_expiration_time, tvb, 
686                                                 helpliste->actualpoffset +4, 
687                                                 helpliste->length,
688                                                 potential_expiration_time,
689                                                 "Potential expiration time: %s", 
690                                                 potential_expiration_time_str); 
691                                         break;          
692
693                                 case DHCP_FO_PD_GRACE_EXPIRATION_TIME:
694
695                                         grace_expiration_time = tvb_get_ntohl(tvb,
696                                                                 helpliste->actualpoffset+4);
697
698                                         grace_expiration_time_str =
699                                                 abs_time_secs_to_str(grace_expiration_time);
700
701                                         proto_item_append_text(oi, ", %s",
702                                                                 grace_expiration_time_str);
703
704                                         proto_tree_add_uint_format(option_tree,
705                                                 hf_dhcpfo_grace_expiration_time, tvb,
706                                                 helpliste->actualpoffset +4,
707                                                 helpliste->length,
708                                                 grace_expiration_time,
709                                                 "Grace expiration time: %s", 
710                                                         grace_expiration_time_str);
711
712                                         break;                 
713
714                                 case DHCP_FO_PD_CLIENT_LAST_TRANSACTION_TIME:
715
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);
720
721                                         proto_item_append_text(oi, ", %s", 
722                                                                 client_last_transaction_time_str);
723
724                                         proto_tree_add_uint_format(option_tree,
725                                                 hf_dhcpfo_client_last_transaction_time, tvb,
726                                                 helpliste->actualpoffset +4,
727                                                 helpliste->length,
728                                                 client_last_transaction_time,
729                                                 "Last transaction time: %s", abs_time_secs_to_str(client_last_transaction_time));
730                                         break;                 
731
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);
737
738                                         proto_item_append_text(oi, ", %s",
739                                                                 start_time_of_state_str);
740
741                                         proto_tree_add_uint_format(option_tree,
742                                                 hf_dhcpfo_start_time_of_state, tvb,
743                                                 helpliste->actualpoffset +4,
744                                                 helpliste->length,
745                                                 start_time_of_state,
746                                                 "Start time of state: %s", abs_time_secs_to_str(start_time_of_state));
747                                         break;  
748
749                                 case DHCP_FO_PD_SERVERSTATE:     
750
751                                         server_state = tvb_get_guint8(tvb, helpliste->actualpoffset+4);
752
753                                         server_state_str = match_strval(server_state,server_state_vals);
754                                         if (server_state_str==NULL) {
755                                                 server_state_str="Unknown Packet";
756                                         }
757                                         proto_item_append_text(oi, ", %s (%d)", 
758                                                 server_state_str, server_state);
759
760                                         proto_tree_add_item(option_tree,
761                                                 hf_dhcpfo_server_state, tvb,
762                                                 helpliste->actualpoffset + 4, 1, FALSE);
763                                         break;
764
765                                 case DHCP_FO_PD_SERVERFLAG:
766
767                                         serverflag = tvb_get_guint8(tvb,
768                                                         helpliste->actualpoffset+4);
769
770                                         if(serverflag == 1)
771                                         {
772                                                 proto_item_append_text(oi, ", STARTUP (1)");
773                                                 proto_tree_add_text(option_tree,tvb,
774                                                         helpliste->actualpoffset +4,
775                                                         helpliste->length,
776                                                         "Serverflag: STARTUP");
777
778                                         }
779                                         else if(serverflag == 0)
780                                         {
781                                                 proto_item_append_text(oi, ", NONE (%d)",
782                                                                 serverflag);
783                                                 proto_tree_add_text(option_tree,tvb,
784                                                         helpliste->actualpoffset +4,
785                                                         helpliste->length,
786                                                         "Serverflag: NONE");
787                                         }
788                                         else
789                                         {
790                                                 proto_item_append_text(oi, 
791                                                         "UNKNOWN FLAGS (%d)", serverflag);
792
793                                                 proto_tree_add_text(option_tree,tvb,
794                                                         helpliste->actualpoffset +4,
795                                                         helpliste->length,
796                                                         "Serverflag: UNKNOWN FLAGS");
797                                         }
798                                         break;                
799
800                                 case DHCP_FO_PD_VENDOR_OPTION:
801
802                                         proto_tree_add_item(option_tree,
803                                                 hf_dhcpfo_vendor_option, tvb,
804                                                 helpliste->actualpoffset + 4, 
805                                                 helpliste->length , FALSE); 
806
807                                         break;         
808
809                                 case DHCP_FO_PD_MAX_UNACKED_BNDUPD:
810
811                                         max_unacked_bndupd = 
812                                                 tvb_get_ntohl(tvb,helpliste->actualpoffset+4);
813                                         proto_item_append_text(oi,", %d", max_unacked_bndupd);
814
815                                         proto_tree_add_item(option_tree,
816                                                 hf_dhcpfo_max_unacked_bndupd, tvb,
817                                                 helpliste->actualpoffset + 4, 
818                                                 helpliste->length , FALSE); 
819                                         break;               
820
821                                 case DHCP_FO_PD_RECEIVE_TIMER:
822
823                                         receive_timer = 
824                                                 tvb_get_ntohl(tvb,helpliste->actualpoffset+4);
825                                         proto_item_append_text(oi,", %d seconds", receive_timer);
826
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");
832                                         break;             
833
834                                 case DHCP_FO_PD_HASH_BUCKET_ASSIGNMENT:
835
836                                         proto_tree_add_item(option_tree,
837                                                 hf_dhcpfo_hash_bucket_assignment, tvb,
838                                                 helpliste->actualpoffset +4,
839                                                 helpliste->length, FALSE);
840                                         break;               
841
842                                 case DHCP_FO_PD_MESSAGE_DIGEST:
843
844                                         message_digest_type = tvb_get_guint8(tvb,helpliste->actualpoffset+4);
845                                         if(message_digest_type == 1)
846                                         {
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");
849                                         }
850                                         else
851                                         {
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");
854                                         }
855
856                                         proto_tree_add_item(option_tree,
857                                                 hf_dhcpfo_message_digest, tvb,
858                                                 helpliste->actualpoffset+5,
859                                                 helpliste->length-1,FALSE);
860                                         break;             
861
862                                 case DHCP_FO_PD_PROTOCOL_VERSION:
863
864                                         protocol_version = 
865                                                 tvb_get_guint8(tvb, helpliste->actualpoffset+4);
866
867                                         proto_item_append_text(oi, ", version: %d", 
868                                                                         protocol_version);
869                                         proto_tree_add_item(option_tree,
870                                                 hf_dhcpfo_protocol_version, tvb,
871                                                 helpliste->actualpoffset + 4, 
872                                                 helpliste->length , FALSE); 
873                                         break;            
874
875                                 case DHCP_FO_PD_TLS_REQUEST:
876
877                                         tls_request = tvb_get_ntohs(tvb,helpliste->actualpoffset+4);
878                                         if(tls_request == 0)
879                                         {
880                                                 tls_request_string = "No TLS operation";
881                                         }
882                                         else if(tls_request == 1)
883                                         {
884                                                 tls_request_string = "TLS operation desired but not required";
885                                         }
886                                         else if(tls_request == 2)
887                                         {
888                                                 tls_request_string = "TLS operation is required";
889                                         }
890                                         else
891                                         {
892                                                 tls_request_string = "Unknown value";
893                                         }
894                                         proto_item_append_text(oi, ", %s", tls_request_string);
895
896                                         proto_tree_add_text(option_tree, tvb,
897                                                 helpliste->actualpoffset+4,
898                                                 helpliste->length,
899                                                 "TLS request: %s", tls_request_string);
900                                         break;                   
901
902                                 case DHCP_FO_PD_TLS_REPLY:
903                                         break;               
904                                 case DHCP_FO_PD_REQUEST_OPTION:
905                                         break;
906                                 case DHCP_FO_PD_REPLY_OPTION:
907                                         break;
908                                 default:
909                                         break;
910                                 }
911
912                                 helpliste=helpliste->next;
913                         }
914
915                 }
916
917
918         }
919         g_free(liste);
920
921 }
922
923 void
924 proto_reg_handoff_dhcpfo(void)
925 {
926         static gboolean initialized = FALSE;
927         static unsigned int port = 0;
928
929         if (initialized) {
930                 dissector_delete("tcp.port", port, dhcpfo_handle);
931         } else {
932                 initialized = TRUE;
933         }
934         port = tcp_port_pref;
935         dissector_add("tcp.port", tcp_port_pref, dhcpfo_handle);
936 }
937
938 /* Register the protocol with Ethereal */
939 void
940 proto_register_dhcpfo(void)
941 {                 
942
943 /* Setup list of header fields  See Section 1.6.1 for details*/
944         static hf_register_info hf[] = {
945                 { &hf_dhcpfo_length,
946                         { "Message length",           "dhcpfo.length",
947                         FT_UINT16, BASE_DEC, NULL, 0,          
948                         "", HFILL }
949                 },
950                 { &hf_dhcpfo_type,
951                         { "Message Type",           "dhcpfo.type",
952                         FT_UINT8, BASE_DEC, VALS(failover_vals), 0,          
953                         "", HFILL }
954                 },
955
956                 { &hf_dhcpfo_poffset,
957                         { "Payload Offset",           "dhcpfo.poffset",
958                         FT_UINT8, BASE_DEC, NULL, 0,          
959                         "", HFILL }
960                 },
961
962                 { &hf_dhcpfo_time,
963                         { "Time",           "dhcpfo.time",
964                         FT_UINT32, BASE_DEC, NULL, 0,          
965                         "", HFILL }
966                 },
967
968                 { &hf_dhcpfo_xid,
969                         { "Xid",           "dhcpfo.xid",
970                         FT_UINT32, BASE_HEX, NULL, 0,          
971                         "", HFILL }
972                 },
973
974                 { &hf_dhcpfo_additional_HB,
975                         {"Additional Header Bytes",     "dhcpfo.additionalheaderbytes",
976                         FT_BYTES, BASE_NONE, NULL, 0x0,
977                         "", HFILL }
978                 },
979
980                 { &hf_dhcpfo_payload_data,
981                         {"Payload Data",        "dhcpfo.payloaddata",
982                         FT_NONE, BASE_NONE, NULL, 0,
983                         "", HFILL }
984                 },
985
986                 { &hf_dhcpfo_dhcp_style_option,
987                         {"DHCP Style Option",   "dhcpfo.dhcpstyleoption",
988                         FT_NONE, BASE_NONE, NULL, 0,
989                         "", HFILL }
990                 },
991                 
992                 { &hf_dhcpfo_option_code,
993                         {"Option Code",         "dhcpfo.optioncode",
994                         FT_UINT16, BASE_DEC, VALS(option_code_vals), 0,
995                         "", HFILL }
996                 },
997
998                 {&hf_dhcpfo_option_length,
999                         {"Length",              "dhcpfo.optionlength",
1000                         FT_UINT16, BASE_DEC, NULL, 0,
1001                         "", HFILL }
1002                 },
1003
1004                 {&hf_dhcpfo_binding_status,
1005                         {"Type", "dhcpfo.bindingstatus",
1006                         FT_UINT32, BASE_DEC, VALS(binding_status_vals), 0,
1007                         "", HFILL }
1008                 },
1009
1010                 
1011                 {&hf_dhcpfo_server_state,
1012                         {"server status", "dhcpfo.serverstatus",
1013                         FT_UINT8, BASE_DEC, VALS(server_state_vals), 0,
1014                         "", HFILL }
1015                 },
1016
1017
1018                 {&hf_dhcpfo_assigned_ip_address,
1019                         {"assigned ip address", "dhcpfo.assignedipaddress",
1020                         FT_IPv4, BASE_NONE, NULL, 0x0,
1021                         "", HFILL }
1022                 },
1023
1024                 {&hf_dhcpfo_sending_server_ip_address,
1025                         {"sending server ip-address", "dhcpfo.sendingserveripaddress",
1026                         FT_IPv4, BASE_NONE, NULL, 0x0,
1027                         "", HFILL }
1028                 },
1029
1030
1031                 {&hf_dhcpfo_addresses_transfered,
1032                         {"addresses transfered", "dhcpfo.addressestransfered",
1033                         FT_UINT8, BASE_DEC, NULL, 0,
1034                         "", HFILL }
1035                 },
1036
1037
1038                 {&hf_dhcpfo_client_identifier,
1039                         {"Client Identifier", "dhcpfo.clientidentifier",
1040                         FT_STRING, BASE_NONE, NULL, 0,
1041                         "", HFILL }
1042                 },
1043
1044                 {&hf_dhcpfo_client_hw_type,
1045                         {"Client Hardware Type", "dhcpfo.clienthardwaretype",
1046                         FT_UINT8, BASE_HEX, NULL, 0x0,
1047                         "", HFILL }},
1048
1049                 {&hf_dhcpfo_client_hardware_address,
1050                         {"Client Hardware Address", "dhcpfo.clienthardwareaddress",
1051                         FT_BYTES, BASE_NONE, NULL, 0,
1052                         "", HFILL }
1053                 },
1054
1055                 {&hf_dhcpfo_ftddns,
1056                         {"FTDDNS", "dhcpfo.ftddns",
1057                         FT_STRING, BASE_NONE, NULL, 0,
1058                         "", HFILL }
1059                 },
1060
1061                 {&hf_dhcpfo_reject_reason,
1062                         {"Reject reason", "dhcpfo.rejectreason",
1063                         FT_UINT8, BASE_DEC, VALS(reject_reason_vals), 0,
1064                         "", HFILL }
1065                 },
1066
1067                 {&hf_dhcpfo_message,
1068                         {"Message", "dhcpfo.message",
1069                         FT_STRING, BASE_NONE, NULL, 0,
1070                         "", HFILL }
1071                 },
1072
1073                 
1074                 {&hf_dhcpfo_mclt,
1075                         {"MCLT", "dhcpfo.mclt",
1076                         FT_UINT32, BASE_DEC, NULL, 0,
1077                         "", HFILL }
1078                 },
1079
1080                 {&hf_dhcpfo_vendor_class,
1081                         {"Vendor class", "dhcpfo.vendorclass",
1082                         FT_STRING, BASE_NONE, NULL, 0,
1083                         "", HFILL }
1084                 },
1085
1086                 {&hf_dhcpfo_lease_expiration_time,
1087                         {"Lease expiration time", "dhcpfo.leaseexpirationtime",
1088                         FT_UINT32, BASE_DEC, NULL, 0,   
1089                         "", HFILL }
1090                 },
1091
1092                 {&hf_dhcpfo_grace_expiration_time,
1093                         {"Grace expiration time", "dhcpfo.graceexpirationtime",
1094                         FT_UINT32, BASE_DEC, NULL, 0,   
1095                         "", HFILL }
1096                 },
1097
1098                 {&hf_dhcpfo_potential_expiration_time,
1099                         {"Potential expiration time", "dhcpfo.potentialexpirationtime",
1100                         FT_UINT32, BASE_DEC, NULL, 0,   
1101                         "", HFILL }
1102                 },
1103
1104                 {&hf_dhcpfo_client_last_transaction_time,
1105                         {"Client last transaction time", "dhcpfo.clientlasttransactiontime",
1106                         FT_UINT32, BASE_DEC, NULL, 0,   
1107                         "", HFILL }
1108                 },
1109         
1110                 {&hf_dhcpfo_start_time_of_state,
1111                         {"Start time of state", "dhcpfo.starttimeofstate",
1112                         FT_UINT32, BASE_DEC, NULL, 0,   
1113                         "", HFILL }
1114                 },
1115
1116                 {&hf_dhcpfo_vendor_option,
1117                         {"Vendor option", "dhcpfo.vendoroption",
1118                         FT_NONE, BASE_NONE, NULL, 0x0,  
1119                         "", HFILL }
1120                 },
1121
1122                 {&hf_dhcpfo_max_unacked_bndupd,
1123                         {"Max unacked BNDUPD", "dhcpfo.maxunackedbndupd",
1124                         FT_UINT8, BASE_DEC, NULL, 0,
1125                         "", HFILL }
1126                 },
1127
1128                 {&hf_dhcpfo_protocol_version,
1129                         {"Protocol version", "dhcpfo.protocolversion",
1130                         FT_UINT8, BASE_DEC, NULL, 0,
1131                         "", HFILL }
1132                 },
1133
1134                 {&hf_dhcpfo_receive_timer,
1135                         {"Receive timer", "dhcpfo.receivetimer",
1136                         FT_UINT8, BASE_DEC, NULL, 0,
1137                         "", HFILL }
1138                 },
1139
1140                 {&hf_dhcpfo_message_digest,
1141                         {"Message digest", "dhcpfo.messagedigest",
1142                         FT_STRING, BASE_NONE, NULL, 0,
1143                         "", HFILL }
1144                 },
1145
1146                 {&hf_dhcpfo_hash_bucket_assignment,
1147                         {"Hash bucket assignment", "dhcpfo.hashbucketassignment",
1148                         FT_BYTES, BASE_HEX, NULL, 0,
1149                         "", HFILL }
1150                 },
1151         };
1152
1153 /* Setup protocol subtree array */
1154         static gint *ett[] = {
1155                 &ett_dhcpfo,
1156                 &ett_fo_payload,
1157                 &ett_fo_option,
1158         };
1159
1160         module_t *dhcpfo_module;
1161
1162 /* Register the protocol name and description */
1163         proto_dhcpfo = proto_register_protocol("DHCP Failover", "DHCPFO",
1164             "dhcpfo");
1165
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));
1169
1170         dhcpfo_handle = create_dissector_handle(dissect_dhcpfo, proto_dhcpfo);
1171
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);
1176 }