2 * Routines for BOOTP/DHCP packet disassembly
3 * Gilbert Ramirez <gram@xiexie.org>
5 * $Id: packet-bootp.c,v 1.42 2000/11/19 08:53:55 guy Exp $
7 * The information used comes from:
8 * RFC 951: Bootstrap Protocol
9 * RFC 1542: Clarifications and Extensions for the Bootstrap Protocol
10 * RFC 2131: Dynamic Host Configuration Protocol
11 * RFC 2132: DHCP Options and BOOTP Vendor Extensions
12 * RFC 2489: Procedure for Defining New DHCP Options
13 * BOOTP and DHCP Parameters
14 * http://www.isi.edu/in-notes/iana/assignments/bootp-dhcp-parameters
16 * Ethereal - Network traffic analyzer
17 * By Gerald Combs <gerald@zing.org>
18 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #ifdef HAVE_SYS_TYPES_H
41 # include <sys/types.h>
47 #include "packet-arp.h"
49 static int proto_bootp = -1;
50 static int hf_bootp_type = -1;
51 static int hf_bootp_hw_type = -1;
52 static int hf_bootp_hw_len = -1;
53 static int hf_bootp_hops = -1;
54 static int hf_bootp_id = -1;
55 static int hf_bootp_secs = -1;
56 static int hf_bootp_flag = -1;
57 static int hf_bootp_ip_client = -1;
58 static int hf_bootp_ip_your = -1;
59 static int hf_bootp_ip_server = -1;
60 static int hf_bootp_ip_relay = -1;
61 static int hf_bootp_hw_addr = -1;
62 static int hf_bootp_server = -1;
63 static int hf_bootp_file = -1;
64 static int hf_bootp_cookie = -1;
65 static int hf_bootp_dhcp = -1;
67 static guint ett_bootp = -1;
68 static guint ett_bootp_option = -1;
70 #define UDP_PORT_BOOTPS 67
72 enum field_type { none, ipv4, string, toggle, yes_no, special, opaque,
74 val_u_byte, val_u_short, val_u_long,
79 enum field_type ftype;
82 #define NUM_OPT_INFOS 128
83 #define NUM_O63_SUBOPTS 11
85 static int dissect_netware_ip_suboption(proto_tree *v_tree, const u_char *pd,
89 get_dhcp_type(guint8 byte)
91 static const char *opt53_text[] = {
92 "Unknown Message Type",
104 if (byte > 0 && byte < (sizeof opt53_text / sizeof opt53_text[0]))
108 return opt53_text[i];
111 /* Returns the number of bytes consumed by this option. */
113 bootp_option(const u_char *pd, proto_tree *bp_tree, int voff, int eoff)
116 enum field_type ftype;
117 u_char code = pd[voff];
118 int vlen = pd[voff+1];
120 int i,optp, consumed = vlen + 2;
125 static const value_string nbnt_vals[] = {
132 static struct opt_info opt[] = {
133 /* 0 */ { "Padding", none },
134 /* 1 */ { "Subnet Mask", ipv4 },
135 /* 2 */ { "Time Offset", val_s_long },
136 /* 3 */ { "Router", ipv4 },
137 /* 4 */ { "Time Server", ipv4 },
138 /* 5 */ { "Name Server", ipv4 },
139 /* 6 */ { "Domain Name Server", ipv4 },
140 /* 7 */ { "Log Server", ipv4 },
141 /* 8 */ { "Cookie Server", ipv4 },
142 /* 9 */ { "LPR Server", ipv4 },
143 /* 10 */ { "Impress Server", ipv4 },
144 /* 11 */ { "Resource Location Server", ipv4 },
145 /* 12 */ { "Host Name", string },
146 /* 13 */ { "Boot File Size", val_u_short },
147 /* 14 */ { "Merit Dump File", string },
148 /* 15 */ { "Domain Name", string },
149 /* 16 */ { "Swap Server", ipv4 },
150 /* 17 */ { "Root Path", string },
151 /* 18 */ { "Extensions Path", string },
152 /* 19 */ { "IP Forwarding", toggle },
153 /* 20 */ { "Non-Local Source Routing", toggle },
154 /* 21 */ { "Policy Filter", special },
155 /* 22 */ { "Maximum Datagram Reassembly Size", val_u_short },
156 /* 23 */ { "Default IP Time-to-Live", val_u_byte },
157 /* 24 */ { "Path MTU Aging Timeout", time_in_secs },
158 /* 25 */ { "Path MTU Plateau Table", val_u_short },
159 /* 26 */ { "Interface MTU", val_u_short },
160 /* 27 */ { "All Subnets are Local", yes_no },
161 /* 28 */ { "Broadcast Address", ipv4 },
162 /* 29 */ { "Perform Mask Discovery", toggle },
163 /* 30 */ { "Mask Supplier", yes_no },
164 /* 31 */ { "Perform Router Discover", toggle },
165 /* 32 */ { "Router Solicitation Address", ipv4 },
166 /* 33 */ { "Static Route", special },
167 /* 34 */ { "Trailer Encapsulation", toggle },
168 /* 35 */ { "ARP Cache Timeout", time_in_secs },
169 /* 36 */ { "Ethernet Encapsulation", toggle },
170 /* 37 */ { "TCP Default TTL", val_u_byte },
171 /* 38 */ { "TCP Keepalive Interval", time_in_secs },
172 /* 39 */ { "TCP Keepalive Garbage", toggle },
173 /* 40 */ { "Network Information Service Domain", string },
174 /* 41 */ { "Network Information Service Servers", ipv4 },
175 /* 42 */ { "Network Time Protocol Servers", ipv4 },
176 /* 43 */ { "Vendor-Specific Information", special },
177 /* 44 */ { "NetBIOS over TCP/IP Name Server", ipv4 },
178 /* 45 */ { "NetBIOS over TCP/IP Datagram Distribution Name Server", ipv4 },
179 /* 46 */ { "NetBIOS over TCP/IP Node Type", special },
180 /* 47 */ { "NetBIOS over TCP/IP Scope", string },
181 /* 48 */ { "X Window System Font Server", ipv4 },
182 /* 49 */ { "X Window System Display Manager", ipv4 },
183 /* 50 */ { "Requested IP Address", ipv4 },
184 /* 51 */ { "IP Address Lease Time", time_in_secs },
185 /* 52 */ { "Option Overload", special },
186 /* 53 */ { "DHCP Message Type", special },
187 /* 54 */ { "Server Identifier", ipv4 },
188 /* 55 */ { "Parameter Request List", special },
189 /* 56 */ { "Message", string },
190 /* 57 */ { "Maximum DHCP Message Size", val_u_short },
191 /* 58 */ { "Renewal Time Value", time_in_secs },
192 /* 59 */ { "Rebinding Time Value", time_in_secs },
193 /* 60 */ { "Vendor class identifier", opaque },
194 /* 61 */ { "Client identifier", special },
195 /* 62 */ { "Novell/Netware IP domain", string },
196 /* 63 */ { "Novell Options", special },
197 /* 64 */ { "Network Information Service+ Domain", string },
198 /* 65 */ { "Network Information Service+ Servers", ipv4 },
199 /* 66 */ { "TFTP Server Name", string },
200 /* 67 */ { "Bootfile name", string },
201 /* 68 */ { "Mobile IP Home Agent", ipv4 },
202 /* 69 */ { "SMTP Server", ipv4 },
203 /* 70 */ { "POP3 Server", ipv4 },
204 /* 71 */ { "NNTP Server", ipv4 },
205 /* 72 */ { "Default WWW Server", ipv4 },
206 /* 73 */ { "Default Finger Server", ipv4 },
207 /* 74 */ { "Default IRC Server", ipv4 },
208 /* 75 */ { "StreetTalk Server", ipv4 },
209 /* 76 */ { "StreetTalk Directory Assistance Server", ipv4 },
210 /* 77 */ { "User Class Information", opaque },
211 /* 78 */ { "Directory Agent Information", opaque },
212 /* 79 */ { "Service Location Agent Scope", opaque },
213 /* 80 */ { "Naming Authority", opaque },
214 /* 81 */ { "Client Fully Qualified Domain Name", opaque },
215 /* 82 */ { "Agent Circuit ID", opaque },
216 /* 83 */ { "Agent Remote ID", opaque },
217 /* 84 */ { "Agent Subnet Mask", opaque },
218 /* 85 */ { "Novell Directory Services Servers", opaque },
219 /* 86 */ { "Novell Directory Services Tree Name", opaque },
220 /* 87 */ { "Novell Directory Services Context", opaque },
221 /* 88 */ { "IEEE 1003.1 POSIX Timezone", opaque },
222 /* 89 */ { "Fully Qualified Domain Name", opaque },
223 /* 90 */ { "Authentication", opaque },
224 /* 91 */ { "Vines TCP/IP Server Option", opaque },
225 /* 92 */ { "Server Selection Option", opaque },
226 /* 93 */ { "Client System Architecture", opaque },
227 /* 94 */ { "Client Network Device Interface", opaque },
228 /* 95 */ { "Lightweight Directory Access Protocol", opaque },
229 /* 96 */ { "IPv6 Transitions", opaque },
230 /* 97 */ { "UUID/GUID-based Client Identifier", opaque },
231 /* 98 */ { "Open Group's User Authentication", opaque },
232 /* 99 */ { "Unassigned", opaque },
233 /* 100 */ { "Printer Name", opaque },
234 /* 101 */ { "MDHCP multicast address", opaque },
235 /* 102 */ { "Removed/unassigned", opaque },
236 /* 103 */ { "Removed/unassigned", opaque },
237 /* 104 */ { "Removed/unassigned", opaque },
238 /* 105 */ { "Removed/unassigned", opaque },
239 /* 106 */ { "Removed/unassigned", opaque },
240 /* 107 */ { "Removed/unassigned", opaque },
241 /* 108 */ { "Swap Path Option", opaque },
242 /* 109 */ { "Unassigned", opaque },
243 /* 110 */ { "IPX Compability", opaque },
244 /* 111 */ { "Unassigned", opaque },
245 /* 112 */ { "Netinfo Parent Server Address", opaque },
246 /* 113 */ { "Netinfo Parent Server Tag", opaque },
247 /* 114 */ { "URL", opaque },
248 /* 115 */ { "DHCP Failover Protocol", opaque },
249 /* 116 */ { "DHCP Auto-Configuration", opaque },
250 /* 117 */ { "Unassigned", opaque },
251 /* 118 */ { "Unassigned", opaque },
252 /* 119 */ { "Unassigned", opaque },
253 /* 120 */ { "Unassigned", opaque },
254 /* 121 */ { "Unassigned", opaque },
255 /* 122 */ { "Unassigned", opaque },
256 /* 123 */ { "Unassigned", opaque },
257 /* 124 */ { "Unassigned", opaque },
258 /* 125 */ { "Unassigned", opaque },
259 /* 126 */ { "Extension", opaque },
260 /* 127 */ { "Extension", opaque }
263 /* Options whose length isn't "vlen + 2". */
266 case 0: /* Padding */
267 /* check how much padding we have */
268 for (i = voff + 1; i < eoff; i++ ) {
275 proto_tree_add_text(bp_tree, NullTVB, voff, i, "Padding");
280 case 255: /* End Option */
282 proto_tree_add_text(bp_tree, NullTVB, voff, 1, "End Option");
287 if (bp_tree == NULL) {
288 /* Don't put anything in the protocol tree. */
292 text = opt[code].text;
296 case 21: /* Policy Filter */
298 /* one IP address pair */
299 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
300 "Option %d: %s = %s/%s", code, text,
301 ip_to_str((guint8*)&pd[voff+2]),
302 ip_to_str((guint8*)&pd[voff+6]));
304 /* > 1 IP address pair. Let's make a sub-tree */
305 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
306 consumed, "Option %d: %s", code, text);
307 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
308 for (i = voff + 2; i < voff + consumed; i += 8) {
309 proto_tree_add_text(v_tree, NullTVB, i, 8, "IP Address/Mask: %s/%s",
310 ip_to_str((guint8*)&pd[i]),
311 ip_to_str((guint8*)&pd[i+4]));
316 case 33: /* Static Route */
318 /* one IP address pair */
319 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
320 "Option %d: %s = %s/%s", code, text,
321 ip_to_str((guint8*)&pd[voff+2]),
322 ip_to_str((guint8*)&pd[voff+6]));
324 /* > 1 IP address pair. Let's make a sub-tree */
325 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
326 consumed, "Option %d: %s", code, text);
327 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
328 for (i = voff + 2; i < voff + consumed; i += 8) {
329 proto_tree_add_text(v_tree, NullTVB, i, 8,
330 "Destination IP Address/Router: %s/%s",
331 ip_to_str((guint8*)&pd[i]),
332 ip_to_str((guint8*)&pd[i+4]));
337 case 43: /* Vendor-Specific Info */
338 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
339 "Option %d: %s", code, text);
342 case 46: /* NetBIOS-over-TCP/IP Node Type */
344 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
345 "Option %d: %s = %s", code, text,
346 val_to_str(byte, nbnt_vals,
347 "Unknown (0x%02x)"));
350 case 53: /* DHCP Message Type */
351 proto_tree_add_text(bp_tree, NullTVB, voff, 3, "Option %d: %s = DHCP %s",
352 code, text, get_dhcp_type(pd[voff+2]));
355 case 55: /* Parameter Request List */
356 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
357 vlen + 2, "Option %d: %s", code, text);
358 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
359 for (i = 0; i < vlen; i++) {
361 if (byte < NUM_OPT_INFOS) {
362 proto_tree_add_text(v_tree, NullTVB, voff+2+i, 1, "%d = %s",
363 byte, opt[byte].text);
365 proto_tree_add_text(vti, NullTVB, voff+2+i, 1,
366 "Unknown Option Code: %d", byte);
371 case 61: /* Client Identifier */
372 /* We *MAY* use hwtype/hwaddr. If we have 7 bytes, I'll
373 guess that the first is the hwtype, and the last 6
376 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
377 consumed, "Option %d: %s", code, text);
378 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
379 proto_tree_add_text(v_tree, NullTVB, voff+2, 1,
381 arphrdtype_to_str(pd[voff+2],
382 "Unknown (0x%02x)"));
383 proto_tree_add_text(v_tree, NullTVB, voff+3, 6,
384 "Client hardware address: %s",
385 arphrdaddr_to_str((guint8*)&pd[voff+3],
388 /* otherwise, it's opaque data */
389 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
390 "Option %d: %s (%d bytes)", code, text, vlen);
394 case 63: /* NetWare/IP options */
395 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
396 consumed, "Option %d: %s", code, text);
397 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
400 while (optp < voff+consumed)
401 optp = dissect_netware_ip_suboption(v_tree, pd, optp);
404 default: /* not special */
409 if (code < NUM_OPT_INFOS) {
410 text = opt[code].text;
411 ftype = opt[code].ftype;
421 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
422 "Option %d: %s = %s", code, text,
423 ip_to_str((guint8*)&pd[voff+2]));
425 /* > 1 IP addresses. Let's make a sub-tree */
426 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
427 consumed, "Option %d: %s", code, text);
428 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
429 for (i = voff + 2; i < voff + consumed; i += 4) {
430 proto_tree_add_text(v_tree, NullTVB, i, 4, "IP Address: %s",
431 ip_to_str((guint8*)&pd[i]));
437 /* Fix for non null-terminated string supplied by
438 * John Lines <John.Lines@aeat.co.uk>
440 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
441 "Option %d: %s = %.*s", code, text, vlen, &pd[voff+2]);
445 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
446 "Option %d: %s (%d bytes)",
453 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
454 "Option %d: %s = %d", code, text,
455 pntohs(&pd[voff+2]));
458 vti = proto_tree_add_text(bp_tree, NullTVB, voff,
459 consumed, "Option %d: %s", code, text);
460 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
461 for (i = voff + 2; i < voff + consumed; i += 2) {
462 proto_tree_add_text(v_tree, NullTVB, i, 4, "Value: %d",
469 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
470 "Option %d: %s = %d", code, text,
471 pntohl(&pd[voff+2]));
475 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
476 "Option %d: %s = %d", code, text, pd[voff+2]);
481 if (i != 0 && i != 1) {
482 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
483 "Option %d: %s = Invalid Value %d", code, text,
486 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
487 "Option %d: %s = %s", code, text,
488 pd[voff+2] == 0 ? "Disabled" : "Enabled");
494 if (i != 0 && i != 1) {
495 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
496 "Option %d: %s = Invalid Value %d", code, text,
499 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
500 "Option %d: %s = %s", code, text,
501 pd[voff+2] == 0 ? "No" : "Yes");
506 time_secs = pntohl(&pd[voff+2]);
507 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
508 "Option %d: %s = %s", code, text,
509 ((time_secs == 0xffffffff) ?
511 time_secs_to_str(time_secs)));
515 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
516 "Option %d: %s (%d bytes)", code, text, vlen);
519 proto_tree_add_text(bp_tree, NullTVB, voff, consumed,
520 "Unknown Option Code: %d (%d bytes)", code, vlen);
527 dissect_netware_ip_suboption(proto_tree *v_tree, const u_char *pd, int optp)
530 proto_tree *o63_v_tree;
533 struct o63_opt_info {
539 static struct o63_opt_info o63_opt[]= {
540 /* 0 */ {"","",none},
541 /* 1 */ {"NWIP does not exist on subnet","",string},
542 /* 2 */ {"NWIP exist in options area","",string},
543 /* 3 */ {"NWIP exists in sname/file","",string},
544 /* 4 */ {"NWIP exists, but too big","",string},
545 /* 5 */ {"Broadcast for nearest Netware server","Do NOT Broadcast for nearest Netware server",yes_no},
546 /* 6 */ {"Preferred DSS server","",ipv4},
547 /* 7 */ {"Nearest NWIP server","",ipv4},
548 /* 8 */ {"Autoretries","",val_u_short},
549 /* 9 */ {"Autoretry delay, secs ","",val_u_short},
550 /* 10*/ {"Support NetWare/IP v1.1","Do NOT support NetWare/IP v1.1",yes_no},
551 /* 11*/ {"Primary DSS ", "" , special}
554 if (pd[optp] > NUM_O63_SUBOPTS) {
555 proto_tree_add_text(v_tree, NullTVB,optp,1,"Unknown suboption %d", pd[optp]);
558 switch (o63_opt[pd[optp]].ft) {
561 proto_tree_add_text(v_tree, NullTVB, optp, 2, "Suboption %d: %s", pd[optp], o63_opt[pd[optp]].truet);
567 proto_tree_add_text(v_tree, NullTVB, optp, 3, "Suboption %d: %s", pd[optp], o63_opt[pd[optp]].truet);
569 proto_tree_add_text(v_tree, NullTVB, optp, 3, "Suboption %d: %s" , pd[optp], o63_opt[pd[optp]].falset);
575 proto_tree_add_text(v_tree, NullTVB, optp, 6,
576 "Suboption %d: %s = %s" ,
577 pd[optp], o63_opt[pd[optp]].truet,
578 ip_to_str((guint8*)&pd[optp+2]));
583 proto_tree_add_text(v_tree, NullTVB, optp, 3, "Suboption %d: %s = %d",pd[optp], o63_opt[pd[optp]].truet, pd[optp+2]);
588 if (pd[optp+1] == 4) {
590 proto_tree_add_text(v_tree, NullTVB, optp, 6,
591 "Suboption %d : %s = %s",
592 pd[optp], o63_opt[pd[optp]].truet,
593 ip_to_str((guint8*)&pd[optp+2]));
596 /* > 1 IP addresses. Let's make a sub-tree */
597 vti = proto_tree_add_text(v_tree, NullTVB, optp,
598 pd[optp+1]+2, "Suboption %d: %s",
599 pd[optp], o63_opt[pd[optp]].truet);
600 o63_v_tree = proto_item_add_subtree(vti, ett_bootp_option);
601 for (slask = optp + 2 ; slask < optp+pd[optp+1]; slask += 4) {
602 proto_tree_add_text(o63_v_tree, NullTVB, slask, 4, "IP Address: %s",
603 ip_to_str((guint8*)&pd[slask]));
609 proto_tree_add_text(v_tree, NullTVB,optp,1,"Unknown suboption %d", pd[optp]);
618 dissect_bootp(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
620 proto_tree *bp_tree = NULL;
622 int voff, eoff; /* vender offset, end offset */
624 const char *dhcp_type;
626 OLD_CHECK_DISPLAY_AS_DATA(proto_bootp, pd, offset, fd, tree);
630 if (check_col(fd, COL_PROTOCOL))
631 col_set_str(fd, COL_PROTOCOL, "BOOTP");
633 if (check_col(fd, COL_INFO)) {
634 if (pd[offset] == 1) {
635 col_add_fstr(fd, COL_INFO, "Boot Request from %s",
636 arphrdaddr_to_str((guint8*)&pd[offset+28],
637 pd[offset+2], pd[offset+1]));
640 col_set_str(fd, COL_INFO, "Boot Reply");
645 ti = proto_tree_add_item(tree, proto_bootp, NullTVB, offset, END_OF_FRAME, FALSE);
646 bp_tree = proto_item_add_subtree(ti, ett_bootp);
648 proto_tree_add_uint_format(bp_tree, hf_bootp_type, NullTVB,
652 "Boot Request" : "Boot Reply");
653 proto_tree_add_uint_format(bp_tree, hf_bootp_hw_type, NullTVB,
657 arphrdtype_to_str(pd[offset+1],
658 "Unknown (0x%02x)"));
659 proto_tree_add_uint(bp_tree, hf_bootp_hw_len, NullTVB,
660 offset + 2, 1, pd[offset+2]);
661 proto_tree_add_uint(bp_tree, hf_bootp_hops, NullTVB,
662 offset + 3, 1, pd[offset+3]);
663 proto_tree_add_uint(bp_tree, hf_bootp_id, NullTVB,
664 offset + 4, 4, pntohl(&pd[offset+4]));
665 proto_tree_add_uint(bp_tree, hf_bootp_secs, NullTVB,
666 offset + 8, 2, pntohs(&pd[offset+8]));
667 proto_tree_add_uint(bp_tree, hf_bootp_flag, NullTVB,
668 offset + 10, 2, pntohs(&pd[offset+10]) & 0x8000);
670 memcpy(&ip_addr, &pd[offset+12], sizeof(ip_addr));
671 proto_tree_add_ipv4(bp_tree, hf_bootp_ip_client, NullTVB,
672 offset + 12, 4, ip_addr);
673 memcpy(&ip_addr, &pd[offset+16], sizeof(ip_addr));
674 proto_tree_add_ipv4(bp_tree, hf_bootp_ip_your, NullTVB,
675 offset + 16, 4, ip_addr);
676 memcpy(&ip_addr, &pd[offset+20], sizeof(ip_addr));
677 proto_tree_add_ipv4(bp_tree, hf_bootp_ip_server, NullTVB,
678 offset + 20, 4, ip_addr);
679 memcpy(&ip_addr, &pd[offset+24], sizeof(ip_addr));
680 proto_tree_add_ipv4(bp_tree, hf_bootp_ip_relay, NullTVB,
681 offset + 24, 4, ip_addr);
683 if (pd[offset+2] > 0) {
684 proto_tree_add_bytes_format(bp_tree, hf_bootp_hw_addr, NullTVB,
685 offset + 28, pd[offset+2],
687 "Client hardware address: %s",
688 arphrdaddr_to_str((guint8*)&pd[offset+28],
689 pd[offset+2], pd[offset+1]));
692 proto_tree_add_text(bp_tree, NullTVB,
693 offset + 28, 0, "Client address not given");
696 /* The server host name is optional */
698 proto_tree_add_string_format(bp_tree, hf_bootp_server, NullTVB,
701 "Server host name: %s",
705 proto_tree_add_string_format(bp_tree, hf_bootp_server, NullTVB,
708 "Server host name not given");
712 if (pd[offset+108]) {
713 proto_tree_add_string_format(bp_tree, hf_bootp_file, NullTVB,
716 "Boot file name: %s",
720 proto_tree_add_string_format(bp_tree, hf_bootp_file, NullTVB,
723 "Boot file name not given");
726 memcpy(&ip_addr, &pd[offset + 236], sizeof(ip_addr));
727 if (pntohl(&pd[offset+236]) == 0x63825363) {
728 proto_tree_add_ipv4_format(bp_tree, hf_bootp_cookie, NullTVB,
729 offset + 236, 4, ip_addr,
730 "Magic cookie: (OK)");
733 proto_tree_add_ipv4(bp_tree, hf_bootp_cookie, NullTVB,
734 offset + 236, 4, ip_addr);
739 eoff = pi.captured_len;
740 while (voff < eoff) {
741 /* Handle the DHCP option specially here, so that we
742 can flag DHCP packets as such. */
744 dhcp_type = get_dhcp_type(pd[voff+2]);
745 voff += bootp_option(pd, bp_tree, voff, eoff);
747 if (dhcp_type != NULL ) {
748 if (check_col(fd, COL_PROTOCOL))
749 col_set_str(fd, COL_PROTOCOL, "DHCP");
750 if (check_col(fd, COL_INFO))
751 col_add_fstr(fd, COL_INFO, "DHCP %-8s - Transaction ID 0x%x",
752 dhcp_type, pntohl(&pd[offset+4]));
754 proto_tree_add_boolean_hidden(bp_tree, hf_bootp_dhcp,
760 proto_register_bootp(void)
762 static hf_register_info hf[] = {
764 { "Frame is DHCP", "bootp.dhcp", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
768 { "Message type", "bootp.type", FT_UINT8, BASE_NONE, NULL, 0x0,
772 { "Hardware type", "bootp.hw.type", FT_UINT8, BASE_HEX, NULL, 0x0,
776 { "Hardware address length", "bootp.hw.len", FT_UINT8, BASE_DEC, NULL, 0x0,
780 { "Hops", "bootp.hops", FT_UINT8, BASE_DEC, NULL, 0x0,
784 { "Transaction ID", "bootp.id", FT_UINT32, BASE_HEX, NULL, 0x0,
788 { "Seconds elapsed", "bootp.secs", FT_UINT16, BASE_DEC, NULL, 0x0,
792 { "Broadcast flag", "bootp.flag", FT_UINT16, BASE_HEX, NULL, 0x0,
795 { &hf_bootp_ip_client,
796 { "Client IP address", "bootp.ip.client",FT_IPv4, BASE_NONE, NULL, 0x0,
800 { "Your (client) IP address", "bootp.ip.your", FT_IPv4, BASE_NONE, NULL, 0x0,
803 { &hf_bootp_ip_server,
804 { "Next server IP address", "bootp.ip.server",FT_IPv4, BASE_NONE, NULL, 0x0,
807 { &hf_bootp_ip_relay,
808 { "Relay agent IP address", "bootp.ip.relay", FT_IPv4, BASE_NONE, NULL, 0x0,
812 { "Client hardware address", "bootp.hw.addr", FT_BYTES, BASE_NONE, NULL, 0x0,
816 { "Server host name", "bootp.server", FT_STRING, BASE_NONE, NULL, 0x0,
820 { "Boot file name", "bootp.file", FT_STRING, BASE_NONE, NULL, 0x0,
824 { "Magic cookie", "bootp.cookie", FT_IPv4, BASE_NONE, NULL, 0x0,
827 static gint *ett[] = {
832 proto_bootp = proto_register_protocol("Bootstrap Protocol", "bootp");
833 proto_register_field_array(proto_bootp, hf, array_length(hf));
834 proto_register_subtree_array(ett, array_length(ett));
838 proto_reg_handoff_bootp(void)
840 old_dissector_add("udp.port", UDP_PORT_BOOTPS, dissect_bootp);