Use "strrchr()" instead of "rindex()" - "strrchr()" is the routine the
[obnox/wireshark/wip.git] / packet-bootp.c
1 /* packet-bootp.c
2  * Routines for BOOTP/DHCP packet disassembly
3  * Gilbert Ramirez <gram@verdict.uthscsa.edu>
4  *
5  * $Id: packet-bootp.c,v 1.24 2000/01/07 22:05:30 guy Exp $
6  *
7  * The information used comes from:
8  * RFC 2132: DHCP Options and BOOTP Vendor Extensions
9  * RFC 1542: Clarifications and Extensions for the Bootstrap Protocol
10  * RFC 2131: Dynamic Host Configuration Protocol
11  *
12  * Ethereal - Network traffic analyzer
13  * By Gerald Combs <gerald@zing.org>
14  * Copyright 1998 Gerald Combs
15  *
16  * 
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU General Public License
19  * as published by the Free Software Foundation; either version 2
20  * of the License, or (at your option) any later version.
21  * 
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  * 
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 # include "config.h"
34 #endif
35
36 #ifdef HAVE_SYS_TYPES_H
37 # include <sys/types.h>
38 #endif
39
40 #include <glib.h>
41 #include "packet.h"
42 #include "packet-arp.h"
43
44 static int proto_bootp = -1;
45 static int hf_bootp_type = -1;
46 static int hf_bootp_hw_type = -1;
47 static int hf_bootp_hw_len = -1;
48 static int hf_bootp_hops = -1;
49 static int hf_bootp_id = -1;
50 static int hf_bootp_secs = -1;
51 static int hf_bootp_flag = -1;
52 static int hf_bootp_ip_client = -1;
53 static int hf_bootp_ip_your = -1;
54 static int hf_bootp_ip_server = -1;
55 static int hf_bootp_ip_relay = -1;
56 static int hf_bootp_hw_addr = -1;
57 static int hf_bootp_server = -1;
58 static int hf_bootp_file = -1;
59 static int hf_bootp_cookie = -1;
60
61 static guint ett_bootp = -1;
62 static guint ett_bootp_option = -1;
63
64 enum field_type { none, ipv4, string, toggle, yes_no, special, opaque,
65         time_in_secs,
66         val_u_byte, val_u_short, val_u_long,
67         val_s_long };
68
69 struct opt_info {
70         char    *text;
71         enum field_type ftype;
72 };
73
74 #define NUM_OPT_INFOS 77
75
76 /* returns the number of bytes consumed by this option */
77 static int
78 bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
79 {
80         char                    *text;
81         enum field_type ftype;
82         u_char                  code = pd[voff];
83         int                             vlen = pd[voff+1];
84         u_char                  byte;
85         int                             i, consumed = vlen + 2;
86         u_long                  time_secs;
87         proto_tree              *v_tree;
88         proto_item              *vti;
89
90         static const char       *opt53_text[] = {
91                 "Unknown Message Type",
92                 "Discover",
93                 "Offer",
94                 "Request",
95                 "Decline",
96                 "ACK",
97                 "NAK",
98                 "Release",
99                 "Inform"
100         };
101         static const value_string nbnt_vals[] = {
102             {0x1,   "B-node" },
103             {0x2,   "P-node" },
104             {0x4,   "M-node" },
105             {0x8,   "H-node" },
106             {0,     NULL     } };
107
108         static struct opt_info opt[] = {
109                 /*   0 */ { "Padding",                                                          none },
110                 /*   1 */ { "Subnet Mask",                                                      ipv4 },
111                 /*   2 */ { "Time Offset",                                                      val_s_long },
112                 /*   3 */ { "Router",                                                           ipv4 },
113                 /*   4 */ { "Time Server",                                                      ipv4 },
114                 /*   5 */ { "Name Server",                                                      ipv4 },
115                 /*   6 */ { "Domain Name Server",                                       ipv4 },
116                 /*   7 */ { "Log Server",                                                       ipv4 },
117                 /*   8 */ { "Cookie Server",                                            ipv4 },
118                 /*   9 */ { "LPR Server",                                                       ipv4 },
119                 /*  10 */ { "Impress Server",                                           ipv4 },
120                 /*  11 */ { "Resource Location Server",                         ipv4 },
121                 /*  12 */ { "Host Name",                                                        string },
122                 /*  13 */ { "Boot File Size",                                           val_u_short },
123                 /*  14 */ { "Merit Dump File",                                          string },
124                 /*  15 */ { "Domain Name",                                                      string },
125                 /*  16 */ { "Swap Server",                                                      ipv4 },
126                 /*  17 */ { "Root Path",                                                        string },
127                 /*  18 */ { "Extensions Path",                                          string },
128                 /*  19 */ { "IP Forwarding",                                            toggle },
129                 /*  20 */ { "Non-Local Source Routing",                         toggle },
130                 /*  21 */ { "Policy Filter",                                            special },
131                 /*  22 */ { "Maximum Datagram Reassembly Size",         val_u_short },
132                 /*  23 */ { "Default IP Time-to-Live",                          val_u_byte },
133                 /*  24 */ { "Path MTU Aging Timeout",                           time_in_secs },
134                 /*  25 */ { "Path MTU Plateau Table",                           val_u_short },
135                 /*  26 */ { "Interface MTU",                                            val_u_short },
136                 /*  27 */ { "All Subnets are Local",                            yes_no },
137                 /*  28 */ { "Broadcast Address",                                        ipv4 },
138                 /*  29 */ { "Perform Mask Discovery",                           toggle },
139                 /*  30 */ { "Mask Supplier",                                            yes_no },
140                 /*  31 */ { "Perform Router Discover",                          toggle },
141                 /*  32 */ { "Router Solicitation Address",                      ipv4 },
142                 /*  33 */ { "Static Route",                                                     special },
143                 /*  34 */ { "Trailer Encapsulation",                            toggle },
144                 /*  35 */ { "ARP Cache Timeout",                                        time_in_secs },
145                 /*  36 */ { "Ethernet Encapsulation",                           toggle },
146                 /*  37 */ { "TCP Default TTL",                                          val_u_byte },
147                 /*  38 */ { "TCP Keepalive Interval",                           time_in_secs },
148                 /*  39 */ { "TCP Keepalive Garbage",                            toggle },
149                 /*  40 */ { "Network Information Service Domain",       string },
150                 /*  41 */ { "Network Information Service Servers",      ipv4 },
151                 /*  42 */ { "Network Time Protocol Servers",            ipv4 },
152                 /*  43 */ { "Vendor-Specific Information",                      special },
153                 /*  44 */ { "NetBIOS over TCP/IP Name Server",          ipv4 },
154                 /*  45 */ { "NetBIOS over TCP/IP Datagram Distribution Name Server", ipv4 },
155                 /*  46 */ { "NetBIOS over TCP/IP Node Type",            special },
156                 /*  47 */ { "NetBIOS over TCP/IP Scope",                        string },
157                 /*  48 */ { "X Window System Font Server",                      ipv4 },
158                 /*  49 */ { "X Window System Display Manager",          ipv4 },
159                 /*  50 */ { "Requested IP Address",                                     ipv4 },
160                 /*  51 */ { "IP Address Lease Time",                            time_in_secs },
161                 /*  52 */ { "Option Overload",                                          special },
162                 /*  53 */ { "DHCP Message Type",                                        special },
163                 /*  54 */ { "Server Identifier",                                        ipv4 },
164                 /*  55 */ { "Parameter Request List",                           special },
165                 /*  56 */ { "Message",                                                          string },
166                 /*  57 */ { "Maximum DHCP Message Size",                        val_u_short },
167                 /*  58 */ { "Renewal Time Value",                                       time_in_secs },
168                 /*  59 */ { "Rebinding Time Value",                                     time_in_secs },
169                 /*  60 */ { "Vendor class identifier",                          opaque },
170                 /*  61 */ { "Client identifier",                                        special },
171                 /*  64 */ { "Network Information Service+ Domain",      string },
172                 /*  65 */ { "Network Information Service+ Servers",     ipv4 },
173                 /*  66 */ { "TFTP Server Name",                                         string },
174                 /*  67 */ { "Bootfile name",                                            string },
175                 /*  68 */ { "Mobile IP Home Agent",                                     ipv4 },
176                 /*  69 */ { "SMTP Server",                                                      ipv4 },
177                 /*  70 */ { "POP3 Server",                                                      ipv4 },
178                 /*  71 */ { "NNTP Server",                                                      ipv4 },
179                 /*  72 */ { "Default WWW Server",                                       ipv4 },
180                 /*  73 */ { "Default Finger Server",                            ipv4 },
181                 /*  74 */ { "Default IRC Server",                                       ipv4 },
182                 /*  75 */ { "StreetTalk Server",                                        ipv4 },
183                 /*  76 */ { "StreetTalk Directory Assistance Server", ipv4 }
184         };
185
186         text = opt[code].text;
187         /* Special cases */
188         switch (code) {
189                 /* Padding */
190                 case 0:
191                         /* check how much padding we have */
192                         for (i = voff + 1; i < eoff; i++ ) {
193                                 if (pd[i] != 0) {
194                                         break;
195                                 }
196                         }
197                         i = i - voff;
198                         proto_tree_add_text(bp_tree, voff, i, "Padding");
199                         consumed = i;
200                         return consumed;
201
202                 /* Policy Filter */
203                 case 21:
204                         /* one IP address pair */
205                         if (vlen == 8) {
206                                 proto_tree_add_text(bp_tree, voff, consumed,
207                                         "Option %d: %s = %s/%s", code, text,
208                                         ip_to_str((guint8*)&pd[voff+2]),
209                                         ip_to_str((guint8*)&pd[voff+6]));
210                         }
211                         /* > 1 IP address pair. Let's make a sub-tree */
212                         else {
213
214                                 vti = proto_tree_add_text(bp_tree, voff,
215                                         consumed, "Option %d: %s", code, text);
216                                 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
217                                 for (i = voff + 2; i < voff + consumed; i += 8) {
218                                         proto_tree_add_text(v_tree, i, 8, "IP Address/Mask: %s/%s",
219                                                 ip_to_str((guint8*)&pd[i]),
220                                                 ip_to_str((guint8*)&pd[i+4]));
221                                 }
222                         }
223                         break;
224
225                 /* Static Route */
226                 case 33:
227                         /* one IP address pair */
228                         if (vlen == 8) {
229                                 proto_tree_add_text(bp_tree, voff, consumed,
230                                         "Option %d: %s = %s/%s", code, text,
231                                         ip_to_str((guint8*)&pd[voff+2]),
232                                         ip_to_str((guint8*)&pd[voff+6]));
233                         }
234                         /* > 1 IP address pair. Let's make a sub-tree */
235                         else {
236
237                                 vti = proto_tree_add_text(bp_tree, voff,
238                                         consumed, "Option %d: %s", code, text);
239                                 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
240                                 for (i = voff + 2; i < voff + consumed; i += 8) {
241                                         proto_tree_add_text(v_tree, i, 8,
242                                                 "Destination IP Address/Router: %s/%s",
243                                                 ip_to_str((guint8*)&pd[i]),
244                                                 ip_to_str((guint8*)&pd[i+4]));
245                                 }
246                         }
247                         break;
248
249                 /* Vendor-Specific Info */
250                 case 43:
251                         proto_tree_add_text(bp_tree, voff, consumed,
252                                         "Option %d: %s", code, text);
253                         break;
254
255                 /* NetBIOS-over-TCP/IP Node Type */
256                 case 46:
257                         byte = pd[voff+2];
258                         proto_tree_add_text(bp_tree, voff, consumed,
259                                         "Option %d: %s = %s", code, text,
260                                         val_to_str(byte, nbnt_vals,
261                                             "Unknown (0x%02x)"));
262                         break;
263                                 
264                 /* DHCP Message Type */
265                 case 53:
266                         byte = pd[voff+2];
267                         if (byte > 0 && byte < 9) {
268                                 i = byte;
269                         }
270                         else {
271                                 i = 0;
272                         }
273                         proto_tree_add_text(bp_tree, voff, 3, "Option %d: %s = DHCP %s",
274                                 code, text, opt53_text[i]);
275                         break;
276
277                 /* Parameter Request List */
278                 case 55:
279                         vti = proto_tree_add_text(bp_tree, voff,
280                                 vlen + 2, "Option %d: %s", code, text);
281                         v_tree = proto_item_add_subtree(vti, ett_bootp_option);
282                         for (i = 0; i < vlen; i++) {
283                                 byte = pd[voff+2+i];
284                                 if (byte < NUM_OPT_INFOS) {
285                                         proto_tree_add_text(v_tree, voff+2+i, 1, "%d = %s",
286                                                         byte, opt[byte].text);
287                                 }
288                                 else {
289                                         proto_tree_add_text(vti, voff+2+i, 1,
290                                                 "Unknown Option Code: %d", byte);
291                                 }
292                         }
293                         break;
294
295                 /* Client Identifier */
296                 case 61:
297                         /* We *MAY* use hwtype/hwaddr. If we have 7 bytes, I'll
298                                 guess that the first is the hwtype, and the last 6 are
299                                 the hw addr */
300                         if (vlen == 7) {
301                                 vti = proto_tree_add_text(bp_tree, voff,
302                                         consumed, "Option %d: %s", code, text);
303                                 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
304                                 proto_tree_add_text(v_tree, voff+2, 1,
305                                         "Hardware type: %s",
306                                         arphrdtype_to_str(pd[voff+2],
307                                                 "Unknown (0x%02x)"));
308                                 proto_tree_add_text(v_tree, voff+3, 6,
309                                         "Client hardware address: %s",
310                                         arphrdaddr_to_str((guint8*)&pd[voff+3],
311                                                 6, pd[voff+2]));
312                         }
313                         /* otherwise, it's opaque data */
314                         else {
315                                 proto_tree_add_text(bp_tree, voff, consumed,
316                                         "Option %d: %s (%d bytes)", code, text, vlen);
317                         }
318                         break;
319
320                 /* End Option */
321                 case 255:
322                         proto_tree_add_text(bp_tree, voff, 1, "End Option");
323                         consumed = 1;
324                         return consumed;
325
326                 default:
327                         /* nothing */
328                         break;
329         }
330
331         /* Normal cases */
332         if (code < NUM_OPT_INFOS) {
333                 text = opt[code].text;
334                 ftype = opt[code].ftype;
335
336                 switch (ftype) {
337                         case special:
338                                 return consumed;
339
340                         case ipv4:
341                                 /* one IP address */
342                                 if (vlen == 4) {
343                                         proto_tree_add_text(bp_tree, voff, consumed,
344                                                 "Option %d: %s = %s", code, text,
345                                                 ip_to_str((guint8*)&pd[voff+2]));
346                                 }
347                                 /* > 1 IP addresses. Let's make a sub-tree */
348                                 else {
349
350                                         vti = proto_tree_add_text(bp_tree, voff,
351                                                 consumed, "Option %d: %s", code, text);
352                                         v_tree = proto_item_add_subtree(vti, ett_bootp_option);
353                                         for (i = voff + 2; i < voff + consumed; i += 4) {
354                                                 proto_tree_add_text(v_tree, i, 4, "IP Address: %s",
355                                                         ip_to_str((guint8*)&pd[i]));
356                                         }
357                                 }
358                                 break;
359
360                         case string:
361                                 /* Fix for non null-terminated string supplied by
362                                  * John Lines <John.Lines@aeat.co.uk>
363                                  */
364                                 proto_tree_add_text(bp_tree, voff, consumed,
365                                                 "Option %d: %s = %.*s", code, text, vlen, &pd[voff+2]);
366                                 break;
367
368                         case opaque:
369                                 proto_tree_add_text(bp_tree, voff, consumed,
370                                                 "Option %d: %s (%d bytes)",
371                                                 code, text, vlen);
372                                 break;
373
374                         case val_u_short:
375                                 /* one IP address */
376                                 if (vlen == 2) {
377                                         proto_tree_add_text(bp_tree, voff, consumed,
378                                                         "Option %d: %s = %d", code, text,
379                                                         pntohs(&pd[voff+2]));
380                                 }
381                                 /* > 1 u_short */
382                                 else {
383                                         vti = proto_tree_add_text(bp_tree, voff,
384                                                 consumed, "Option %d: %s", code, text);
385                                         v_tree = proto_item_add_subtree(vti, ett_bootp_option);
386                                         for (i = voff + 2; i < voff + consumed; i += 2) {
387                                                 proto_tree_add_text(v_tree, i, 4, "Value: %d",
388                                                         pntohs(&pd[i]));
389                                         }
390                                 }
391                                 break;
392
393                         case val_u_long:
394                                 proto_tree_add_text(bp_tree, voff, consumed,
395                                                 "Option %d: %s = %d", code, text,
396                                                 pntohl(&pd[voff+2]));
397                                 break;
398
399                         case val_u_byte:
400                                 proto_tree_add_text(bp_tree, voff, consumed,
401                                                 "Option %d: %s = %d", code, text, pd[voff+2]);
402                                 break;
403
404                         case toggle:
405                                 i = pd[voff+2];
406                                 if (i != 0 && i != 1) {
407                                         proto_tree_add_text(bp_tree, voff, consumed,
408                                                         "Option %d: %s = Invalid Value %d", code, text,
409                                                         pd[voff+2]);
410                                 }
411                                 else {
412                                         proto_tree_add_text(bp_tree, voff, consumed,
413                                                         "Option %d: %s = %s", code, text,
414                                                         pd[voff+2] == 0 ? "Disabled" : "Enabled");
415                                 }
416                                 break;
417
418                         case yes_no:
419                                 i = pd[voff+2];
420                                 if (i != 0 && i != 1) {
421                                         proto_tree_add_text(bp_tree, voff, consumed,
422                                                         "Option %d: %s = Invalid Value %d", code, text,
423                                                         pd[voff+2]);
424                                 }
425                                 else {
426                                         proto_tree_add_text(bp_tree, voff, consumed,
427                                                         "Option %d: %s = %s", code, text,
428                                                         pd[voff+2] == 0 ? "No" : "Yes");
429                                 }
430                                 break;
431
432                         case time_in_secs:
433                                 time_secs = pntohl(&pd[voff+2]);
434                                 proto_tree_add_text(bp_tree, voff, consumed,
435                                         "Option %d: %s = %s", code, text,
436                                         ((time_secs == 0xffffffff) ?
437                                             "infinity" :
438                                             time_secs_to_str(time_secs)));
439                                 break;
440
441                         default:
442                                 proto_tree_add_text(bp_tree, voff, consumed,
443                                                 "Option %d: %s (%d bytes)", code, text, vlen);
444                 }
445         }
446         else {
447                 proto_tree_add_text(bp_tree, voff, consumed,
448                                 "Unknown Option Code: %d (%d bytes)", code, vlen);
449         }
450
451         return consumed;
452 }
453
454 void
455 dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
456 {
457         proto_tree      *bp_tree;
458         proto_item      *ti;
459         int                     voff, eoff; /* vender offset, end offset */
460         guint32         ip_addr;
461
462         if (check_col(fd, COL_PROTOCOL))
463                 col_add_str(fd, COL_PROTOCOL, "BOOTP");
464
465         if (check_col(fd, COL_INFO)) {
466                 if (pd[offset] == 1) {
467                         col_add_fstr(fd, COL_INFO, "Boot Request from %s",
468                                 arphrdaddr_to_str((guint8*)&pd[offset+28],
469                                         pd[offset+2], pd[offset+1]));
470                 }
471                 else {
472                         col_add_str(fd, COL_INFO, "Boot Reply");
473                 }
474         }
475
476         if (tree) {
477                 ti = proto_tree_add_item(tree, proto_bootp, offset, END_OF_FRAME, NULL);
478                 bp_tree = proto_item_add_subtree(ti, ett_bootp);
479
480                 proto_tree_add_item_format(bp_tree, hf_bootp_type, 
481                                            offset, 1,
482                                            pd[offset], 
483                                            pd[offset] == 1 ?
484                                            "Boot Request" : "Boot Reply");
485                 proto_tree_add_item_format(bp_tree, hf_bootp_hw_type,
486                                            offset + 1, 1,
487                                            pd[offset+1],
488                                            "Hardware type: %s",
489                                            arphrdtype_to_str(pd[offset+1],
490                                                              "Unknown (0x%02x)"));
491                 proto_tree_add_item(bp_tree, hf_bootp_hw_len,
492                                     offset + 2, 1, pd[offset+2]);
493                 proto_tree_add_item(bp_tree, hf_bootp_hops,
494                                     offset + 3, 1, pd[offset+3]);
495                 proto_tree_add_item(bp_tree, hf_bootp_id,
496                                    offset + 4, 4, pntohl(&pd[offset+4]));
497                 proto_tree_add_item(bp_tree, hf_bootp_secs,
498                                     offset + 8, 2, pntohs(&pd[offset+8]));
499                 proto_tree_add_item(bp_tree, hf_bootp_flag,
500                                     offset + 10, 2, pd[offset+10] & 1);
501
502                 memcpy(&ip_addr, &pd[offset+12], sizeof(ip_addr));
503                 proto_tree_add_item(bp_tree, hf_bootp_ip_client, 
504                                     offset + 12, 4, ip_addr);
505                 memcpy(&ip_addr, &pd[offset+16], sizeof(ip_addr));
506                 proto_tree_add_item(bp_tree, hf_bootp_ip_your, 
507                                     offset + 16, 4, ip_addr);
508                 memcpy(&ip_addr, &pd[offset+20], sizeof(ip_addr));
509                 proto_tree_add_item(bp_tree, hf_bootp_ip_server,
510                                     offset + 20, 4, ip_addr);
511                 memcpy(&ip_addr, &pd[offset+24], sizeof(ip_addr));
512                 proto_tree_add_item(bp_tree, hf_bootp_ip_relay,
513                                     offset + 24, 4, ip_addr);
514
515                 proto_tree_add_item_format(bp_tree, hf_bootp_hw_addr, 
516                                            offset + 28, pd[offset+2],
517                                            &pd[offset+28],
518                                            "Client hardware address: %s",
519                                            arphrdaddr_to_str((guint8*)&pd[offset+28],
520                                                              pd[offset+2], pd[offset+1]));
521
522                 /* The server host name is optional */
523                 if (pd[offset+44]) {
524                         proto_tree_add_item_format(bp_tree, hf_bootp_server,
525                                                    offset + 44, 64,
526                                                    &pd[offset+44],
527                                                    "Server host name: %s",
528                                                    &pd[offset+44]);
529                 }
530                 else {
531                         proto_tree_add_item_format(bp_tree, hf_bootp_server,
532                                                    offset + 44, 64,
533                                                    &pd[offset+44],
534                                                    "Server host name not given");
535                 }
536
537                 /* Boot file */
538                 if (pd[offset+108]) {
539                         proto_tree_add_item_format(bp_tree, hf_bootp_file,
540                                                    offset + 108, 128,
541                                                    &pd[offset+108],
542                                                    "Boot file name: %s",
543                                                    &pd[offset+108]);
544                 }
545                 else {
546                         proto_tree_add_item_format(bp_tree, hf_bootp_file,
547                                                    offset + 108, 128,
548                                                    &pd[offset+108],
549                                                    "Boot file name not given");
550                 }
551
552                 if (pntohl(&pd[offset+236]) == 0x63825363) {
553                         proto_tree_add_item_format(bp_tree, hf_bootp_cookie,
554                                                    offset + 236, 4,
555                                                    pd[offset+236],
556                                                    "Magic cookie: (OK)");
557                 }
558                 else {
559                         memcpy(&ip_addr, &pd[offset + 236], sizeof(ip_addr));
560                         proto_tree_add_item(bp_tree, hf_bootp_cookie,
561                                             offset + 236, 4, ip_addr);
562                 }
563
564                 voff = offset+240;
565                 eoff = pi.captured_len;
566
567                 while (voff < eoff) {
568                         voff += bootp_option(pd, bp_tree, voff, eoff);
569                 }
570         }
571 }
572
573 void
574 proto_register_bootp(void)
575 {
576   static hf_register_info hf[] = {
577     { &hf_bootp_type,
578       { "Message type",                 "bootp.type",    FT_UINT8,  BASE_NONE, NULL, 0x0,
579         "" }},
580
581     { &hf_bootp_hw_type,
582       { "Hardware type",                "bootp.hw.type", FT_UINT8,  BASE_HEX, NULL, 0x0,
583         "" }},
584
585     { &hf_bootp_hw_len,
586       { "Hardware address length",      "bootp.hw.len",  FT_UINT8,  BASE_DEC, NULL, 0x0,
587         "" }},
588
589     { &hf_bootp_hops,
590       { "Hops",                         "bootp.hops",    FT_UINT8,  BASE_DEC, NULL, 0x0,
591         "" }},
592
593     { &hf_bootp_id,
594       { "Transaction ID",               "bootp.id",      FT_UINT32, BASE_HEX, NULL, 0x0,
595         "" }},
596
597     { &hf_bootp_secs,
598       { "Seconds elapsed",              "bootp.secs",    FT_UINT16, BASE_DEC, NULL, 0x0,
599         "" }},
600
601     { &hf_bootp_flag,
602       { "Broadcast flag",               "bootp.flag",    FT_UINT16, BASE_DEC, NULL, 0x0,
603         "" }},
604
605     { &hf_bootp_ip_client,
606       { "Client IP address",            "bootp.ip.client",FT_IPv4,  BASE_NONE, NULL, 0x0,
607         "" }},
608
609     { &hf_bootp_ip_your,
610       { "Your (client) IP address",     "bootp.ip.your",  FT_IPv4,  BASE_NONE, NULL, 0x0,
611         "" }},
612
613     { &hf_bootp_ip_server,
614       { "Next server IP address",       "bootp.ip.server",FT_IPv4,  BASE_NONE, NULL, 0x0,
615         "" }},
616
617     { &hf_bootp_ip_relay,
618       { "Relay agent IP address",       "bootp.ip.relay", FT_IPv4,  BASE_NONE, NULL, 0x0,
619         "" }},
620
621     { &hf_bootp_hw_addr,
622       { "Client hardware address",      "bootp.hw.addr", FT_BYTES,  BASE_NONE, NULL, 0x0,
623         "" }},
624
625     { &hf_bootp_server,
626       { "Server host name",             "bootp.server",  FT_STRING, BASE_NONE, NULL, 0x0,
627         "" }},
628
629     { &hf_bootp_file,
630       { "Boot file name",               "bootp.file",    FT_STRING, BASE_NONE, NULL, 0x0,
631         "" }},
632
633     { &hf_bootp_cookie,
634       { "Magic cookie",                 "bootp.cookie",  FT_IPv4,   BASE_NONE, NULL, 0x0,
635         "" }},
636   };
637   static gint *ett[] = {
638     &ett_bootp,
639     &ett_bootp_option,
640   };
641   
642   proto_bootp = proto_register_protocol("Bootstrap Protocol", "bootp");
643   proto_register_field_array(proto_bootp, hf, array_length(hf));
644   proto_register_subtree_array(ett, array_length(ett));
645 }