Group all "Seconds elapsed appears to be encoded as little-endian" expert info messag...
[metze/wireshark/wip.git] / epan / dissectors / packet-bootp.c
1 /* packet-bootp.c
2  * Routines for BOOTP/DHCP packet disassembly
3  *
4  * Copyright 1998, Gilbert Ramirez <gram@alumni.rice.edu>
5  * Copyright 2004, Thomas Anders <thomas.anders [AT] blue-cable.de>
6  *
7  * Added option field filters
8  * Copyright 2011, Michael Mann
9  *
10  * Added option  77 : RFC 3004 - The User Class Option for DHCP
11  * Added option 117 : RFC 2937 - The Name Service Search Option for DHCP
12  * Added option 119 : RFC 3397 - Dynamic Host Configuration Protocol (DHCP) Domain Search Option
13  *                    RFC 3396 - Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)
14  * Improved opt 120 : Add support of RFC 3396 - Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)
15  *                    Add support compression according to the encoding in Section 4.1.4 of RFC 1035 - DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION
16  *
17  *
18  * Copyright 2012, Jerome LAFORGE <jerome.laforge [AT] gmail.com>
19  *
20  * $Id$
21  *
22  * The information used comes from:
23  * RFC  951: Bootstrap Protocol
24  * RFC 1035: Domain Names - Implementation And Specification
25  * RFC 1497: BOOTP extensions
26  * RFC 1542: Clarifications and Extensions for the Bootstrap Protocol
27  * RFC 2131: Dynamic Host Configuration Protocol
28  * RFC 2132: DHCP Options and BOOTP Vendor Extensions
29  * RFC 2241: DHCP Options for Novell Directory Services
30  * RFC 2242: NetWare/IP Domain Name and Information
31  * RFC 2489: Procedure for Defining New DHCP Options
32  * RFC 2610: DHCP Options for Service Location Protocol
33  * RFC 2685: Virtual Private Networks Identifier
34  * RFC 2937: The Name Service Search Option for DHCP
35  * RFC 3004: The User Class Option for DHCP
36  * RFC 3046: DHCP Relay Agent Information Option
37  * RFC 3118: Authentication for DHCP Messages
38  * RFC 3203: DHCP reconfigure extension
39  * RFC 3315: Dynamic Host Configuration Protocol for IPv6 (DHCPv6)
40  * RFC 3396: Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4)
41  * RFC 3397: Dynamic Host Configuration Protocol (DHCP) Domain Search Option
42  * RFC 3495: DHCP Option (122) for CableLabs Client Configuration
43  * RFC 3594: PacketCable Security Ticket Control Sub-Option (122.9)
44  * RFC 3442: Classless Static Route Option for DHCP version 4
45  * RFC 3825: Dynamic Host Configuration Protocol Option for Coordinate-based Location Configuration Information
46  * RFC 3925: Vendor-Identifying Vendor Options for Dynamic Host Configuration Protocol version 4 (DHCPv4)
47  * RFC 3942: Reclassifying DHCPv4 Options
48  * RFC 4243: Vendor-Specific Information Suboption for the Dynamic Host Configuration Protocol (DHCP) Relay Agent Option
49  * RFC 4361: Node-specific Client Identifiers for Dynamic Host Configuration Protocol Version Four (DHCPv4)
50  * RFC 4388: Dynamic Host Configuration Protocol (DHCP) Leasequery
51  * RFC 4578: Dynamic Host Configuration Protocol (DHCP) Options for PXE
52  * RFC 4776: Dynamic Host Configuration Protocol (DHCPv4 and DHCPv6) Option for Civic Addresses Configuration Information
53  * RFC 5223: Discovering Location-to-Service Translation (LoST) Servers Using the Dynamic Host Configuration Protocol (DHCP)
54  * RFC 5417: CAPWAP Access Controller DHCP Option
55  * RFC 5969: IPv6 Rapid Deployment on IPv4 Infrastructures (6rd)
56  * draft-ietf-dhc-fqdn-option-07.txt
57  * TFTP Server Address Option for DHCPv4 [draft-raj-dhc-tftp-addr-option-06.txt: http://tools.ietf.org/html/draft-raj-dhc-tftp-addr-option-06]
58  * BOOTP and DHCP Parameters
59  *     http://www.iana.org/assignments/bootp-dhcp-parameters
60  * DOCSIS(TM) 2.0 Radio Frequency Interface Specification
61  *     http://www.cablelabs.com/specifications/CM-SP-RFI2.0-I11-060602.pdf
62  * DOCSIS(TM) 3.0 MAC and Upper Layer Protocols Interface Specification
63  *     http://www.cablelabs.com/specifications/CM-SP-MULPIv3.0-I20-121113.pdf
64  * PacketCable(TM) 1.0 MTA Device Provisioning Specification
65  *     http://www.cablelabs.com/packetcable/downloads/specs/PKT-SP-PROV-I11-050812.pdf
66  *     http://www.cablelabs.com/specifications/archives/PKT-SP-PROV-I05-021127.pdf (superseded by above)
67  * PacketCable(TM) 1.5 MTA Device Provisioning Specification
68  *     http://www.cablelabs.com/packetcable/downloads/specs/PKT-SP-PROV1.5-I02-050812.pdf
69  * PacketCable(TM) 2.0 EUE Device Provisioning Specification
70  *     http://www.cablelabs.com/specifications/PKT-SP-EUE-DATA-I03-090528.pdf
71  * Business Services over DOCSIS(R) Layer 2 Virtual Private Networks
72  *     http://www.cablelabs.com/specifications/CM-SP-L2VPN-I09-100611.pdf
73  * CableHome(TM) 1.1 Specification
74  *     http://www.cablelabs.com/projects/cablehome/downloads/specs/CH-SP-CH1.1-I11-060407.pdf
75  * Broadband Forum TR-111
76  *     http://www.broadband-forum.org/technical/download/TR-111.pdf
77  *
78  * Wireshark - Network traffic analyzer
79  * By Gerald Combs <gerald@wireshark.org>
80  * Copyright 1998 Gerald Combs
81  *
82  * This program is free software; you can redistribute it and/or
83  * modify it under the terms of the GNU General Public License
84  * as published by the Free Software Foundation; either version 2
85  * of the License, or (at your option) any later version.
86  *
87  * This program is distributed in the hope that it will be useful,
88  * but WITHOUT ANY WARRANTY; without even the implied warranty of
89  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
90  * GNU General Public License for more details.
91  *
92  * You should have received a copy of the GNU General Public License
93  * along with this program; if not, write to the Free Software
94  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
95  */
96
97 /*
98  * Some of the development of the BOOTP/DHCP protocol decoder was sponsored by
99  * Cable Television Laboratories, Inc. ("CableLabs") based upon proprietary
100  * CableLabs' specifications. Your license and use of this protocol decoder
101  * does not mean that you are licensed to use the CableLabs'
102  * specifications.  If you have questions about this protocol, contact
103  * jf.mule [AT] cablelabs.com or c.stuart [AT] cablelabs.com for additional
104  * information.
105  */
106
107
108 #include "config.h"
109
110 #include <stdio.h>
111 #include <stdlib.h>
112 #include <string.h>
113
114 #include <glib.h>
115
116 #include <epan/packet.h>
117 #include "packet-arp.h"
118 #include "packet-dns.h"                         /* for get_dns_name() */
119 #include <epan/addr_resolv.h>
120 #include <epan/prefs.h>
121 #include <epan/tap.h>
122 #include <epan/strutil.h>
123 #include <epan/arptypes.h>
124 #include <epan/sminmpec.h>
125 #include <epan/expert.h>
126 #include <epan/uat.h>
127
128 void proto_register_bootp(void);
129 void proto_reg_handoff_bootp(void);
130
131 static int bootp_dhcp_tap = -1;
132 static int proto_bootp = -1;
133 static int hf_bootp_type = -1;
134 static int hf_bootp_hw_type = -1;
135 static int hf_bootp_hw_len = -1;
136 static int hf_bootp_hops = -1;
137 static int hf_bootp_id = -1;
138 static int hf_bootp_secs = -1;
139 static int hf_bootp_flags = -1;
140 static int hf_bootp_flags_broadcast = -1;
141 static int hf_bootp_flags_reserved = -1;
142 static int hf_bootp_ip_client = -1;
143 static int hf_bootp_ip_your = -1;
144 static int hf_bootp_ip_server = -1;
145 static int hf_bootp_ip_relay = -1;
146 static int hf_bootp_hw_addr = -1;
147 static int hf_bootp_hw_addr_padding = -1;
148 static int hf_bootp_hw_ether_addr = -1;
149 static int hf_bootp_server = -1;
150 static int hf_bootp_file = -1;
151 static int hf_bootp_cookie = -1;
152 static int hf_bootp_dhcp = -1;
153 static int hf_bootp_fqdn_s = -1;
154 static int hf_bootp_fqdn_o = -1;
155 static int hf_bootp_fqdn_e = -1;
156 static int hf_bootp_fqdn_n = -1;
157 static int hf_bootp_fqdn_mbz = -1;
158 static int hf_bootp_fqdn_rcode1 = -1;
159 static int hf_bootp_fqdn_rcode2 = -1;
160 static int hf_bootp_fqdn_name = -1;
161 static int hf_bootp_fqdn_asciiname = -1;
162 static int hf_bootp_pkt_mta_cap_len = -1;
163 static int hf_bootp_docsis_cm_cap_type = -1;
164 static int hf_bootp_docsis_cm_cap_len = -1;
165 static int hf_bootp_client_identifier_uuid = -1;
166 static int hf_bootp_client_identifier_duid_llt_hw_type = -1;
167 static int hf_bootp_client_identifier_duid_ll_hw_type = -1;
168 static int hf_bootp_option_type = -1;
169 static int hf_bootp_option_length = -1;
170 static int hf_bootp_option_value = -1;
171 static int hf_bootp_option_value_8 = -1;
172 static int hf_bootp_option_value_16 = -1;
173 static int hf_bootp_option_value_u32 = -1;
174 static int hf_bootp_option_value_i32 = -1;
175 static int hf_bootp_option_value_stringz = -1;
176 static int hf_bootp_option_value_ip_address = -1;
177 static int hf_bootp_option_value_boolean = -1;
178 static int hf_bootp_suboption_length = -1;
179
180 static int hf_bootp_option_padding = -1;                                /* 0 */
181 static int hf_bootp_option_subnet_mask = -1;                            /* 1 */
182 static int hf_bootp_option_time_offset = -1;                            /* 2 */
183 static int hf_bootp_option_router = -1;                                 /* 3 */
184 static int hf_bootp_option_time_server = -1;                            /* 4 */
185 static int hf_bootp_option_name_server = -1;                            /* 5 */
186 static int hf_bootp_option_domain_name_server = -1;                     /* 6 */
187 static int hf_bootp_option_log_server = -1;                             /* 7 */
188 static int hf_bootp_option_quotes_server = -1;                          /* 8 */
189 static int hf_bootp_option_lpr_server = -1;                             /* 9 */
190 static int hf_bootp_option_impress_server = -1;                         /* 10 */
191 static int hf_bootp_option_resource_location_server = -1;               /* 11 */
192 static int hf_bootp_option_hostname = -1;                               /* 12 */
193 static int hf_bootp_option_boot_file_size = -1;                         /* 13 */
194 static int hf_bootp_option_merit_dump_file = -1;                        /* 14 */
195 static int hf_bootp_option_domain_name = -1;                            /* 15 */
196 static int hf_bootp_option_swap_server = -1;                            /* 16 */
197 static int hf_bootp_option_root_path = -1;                              /* 17 */
198 static int hf_bootp_option_extension_path = -1;                         /* 18 */
199 static int hf_bootp_option_ip_forwarding = -1;                          /* 19 */
200 static int hf_bootp_option_non_local_source_routing = -1;               /* 20 */
201 static int hf_bootp_option_policy_filter_ip = -1;                       /* 21 - IP address */
202 static int hf_bootp_option_policy_filter_subnet_mask = -1;              /* 21 - Subnet mask */
203 static int hf_bootp_option_max_datagram_reassembly_size = -1;           /* 22 */
204 static int hf_bootp_option_default_ip_ttl = -1;                         /* 23 */
205 static int hf_bootp_option_path_mtu_aging_timeout = -1;                 /* 24 */
206 static int hf_bootp_option_path_mtu_plateau_table_item = -1;            /* 25 */
207 static int hf_bootp_option_interface_mtu = -1;                          /* 26 */
208 static int hf_bootp_option_all_subnets_are_local = -1;                  /* 27 */
209 static int hf_bootp_option_broadcast_address = -1;                      /* 28 */
210 static int hf_bootp_option_perform_mask_discovery = -1;                 /* 29 */
211 static int hf_bootp_option_mask_supplier = -1;                          /* 30 */
212 static int hf_bootp_option_perform_router_discover = -1;                /* 31 */
213 static int hf_bootp_option_router_solicitation_address = -1;            /* 32 */
214 static int hf_bootp_option_static_route_ip = -1;                        /* 33 - Destination IP */
215 static int hf_bootp_option_static_route_router = -1;                    /* 33 - Router */
216 static int hf_bootp_option_trailer_encapsulation = -1;                  /* 34 */
217 static int hf_bootp_option_arp_cache_timeout = -1;                      /* 35 */
218 static int hf_bootp_option_ethernet_encapsulation = -1;                 /* 36 */
219 static int hf_bootp_option_tcp_default_ttl = -1;                        /* 37 */
220 static int hf_bootp_option_tcp_keepalive_interval = -1;                 /* 38 */
221 static int hf_bootp_option_tcp_keepalive_garbage = -1;                  /* 39 */
222 static int hf_bootp_option_nis_domain = -1;                             /* 40 */
223 static int hf_bootp_option_nis_server = -1;                             /* 41 */
224 static int hf_bootp_option_ntp_server = -1;                             /* 42 */
225
226 static int hf_bootp_option43_value = -1;                                /* 43 suboption value */
227 static int hf_bootp_option43_value_8 = -1;                              /* 43 suboption value */
228 static int hf_bootp_option43_value_32 = -1;                             /* 43 suboption value */
229 static int hf_bootp_option43_value_stringz = -1;                        /* 43 suboption value */
230 static int hf_bootp_option43_value_ip_address = -1;                     /* 43 suboption value */
231
232 static int hf_bootp_option43_pxeclient_suboption = -1;                  /* 43 suboption */
233 static int hf_bootp_option43_pxeclient_padding = -1;                    /* 43:0 PXE  */
234 static int hf_bootp_option43_pxeclient_mtftp_ip = -1;                   /* 43:1 PXE  */
235 static int hf_bootp_option43_pxeclient_mtftp_client_port = -1;          /* 43:2 PXE  */
236 static int hf_bootp_option43_pxeclient_mtftp_server_port = -1;          /* 43:3 PXE  */
237 static int hf_bootp_option43_pxeclient_mtftp_timeout = -1;              /* 43:4 PXE  */
238 static int hf_bootp_option43_pxeclient_mtftp_delay = -1;                /* 43:5 PXE  */
239 static int hf_bootp_option43_pxeclient_discovery_control = -1;          /* 43:6 PXE  */
240 static int hf_bootp_option43_pxeclient_multicast_address = -1;          /* 43:7 PXE  */
241 static int hf_bootp_option43_pxeclient_boot_servers = -1;               /* 43:8 PXE  */
242 static int hf_bootp_option43_pxeclient_boot_menu = -1;                  /* 43:9 PXE  */
243 static int hf_bootp_option43_pxeclient_menu_prompt = -1;                /* 43:10 PXE  */
244 static int hf_bootp_option43_pxeclient_multicast_address_alloc = -1;    /* 43:11 PXE  */
245 static int hf_bootp_option43_pxeclient_credential_types = -1;           /* 43:12 PXE  */
246 static int hf_bootp_option43_pxeclient_boot_item = -1;                  /* 43:71 PXE  */
247 static int hf_bootp_option43_pxeclient_end = -1;                        /* 43:255 PXE */
248
249 static int hf_bootp_option43_cl_suboption = -1;                         /* 43 suboption */
250 static int hf_bootp_option43_cl_padding = -1;                           /* 43:0 CL  */
251 static int hf_bootp_option43_cl_suboption_request_list = -1;            /* 43:1 CL  */
252 static int hf_bootp_option43_cl_device_type = -1;                       /* 43:2 CL  */
253 static int hf_bootp_option43_cl_esafe_type = -1;                        /* 43:3 CL  */
254 static int hf_bootp_option43_cl_serial_number = -1;                     /* 43:4 CL  */
255 static int hf_bootp_option43_cl_hardware_version = -1;                  /* 43:5 CL  */
256 static int hf_bootp_option43_cl_software_version = -1;                  /* 43:6 CL  */
257 static int hf_bootp_option43_cl_boot_rom_version = -1;                  /* 43:7 CL  */
258 static int hf_bootp_option43_cl_oui_bytes = -1;                         /* 43:8 CL  */
259 static int hf_bootp_option43_cl_oui_string = -1;                        /* 43:8 CL  */
260 static int hf_bootp_option43_cl_model_number = -1;                      /* 43:9 CL  */
261 static int hf_bootp_option43_cl_vendor_name10 = -1;                     /* 43:10 CL  */
262 static int hf_bootp_option43_cl_address_realm = -1;                     /* 43:11 CL  */
263 static int hf_bootp_option43_cl_cm_ps_system_desc = -1;                 /* 43:12 CL  */
264 static int hf_bootp_option43_cl_cm_ps_firmware_revision = -1;           /* 43:13 CL  */
265 static int hf_bootp_option43_cl_firewall_policy_file_version = -1;      /* 43:14 CL  */
266 static int hf_bootp_option43_cl_esafe_config_file_devices = -1;         /* 43:15 CL  */
267 static int hf_bootp_option43_cl_video_security_tape = -1;               /* 43:18 CL  */
268 static int hf_bootp_option43_cl_mta_mac_address = -1;                   /* 43:31 CL  */
269 static int hf_bootp_option43_cl_correlation_ID = -1;                    /* 43:32 CL  */
270 static int hf_bootp_option43_cl_vendor_name51 = -1;                     /* 43:51 CL  */
271 static int hf_bootp_option43_cl_cablecard_capability = -1;              /* 43:52 CL  */
272 static int hf_bootp_option43_cl_device_id_ca = -1;                      /* 43:53 CL  */
273 static int hf_bootp_option43_cl_device_id_x509 = -1;                    /* 43:54 CL  */
274 static int hf_bootp_option43_cl_end = -1;                               /* 43:255 CL */
275
276 static int hf_bootp_option43_alcatel_suboption = -1;                    /* 43 suboption */
277 static int hf_bootp_option43_alcatel_padding = -1;                      /* 43:0 Alcatel  */
278 static int hf_bootp_option43_alcatel_vlan_id = -1;                      /* 43:58 Alcatel  */
279 static int hf_bootp_option43_alcatel_tftp1 = -1;                        /* 43:64 Alcatel  */
280 static int hf_bootp_option43_alcatel_tftp2 = -1;                        /* 43:65 Alcatel  */
281 static int hf_bootp_option43_alcatel_app_type = -1;                     /* 43:66 Alcatel  */
282 static int hf_bootp_option43_alcatel_sip_url = -1;                      /* 43:67 Alcatel  */
283 static int hf_bootp_option43_alcatel_end = -1;                          /* 43:255 Alcatel */
284
285
286 static int hf_bootp_option_netbios_over_tcpip_name_server = -1;         /* 44 */
287 static int hf_bootp_option_netbios_over_tcpip_dd_name_server = -1;      /* 45 */
288 static int hf_bootp_option_netbios_over_tcpip_node_type = -1;           /* 46 */
289 static int hf_bootp_option_netbios_over_tcpip_scope = -1;               /* 47 */
290 static int hf_bootp_option_xwindows_system_font_server = -1;            /* 48 */
291 static int hf_bootp_option_xwindows_system_display_manager = -1;        /* 49 */
292 static int hf_bootp_option_requested_ip_address = -1;                   /* 50 */
293 static int hf_bootp_option_ip_address_lease_time = -1;                  /* 51 */
294 static int hf_bootp_option_option_overload = -1;                        /* 52 */
295 static int hf_bootp_option_dhcp = -1;                                   /* 53 */
296 static int hf_bootp_option_dhcp_server_id = -1;                         /* 54 */
297 static int hf_bootp_option_parameter_request_list_item = -1;            /* 55 */
298 static int hf_bootp_option_message = -1;                                /* 56 */
299 static int hf_bootp_option_dhcp_max_message_size = -1;                  /* 57 */
300 static int hf_bootp_option_renewal_time_value = -1;                     /* 58 */
301 static int hf_bootp_option_rebinding_time_value = -1;                   /* 59 */
302 static int hf_bootp_option_vendor_class_id = -1;                        /* 60 */
303
304 static int hf_bootp_option_novell_netware_ip_domain = -1;               /* 62 */
305
306 static int hf_bootp_option63_suboption = -1;                            /* 63 suboption */
307 static int hf_bootp_option63_value = -1;                                /* 63 suboption value */
308 static int hf_bootp_option63_value_8 = -1;                              /* 63 suboption value */
309 static int hf_bootp_option63_value_ip_address = -1;                     /* 63 suboption value */
310 static int hf_bootp_option63_value_boolean = -1;                        /* 63 suboption value */
311 static int hf_bootp_option63_broadcast = -1;                            /* 63:5 */
312 static int hf_bootp_option63_preferred_dss_server = -1;                 /* 63:6 */
313 static int hf_bootp_option63_nearest_nwip_server = -1;                  /* 63:7 */
314 static int hf_bootp_option63_autoretries = -1;                          /* 63:8 */
315 static int hf_bootp_option63_autoretry_delay = -1;                      /* 63:9 */
316 static int hf_bootp_option63_support_netware_v1_1 = -1;                 /* 63:10 */
317 static int hf_bootp_option63_primary_dss = -1;                          /* 63:11 */
318
319 static int hf_bootp_option_nis_plus_domain = -1;                        /* 64 */
320 static int hf_bootp_option_nis_plus_server = -1;                        /* 65 */
321 static int hf_bootp_option_tftp_server_name = -1;                       /* 66 */
322 static int hf_bootp_option_bootfile_name = -1;                          /* 67 */
323 static int hf_bootp_option_mobile_ip_home_agent = -1;                   /* 68 */
324 static int hf_bootp_option_smtp_server = -1;                            /* 69 */
325 static int hf_bootp_option_pop3_server = -1;                            /* 70 */
326 static int hf_bootp_option_nntp_server = -1;                            /* 71 */
327 static int hf_bootp_option_default_www_server = -1;                     /* 72 */
328 static int hf_bootp_option_default_finger_server = -1;                  /* 73 */
329 static int hf_bootp_option_default_irc_server = -1;                     /* 74 */
330 static int hf_bootp_option_streettalk_server = -1;                      /* 75 */
331 static int hf_bootp_option_streettalk_da_server = -1;                   /* 76 */
332 static int hf_bootp_option77_user_class = -1;                           /* 77 User Class instance */
333 static int hf_bootp_option77_user_class_length = -1;                    /* 77 length of User Class instance */
334 static int hf_bootp_option77_user_class_data = -1;                      /* 77 data of User Class instance */
335 static int hf_bootp_option_slp_directory_agent_value = -1;              /* 78 */
336 static int hf_bootp_option_slp_directory_agent_slpda_address = -1;      /* 78 */
337 static int hf_bootp_option_slp_service_scope_value = -1;                /* 79 */
338 static int hf_bootp_option_slp_service_scope_string = -1;               /* 79 */
339
340 static int hf_bootp_option82_suboption = -1;                            /* 82 suboption */
341 static int hf_bootp_option82_value = -1;                                /* 82 suboption value */
342 static int hf_bootp_option82_value_8 = -1;                              /* 82 suboption value */
343 static int hf_bootp_option82_value_32 = -1;                             /* 82 suboption value */
344 static int hf_bootp_option82_value_ip_address = -1;                     /* 82 suboption value */
345 static int hf_bootp_option82_value_stringz = -1;                        /* 82 suboption value */
346 static int hf_bootp_option82_padding = -1;                              /* 82:0 */
347 static int hf_bootp_option82_agent_circuit_id = -1;                     /* 82:1 */
348 static int hf_bootp_option82_agent_remote_id = -1;                      /* 82:2 */
349 static int hf_bootp_option82_reserved = -1;                             /* 82:3 */
350 static int hf_bootp_option82_docsis_device_class = -1;                  /* 82:4 */
351 static int hf_bootp_option82_link_selection = -1;                       /* 82:5 */
352 static int hf_bootp_option82_subscriber_id = -1;                        /* 82:6 */
353 static int hf_bootp_option82_radius_attributes = -1;                    /* 82:7 */
354 static int hf_bootp_option82_authentication = -1;                       /* 82:8 */
355 static int hf_bootp_option82_vi = -1;                                   /* 82:9 */
356                                                                         /* 82:9 suboptions */
357 static int hf_bootp_option82_vi_enterprise = -1;
358 static int hf_bootp_option82_vi_data_length = -1;
359 static int hf_bootp_option82_vi_cl_option = -1;
360 static int hf_bootp_option82_vi_cl_length = -1;
361 static int hf_bootp_option82_vi_cl_tag = -1;
362 static int hf_bootp_option82_vi_cl_tag_length = -1;
363 static int hf_bootp_option82_vi_cl_docsis_version = -1;
364                                                                         /* 82:9 suboptions end */
365 static int hf_bootp_option82_flags = -1;                                /* 82:10 */
366 static int hf_bootp_option82_server_id_override = -1;                   /* 82:11 */
367 static int hf_bootp_option82_link_selection_cisco = -1;                 /* 82:150 */
368 static int hf_bootp_option82_vrf_name_vpn_id = -1;                      /* 82:151 */
369                                                                         /* 82:151 suboptions */
370 static int hf_bootp_option82_vrf_name_vpn_id_oui = -1;
371 static int hf_bootp_option82_vrf_name_vpn_id_index = -1;
372                                                                         /* 82:151 suboptions end */
373 static int hf_bootp_option82_server_id_override_cisco = -1;             /* 82:152 */
374
375 static int hf_bootp_option_novell_dss_string = -1;                      /* 85 */
376 static int hf_bootp_option_novell_dss_ip = -1;                          /* 85 */
377 static int hf_bootp_option_novell_ds_tree_name = -1;                    /* 86 */
378 static int hf_bootp_option_novell_ds_context = -1;                      /* 87 */
379 static int hf_bootp_option_dhcp_authentication_protocol = -1;           /* 90 */
380 static int hf_bootp_option_dhcp_authentication_alg_delay = -1;          /* 90 */
381 static int hf_bootp_option_dhcp_authentication_algorithm = -1;          /* 90 */
382 static int hf_bootp_option_dhcp_authentication_rdm = -1;                /* 90 */
383 static int hf_bootp_option_dhcp_authentication_rdm_replay_detection = -1;   /* 90 */
384 static int hf_bootp_option_dhcp_authentication_rdm_rdv = -1;            /* 90 */
385 static int hf_bootp_option_dhcp_authentication_secret_id = -1;          /* 90 */
386 static int hf_bootp_option_dhcp_authentication_hmac_md5_hash = -1;      /* 90 */
387 static int hf_bootp_option_dhcp_authentication_information = -1;        /* 90 */
388 static int hf_bootp_option_client_last_transaction_time = -1;           /* 91 */
389 static int hf_bootp_option_associated_ip_option = -1;                   /* 92 */
390 static int hf_bootp_option_client_system_architecture = -1;             /* 93 */
391 static int hf_bootp_option_client_network_id_major_ver = -1;            /* 94 */
392 static int hf_bootp_option_client_network_id_minor_ver = -1;            /* 94 */
393 static int hf_bootp_option_civic_location_what = -1;                    /* 99 */
394 static int hf_bootp_option_civic_location_country = -1;                 /* 99 */
395 static int hf_bootp_option_civic_location_ca_type = -1;                 /* 99 */
396 static int hf_bootp_option_civic_location_ca_length = -1;               /* 99 */
397 static int hf_bootp_option_civic_location_ca_value = -1;                /* 99 */
398 static int hf_bootp_option_netinfo_parent_server_address = -1;          /* 112 */
399 static int hf_bootp_option_netinfo_parent_server_tag = -1;              /* 113 */
400 static int hf_bootp_option_dhcp_auto_configuration = -1;                /* 116 */
401 static int hf_bootp_option_dhcp_name_service_search_option = -1;                /* 117 */
402 static int hf_bootp_option_dhcp_dns_domain_search_list_rfc_3396_detected = -1;  /* 119 */
403 static int hf_bootp_option_dhcp_dns_domain_search_list_refer_last_option = -1;  /* 119 */
404 static int hf_bootp_option_dhcp_dns_domain_search_list_fqdn = -1;               /* 119 */
405 static int hf_bootp_option_sip_server_rfc_3396_detected = -1;                   /* 120 */
406 static int hf_bootp_option_sip_server_refer_last_option = -1;                   /* 120 */
407 static int hf_bootp_option_sip_server_enc = -1;                         /* 120 */
408 static int hf_bootp_option_sip_server_name = -1;                                /* 120 */
409 static int hf_bootp_option_sip_server_address = -1;                             /* 120 */
410 static int hf_bootp_option_sip_server_address_stringz = -1;             /* 120 */
411 static int hf_bootp_option_cl_dss_id_option = -1;                       /* 123 CL */
412 static int hf_bootp_option_cl_dss_id_len = -1;                          /* 123 CL */
413 static int hf_bootp_option_cl_dss_id = -1;                              /* 123 CL */
414 static int hf_bootp_option_vi_class_cl_address_mode = -1;               /* 124 */
415 static int hf_bootp_option_vi_class_enterprise = -1;                    /* 124 */
416 static int hf_bootp_option_vi_class_data_length = -1;                   /* 124 */
417 static int hf_bootp_option_vi_class_data = -1;                          /* 124 */
418
419 static int hf_bootp_option125_enterprise = -1;
420 static int hf_bootp_option125_value = -1;                               /* 125 suboption value */
421 static int hf_bootp_option125_value_8 = -1;                             /* 125 suboption value */
422 static int hf_bootp_option125_value_16 = -1;                            /* 125 suboption value */
423 static int hf_bootp_option125_value_ip_address = -1;                    /* 125 suboption value */
424 static int hf_bootp_option125_value_stringz = -1;                       /* 125 suboption value */
425 static int hf_bootp_option125_tr111_suboption = -1;                     /* 125 suboption */
426 static int hf_bootp_option125_tr111_device_manufacturer_oui = -1;       /* 125:TR-111 1 */
427 static int hf_bootp_option125_tr111_device_serial_number = -1;          /* 125:TR-111 2 */
428 static int hf_bootp_option125_tr111_device_product_class = -1;          /* 125:TR-111 3 */
429 static int hf_bootp_option125_tr111_gateway_manufacturer_oui = -1;      /* 125:TR-111 4 */
430 static int hf_bootp_option125_tr111_gateway_serial_number = -1;         /* 125:TR-111 5 */
431 static int hf_bootp_option125_tr111_gateway_product_class = -1;         /* 125:TR-111 6 */
432 static int hf_bootp_option125_cl_suboption = -1;                        /* 125 suboption */
433 static int hf_bootp_option125_cl_option_request = -1;                   /* 125:CL 1 */
434 static int hf_bootp_option125_cl_tftp_server_addresses = -1;            /* 125:CL 2 */
435 static int hf_bootp_option125_cl_erouter_container_option = -1;         /* 125:CL 3 */
436 static int hf_bootp_option125_cl_mib_environment_indicator_option = -1; /* 125:CL 4 */
437 static int hf_bootp_option125_cl_modem_capabilities = -1;               /* 125:CL 5 */
438
439 static int hf_bootp_option_subnet_selection_option = -1;                /* 118 */
440 static int hf_bootp_option_lost_server_domain_name = -1;                /* 137 */
441 static int hf_bootp_option_capwap_access_controller = -1;               /* 138 */
442 static int hf_bootp_option_tftp_server_address = -1;                    /* 150 */
443 static int hf_bootp_option_6RD_ipv4_mask_len = -1;                      /* 212 */
444 static int hf_bootp_option_6RD_prefix_len = -1;                         /* 212 */
445 static int hf_bootp_option_6RD_prefix = -1;                             /* 212 */
446 static int hf_bootp_option_6RD_border_relay_ip = -1;                    /* 212 */
447 static int hf_bootp_option_private_proxy_autodiscovery = -1;            /* 252 */
448 static int hf_bootp_option_end = -1;                                    /* 255 */
449 static int hf_bootp_option_end_overload = -1;                           /* 255 (with overload)*/
450
451
452
453
454 static gint ett_bootp = -1;
455 static gint ett_bootp_flags = -1;
456 static gint ett_bootp_option = -1;
457 static gint ett_bootp_option43_suboption = -1;
458 static gint ett_bootp_option63_suboption = -1;
459 static gint ett_bootp_option77_instance = -1;
460 static gint ett_bootp_option82_suboption = -1;
461 static gint ett_bootp_option82_suboption9 = -1;
462 static gint ett_bootp_option125_suboption = -1;
463 static gint ett_bootp_fqdn = -1;
464
465 static expert_field ei_bootp_bad_length = EI_INIT;
466 static expert_field ei_bootp_missing_subopt_length = EI_INIT;
467 static expert_field ei_bootp_missing_subopt_value = EI_INIT;
468 static expert_field ei_bootp_mal_duid = EI_INIT;
469 static expert_field hf_bootp_opt_overload_file_end_missing = EI_INIT;
470 static expert_field hf_bootp_opt_overload_sname_end_missing = EI_INIT;
471 static expert_field hf_bootp_subopt_unknown_type = EI_INIT;
472 static expert_field ei_bootp_option77_user_class_malformed = EI_INIT;
473 static expert_field ei_bootp_option_civic_location_bad_cattype = EI_INIT;
474 static expert_field ei_bootp_option_dhcp_name_service_invalid = EI_INIT;
475 static expert_field ei_bootp_option_sip_server_address_encoding = EI_INIT;
476 static expert_field ei_bootp_option_classless_static_route = EI_INIT;
477 static expert_field ei_bootp_option125_enterprise_malformed = EI_INIT;
478 static expert_field ei_bootp_option_6RD_malformed = EI_INIT;
479 static expert_field ei_bootp_option82_vi_cl_tag_unknown = EI_INIT;
480 static expert_field ei_bootp_suboption_invalid = EI_INIT;
481 static expert_field ei_bootp_secs_le = EI_INIT;
482 static expert_field ei_bootp_end_option_missing = EI_INIT;
483
484 static dissector_handle_t bootp_handle;
485
486 /* RFC2937 The Name Service Search Option for DHCP */
487 #define RFC2937_LOCAL_NAMING_INFORMATION                           0
488 #define RFC2937_DOMAIN_NAME_SERVER_OPTION                          6
489 #define RFC2937_NETWORK_INFORMATION_SERVERS_OPTION                41
490 #define RFC2937_NETBIOS_OVER_TCP_IP_NAME_SERVER_OPTION            44
491 #define RFC2937_NETWORK_INFORMATION_SERVICE_PLUS_SERVERS_OPTION   65
492
493 /* RFC3825decoder error codes of the conversion function */
494 #define RFC3825_NOERROR                           0
495 #define RFC3825_LATITUDE_OUTOFRANGE               1
496 #define RFC3825_LATITUDE_UNCERTAINTY_OUTOFRANGE   2
497 #define RFC3825_LONGITUDE_OUTOFRANGE              3
498 #define RFC3825_LONGITUDE_UNCERTAINTY_OUTOFRANGE  4
499 #define RFC3825_ALTITUDE_OUTOFRANGE               5
500 #define RFC3825_ALTITUDE_UNCERTAINTY_OUTOFRANGE   6
501 #define RFC3825_ALTITUDE_TYPE_OUTOFRANGE          7
502 #define RFC3825_DATUM_TYPE_OUTOFRANGE             8
503
504 #define DUID_LLT                1
505 #define DUID_EN                 2
506 #define DUID_LL                 3
507
508 struct rfc3825_location_fixpoint_t {
509
510         gint64 latitude;        /* latitude in degrees, allowed range from -90deg to 90deg.
511                                    Fixpoint A(8,25) with 34 bits */
512         guint8 latitude_res;    /* the resolution of the latitude in bits, allowed range is from 0 to 34.
513                                    6 bits. */
514         gint64 longitude;       /* longitude in degrees, range from -180deg to 180deg.
515                                    Fixpoint A(8,25) with 34 bits */
516         guint8 longitude_res;   /* the resolution of the longitude in bits, allowed range is from 0 to 34.
517                                    6 bits. */
518         gint32 altitude;        /* the altitude, 30 bits.
519                                    Depending on alt_type this are meters or floors, no range limit.
520                                    altitude_type==1: A(13,8) with 22 bits
521                                    altitude_type==2: A(13,8) with 22 bits */
522         guint8 altitude_res;    /* the resolution of the altitude in bits, allowed range is from 0 to 30.
523                                    6 bits.
524                                    altitude_type==1: any value between 0 and 30
525                                    altitude_type==2: either 0 (floor unknown) or 30 */
526         guint8 altitude_type;   /* the type of the altitude, 4 bits. allowed values are:
527                                    0: unknown
528                                    1: altitude in meters
529                                    2: altitude in floors */
530         guint8 datum_type;      /* the map datum used for the coordinates. 8 bits.
531                                    All values are allowed although currently only the
532                                    following ones are defined:
533                                    1: WGS84
534                                    2: NAD83/NAVD88
535                                    3: NAD83/MLLW */
536 };
537
538 /* The rfc3825_location_decimal_t structure holds the location parameters
539  * in decimal (floating point) format.
540  */
541 struct rfc3825_location_decimal_t {
542
543         double latitude;        /* latitude in degrees, allowed range from -90deg to 90deg */
544         double latitude_res;    /* the uncertainty of the latitude in grad, "0.01" means +-0.01deg
545                                    from the altitude. During conversion this will be rounded to
546                                    next smaller value which can be represented in fixpoint arithmetic */
547         double longitude;       /* longitude in degrees, range from -180deg to 180deg */
548         double longitude_res;   /* the uncertainty of the longitude in grad, "0.01" means +-0.01deg
549                                    from the longitude. During conversion this will be rounded to
550                                    next smaller value which can be represented in fixpoint arithmetic */
551         double altitude;        /* the altitude, depending on alt_type this are meters or floors, no range limit */
552         double altitude_res;    /* the uncertainty of the altitude in either:
553                                    - altitude-type=meters: "10" means 10 meters which means +-10 meters from the altitude
554                                    - altitude-type=floors: either 0 (unknown) or 30 (exact) */
555         int altitude_type;      /* the type of the altitude, allowed values are
556                                    0: unknown
557                                    1: altitude in meters
558                                    2: altitude in floors */
559         int datum_type;          /* the map datum used for the coordinates.
560                                     All values are allowed although currently only the
561                                     following ones are defined:
562                                     1: WGS84
563                                     2: NAD83/NAVD88
564                                     3: NAD83/MLLW */
565 };
566
567 /* For managing split options with RFC 3396 */
568 struct rfc3396_for_option_t {
569         unsigned int total_number_of_block;
570         unsigned int index_current_block;
571         tvbuff_t* tvb_composite;
572 };
573
574 /* The RFC 3397 allows to cut long option (RFC 3396). */
575 struct rfc3396_for_option_t rfc3396_dns_domain_search_list;
576
577 /* The RFC 3361 allows to cut long option (RFC 3396). */
578 struct rfc3396_for_option_t rfc3396_sip_server;
579
580 enum {
581         RFC_3361_ENC_FQDN,
582         RFC_3361_ENC_IPADDR
583 };
584
585 /* converts fixpoint presentation into decimal presentation
586    also converts values which are out of range to allow decoding of received data */
587 static int rfc3825_fixpoint_to_decimal(struct rfc3825_location_fixpoint_t *fixpoint, struct rfc3825_location_decimal_t *decimal);
588
589 /* decodes the LCI string received from DHCP into the fixpoint values */
590 static void rfc3825_lci_to_fixpoint(const unsigned char lci[16], struct rfc3825_location_fixpoint_t *fixpoint);
591
592
593 /* Map Datum Types used for the coordinates (RFC 3825) */
594 static const value_string map_datum_type_values[] = {
595         { 1,    "WGS 84" },
596         { 2,    "NAD83 (NAVD88)" },
597         { 3,    "NAD83 (MLLW)" },
598         { 0,    NULL }
599 };
600
601
602 /* Altitude Types used for the coordinates (RFC 3825) */
603 static const value_string altitude_type_values[] = {
604         { 1,    "Meters" },
605         { 2,    "Floors" },
606         { 0,    NULL }
607 };
608
609 /* AutoConfigure (RFC 2563) */
610 static const value_string dhcp_autoconfig[] = {
611         { 0,    "DoNotAutoConfigure"},
612         { 1,    "AutoConfigure"},
613         { 0,    NULL }
614 };
615
616 /* Error Types for RFC 3825 coordinate location decoding */
617 static const value_string rfc3825_error_types[] = {
618         { 1,    "Latitude is out of range [-90,90]"},
619         { 2,    "Latitude Uncertainty is out of range [0,90]"},
620         { 3,    "Longitude is out of range [-180,180]"},
621         { 4,    "Longitude Uncertainty is out of range [0,180]"},
622         { 5,    "Altitude is out of range [-(2^21),(2^21)-1]"},
623         { 6,    "Altitude Uncertainty is out of range [0,2^20]"},
624         { 7,    "Altitude Type is out of range [0,2]"},
625         { 8,    "Datum is out of range [1,3]"},
626         { 0,    NULL }
627 };
628
629
630
631 /* Civic Address What field (RFC 4776) */
632 static const value_string civic_address_what_values[] = {
633         { 0,    "Location of the DHCP server" },
634         { 1,    "Location of the network element believed to be closest to the client" },
635         { 2,    "Location of the client"},
636         { 0, NULL}
637 };
638
639 /* Civic Address Type field (RFC 4119, RFC 4776, RFC 5139) */
640 static const value_string civic_address_type_values[] = {
641         {   0,  "Language" },
642         {   1,  "A1" },
643         {   2,  "A2" },
644         {   3,  "A3" },
645         {   4,  "A4" },
646         {   5,  "A5" },
647         {   6,  "A6" },
648         {  16,  "PRD (Leading street direction)" },
649         {  17,  "POD (Trailing street suffix)" },
650         {  18,  "STS (Street suffix)" },
651         {  19,  "HNO (House number)" },
652         {  20,  "HNS (House number suffix)" },
653         {  21,  "LMK (Landmark or vanity address)" },
654         {  22,  "LOC (Additional location information)" },
655         {  23,  "NAM" },
656         {  24,  "PC (Postal/ZIP code)" },
657         {  25,  "BLD (Building)" },
658         {  26,  "UNIT" },
659         {  27,  "FLR (Floor)" },
660         {  28,  "ROOM" },
661         {  29,  "PLC (Place-type)" },
662         {  30,  "PCN (Postal community name)" },
663         {  31,  "POBOX" },
664         {  32,  "ADDCODE (Additional Code)" },
665         {  33,  "SEAT" },
666         {  34,  "RD (Primary road or street)" },
667         {  35,  "RDSEC (Road section)" },
668         {  36,  "RDBR (Road branch)" },
669         {  37,  "RDSUBBR (Road sub-branch)" },
670         {  38,  "PRM (Road pre-modifier)" },
671         {  39,  "POM (Road post-modifier" },
672         { 128,  "Script" },
673         { 0, NULL }
674 };
675
676 static const value_string cablelab_ipaddr_mode_vals[] = {
677         { 1, "IPv4" },
678         { 2, "IPv6" },
679         { 0, NULL }
680 };
681
682 static const value_string duidtype_vals[] =
683 {
684         { DUID_LLT,     "link-layer address plus time" },
685         { DUID_EN,      "assigned by vendor based on Enterprise number" },
686         { DUID_LL,      "link-layer address" },
687         { 0, NULL }
688 };
689
690 static gboolean novell_string = FALSE;
691
692 #define UDP_PORT_BOOTPS  67
693 #define UDP_PORT_BOOTPC  68
694
695 #define BOOTP_BC        0x8000
696 #define BOOTP_MBZ       0x7FFF
697
698 /* FQDN stuff */
699 #define F_FQDN_S        0x01
700 #define F_FQDN_O        0x02
701 #define F_FQDN_E        0x04
702 #define F_FQDN_N        0x08
703 #define F_FQDN_MBZ      0xf0
704
705 static const true_false_string tfs_fqdn_s = {
706         "Server",
707         "Client"
708 };
709
710 static const true_false_string tfs_fqdn_o = {
711         "Override",
712         "No override"
713 };
714
715 static const true_false_string tfs_fqdn_e = {
716         "Binary encoding",
717         "ASCII encoding"
718 };
719
720 static const true_false_string tfs_fqdn_n = {
721         "No server updates",
722         "Some server updates"
723 };
724
725 enum field_type {
726         special,
727         none,
728         presence,
729         ipv4,                   /* single IPv4 address */
730         ipv4_list,              /* list of IPv4 addresses */
731         string,
732         bytes,
733         opaque,
734         val_boolean,
735         val_u_byte,
736         val_u_short,
737         val_u_short_list,
738         val_u_le_short,
739         val_u_long,
740         time_in_s_secs,         /* Signed */
741         time_in_u_secs,         /* Unsigned (not micro) */
742         fqdn,
743         ipv4_or_fqdn
744 };
745
746 struct opt_info {
747         const char      *text;
748         enum field_type ftype;
749         int* phf;
750 };
751
752 static const true_false_string flag_set_broadcast = {
753         "Broadcast",
754         "Unicast"
755 };
756
757 #define BOOTP_MAX_NO_CHAR 64
758
759 /* PacketCable/DOCSIS definitions */
760 #define PACKETCABLE_MTA_CAP10 "pktc1.0:"
761 #define PACKETCABLE_MTA_CAP15 "pktc1.5:"
762 #define PACKETCABLE_MTA_CAP20 "pktc2.0:"
763 #define PACKETCABLE_CM_CAP11  "docsis1.1:"
764 #define PACKETCABLE_CM_CAP20  "docsis2.0:"
765 #define PACKETCABLE_CM_CAP30  "docsis3.0:"
766
767 #define PACKETCABLE_CCC_I05      1
768 #define PACKETCABLE_CCC_DRAFT5   2
769 #define PACKETCABLE_CCC_RFC_3495 3
770
771 static const enum_val_t pkt_ccc_protocol_versions[] = {
772         { "ccc_i05",     "PKT-SP-PROV-I05-021127", PACKETCABLE_CCC_I05 },
773         { "ccc_draft_5", "IETF Draft 5",           PACKETCABLE_CCC_DRAFT5 },
774         { "rfc_3495",    "RFC 3495",               PACKETCABLE_CCC_RFC_3495 },
775         { NULL, NULL, 0 }
776 };
777
778 static gint pkt_ccc_protocol_version = PACKETCABLE_CCC_RFC_3495;
779 static guint pkt_ccc_option = 122;
780
781
782 static int dissect_vendor_pxeclient_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
783                                               tvbuff_t *tvb, int optoff, int optend);
784 static int dissect_vendor_cablelabs_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
785                                               tvbuff_t *tvb, int optoff, int optend);
786 static int dissect_vendor_alcatel_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
787                                             tvbuff_t *tvb, int optoff, int optend);
788 static int dissect_netware_ip_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
789                                             tvbuff_t *tvb, int optoff, int optend);
790 static int dissect_vendor_tr111_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
791                                             tvbuff_t *tvb, int optoff, int optend);
792 static int bootp_dhcp_decode_agent_info(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
793                                             tvbuff_t *tvb, int optoff, int optend);
794 static void dissect_packetcable_mta_cap(proto_tree *v_tree, tvbuff_t *tvb,
795                                         int voff, int len);
796 static void dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb,
797                                   int voff, int len, gboolean opt125);
798 static int dissect_packetcable_i05_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
799                                        tvbuff_t *tvb, int optoff, int optend);
800 static int dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
801                                         tvbuff_t *tvb, int optoff, int optend, int revision);
802 static int dissect_vendor_cl_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
803                                             tvbuff_t *tvb, int optoff, int optend);
804
805 #define OPT53_DISCOVER "Discover"
806 /* http://www.iana.org/assignments/bootp-dhcp-parameters */
807 static const value_string opt53_text[] = {
808         {  1,   OPT53_DISCOVER },
809         {  2,   "Offer" },
810         {  3,   "Request" },
811         {  4,   "Decline" },
812         {  5,   "ACK" },
813         {  6,   "NAK" },
814         {  7,   "Release" },
815         {  8,   "Inform" },
816         {  9,   "Force Renew" },
817         { 10,   "Lease query" },                /* RFC4388 */
818         { 11,   "Lease Unassigned" },           /* RFC4388 */
819         { 12,   "Lease Unknown" },              /* RFC4388 */
820         { 13,   "Lease Active" },               /* RFC4388 */
821         /* draft-ietf-dhc-leasequery-09.txt
822         { 13,   "Lease query" },                        */
823         { 14,   "Lease known" },
824         { 15,   "Lease unknown" },
825         { 16,   "Lease active" },
826         { 17,   "Unimplemented" },
827
828         { 0,    NULL }
829 };
830
831 /* DHCP Authentication protocols */
832 #define AUTHEN_PROTO_CONFIG_TOKEN       0
833 #define AUTHEN_PROTO_DELAYED_AUTHEN     1
834
835 /* DHCP Authentication algorithms for delayed authentication */
836 #define AUTHEN_DELAYED_ALGO_HMAC_MD5    1
837
838 /* DHCP Authentication Replay Detection Methods */
839 #define AUTHEN_RDM_MONOTONIC_COUNTER    0x00
840
841 /* DHCP Option Overload (option code 52) */
842 #define OPT_OVERLOAD_FILE               1
843 #define OPT_OVERLOAD_SNAME              2
844 #define OPT_OVERLOAD_BOTH               3
845
846 /* Server name and boot file offsets and lengths */
847 #define SERVER_NAME_OFFSET              44
848 #define SERVER_NAME_LEN                 64
849 #define FILE_NAME_OFFSET                108
850 #define FILE_NAME_LEN                   128
851 #define VENDOR_INFO_OFFSET              236
852
853 static const value_string bootp_nbnt_vals[] = {
854         {0x1,   "B-node" },
855         {0x2,   "P-node" },
856         {0x4,   "M-node" },
857         {0x8,   "H-node" },
858         {0,     NULL     }
859 };
860
861 static const value_string bootp_client_arch[] = {
862         { 0x0000, "IA x86 PC" },
863         { 0x0001, "NEC/PC98" },
864         { 0x0002, "IA64 PC" },
865         { 0x0003, "DEC Alpha" },
866         { 0x0004, "ArcX86" },
867         { 0x0005, "Intel Lean Client" },
868         { 0x0006, "EFI IA32" },
869         { 0x0007, "EFI BC" },
870         { 0x0008, "EFI Xscale" },
871         { 0x0009, "EFI x86-64" },
872         { 0,      NULL }
873 };
874
875 static const value_string opt_overload_vals[] = {
876         { OPT_OVERLOAD_FILE,  "Boot file name holds options",                },
877         { OPT_OVERLOAD_SNAME, "Server host name holds options",              },
878         { OPT_OVERLOAD_BOTH,  "Boot file and server host names hold options" },
879         { 0,                  NULL                                           } };
880
881 static const value_string slpda_vals[] = {
882         {0x00,   "Dynamic Discovery" },
883         {0x01,   "Static Discovery" },
884         {0x80,   "Backwards compatibility" },
885         {0,     NULL     } };
886
887 static const value_string slp_scope_vals[] = {
888         {0x00,   "Preferred Scope" },
889         {0x01,   "Mandatory Scope" },
890         {0,     NULL     } };
891
892 static const value_string authen_protocol_vals[] = {
893         {AUTHEN_PROTO_CONFIG_TOKEN,   "configuration token" },
894         {AUTHEN_PROTO_DELAYED_AUTHEN, "delayed authentication" },
895         {0,                           NULL     } };
896
897 static const value_string authen_da_algo_vals[] = {
898         {AUTHEN_DELAYED_ALGO_HMAC_MD5, "HMAC_MD5" },
899         {0,                            NULL     } };
900
901 static const value_string authen_rdm_vals[] = {
902         {AUTHEN_RDM_MONOTONIC_COUNTER, "Monotonically-increasing counter" },
903         {0,                            NULL     } };
904
905 static const value_string cl_dss_id_type_vals[] = {
906         {1, "Primary DSS_ID" },
907         {2, "Secondary DSS_ID" },
908         {0, NULL }
909 };
910
911 static const value_string sip_server_enc_vals[] = {
912         {0, "Fully Qualified Domain Name" },
913         {1, "IPv4 Address" },
914         {0, NULL }
915 };
916 /* bootp options administration */
917 #define BOOTP_OPT_NUM   256
918
919 /* Re-define structure.  Values to be updated by bootp_init_protocol */
920 static struct opt_info bootp_opt[BOOTP_OPT_NUM];
921
922 static struct opt_info default_bootp_opt[BOOTP_OPT_NUM] = {
923 /*   0 */ { "Padding",                                  none, &hf_bootp_option_padding },
924 /*   1 */ { "Subnet Mask",                              ipv4, &hf_bootp_option_subnet_mask },
925 /*   2 */ { "Time Offset",                              time_in_s_secs, &hf_bootp_option_time_offset },
926 /*   3 */ { "Router",                                   ipv4_list, &hf_bootp_option_router },
927 /*   4 */ { "Time Server",                              ipv4_list, &hf_bootp_option_time_server },
928 /*   5 */ { "Name Server",                              ipv4_list, &hf_bootp_option_name_server },
929 /*   6 */ { "Domain Name Server",                       ipv4_list, &hf_bootp_option_domain_name_server },
930 /*   7 */ { "Log Server",                               ipv4_list, &hf_bootp_option_log_server },
931 /*   8 */ { "Quotes Server",                            ipv4_list, &hf_bootp_option_quotes_server },
932 /*   9 */ { "LPR Server",                               ipv4_list, &hf_bootp_option_lpr_server },
933 /*  10 */ { "Impress Server",                           ipv4_list, &hf_bootp_option_impress_server },
934 /*  11 */ { "Resource Location Server",                 ipv4_list, &hf_bootp_option_resource_location_server },
935 /*  12 */ { "Host Name",                                string, &hf_bootp_option_hostname },
936 /*  13 */ { "Boot File Size",                           val_u_short, &hf_bootp_option_boot_file_size },
937 /*  14 */ { "Merit Dump File",                          string, &hf_bootp_option_merit_dump_file },
938 /*  15 */ { "Domain Name",                              string, &hf_bootp_option_domain_name },
939 /*  16 */ { "Swap Server",                              ipv4, &hf_bootp_option_swap_server },
940 /*  17 */ { "Root Path",                                string, &hf_bootp_option_root_path },
941 /*  18 */ { "Extensions Path",                          string, &hf_bootp_option_extension_path },
942 /*  19 */ { "IP Forwarding",                            val_boolean, &hf_bootp_option_ip_forwarding },
943 /*  20 */ { "Non-Local Source Routing",                 val_boolean, &hf_bootp_option_non_local_source_routing },
944 /*  21 */ { "Policy Filter",                            special, NULL },
945 /*  22 */ { "Maximum Datagram Reassembly Size",         val_u_short, &hf_bootp_option_max_datagram_reassembly_size },
946 /*  23 */ { "Default IP Time-to-Live",                  val_u_byte, &hf_bootp_option_default_ip_ttl },
947 /*  24 */ { "Path MTU Aging Timeout",                   time_in_u_secs, &hf_bootp_option_path_mtu_aging_timeout },
948 /*  25 */ { "Path MTU Plateau Table",                   val_u_short_list, &hf_bootp_option_path_mtu_plateau_table_item },
949 /*  26 */ { "Interface MTU",                            val_u_short, &hf_bootp_option_interface_mtu },
950 /*  27 */ { "All Subnets are Local",                    val_boolean, &hf_bootp_option_all_subnets_are_local },
951 /*  28 */ { "Broadcast Address",                        ipv4, &hf_bootp_option_broadcast_address },
952 /*  29 */ { "Perform Mask Discovery",                   val_boolean, &hf_bootp_option_perform_mask_discovery },
953 /*  30 */ { "Mask Supplier",                            val_boolean, &hf_bootp_option_mask_supplier },
954 /*  31 */ { "Perform Router Discover",                  val_boolean, &hf_bootp_option_perform_router_discover },
955 /*  32 */ { "Router Solicitation Address",              ipv4, &hf_bootp_option_router_solicitation_address },
956 /*  33 */ { "Static Route",                             special, NULL },
957 /*  34 */ { "Trailer Encapsulation",                    val_boolean, &hf_bootp_option_trailer_encapsulation },
958 /*  35 */ { "ARP Cache Timeout",                        time_in_u_secs, &hf_bootp_option_arp_cache_timeout },
959 /*  36 */ { "Ethernet Encapsulation",                   val_boolean, &hf_bootp_option_ethernet_encapsulation },
960 /*  37 */ { "TCP Default TTL",                          val_u_byte, &hf_bootp_option_tcp_default_ttl },
961 /*  38 */ { "TCP Keepalive Interval",                   time_in_u_secs, &hf_bootp_option_tcp_keepalive_interval },
962 /*  39 */ { "TCP Keepalive Garbage",                    val_boolean, &hf_bootp_option_tcp_keepalive_garbage },
963 /*  40 */ { "Network Information Service Domain",       string, &hf_bootp_option_nis_domain },
964 /*  41 */ { "Network Information Service Servers",      ipv4_list, &hf_bootp_option_nis_server },
965 /*  42 */ { "Network Time Protocol Servers",            ipv4_list, &hf_bootp_option_ntp_server },
966 /*  43 */ { "Vendor-Specific Information",              special, NULL },
967 /*  44 */ { "NetBIOS over TCP/IP Name Server",          ipv4_list, &hf_bootp_option_netbios_over_tcpip_name_server },
968 /*  45 */ { "NetBIOS over TCP/IP Datagram Distribution Name Server", ipv4_list, &hf_bootp_option_netbios_over_tcpip_dd_name_server },
969 /*  46 */ { "NetBIOS over TCP/IP Node Type",            val_u_byte, &hf_bootp_option_netbios_over_tcpip_node_type },
970 /*  47 */ { "NetBIOS over TCP/IP Scope",                string, &hf_bootp_option_netbios_over_tcpip_scope },
971 /*  48 */ { "X Window System Font Server",              ipv4_list, &hf_bootp_option_xwindows_system_font_server },
972 /*  49 */ { "X Window System Display Manager",          ipv4_list, &hf_bootp_option_xwindows_system_display_manager },
973 /*  50 */ { "Requested IP Address",                     ipv4, &hf_bootp_option_requested_ip_address },
974 /*  51 */ { "IP Address Lease Time",                    time_in_u_secs, &hf_bootp_option_ip_address_lease_time },
975 /*  52 */ { "Option Overload",                          special, &hf_bootp_option_option_overload },
976 /*  53 */ { "DHCP Message Type",                        val_u_byte, &hf_bootp_option_dhcp },
977 /*  54 */ { "DHCP Server Identifier",                   ipv4, &hf_bootp_option_dhcp_server_id },
978 /*  55 */ { "Parameter Request List",                   special, &hf_bootp_option_parameter_request_list_item },
979 /*  56 */ { "Message",                                  string, &hf_bootp_option_message },
980 /*  57 */ { "Maximum DHCP Message Size",                val_u_short, &hf_bootp_option_dhcp_max_message_size },
981 /*  58 */ { "Renewal Time Value",                       time_in_u_secs, &hf_bootp_option_renewal_time_value },
982 /*  59 */ { "Rebinding Time Value",                     time_in_u_secs, &hf_bootp_option_rebinding_time_value },
983 /*  60 */ { "Vendor class identifier",                  special, NULL },
984 /*  61 */ { "Client identifier",                        special, NULL },
985 /*  62 */ { "Novell/Netware IP domain",                 string, &hf_bootp_option_novell_netware_ip_domain },
986 /*  63 */ { "Novell Options",                           special, NULL },
987 /*  64 */ { "Network Information Service+ Domain",      string, &hf_bootp_option_nis_plus_domain },
988 /*  65 */ { "Network Information Service+ Servers",     ipv4_list, &hf_bootp_option_nis_plus_server },
989 /*  66 */ { "TFTP Server Name",                         string, &hf_bootp_option_tftp_server_name },
990 /*  67 */ { "Bootfile name",                            string, &hf_bootp_option_bootfile_name },
991 /*  68 */ { "Mobile IP Home Agent",                     ipv4_list, &hf_bootp_option_mobile_ip_home_agent  },
992 /*  69 */ { "SMTP Server",                              ipv4_list, &hf_bootp_option_smtp_server },
993 /*  70 */ { "POP3 Server",                              ipv4_list, &hf_bootp_option_pop3_server },
994 /*  71 */ { "NNTP Server",                              ipv4_list, &hf_bootp_option_nntp_server },
995 /*  72 */ { "Default WWW Server",                       ipv4_list, &hf_bootp_option_default_www_server },
996 /*  73 */ { "Default Finger Server",                    ipv4_list, &hf_bootp_option_default_finger_server },
997 /*  74 */ { "Default IRC Server",                       ipv4_list, &hf_bootp_option_default_irc_server },
998 /*  75 */ { "StreetTalk Server",                        ipv4_list, &hf_bootp_option_streettalk_server },
999 /*  76 */ { "StreetTalk Directory Assistance Server",   ipv4_list, &hf_bootp_option_streettalk_da_server },
1000 /*  77 */ { "User Class Information",                   special, NULL },
1001 /*  78 */ { "Directory Agent Information",              special, NULL },
1002 /*  79 */ { "Service Location Agent Scope",             special, NULL },
1003 /*  80 */ { "Rapid commit",                             opaque, NULL },
1004 /*  81 */ { "Client Fully Qualified Domain Name",       special, NULL},
1005 /*  82 */ { "Agent Information Option",                 special, NULL},
1006 /*  83 */ { "iSNS [TODO:RFC4174]",                      opaque, NULL },
1007 /*  84 */ { "Removed/Unassigned",                       opaque, NULL },
1008 /*  85 */ { "Novell Directory Services Servers",        special, NULL},
1009 /*  86 */ { "Novell Directory Services Tree Name",      string, &hf_bootp_option_novell_ds_tree_name },
1010 /*  87 */ { "Novell Directory Services Context",        string, &hf_bootp_option_novell_ds_context },
1011 /*  88 */ { "BCMCS Controller Domain Name [TODO:RFC4280]",      opaque, NULL },
1012 /*  89 */ { "BCMCS Controller IPv4 address [TODO:RFC4280]",     opaque, NULL },
1013 /*  90 */ { "Authentication",                           special, NULL},
1014 /*  91 */ { "Client last transaction time",             time_in_u_secs, &hf_bootp_option_client_last_transaction_time },
1015 /*  92 */ { "Associated IP option",                     ipv4_list, &hf_bootp_option_associated_ip_option },
1016 /*  93 */ { "Client System Architecture",               val_u_short, &hf_bootp_option_client_system_architecture },
1017 /*  94 */ { "Client Network Device Interface",          special, NULL},
1018 /*  95 */ { "LDAP [TODO:RFC3679]",                      opaque, NULL },
1019 /*  96 */ { "Removed/Unassigned",                       opaque, NULL },
1020 /*  97 */ { "UUID/GUID-based Client Identifier",        special, NULL},
1021 /*  98 */ { "Open Group's User Authentication [TODO:RFC2485]",  opaque, NULL },
1022 /*  99 */ { "Civic Addresses Configuration",            special, NULL},
1023 /* 100 */ { "PCode [TODO:RFC4833]",                     opaque, NULL },
1024 /* 101 */ { "TCode [TODO:RFC4833]",                     opaque, NULL },
1025 /* 102 */ { "Removed/unassigned",                       opaque, NULL },
1026 /* 103 */ { "Removed/unassigned",                       opaque, NULL },
1027 /* 104 */ { "Removed/unassigned",                       opaque, NULL },
1028 /* 105 */ { "Removed/unassigned",                       opaque, NULL },
1029 /* 106 */ { "Removed/unassigned",                       opaque, NULL },
1030 /* 107 */ { "Removed/unassigned",                       opaque, NULL },
1031 /* 108 */ { "Removed/Unassigned",                       opaque, NULL },
1032 /* 109 */ { "Unassigned",                               opaque, NULL },
1033 /* 110 */ { "Removed/Unassigned",                       opaque, NULL },
1034 /* 111 */ { "Unassigned",                               opaque, NULL },
1035 /* 112 */ { "NetInfo Parent Server Address",            ipv4_list, &hf_bootp_option_netinfo_parent_server_address },
1036 /* 113 */ { "NetInfo Parent Server Tag",                string, &hf_bootp_option_netinfo_parent_server_tag },
1037 /* 114 */ { "URL [TODO:RFC3679]",                       opaque, NULL },
1038 /* 115 */ { "Removed/Unassigned",                       opaque, NULL },
1039 /* 116 */ { "DHCP Auto-Configuration",                  val_u_byte, &hf_bootp_option_dhcp_auto_configuration },
1040 /* 117 */ { "Name Service Search",                      special, NULL },
1041 /* 118 */ { "Subnet Selection Option",                  ipv4_list, &hf_bootp_option_subnet_selection_option },
1042 /* 119 */ { "Domain Search",                            special, NULL },
1043 /* 120 */ { "SIP Servers",              special, NULL },
1044 /* 121 */ { "Classless Static Route",                   special, NULL},
1045 /* 122 */ { "CableLabs Client Configuration [TODO:RFC3495]",    opaque, NULL },
1046 /* 123 */ { "Coordinate-based Location Configuration",  special, NULL},
1047 /* 124 */ { "V-I Vendor Class",                         special, NULL},
1048 /* 125 */ { "V-I Vendor-specific Information",          special, NULL},
1049 /* 126 */ { "Removed/Unassigned",                       opaque, NULL },
1050 /* 127 */ { "Removed/Unassigned",                       opaque, NULL },
1051 /* 128 */ { "DOCSIS full security server IP [TODO]",    opaque, NULL },
1052 /* 129 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1053 /* 130 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1054 /* 131 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1055 /* 132 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1056 /* 133 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1057 /* 134 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1058 /* 135 */ { "PXE - undefined (vendor specific)",        opaque, NULL },
1059 /* 136 */ { "OPTION_PANA_AGENT [TODO:RFC5192]",         opaque, NULL },
1060 /* 137 */ { "LoST Server Domain Name",                  string, &hf_bootp_option_lost_server_domain_name },
1061 /* 138 */ { "CAPWAP Access Controllers",                ipv4_list, &hf_bootp_option_capwap_access_controller },
1062 /* 139 */ { "IPv4 Address-MoS",                         opaque, NULL },
1063 /* 140 */ { "IPv4 FQDN-MoS",                            opaque, NULL },
1064 /* 141 */ { "SIP UA Configuration Domains",             opaque, NULL },
1065 /* 142 */ { "Unassigned",                               opaque, NULL },
1066 /* 143 */ { "Unassigned",                               opaque, NULL },
1067 /* 144 */ { "Unassigned",                               opaque, NULL },
1068 /* 145 */ { "Unassigned",                               opaque, NULL },
1069 /* 146 */ { "Unassigned",                               opaque, NULL },
1070 /* 147 */ { "Unassigned",                               opaque, NULL },
1071 /* 148 */ { "Unassigned",                               opaque, NULL },
1072 /* 149 */ { "Unassigned",                               opaque, NULL },
1073 /* 150 */ { "TFTP Server Address",                      ipv4_list, &hf_bootp_option_tftp_server_address },
1074 /* 151 */ { "Unassigned",                               opaque, NULL },
1075 /* 152 */ { "Unassigned",                               opaque, NULL },
1076 /* 153 */ { "Unassigned",                               opaque, NULL },
1077 /* 154 */ { "Unassigned",                               opaque, NULL },
1078 /* 155 */ { "Unassigned",                               opaque, NULL },
1079 /* 156 */ { "Unassigned",                               opaque, NULL },
1080 /* 157 */ { "Unassigned",                               opaque, NULL },
1081 /* 158 */ { "Unassigned",                               opaque, NULL },
1082 /* 159 */ { "Unassigned",                               opaque, NULL },
1083 /* 160 */ { "Unassigned",                               opaque, NULL },
1084 /* 161 */ { "Unassigned",                               opaque, NULL },
1085 /* 162 */ { "Unassigned",                               opaque, NULL },
1086 /* 163 */ { "Unassigned",                               opaque, NULL },
1087 /* 164 */ { "Unassigned",                               opaque, NULL },
1088 /* 165 */ { "Unassigned",                               opaque, NULL },
1089 /* 166 */ { "Unassigned",                               opaque, NULL },
1090 /* 167 */ { "Unassigned",                               opaque, NULL },
1091 /* 168 */ { "Unassigned",                               opaque, NULL },
1092 /* 169 */ { "Unassigned",                               opaque, NULL },
1093 /* 170 */ { "Unassigned",                               opaque, NULL },
1094 /* 171 */ { "Unassigned",                               opaque, NULL },
1095 /* 172 */ { "Unassigned",                               opaque, NULL },
1096 /* 173 */ { "Unassigned",                               opaque, NULL },
1097 /* 174 */ { "Unassigned",                               opaque, NULL },
1098 /* 175 */ { "Etherboot",                                opaque, NULL },
1099 /* 176 */ { "IP Telephone",                             opaque, NULL },
1100 /* 177 */ { "Etherboot",                                opaque, NULL },
1101 /* 178 */ { "Unassigned",                               opaque, NULL },
1102 /* 179 */ { "Unassigned",                               opaque, NULL },
1103 /* 180 */ { "Unassigned",                               opaque, NULL },
1104 /* 181 */ { "Unassigned",                               opaque, NULL },
1105 /* 182 */ { "Unassigned",                               opaque, NULL },
1106 /* 183 */ { "Unassigned",                               opaque, NULL },
1107 /* 184 */ { "Unassigned",                               opaque, NULL },
1108 /* 185 */ { "Unassigned",                               opaque, NULL },
1109 /* 186 */ { "Unassigned",                               opaque, NULL },
1110 /* 187 */ { "Unassigned",                               opaque, NULL },
1111 /* 188 */ { "Unassigned",                               opaque, NULL },
1112 /* 189 */ { "Unassigned",                               opaque, NULL },
1113 /* 190 */ { "Unassigned",                               opaque, NULL },
1114 /* 191 */ { "Unassigned",                               opaque, NULL },
1115 /* 192 */ { "Unassigned",                               opaque, NULL },
1116 /* 193 */ { "Unassigned",                               opaque, NULL },
1117 /* 194 */ { "Unassigned",                               opaque, NULL },
1118 /* 195 */ { "Unassigned",                               opaque, NULL },
1119 /* 196 */ { "Unassigned",                               opaque, NULL },
1120 /* 197 */ { "Unassigned",                               opaque, NULL },
1121 /* 198 */ { "Unassigned",                               opaque, NULL },
1122 /* 199 */ { "Unassigned",                               opaque, NULL },
1123 /* 200 */ { "Unassigned",                               opaque, NULL },
1124 /* 201 */ { "Unassigned",                               opaque, NULL },
1125 /* 202 */ { "Unassigned",                               opaque, NULL },
1126 /* 203 */ { "Unassigned",                               opaque, NULL },
1127 /* 204 */ { "Unassigned",                               opaque, NULL },
1128 /* 205 */ { "Unassigned",                               opaque, NULL },
1129 /* 206 */ { "Unassigned",                               opaque, NULL },
1130 /* 207 */ { "Unassigned",                               opaque, NULL },
1131 /* 208 */ { "PXELINUX Magic",                           opaque, NULL },
1132 /* 209 */ { "Configuration file",                       opaque, NULL },
1133 /* 210 */ { "Authentication",                           special, NULL}, /* Path Prefix rfc5071 */
1134 /* 211 */ { "Reboot Time",                              opaque, NULL },
1135 /* 212 */ { "6RD",                                      opaque, NULL },
1136 /* 213 */ { "V4 Access Domain",                         opaque, NULL },
1137 /* 214 */ { "Unassigned",                               opaque, NULL },
1138 /* 215 */ { "Unassigned",                               opaque, NULL },
1139 /* 216 */ { "Unassigned",                               opaque, NULL },
1140 /* 217 */ { "Unassigned",                               opaque, NULL },
1141 /* 218 */ { "Unassigned",                               opaque, NULL },
1142 /* 219 */ { "Unassigned",                               opaque, NULL },
1143 /* 220 */ { "Subnet Allocation",                        opaque, NULL },
1144 /* 221 */ { "Virtual Subnet Selection",                 opaque, NULL },
1145 /* 222 */ { "Unassigned",                               opaque, NULL },
1146 /* 223 */ { "Unassigned",                               opaque, NULL },
1147 /* 224 */ { "Private",                                  opaque, NULL },
1148 /* 225 */ { "Private",                                  opaque, NULL },
1149 /* 226 */ { "Private",                                  opaque, NULL },
1150 /* 227 */ { "Private",                                  opaque, NULL },
1151 /* 228 */ { "Private",                                  opaque, NULL },
1152 /* 229 */ { "Private",                                  opaque, NULL },
1153 /* 230 */ { "Private",                                  opaque, NULL },
1154 /* 231 */ { "Private",                                  opaque, NULL },
1155 /* 232 */ { "Private",                                  opaque, NULL },
1156 /* 233 */ { "Private",                                  opaque, NULL },
1157 /* 234 */ { "Private",                                  opaque, NULL },
1158 /* 235 */ { "Private",                                  opaque, NULL },
1159 /* 236 */ { "Private",                                  opaque, NULL },
1160 /* 237 */ { "Private",                                  opaque, NULL },
1161 /* 238 */ { "Private",                                  opaque, NULL },
1162 /* 239 */ { "Private",                                  opaque, NULL },
1163 /* 240 */ { "Private",                                  opaque, NULL },
1164 /* 241 */ { "Private",                                  opaque, NULL },
1165 /* 242 */ { "Private",                                  opaque, NULL },
1166 /* 243 */ { "Private",                                  opaque, NULL },
1167 /* 244 */ { "Private",                                  opaque, NULL },
1168 /* 245 */ { "Private",                                  opaque, NULL },
1169 /* 246 */ { "Private",                                  opaque, NULL },
1170 /* 247 */ { "Private",                                  opaque, NULL },
1171 /* 248 */ { "Private",                                  opaque, NULL },
1172 /* 249 */ { "Private/Classless Static Route (Microsoft)",       special, NULL},
1173 /* 250 */ { "Private",                                  opaque, NULL },
1174 /* 251 */ { "Private",                                  opaque, NULL },
1175 /* 252 */ { "Private/Proxy autodiscovery",                      string, &hf_bootp_option_private_proxy_autodiscovery },
1176 /* 253 */ { "Private",                                  opaque, NULL },
1177 /* 254 */ { "Private",                                  opaque, NULL },
1178 /* 255 */ { "End",                                      opaque, NULL }
1179 };
1180
1181 /*-------------------------------------
1182  * UAT for BOOTP
1183  *-------------------------------------
1184  */
1185 /* UAT entry structure. */
1186 typedef struct {
1187         guint  opt;
1188         gchar *text;
1189         enum field_type ftype;
1190
1191 } uat_bootp_record_t;
1192
1193 static uat_bootp_record_t *uat_bootp_records = NULL;
1194 static uat_t *bootp_uat = NULL;
1195 static guint num_bootp_records_uat = 0;
1196
1197 static void* uat_bootp_record_copy_cb(void* n, const void* o, size_t siz _U_) {
1198         uat_bootp_record_t* new_record = (uat_bootp_record_t *)n;
1199         const uat_bootp_record_t* old_record = (const uat_bootp_record_t *)o;
1200
1201         if (old_record->text) {
1202                 new_record->text = g_strdup(old_record->text);
1203         } else {
1204                 new_record->text = NULL;
1205         }
1206
1207         return new_record;
1208 }
1209
1210 static void uat_bootp_record_update_cb(void* r, const char** err) {
1211         uat_bootp_record_t* rec = (uat_bootp_record_t *)r;
1212
1213         if ((rec->opt == 0) || (rec->opt >=BOOTP_OPT_NUM-1))
1214                 *err = ep_strdup_printf("Option must be between 1 and %d", BOOTP_OPT_NUM-2);
1215 }
1216
1217 static void uat_bootp_record_free_cb(void*r) {
1218         uat_bootp_record_t* rec = (uat_bootp_record_t *)r;
1219
1220         if (rec->text) g_free(rec->text);
1221 }
1222
1223 UAT_DEC_CB_DEF(uat_bootp_records, opt, uat_bootp_record_t)
1224 UAT_CSTRING_CB_DEF(uat_bootp_records, text, uat_bootp_record_t)
1225 UAT_VS_DEF(uat_bootp_records, ftype, uat_bootp_record_t, enum field_type, special, "string")
1226
1227
1228 static struct opt_info* bootp_get_opt(unsigned int idx)
1229 {
1230         if(idx>=BOOTP_OPT_NUM)
1231                 return NULL;
1232
1233         return &bootp_opt[idx];
1234 }
1235
1236 static const char *
1237 bootp_get_opt_text(unsigned int idx)
1238 {
1239         if(idx>=BOOTP_OPT_NUM)
1240                 return "unknown";
1241         return bootp_opt[idx].text;
1242 }
1243
1244 struct basic_types_hfs {
1245         gint* bytes;
1246         gint* ipv4;
1247         gint* ipv4_list;
1248         gint* string;
1249         gint* val_boolean;
1250         gint* val_u_byte;
1251         gint* val_u_short;
1252         gint* val_u_short_list;
1253         gint* val_u_long;
1254         gint* time_in_s_secs;
1255         gint* time_in_u_secs;
1256 };
1257
1258 /* Handle "basic" datatypes adding to a tree */
1259 static int
1260 bootp_handle_basic_types(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb,
1261                          enum field_type ftype, int offset, int total_len,
1262                          gint *hf, struct basic_types_hfs* hf_default)
1263 {
1264         int     i, left;
1265         gint32  time_s_secs;
1266         guint32 time_u_secs;
1267         int     consumed = 0;
1268
1269         switch (ftype) {
1270         case bytes:
1271                 if (hf != NULL)
1272                         proto_tree_add_item(tree, *hf, tvb, offset, total_len, ENC_BIG_ENDIAN);
1273                 else if (hf_default->bytes != NULL)
1274                         proto_tree_add_item(tree, *hf_default->bytes, tvb, offset, total_len, ENC_BIG_ENDIAN);
1275                 consumed = total_len;
1276                 break;
1277
1278         case ipv4:
1279                 if (total_len != 4) {
1280                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 4");
1281                         break;
1282                 }
1283
1284                 if (hf != NULL)
1285                         proto_tree_add_item(tree, *hf, tvb, offset, 4, ENC_BIG_ENDIAN);
1286                 else if (hf_default->ipv4 != NULL)
1287                         proto_tree_add_item(tree, *hf_default->ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
1288                 consumed = 4;
1289                 break;
1290
1291         case ipv4_list:
1292                 for (i = offset, left = total_len; left > 0; i += 4, left -= 4) {
1293                         if (left < 4) {
1294                                 expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "Option length isn't a multiple of 4");
1295                                 break;
1296                         }
1297
1298                         if (hf != NULL)
1299                                 proto_tree_add_item(tree, *hf, tvb, i, 4, ENC_BIG_ENDIAN);
1300                         else if (hf_default->ipv4_list != NULL)
1301                                 proto_tree_add_item(tree, *hf_default->ipv4_list, tvb, i, 4, ENC_BIG_ENDIAN);
1302                         consumed += 4;
1303                 }
1304
1305                 break;
1306
1307         case string:
1308                 if (hf != NULL)
1309                         proto_tree_add_item(tree, *hf, tvb, offset, total_len, ENC_BIG_ENDIAN);
1310                 else if (hf_default->string != NULL)
1311                         proto_tree_add_item(tree, *hf_default->string, tvb, offset, total_len, ENC_BIG_ENDIAN);
1312                 consumed = total_len;
1313                 break;
1314
1315         case val_boolean:
1316                 if (total_len != 1) {
1317                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 1");
1318                         break;
1319                 }
1320
1321                 if (hf != NULL)
1322                         proto_tree_add_item(tree, *hf, tvb, offset, 1, ENC_BIG_ENDIAN);
1323                 else if (hf_default->val_boolean != NULL)
1324                         proto_tree_add_item(tree, *hf_default->val_boolean, tvb, offset, 1, ENC_BIG_ENDIAN);
1325                 consumed = 1;
1326                 break;
1327
1328         case val_u_byte:
1329                 if (total_len != 1) {
1330                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 1");
1331                         break;
1332                 }
1333
1334                 if (hf != NULL)
1335                         proto_tree_add_item(tree, *hf, tvb, offset, 1, ENC_BIG_ENDIAN);
1336                 else if (hf_default->val_u_byte != NULL)
1337                         proto_tree_add_item(tree, *hf_default->val_u_byte, tvb, offset, 1, ENC_BIG_ENDIAN);
1338                 consumed = 1;
1339                 break;
1340
1341         case val_u_short:
1342                 if (total_len != 2) {
1343                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 2");
1344                         break;
1345                 }
1346
1347                 if (hf != NULL)
1348                         proto_tree_add_item(tree, *hf, tvb, offset, 2, ENC_BIG_ENDIAN);
1349                 else if (hf_default->val_u_short != NULL)
1350                         proto_tree_add_item(tree, *hf_default->val_u_short, tvb, offset, 2, ENC_BIG_ENDIAN);
1351                 consumed = 2;
1352                 break;
1353
1354         case val_u_le_short:
1355                 if (total_len != 2) {
1356                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 2");
1357                         break;
1358                 }
1359
1360                 if (hf != NULL)
1361                         proto_tree_add_item(tree, *hf, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1362                 else if (hf_default->val_u_short != NULL)
1363                         proto_tree_add_item(tree, *hf_default->val_u_short, tvb, offset, 2, ENC_LITTLE_ENDIAN);
1364                 consumed = 2;
1365                 break;
1366
1367         case val_u_short_list:
1368                 for (i = offset, left = total_len; left > 0; i += 2, left -= 2) {
1369                         if (left < 2) {
1370                                 expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "Option length isn't a multiple of 2");
1371                                 break;
1372                         }
1373
1374                         if (hf != NULL)
1375                                 proto_tree_add_item(tree, *hf, tvb, i, 2, ENC_BIG_ENDIAN);
1376                         else if (hf_default->val_u_short_list != NULL)
1377                                 proto_tree_add_item(tree, *hf_default->val_u_short_list, tvb, i, 2, ENC_BIG_ENDIAN);
1378                         consumed += 2;
1379                 }
1380                 break;
1381
1382         case val_u_long:
1383                 if (total_len != 4) {
1384                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 4");
1385                         break;
1386                 }
1387
1388                 if (hf != NULL)
1389                         proto_tree_add_item(tree, *hf, tvb, offset, 4, ENC_BIG_ENDIAN);
1390                 else if (hf_default->val_u_long != NULL)
1391                         proto_tree_add_item(tree, *hf_default->val_u_long, tvb, offset, 4, ENC_BIG_ENDIAN);
1392                 consumed = 4;
1393                 break;
1394
1395         case time_in_s_secs:
1396                 if (total_len != 4) {
1397                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 4");
1398                         break;
1399                 }
1400
1401                 if (hf != NULL) {
1402                         time_s_secs = (gint32) tvb_get_ntohl(tvb, offset);
1403                         proto_tree_add_int_format_value(tree, *hf,
1404                                 tvb, offset, 4, time_s_secs, "(%ds) %s", time_s_secs, time_secs_to_str(time_s_secs));
1405                 }
1406                 else if (hf_default->time_in_s_secs != NULL)
1407                         proto_tree_add_item(tree, *hf_default->time_in_s_secs, tvb, offset, 4, ENC_BIG_ENDIAN);
1408
1409                 consumed = 4;
1410                 break;
1411
1412         case time_in_u_secs:
1413                 if (total_len != 4) {
1414                         expert_add_info_format_text(pinfo, item, &ei_bootp_bad_length, "length isn't 4");
1415                         break;
1416                 }
1417
1418                 if (hf != NULL) {
1419                         time_u_secs = tvb_get_ntohl(tvb, offset);
1420                         proto_tree_add_uint_format_value(tree, *hf,
1421                                 tvb, offset, 4, time_u_secs, "(%us) %s", time_u_secs,
1422                                 ((time_u_secs == 0xffffffff) ? "infinity" : time_secs_to_str_unsigned(time_u_secs)));
1423                 }
1424                 else if (hf_default->time_in_u_secs != NULL)
1425                         proto_tree_add_item(tree, *hf_default->time_in_u_secs, tvb, offset, 4, ENC_BIG_ENDIAN);
1426                 consumed = 4;
1427                 break;
1428         default:
1429                 /* Ignore other field_types */
1430                 break;
1431    }
1432
1433    return consumed;
1434 }
1435
1436 /* Returns the number of bytes consumed by this option. */
1437 static int
1438 bootp_option(tvbuff_t *tvb, packet_info *pinfo, proto_tree *bp_tree, int voff,
1439              int eoff, gboolean first_pass, gboolean *at_end, const char **dhcp_type_p,
1440              const guint8 **vendor_class_id_p, guint8 *overload_p)
1441 {
1442         struct opt_info *opt;
1443         enum field_type  ftype;
1444         guchar           code = tvb_get_guint8(tvb, voff);
1445         int              optlen;
1446         guchar           byte;
1447         int              i, consumed, basictype_consumed;
1448         int              optoff, optleft, optend;
1449         proto_tree      *v_tree;
1450         proto_item      *vti, *ti;
1451         guint8           protocol;
1452         guint8           algorithm;
1453         guint8           rdm;
1454         guint8           fqdn_flags;
1455         int              o52voff, o52eoff;
1456         gboolean         o52at_end;
1457         guint8           s_option;
1458         guint8           s_len;
1459         const guchar    *dns_name;
1460         gboolean         option_handled = TRUE;
1461
1462         struct basic_types_hfs default_hfs = {
1463                 &hf_bootp_option_value,
1464                 &hf_bootp_option_value_ip_address,
1465                 &hf_bootp_option_value_ip_address,
1466                 &hf_bootp_option_value_stringz,
1467                 &hf_bootp_option_value_boolean,
1468                 &hf_bootp_option_value_8,
1469                 &hf_bootp_option_value_16,
1470                 &hf_bootp_option_value_16,
1471                 &hf_bootp_option_value_u32,
1472                 &hf_bootp_option_value_i32,
1473                 &hf_bootp_option_value_u32
1474         };
1475
1476         /* Options whose length isn't "optlen + 2". */
1477         switch (code) {
1478
1479         case 0:         /* Padding */
1480                 /* check how much padding we have */
1481                 for (i = voff + 1; i < eoff; i++ ) {
1482                         if (tvb_get_guint8(tvb, i) != 0) {
1483                                 break;
1484                         }
1485                 }
1486                 i = i - voff;
1487                 if (!first_pass) {
1488                         if (bp_tree != NULL) {
1489                                 vti = proto_tree_add_uint_format_value(bp_tree, hf_bootp_option_type,
1490                                                 tvb, voff, 1, 0, "(0) Padding");
1491                                 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
1492                                 proto_tree_add_item(v_tree, hf_bootp_option_padding, tvb, voff, i, ENC_NA);
1493                         }
1494                 }
1495                 consumed = i;
1496                 return consumed;
1497
1498         case 255:       /* End Option */
1499                 if (!first_pass) {
1500                         if (bp_tree != NULL) {
1501                                 vti = proto_tree_add_uint_format_value(bp_tree, hf_bootp_option_type,
1502                                                 tvb, voff, 1, 0, "(255) End");
1503                                 v_tree = proto_item_add_subtree(vti, ett_bootp_option);
1504                                 if (*overload_p)
1505                                         proto_tree_add_item(v_tree, hf_bootp_option_end_overload, tvb, voff, 1, ENC_BIG_ENDIAN);
1506                                 else
1507                                         proto_tree_add_item(v_tree, hf_bootp_option_end, tvb, voff, 1, ENC_BIG_ENDIAN);
1508                         }
1509                 }
1510                 *at_end = TRUE;
1511                 consumed = 1;
1512                 return consumed;
1513         }
1514
1515         /*
1516          * Get the length of the option, and the number of bytes it
1517          * consumes (the length doesn't include the option code or
1518          * length bytes).
1519          *
1520          * On the first pass, check first whether we have the length
1521          * byte, so that we don't throw an exception; if we throw an
1522          * exception in the first pass, which is only checking for options
1523          * whose values we need in order to properly dissect the packet
1524          * on the second pass, we won't actually dissect the options, so
1525          * you won't be able to see which option had the problem.
1526          */
1527         if (first_pass) {
1528                 if (!tvb_bytes_exist(tvb, voff+1, 1)) {
1529                         /*
1530                          * We don't have the length byte; just return 1
1531                          * as the number of bytes we consumed, to count
1532                          * the code byte.
1533                          */
1534                         return 1;
1535                 }
1536         }
1537         optlen = tvb_get_guint8(tvb, voff+1);
1538         consumed = optlen + 2;
1539
1540         /*
1541          * In the first pass, we don't put anything into the protocol
1542          * tree; we just check for some options we have to look at
1543          * in order to properly process the packet:
1544          *
1545          *      52 (Overload) - we need this to properly dissect the
1546          *         file and sname fields
1547          *
1548          *      53 (DHCP message type) - if this is present, this is DHCP
1549          *
1550          *      60 (Vendor class identifier) - we need this in order to
1551          *         interpret the vendor-specific info
1552          *
1553          * We also check, before fetching anything, to make sure we
1554          * have the entire item we're fetching, so that we don't throw
1555          * an exception.
1556          */
1557         if (first_pass) {
1558                 if (tvb_bytes_exist(tvb, voff+2, consumed-2)) {
1559                         switch (code) {
1560
1561                         case 52:
1562                                 *overload_p = tvb_get_guint8(tvb, voff+2);
1563                                 break;
1564
1565                         case 53:
1566                                 *dhcp_type_p =
1567                                     val_to_str(tvb_get_guint8(tvb, voff+2),
1568                                         opt53_text,
1569                                         "Unknown Message Type (0x%02x)");
1570                                 break;
1571
1572                         case 60:
1573                                 *vendor_class_id_p =
1574                                     tvb_get_ptr(tvb, voff+2, consumed-2);
1575                                 break;
1576                         case 119:
1577                                 rfc3396_dns_domain_search_list.total_number_of_block++;
1578                                 break;
1579                         case 120:
1580                                 rfc3396_sip_server.total_number_of_block++;
1581                                 break;
1582                         }
1583                 }
1584
1585                 /*
1586                  * We don't do anything else here.
1587                  */
1588                 return consumed;
1589         }
1590
1591         /* Normal cases */
1592         opt = bootp_get_opt(code);
1593         if (opt == NULL)
1594         {
1595                 /* THIS SHOULD NEVER HAPPEN!!! */
1596                 return consumed;
1597         }
1598
1599         /* function type may be overridden and that shouldn't be a 'saved' change */
1600         ftype = opt->ftype;
1601
1602         optoff = voff+2;
1603
1604         vti = proto_tree_add_uint_format_value(bp_tree, hf_bootp_option_type,
1605                 tvb, voff, consumed, code, "(%d) %s", code, opt->text);
1606         v_tree = proto_item_add_subtree(vti, ett_bootp_option);
1607         proto_tree_add_item(v_tree, hf_bootp_option_length, tvb, voff+1, 1, ENC_BIG_ENDIAN);
1608
1609         ti = proto_tree_add_item(v_tree, hf_bootp_option_value, tvb, voff+2, optlen, ENC_NA);
1610         PROTO_ITEM_SET_HIDDEN(ti);
1611
1612         /* Special cases */
1613         switch (code) {
1614
1615         case 21:        /* Policy Filter */
1616                 for (i = optoff, optleft = optlen;
1617                         optleft > 0; i += 8, optleft -= 8) {
1618                         if (optleft < 8) {
1619                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Option length isn't a multiple of 8");
1620                                 break;
1621                         }
1622
1623                         proto_tree_add_item(v_tree, hf_bootp_option_policy_filter_ip, tvb, i, 4, ENC_BIG_ENDIAN);
1624                         proto_tree_add_item(v_tree, hf_bootp_option_policy_filter_subnet_mask, tvb, i+4, 4, ENC_BIG_ENDIAN);
1625                 }
1626                 break;
1627
1628         case 33:        /* Static Route */
1629                 for (i = optoff, optleft = optlen;
1630                         optleft > 0; i += 8, optleft -= 8) {
1631                         if (optleft < 8) {
1632                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Option length isn't a multiple of 8");
1633                                 break;
1634                         }
1635
1636                         proto_tree_add_item(v_tree, hf_bootp_option_static_route_ip, tvb, i, 4, ENC_BIG_ENDIAN);
1637                         proto_tree_add_item(v_tree, hf_bootp_option_static_route_router, tvb, i+4, 4, ENC_BIG_ENDIAN);
1638                 }
1639                 break;
1640
1641         case 43:        /* Vendor-Specific Info */
1642                 s_option = tvb_get_guint8(tvb, optoff);
1643
1644                 /* PXE protocol 2.1 as described in the Intel specs */
1645                 if (*vendor_class_id_p != NULL &&
1646                     strncmp((const gchar*)*vendor_class_id_p, "PXEClient", strlen("PXEClient")) == 0) {
1647                         proto_item_append_text(vti, " (PXEClient)");
1648                         v_tree = proto_item_add_subtree(vti, ett_bootp_option);
1649
1650                         optend = optoff + optlen;
1651                         while (optoff < optend) {
1652                                 optoff = dissect_vendor_pxeclient_suboption(pinfo, vti, v_tree,
1653                                         tvb, optoff, optend);
1654                         }
1655                 } else if (*vendor_class_id_p != NULL &&
1656                            ((strncmp((const gchar*)*vendor_class_id_p, "pktc", strlen("pktc")) == 0) ||
1657                             (strncmp((const gchar*)*vendor_class_id_p, "docsis", strlen("docsis")) == 0) ||
1658                             (strncmp((const gchar*)*vendor_class_id_p, "OpenCable2.0", strlen("OpenCable2.0")) == 0) ||
1659                             (strncmp((const gchar*)*vendor_class_id_p, "CableHome", strlen("CableHome")) == 0))) {
1660                         /* CableLabs standard - see www.cablelabs.com/projects */
1661                         proto_item_append_text(vti, " (CableLabs)");
1662
1663                         optend = optoff + optlen;
1664                         while (optoff < optend) {
1665                                 optoff = dissect_vendor_cablelabs_suboption(pinfo, vti, v_tree,
1666                                         tvb, optoff, optend);
1667                         }
1668                 } else if (s_option==58 || s_option==64 || s_option==65
1669                         || s_option==66 || s_option==67) {
1670                         /* Note that this is a rather weak (permissive) heuristic, */
1671                         /* but since it comes last, I guess this is OK. */
1672                         /* Add any stronger (less permissive) heuristics before this! */
1673                         /* Alcatel-Lucent DHCP Extensions */
1674                         proto_item_append_text(vti, " (Alcatel-Lucent)");
1675                         optend = optoff + optlen;
1676                         while (optoff < optend) {
1677                                 optoff = dissect_vendor_alcatel_suboption(pinfo, vti, v_tree,
1678                                         tvb, optoff, optend);
1679                         }
1680                 }
1681                 break;
1682
1683         case 52:        /* Option Overload */
1684                 if (optlen < 1) {
1685                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 1");
1686                         break;
1687                 }
1688
1689                 byte = tvb_get_guint8(tvb, optoff);
1690                 proto_tree_add_item(v_tree, *opt->phf, tvb, optoff, 1, ENC_BIG_ENDIAN);
1691
1692                 /* Just in case we find an option 52 in sname or file */
1693                 if (voff > VENDOR_INFO_OFFSET && byte >= 1 && byte <= 3) {
1694                         if (byte & OPT_OVERLOAD_FILE) {
1695                                 proto_item *oti;
1696                                 oti = proto_tree_add_text (bp_tree, tvb,
1697                                         FILE_NAME_OFFSET, FILE_NAME_LEN,
1698                                         "Boot file name option overload");
1699                                 o52voff = FILE_NAME_OFFSET;
1700                                 o52eoff = FILE_NAME_OFFSET + FILE_NAME_LEN;
1701                                 o52at_end = FALSE;
1702                                 rfc3396_dns_domain_search_list.index_current_block = 0;
1703                                 rfc3396_sip_server.index_current_block = 0;
1704                                 while (o52voff < o52eoff && !o52at_end) {
1705                                         o52voff += bootp_option(tvb, pinfo, bp_tree, o52voff,
1706                                                 o52eoff, FALSE, &o52at_end,
1707                                                 dhcp_type_p, vendor_class_id_p,
1708                                                 overload_p);
1709                                 }
1710                                 if (!o52at_end)
1711                                 {
1712                                         expert_add_info(pinfo, oti, &hf_bootp_opt_overload_file_end_missing);
1713                                 }
1714                         }
1715                         if (byte & OPT_OVERLOAD_SNAME) {
1716                                 proto_item *oti;
1717                                 oti = proto_tree_add_text (bp_tree, tvb,
1718                                         SERVER_NAME_OFFSET, SERVER_NAME_LEN,
1719                                         "Server host name option overload");
1720                                 o52voff = SERVER_NAME_OFFSET;
1721                                 o52eoff = SERVER_NAME_OFFSET + SERVER_NAME_LEN;
1722                                 o52at_end = FALSE;
1723                                 rfc3396_dns_domain_search_list.index_current_block = 0;
1724                                 rfc3396_sip_server.index_current_block = 0;
1725                                 while (o52voff < o52eoff && !o52at_end) {
1726                                         o52voff += bootp_option(tvb, pinfo, bp_tree, o52voff,
1727                                                 o52eoff, FALSE, &o52at_end,
1728                                                 dhcp_type_p, vendor_class_id_p,
1729                                                 overload_p);
1730                                 }
1731                                 if (!o52at_end)
1732                                 {
1733                                         expert_add_info(pinfo, oti, &hf_bootp_opt_overload_sname_end_missing);
1734                                 }
1735                         }
1736                         /* The final end option is not in overload */
1737                         *overload_p = 0;
1738                 }
1739                 break;
1740
1741         case 55:        /* Parameter Request List */
1742                 for (i = 0; i < optlen; i++) {
1743                         byte = tvb_get_guint8(tvb, optoff+i);
1744                         proto_tree_add_uint_format_value(v_tree, hf_bootp_option_parameter_request_list_item,
1745                                         tvb, optoff+i, 1, byte, "(%d) %s", byte, bootp_get_opt_text(byte));
1746                 }
1747                 break;
1748
1749         case 60:        /* Vendor class identifier */
1750                 /*
1751                  * XXX - RFC 2132 says this is a string of octets;
1752                  * should we check for non-printables?
1753                  */
1754
1755                 proto_tree_add_item(v_tree, hf_bootp_option_vendor_class_id, tvb, optoff, consumed-2, ENC_ASCII|ENC_NA);
1756                 if ((tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_MTA_CAP10,
1757                                       (int)strlen(PACKETCABLE_MTA_CAP10)) == 0)
1758                     ||
1759                     (tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_MTA_CAP15,
1760                                       (int)strlen(PACKETCABLE_MTA_CAP15)) == 0)
1761                         ||
1762                         (tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_MTA_CAP20,
1763                                       (int)strlen(PACKETCABLE_MTA_CAP20)) == 0))
1764                 {
1765                         dissect_packetcable_mta_cap(v_tree, tvb, optoff, optlen);
1766                 } else
1767                         if ((tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_CM_CAP11,
1768                                 (int)strlen(PACKETCABLE_CM_CAP11)) == 0)
1769                         ||
1770                         (tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_CM_CAP20,
1771                                 (int)strlen(PACKETCABLE_CM_CAP20)) == 0 ))
1772                 {
1773                         dissect_docsis_cm_cap(v_tree, tvb, optoff, optlen, FALSE);
1774                 } else
1775                         if (tvb_memeql(tvb, optoff, (const guint8*)PACKETCABLE_CM_CAP30,
1776                                 (int)strlen(PACKETCABLE_CM_CAP30)) == 0 )
1777                 {
1778                         proto_tree_add_text(v_tree, tvb, optoff, optlen,
1779                                 "vendor-class-data: \"%s\"", tvb_format_stringzpad(tvb, optoff, optlen));
1780                 }
1781                 break;
1782
1783         case 61:        /* Client Identifier */
1784                 if (optlen > 0)
1785                         byte = tvb_get_guint8(tvb, optoff);
1786                 else
1787                         byte = 0;
1788
1789                 /* We *MAY* use hwtype/hwaddr. If we have 7 bytes, I'll
1790                    guess that the first is the hwtype, and the last 6
1791                    are the hw addr */
1792                 /* See http://www.iana.org/assignments/arp-parameters */
1793                 /* RFC2132 9.14 Client-identifier has the following to say:
1794                    A hardware type of 0 (zero) should be used when the value
1795                    field contains an identifier other than a hardware address
1796                    (e.g. a fully qualified domain name). */
1797
1798                 if (optlen == 7 && byte > 0 && byte < 48) {
1799                         proto_tree_add_item(v_tree,
1800                                         hf_bootp_hw_type, tvb, optoff, 1,
1801                                         ENC_NA);
1802
1803                         if (byte == ARPHRD_ETHER || byte == ARPHRD_IEEE802)
1804                                 proto_tree_add_item(v_tree,
1805                                         hf_bootp_hw_ether_addr, tvb, optoff+1, 6,
1806                                         ENC_NA);
1807                         else
1808                                 proto_tree_add_text(v_tree, tvb, optoff+1, 6,
1809                                         "Client hardware address: %s",
1810                                         tvb_arphrdaddr_to_str(tvb, optoff+1, 6, byte));
1811                 } else if (optlen == 17 && byte == 0) {
1812                         /* Identifier is a UUID */
1813                         proto_tree_add_item(v_tree, hf_bootp_client_identifier_uuid,
1814                                             tvb, optoff + 1, 16, ENC_LITTLE_ENDIAN);
1815                 /* From RFC 4631 paragraph 6.1 DHCPv4 Client Behavior:
1816                         To send an RFC 3315-style binding identifier in a DHCPv4 'client
1817                         identifier' option, the type of the 'client identifier' option is set
1818                         to 255. */
1819                 } else if (byte == 255) {
1820                         guint16 duidtype;
1821                         guint16 hwtype;
1822                         guint8  *buf;
1823                         int     enterprise;
1824
1825                         /*      The type field is immediately followed by the IAID, which is
1826                                 an opaque 32-bit quantity       */
1827                         proto_tree_add_text(v_tree, tvb, optoff+1, 4,
1828                                 "IAID: %s",
1829                                 tvb_arphrdaddr_to_str(tvb, optoff+1, 4, byte));
1830                         optoff = optoff + 5;
1831                         duidtype = tvb_get_ntohs(tvb, optoff);
1832                         proto_tree_add_text(v_tree, tvb, optoff, 2,
1833                                             "DUID type: %s (%u)",
1834                                             val_to_str_const(duidtype, duidtype_vals, "Unknown"),
1835                                             duidtype);
1836                         switch (duidtype) {
1837                         case DUID_LLT:
1838                                 if (optlen < 8) {
1839                                         expert_add_info(pinfo, vti, &ei_bootp_mal_duid);
1840                                         break;
1841                                 }
1842                                 hwtype=tvb_get_ntohs(tvb, optoff + 2);
1843                                 proto_tree_add_item(v_tree, hf_bootp_client_identifier_duid_llt_hw_type,
1844                                                 tvb, optoff + 2, 2, ENC_BIG_ENDIAN);
1845
1846                                 /* XXX seconds since Jan 1 2000 */
1847                                 proto_tree_add_text(v_tree, tvb, optoff + 4, 4,
1848                                         "Time: %u", tvb_get_ntohl(tvb, optoff + 4));
1849                                 if (optlen > 8) {
1850                                         proto_tree_add_text(v_tree, tvb, optoff + 8,
1851                                                 optlen - 13, "Link-layer address: %s",
1852                                                 tvb_arphrdaddr_to_str(tvb, optoff+8, optlen-13, hwtype));
1853                                 }
1854                                 break;
1855                         case DUID_EN:
1856                                 if (optlen < 6) {
1857                                         expert_add_info(pinfo, vti, &ei_bootp_mal_duid);
1858                                         break;
1859                                 }
1860                                 enterprise = tvb_get_ntohl(tvb, optoff+2);
1861                                 proto_tree_add_text(v_tree, tvb, optoff + 2, 4,
1862                                             "Enterprise-number: %s (%u)",
1863                                             val_to_str_ext_const( enterprise, &sminmpec_values_ext, "Unknown"),
1864                                             enterprise);
1865                                 if (optlen > 6) {
1866                                                 buf = tvb_bytes_to_str(tvb, optoff + 6, optlen - 11);
1867                                         proto_tree_add_text(v_tree, tvb, optoff + 6,
1868                                                 optlen - 11, "identifier: %s", buf);
1869                                 }
1870                                 break;
1871                         case DUID_LL:
1872                                 if (optlen < 4) {
1873                                         expert_add_info(pinfo, vti, &ei_bootp_mal_duid);
1874                                         break;
1875                                 }
1876                                 hwtype=tvb_get_ntohs(tvb, optoff + 2);
1877                                 proto_tree_add_item(v_tree, hf_bootp_client_identifier_duid_ll_hw_type,
1878                                                 tvb, optoff + 2, 2, ENC_BIG_ENDIAN);
1879
1880                                 if (optlen > 4) {
1881                                         proto_tree_add_text(v_tree, tvb, optoff + 4,
1882                                                 optlen - 9, "Link-layer address: %s",
1883                                                 tvb_arphrdaddr_to_str(tvb, optoff+4, optlen-9, hwtype));
1884                                 }
1885                                 break;
1886                         }
1887                 } else {
1888                         /* otherwise, it's opaque data */
1889                 }
1890                 break;
1891         case 77: {      /* User Class Information RFC 3004 */
1892                 guchar user_class_instance_index;
1893                 proto_item *vtix;
1894                 proto_tree *o77_v_tree;
1895                 if (optlen < 2) {
1896                         expert_add_info_format_text(pinfo, v_tree, &ei_bootp_bad_length, "length isn't >= 2");
1897                         break;
1898                 }
1899                 optleft = optlen;
1900                 for (user_class_instance_index = 0, i = 0, byte = tvb_get_guint8(tvb, optoff); i < optlen; byte = tvb_get_guint8(tvb, optoff + i), user_class_instance_index++) {
1901                         /* Create subtree for instance of User Class. */
1902                         vtix = proto_tree_add_uint_format_value(v_tree, hf_bootp_option77_user_class,
1903                                         tvb, optoff + i, byte + 1, user_class_instance_index, "[%d]", user_class_instance_index);
1904                         o77_v_tree = proto_item_add_subtree(vtix, ett_bootp_option77_instance);
1905
1906                         /* Add length for instance of User Class. */
1907                         proto_tree_add_item(o77_v_tree, hf_bootp_option77_user_class_length,
1908                                         tvb, optoff + i, 1, ENC_BIG_ENDIAN);
1909
1910                         if (byte == 0) {
1911                                 expert_add_info_format_text(pinfo, vtix, &ei_bootp_bad_length, "UC_Len_%u isn't >= 1 (UC_Len_%u = 0)", user_class_instance_index, user_class_instance_index);
1912                                 break;
1913                         }
1914                         optleft -= byte + 1;
1915                         if (optleft < 0) {
1916                                 expert_add_info(pinfo, vtix, &ei_bootp_option77_user_class_malformed);
1917                                 break;
1918                         }
1919
1920                         /* Add data for instance of User Class. */
1921                         proto_tree_add_item(o77_v_tree, hf_bootp_option77_user_class_data,
1922                                         tvb, optoff + i + 1, byte, ENC_BIG_ENDIAN);
1923
1924                         /* Slide to next instance of User Class if any. */
1925                         i += byte + 1;
1926                 }
1927                 break;
1928         }
1929         case 97:        /* Client Identifier (UUID) */
1930                 if (optlen > 0)
1931                         byte = tvb_get_guint8(tvb, optoff);
1932                 else
1933                         byte = 0;
1934
1935                 /* We *MAY* use hwtype/hwaddr. If we have 7 bytes, I'll
1936                    guess that the first is the hwtype, and the last 6
1937                    are the hw addr */
1938                 /* See http://www.iana.org/assignments/arp-parameters */
1939                 /* RFC2132 9.14 Client-identifier has the following to say:
1940                    A hardware type of 0 (zero) should be used when the value
1941                    field contains an identifier other than a hardware address
1942                    (e.g. a fully qualified domain name). */
1943
1944                 if (optlen == 7 && byte > 0 && byte < 48) {
1945                         proto_tree_add_item(v_tree,
1946                                         hf_bootp_hw_type, tvb, optoff, 1,
1947                                         ENC_NA);
1948                         if (byte == ARPHRD_ETHER || byte == ARPHRD_IEEE802)
1949                                 proto_tree_add_item(v_tree,
1950                                         hf_bootp_hw_ether_addr, tvb, optoff+1, 6,
1951                                         ENC_NA);
1952                         else
1953                                 proto_tree_add_text(v_tree, tvb, optoff+1, 6,
1954                                         "Client hardware address: %s",
1955                                         tvb_arphrdaddr_to_str(tvb, optoff+1, 6, byte));
1956                 } else if (optlen == 17 && byte == 0) {
1957                         /* Identifier is a UUID */
1958                         proto_tree_add_item(v_tree, hf_bootp_client_identifier_uuid,
1959                                             tvb, optoff + 1, 16, ENC_LITTLE_ENDIAN);
1960                 } else {
1961                         /* otherwise, it's opaque data */
1962                 }
1963                 break;
1964
1965         case 63:        /* NetWare/IP options (RFC 2242) */
1966
1967                 optend = optoff + optlen;
1968                 while (optoff < optend)
1969                         optoff = dissect_netware_ip_suboption(pinfo, vti, v_tree, tvb, optoff, optend);
1970                 break;
1971
1972         case 78:        /* SLP Directory Agent Option RFC2610 Added by Greg Morris (gmorris@novell.com)*/
1973                 if (optlen < 1) {
1974                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 1");
1975                         break;
1976                 }
1977                 optleft = optlen;
1978                 byte = tvb_get_guint8(tvb, optoff);
1979                 proto_tree_add_item(v_tree, hf_bootp_option_slp_directory_agent_value, tvb, optoff, 1, ENC_BIG_ENDIAN);
1980
1981                 optoff++;
1982                 optleft--;
1983                 if (byte == 0x80) {
1984                         if (optleft == 0)
1985                                 break;
1986                         optoff++;
1987                         optleft--;
1988                 }
1989                 for (i = optoff; optleft > 0; i += 4, optleft -= 4) {
1990                         if (optleft < 4) {
1991                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Option length isn't a multiple of 4");
1992                                 break;
1993                         }
1994
1995                         proto_tree_add_item(v_tree, hf_bootp_option_slp_directory_agent_slpda_address, tvb, i, 4, ENC_BIG_ENDIAN);
1996                 }
1997                 break;
1998
1999         case 79:        /* SLP Service Scope Option RFC2610 Added by Greg Morris (gmorris@novell.com)*/
2000                 proto_tree_add_item(v_tree, hf_bootp_option_slp_service_scope_value, tvb, optoff, 1, ENC_BIG_ENDIAN);
2001
2002                 optoff++;
2003                 optleft = optlen - 1;
2004                 proto_tree_add_item(v_tree, hf_bootp_option_slp_service_scope_string, tvb, optoff, optleft, ENC_ASCII|ENC_NA);
2005                 break;
2006
2007         case 81:        /* Client Fully Qualified Domain Name */
2008                 if (optlen < 3) {
2009                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 3");
2010                         break;
2011                 }
2012                 fqdn_flags = tvb_get_guint8(tvb, optoff);
2013                 proto_tree_add_text(v_tree, tvb, optoff, 1, "Flags: 0x%02x", fqdn_flags);
2014                 proto_tree_add_item(v_tree, hf_bootp_fqdn_mbz, tvb, optoff, 1, ENC_BIG_ENDIAN);
2015                 proto_tree_add_item(v_tree, hf_bootp_fqdn_n, tvb, optoff, 1, ENC_BIG_ENDIAN);
2016                 proto_tree_add_item(v_tree, hf_bootp_fqdn_e, tvb, optoff, 1, ENC_BIG_ENDIAN);
2017                 proto_tree_add_item(v_tree, hf_bootp_fqdn_o, tvb, optoff, 1, ENC_BIG_ENDIAN);
2018                 proto_tree_add_item(v_tree, hf_bootp_fqdn_s, tvb, optoff, 1, ENC_BIG_ENDIAN);
2019                 /* XXX: use code from packet-dns for return code decoding */
2020                 proto_tree_add_item(v_tree, hf_bootp_fqdn_rcode1, tvb, optoff+1, 1, ENC_BIG_ENDIAN);
2021                 /* XXX: use code from packet-dns for return code decoding */
2022                 proto_tree_add_item(v_tree, hf_bootp_fqdn_rcode2, tvb, optoff+2, 1, ENC_BIG_ENDIAN);
2023                 if (optlen > 3) {
2024                         if (fqdn_flags & F_FQDN_E) {
2025                                 get_dns_name(tvb, optoff+3, optlen-3, optoff+3, &dns_name);
2026                                 proto_tree_add_string(v_tree, hf_bootp_fqdn_name,
2027                                     tvb, optoff+3, optlen-3, dns_name);
2028                         } else {
2029                                 proto_tree_add_item(v_tree, hf_bootp_fqdn_asciiname,
2030                                     tvb, optoff+3, optlen-3, ENC_ASCII|ENC_NA);
2031                         }
2032                 }
2033                 break;
2034
2035         case 82:        /* Relay Agent Information Option */
2036                 optend = optoff + optlen;
2037                 while (optoff < optend)
2038                         optoff = bootp_dhcp_decode_agent_info(pinfo, vti, v_tree, tvb, optoff, optend);
2039                 break;
2040
2041         case 85:        /* Novell Servers (RFC 2241) */
2042                 /* Option 85 can be sent as a string */
2043                 /* Added by Greg Morris (gmorris[AT]novell.com) */
2044                 if (novell_string) {
2045                         proto_tree_add_item(v_tree, hf_bootp_option_novell_dss_string, tvb, optoff, optlen, ENC_ASCII|ENC_NA);
2046                 } else{
2047                         /* IP addresses */
2048                         for (i = optoff, optleft = optlen; optleft > 0;
2049                                 i += 4, optleft -= 4) {
2050                                 if (optleft < 4) {
2051                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Option length isn't a multiple of 4");
2052                                         break;
2053                                 }
2054
2055                                 proto_tree_add_item(v_tree, hf_bootp_option_novell_dss_ip, tvb, i, 4, ENC_BIG_ENDIAN);
2056                         }
2057                 }
2058                 break;
2059
2060         case 94: {      /* Client network interface identifier */
2061                 guint8 id_type;
2062
2063                 id_type = tvb_get_guint8(tvb, optoff);
2064
2065                 if (id_type == 0x01) {
2066                         proto_tree_add_item(v_tree, hf_bootp_option_client_network_id_major_ver,
2067                                                                 tvb, optoff + 1, 1, ENC_LITTLE_ENDIAN);
2068                         proto_tree_add_item(v_tree, hf_bootp_option_client_network_id_minor_ver,
2069                                                                 tvb, optoff + 2, 1, ENC_LITTLE_ENDIAN);
2070                 }
2071
2072                 break;
2073         }
2074
2075         case 90:        /* DHCP Authentication */
2076         case 210:       /* Was this used for authentication at one time? */
2077                 if (optlen < 11) {
2078                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 11");
2079                         break;
2080                 }
2081                 optleft = optlen;
2082                 protocol = tvb_get_guint8(tvb, optoff);
2083
2084                 proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_protocol, tvb, optoff, 1, ENC_BIG_ENDIAN);
2085                 optoff++;
2086                 optleft--;
2087
2088                 algorithm = tvb_get_guint8(tvb, optoff);
2089                 switch (protocol) {
2090
2091                 case AUTHEN_PROTO_DELAYED_AUTHEN:
2092                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_alg_delay, tvb, optoff, 1, ENC_BIG_ENDIAN);
2093                         break;
2094
2095                 default:
2096                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_algorithm, tvb, optoff, 1, ENC_BIG_ENDIAN);
2097                         break;
2098                 }
2099                 optoff++;
2100                 optleft--;
2101
2102                 rdm = tvb_get_guint8(tvb, optoff);
2103                 proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_rdm, tvb, optoff, 1, ENC_BIG_ENDIAN);
2104                 optoff++;
2105                 optleft--;
2106
2107                 switch (rdm) {
2108
2109                 case AUTHEN_RDM_MONOTONIC_COUNTER:
2110                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_rdm_replay_detection, tvb, optoff, 8, ENC_BIG_ENDIAN);
2111                         break;
2112
2113                 default:
2114                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_rdm_rdv, tvb, optoff, 8, ENC_ASCII|ENC_NA);
2115                         break;
2116                 }
2117                 optoff += 8;
2118                 optleft -= 8;
2119
2120                 switch (protocol) {
2121
2122                 case AUTHEN_PROTO_DELAYED_AUTHEN:
2123                         switch (algorithm) {
2124
2125                         case AUTHEN_DELAYED_ALGO_HMAC_MD5:
2126                                 if (*dhcp_type_p && !strcmp(*dhcp_type_p, OPT53_DISCOVER)) {
2127                                         /* Discover has no Secret ID nor HMAC MD5 Hash */
2128                                         break;
2129                                 } else {
2130                                         if (optlen < 31) {
2131                                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 31");
2132                                                 break;
2133                                         }
2134
2135                                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_secret_id, tvb, optoff, 4, ENC_BIG_ENDIAN);
2136                                         optoff += 4;
2137                                         /*optleft -= 4;*/
2138                                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_hmac_md5_hash, tvb, optoff, 16, ENC_ASCII|ENC_NA);
2139                                         break;
2140                                 }
2141
2142                         default:
2143                                 if (optleft == 0)
2144                                         break;
2145
2146                                 proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_information, tvb, optoff, optleft, ENC_ASCII|ENC_NA);
2147                                 break;
2148                         }
2149                         break;
2150
2151                 default:
2152                         if (optleft == 0)
2153                                 break;
2154
2155                         proto_tree_add_item(v_tree, hf_bootp_option_dhcp_authentication_information, tvb, optoff, optleft, ENC_ASCII|ENC_NA);
2156                         break;
2157                 }
2158                 break;
2159
2160         case 99: /* civic location (RFC 4776) */
2161
2162                 optleft = optlen;
2163                 if (optleft >= 3)
2164                 {
2165                         proto_tree_add_item(v_tree, hf_bootp_option_civic_location_what, tvb, optoff, 1, ENC_BIG_ENDIAN);
2166                         proto_tree_add_item(v_tree, hf_bootp_option_civic_location_country, tvb, optoff+1, 2, ENC_ASCII|ENC_NA);
2167                         optleft = optleft - 3;
2168                         optoff = optoff + 3;
2169
2170                         while (optleft >= 2)
2171                         {
2172                                 int calength = tvb_get_guint8(tvb, optoff+1);
2173                                 proto_tree_add_item(v_tree, hf_bootp_option_civic_location_ca_type, tvb, optoff, 1, ENC_BIG_ENDIAN);
2174                                 proto_tree_add_item(v_tree, hf_bootp_option_civic_location_ca_length, tvb, optoff+1, 1, ENC_BIG_ENDIAN);
2175
2176                                 optoff += 2;
2177                                 optleft -= 2;
2178
2179                                 if (calength == 0)
2180                                         continue;
2181
2182                                 if (optleft >= calength)
2183                                 {
2184                                         proto_tree_add_item(v_tree, hf_bootp_option_civic_location_ca_value, tvb, optoff, calength, ENC_ASCII|ENC_NA);
2185
2186                                         optoff = optoff + calength;
2187                                         optleft = optleft - calength;
2188                                 }
2189                                 else
2190                                 {
2191                                         optleft = 0;
2192                                         expert_add_info(pinfo, vti, &ei_bootp_option_civic_location_bad_cattype);
2193                                 }
2194                         }
2195                 }
2196                 break;
2197
2198         case 117:   /* The Name Service Search Option for DHCP (RFC 2937) */
2199                 if (optlen < 2) {
2200                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 2");
2201                 } else if (optlen & 1) {
2202                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length (%u) isn't even number", optlen);
2203                 } else {
2204                         guint16 ns;
2205                         for (i = 0, ns = tvb_get_ntohs(tvb, optoff); i < optlen; i += 2, ns = tvb_get_ntohs(tvb, optoff + i)) {
2206                                 switch (ns) {
2207                                 case RFC2937_LOCAL_NAMING_INFORMATION:
2208                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_name_service_search_option, tvb, optoff + i, 2, "Local naming information (e.g., an /etc/hosts file on a UNIX machine) (0)");
2209                                         break;
2210                                 case RFC2937_DOMAIN_NAME_SERVER_OPTION:
2211                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_name_service_search_option, tvb, optoff + i, 2, "Domain Name Server Option (6)");
2212                                         break;
2213                                 case RFC2937_NETWORK_INFORMATION_SERVERS_OPTION:
2214                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_name_service_search_option, tvb, optoff + i, 2, "Network Information Servers Option (41)");
2215                                         break;
2216                                 case RFC2937_NETBIOS_OVER_TCP_IP_NAME_SERVER_OPTION:
2217                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_name_service_search_option, tvb, optoff + i, 2, "NetBIOS over TCP/IP Name Server Option (44)");
2218                                         break;
2219                                 case RFC2937_NETWORK_INFORMATION_SERVICE_PLUS_SERVERS_OPTION:
2220                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_name_service_search_option, tvb, optoff + i, 2, "Network Information Service+ Servers Option (65)");
2221                                         break;
2222                                 default:
2223                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_option_dhcp_name_service_invalid,
2224                                                                 "Invalid Name Service (%u). RFC 2937 defines only 0, 6, 41, 44, and 65 as possible values.", ns);
2225                                         break;
2226                                 }
2227                         }
2228                 }
2229                 break;
2230
2231         case 119: { /* Dynamic Host Configuration Protocol (DHCP) Domain Search Option (RFC 3397) */
2232                     /* Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4) (RFC 3396) */
2233                     /* Domain Names - Implementation And Specification (RFC 1035) */
2234                 char tmpChar[BOOTP_MAX_NO_CHAR];
2235                 rfc3396_dns_domain_search_list.index_current_block++;
2236                 if (rfc3396_dns_domain_search_list.total_number_of_block > 1) {
2237                         g_snprintf(tmpChar, BOOTP_MAX_NO_CHAR, "%u/%u", rfc3396_dns_domain_search_list.index_current_block, rfc3396_dns_domain_search_list.total_number_of_block);
2238                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_rfc_3396_detected, tvb, optoff, optlen, tmpChar);
2239                         if (rfc3396_dns_domain_search_list.index_current_block != rfc3396_dns_domain_search_list.total_number_of_block) {
2240                                 g_snprintf(tmpChar, BOOTP_MAX_NO_CHAR, "%u/%u", rfc3396_dns_domain_search_list.total_number_of_block, rfc3396_dns_domain_search_list.total_number_of_block);
2241                                 proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_refer_last_option, tvb, optoff, optlen, tmpChar);
2242                         }
2243                 }
2244
2245                 if (rfc3396_dns_domain_search_list.tvb_composite == NULL && optlen) {
2246                         /* We use composite tvb for managing RFC 3396 */
2247                         rfc3396_dns_domain_search_list.tvb_composite = tvb_new_composite();
2248                 }
2249
2250                 /* Concatenate the block before being interpreted for managing RFC 3396 */
2251                 if (optlen)
2252                         tvb_composite_append(rfc3396_dns_domain_search_list.tvb_composite, tvb_new_subset(tvb, optoff, optlen, optlen));
2253
2254                 if (rfc3396_dns_domain_search_list.index_current_block == rfc3396_dns_domain_search_list.total_number_of_block
2255                     && rfc3396_dns_domain_search_list.tvb_composite) {
2256                         /* Here, we are into the last (or unique) option 119. */
2257                         /* We will display the information about fqdn */
2258                         unsigned int consumedx = 0;
2259                         unsigned int offset = 0;
2260                         tvb_composite_finalize(rfc3396_dns_domain_search_list.tvb_composite);
2261
2262                         while (offset < tvb_length(rfc3396_dns_domain_search_list.tvb_composite)) {
2263                                 /* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
2264                                 consumedx = get_dns_name(rfc3396_dns_domain_search_list.tvb_composite, offset, tvb_length(rfc3396_dns_domain_search_list.tvb_composite), 0, &dns_name);
2265                                 if (rfc3396_dns_domain_search_list.total_number_of_block == 1) {
2266                                         /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
2267                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, optoff + offset, consumedx, dns_name);
2268                                 } else {
2269                                         /* RFC 3396 is used, so the option is split into several option 119. We don't link fqdn with v_tree. */
2270                                         proto_tree_add_string(v_tree, hf_bootp_option_dhcp_dns_domain_search_list_fqdn, tvb, 0, 0, dns_name);
2271                                 }
2272                                 offset += consumedx;
2273                         }
2274                         rfc3396_dns_domain_search_list.tvb_composite = NULL;
2275                 }
2276                 break;
2277         }
2278         case 120: { /* SIP Servers (RFC 3361) */
2279                     /* Encoding Long Options in the Dynamic Host Configuration Protocol (DHCPv4) (RFC 3396) */
2280                     /* Domain Names - Implementation And Specification (RFC 1035) */
2281                 char tmpChar[BOOTP_MAX_NO_CHAR];
2282                 rfc3396_sip_server.index_current_block++;
2283                 if (rfc3396_sip_server.total_number_of_block > 1) {
2284                         g_snprintf(tmpChar, BOOTP_MAX_NO_CHAR, "%u/%u", rfc3396_sip_server.index_current_block, rfc3396_sip_server.total_number_of_block);
2285                         proto_tree_add_string(v_tree, hf_bootp_option_sip_server_rfc_3396_detected, tvb, optoff, optlen, tmpChar);
2286                         if (rfc3396_sip_server.index_current_block != rfc3396_sip_server.total_number_of_block) {
2287                                 g_snprintf(tmpChar, BOOTP_MAX_NO_CHAR, "%u/%u", rfc3396_sip_server.total_number_of_block, rfc3396_sip_server.total_number_of_block);
2288                                 proto_tree_add_string(v_tree, hf_bootp_option_sip_server_refer_last_option, tvb, optoff, optlen, tmpChar);
2289                         }
2290                 }
2291
2292                 if (rfc3396_sip_server.tvb_composite == NULL && optlen) {
2293                         /* We use composite tvb for managing RFC 3396 */
2294                         rfc3396_sip_server.tvb_composite = tvb_new_composite();
2295                 }
2296
2297                 /* Concatenate the block before being interpreted for managing RFC 3396 */
2298                 if (optlen)
2299                         tvb_composite_append(rfc3396_sip_server.tvb_composite, tvb_new_subset(tvb, optoff, optlen, optlen));
2300
2301                 if (rfc3396_sip_server.index_current_block == rfc3396_sip_server.total_number_of_block
2302                     && rfc3396_sip_server.tvb_composite) {
2303                         /* Here, we are into the last (or unique) option 120. */
2304                         /* We will display the information about SIP server */
2305                         guint8 enc;
2306                         unsigned int offset = 1; /* ignore enc */
2307                         tvb_composite_finalize(rfc3396_sip_server.tvb_composite);
2308
2309                         enc = tvb_get_guint8(rfc3396_sip_server.tvb_composite, 0);
2310                         if (rfc3396_sip_server.total_number_of_block == 1) {
2311                                 /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
2312                                 proto_tree_add_uint(v_tree, hf_bootp_option_sip_server_enc, tvb, optoff, 1, enc);
2313                         } else {
2314                                 /* RFC 3396 is used, so the option is split into several option 120. We don't link fqdn with v_tree. */
2315                                 proto_tree_add_uint(v_tree, hf_bootp_option_sip_server_enc, tvb, 0, 0, enc);
2316                         }
2317
2318                         switch (enc) {
2319                         case RFC_3361_ENC_FQDN: {
2320                                 unsigned int consumedx = 0;
2321                                 if (tvb_length(rfc3396_sip_server.tvb_composite) < 3) {
2322                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 3 (len = %u)", tvb_length(rfc3396_sip_server.tvb_composite));
2323                                         break;
2324                                 }
2325
2326                                 while (offset < tvb_length(rfc3396_sip_server.tvb_composite)) {
2327                                         /* use the get_dns_name method that manages all techniques of RFC 1035 (compression pointer and so on) */
2328                                         consumedx = get_dns_name(rfc3396_sip_server.tvb_composite, offset, tvb_length(rfc3396_sip_server.tvb_composite), 1 /* ignore enc */, &dns_name);
2329
2330                                         if (rfc3396_sip_server.total_number_of_block == 1) {
2331                                                 /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
2332                                                 proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, optoff + offset, consumedx, dns_name);
2333                                         } else {
2334                                                 /* RFC 3396 is used, so the option is split into several option 120. We don't link fqdn with v_tree. */
2335                                                 proto_tree_add_string(v_tree, hf_bootp_option_sip_server_name, tvb, 0, 0, dns_name);
2336                                         }
2337                                         offset += consumedx;
2338                                 }
2339                                 rfc3396_sip_server.tvb_composite = NULL;
2340                                 break;
2341                         }
2342                         case RFC_3361_ENC_IPADDR:
2343                                 if (tvb_length(rfc3396_sip_server.tvb_composite) < 5) {
2344                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 5 (len = %u)", tvb_length(rfc3396_sip_server.tvb_composite));
2345                                         break;
2346                                 }
2347                                 /* x % 2^n == x & (2^n - 1) note : (assuming x is a positive integer) */
2348                                 if ((tvb_length(rfc3396_sip_server.tvb_composite) - 1) & 3) {
2349                                         if (rfc3396_sip_server.total_number_of_block == 1)
2350                                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't a multiple of 4 plus 1 (len = %u).", tvb_length(rfc3396_sip_server.tvb_composite));
2351                                         else
2352                                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length,
2353                                                         "length isn't a multiple of 4 plus 1 (len = %u). For your information with RFC 3396, the length is the length sum of all options 120 into this BOOTP packet.",
2354                                                         tvb_length(rfc3396_sip_server.tvb_composite));
2355                                         break;
2356                                 }
2357                                 while (offset < tvb_length(rfc3396_sip_server.tvb_composite)) {
2358                                         if (rfc3396_sip_server.total_number_of_block == 1) {
2359                                                 /* RFC 3396 is not used, so we can easily link the fqdn with v_tree. */
2360                                                 proto_tree_add_item(v_tree, hf_bootp_option_sip_server_address, rfc3396_sip_server.tvb_composite, offset, 4, ENC_BIG_ENDIAN);
2361                                         } else {
2362                                                 /* RFC 3396 is used, so the option is split into several option 120. We don't link fqdn with v_tree. */
2363                                                 /* Since we don't use the "numbered argument" as described by README.developer, we have to repeat the arguments :( */
2364                                                 g_snprintf(tmpChar, BOOTP_MAX_NO_CHAR, "%u.%u.%u.%u (%u.%u.%u.%u)",
2365                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset),
2366                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 1),
2367                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 2),
2368                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 3),
2369                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset),
2370                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 1),
2371                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 2),
2372                                                            tvb_get_guint8(rfc3396_sip_server.tvb_composite, offset + 3)
2373                                                            );
2374                                                 proto_tree_add_string(v_tree, hf_bootp_option_sip_server_address_stringz, tvb, 0, 0, tmpChar);
2375                                         }
2376                                         offset += 4;
2377                                 }
2378                                 break;
2379                         default:
2380                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_option_sip_server_address_encoding, "RFC 3361 defines only 0 and 1 for Encoding byte (Encoding = %u).", enc);
2381                                 break;
2382                         }
2383                 }
2384                 break;
2385         }
2386         case 121:       /* Classless Static Route */
2387         case 249: {     /* Classless Static Route (Microsoft) */
2388                 int mask_width, significant_octets;
2389                 optend = optoff + optlen;
2390                 /* minimum length is 5 bytes */
2391                 if (optlen < 5) {
2392                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't >= 5");
2393                         break;
2394                 }
2395                 while (optoff < optend) {
2396                         mask_width = tvb_get_guint8(tvb, optoff);
2397                         /* mask_width <= 32 */
2398                         if (mask_width > 32) {
2399                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_option_classless_static_route, "Mask width (%d) > 32", mask_width);
2400                                 break;
2401                         }
2402                         significant_octets = (mask_width + 7) / 8;
2403                         vti = proto_tree_add_text(v_tree, tvb, optoff,
2404                                 1 + significant_octets + 4,
2405                                 "Subnet/MaskWidth-Router: ");
2406                         optoff++;
2407                         /* significant octets + router(4) */
2408                         if (optend < optoff + significant_octets + 4) {
2409                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Remaining length (%d) < %d bytes", optend - optoff, significant_octets + 4);
2410                                 break;
2411                         }
2412                         if(mask_width == 0)
2413                                 proto_item_append_text(vti, "default");
2414                         else {
2415                                 for(i = 0 ; i < significant_octets ; i++) {
2416                                         if (i > 0)
2417                                                 proto_item_append_text(vti, ".");
2418                                         byte = tvb_get_guint8(tvb, optoff++);
2419                                         proto_item_append_text(vti, "%d", byte);
2420                                 }
2421                                 for(i = significant_octets ; i < 4 ; i++)
2422                                         proto_item_append_text(vti, ".0");
2423                                 proto_item_append_text(vti, "/%d", mask_width);
2424                         }
2425                         proto_item_append_text(vti, "-%s", tvb_ip_to_str(tvb, optoff));
2426                         optoff += 4;
2427                 }
2428                 break;
2429         }
2430
2431         case 123: /* coordinate based location RFC 3825 or CableLabs DSS_ID  */
2432                 if (optlen == 16) {
2433                         int c;
2434                         unsigned char lci[16];
2435                         struct rfc3825_location_fixpoint_t location_fp;
2436                         struct rfc3825_location_decimal_t location;
2437
2438                         for (c=0; c < 16;c++)
2439                                 lci[c] = (unsigned char) tvb_get_guint8(tvb, optoff + c);
2440
2441                         /* convert lci encoding into fixpoint location */
2442                         rfc3825_lci_to_fixpoint(lci, &location_fp);
2443
2444                         /* convert location from decimal to fixpoint */
2445                         i = rfc3825_fixpoint_to_decimal(&location_fp, &location);
2446
2447                         if (i != RFC3825_NOERROR) {
2448                                 proto_tree_add_text(v_tree, tvb, optoff, optlen, "Error: %s", val_to_str_const(i, rfc3825_error_types, "Unknown"));
2449                         } else {
2450                                 proto_tree_add_text(v_tree, tvb, optoff, 5, "Latitude: %15.10f", location.latitude);
2451                                 proto_tree_add_text(v_tree, tvb, optoff+5, 5, "Longitude: %15.10f", location.longitude);
2452                                 proto_tree_add_text(v_tree, tvb, optoff, 1, "Latitude resolution: %15.10f", location.latitude_res);
2453                                 proto_tree_add_text(v_tree, tvb, optoff+5, 1, "Longitude resolution: %15.10f", location.longitude_res);
2454                                 proto_tree_add_text(v_tree, tvb, optoff+12, 4, "Altitude: %15.10f", location.altitude);
2455                                 proto_tree_add_text(v_tree, tvb, optoff+10, 2, "Altitude resolution: %15.10f", location.altitude_res);
2456                                 proto_tree_add_text(v_tree, tvb, optoff+10, 1, "Altitude type: %s (%d)", val_to_str_const(location.altitude_type, altitude_type_values, "Unknown"), location.altitude_type);
2457                                 proto_tree_add_text(v_tree, tvb, optoff+15, 1, "Map Datum: %s (%d)", val_to_str_const(location.datum_type, map_datum_type_values, "Unknown"), location.datum_type);
2458                         }
2459                 } else if (optlen < 69) { /* CableLabs DSS_ID */
2460
2461                         proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id_option, tvb, optoff, 1, ENC_BIG_ENDIAN);
2462                         proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id_len, tvb, optoff+1, 1, ENC_BIG_ENDIAN);
2463                         s_len = tvb_get_guint8(tvb, optoff+1);
2464                         proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id, tvb, optoff+2, s_len, ENC_ASCII|ENC_NA);
2465
2466                         if (optlen > s_len+2) { /* Second DSS_ID*/
2467
2468                                 proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id_option, tvb, optoff+2+s_len, 1, ENC_BIG_ENDIAN);
2469                                 proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id_len, tvb, optoff+1+2+s_len, 1, ENC_BIG_ENDIAN);
2470                                 s_len = tvb_get_guint8(tvb, optoff+1+2+s_len);
2471                                 proto_tree_add_item(v_tree, hf_bootp_option_cl_dss_id, tvb, optoff+2+2+s_len, s_len, ENC_ASCII|ENC_NA);
2472                         }
2473                 } else {
2474                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Invalid length of DHCP option!");
2475                 }
2476                 break;
2477
2478         case 124: {     /* V-I Vendor Class */
2479                 int data_len;
2480
2481                 if (optlen == 1) {
2482                         /* CableLab specific */
2483                         proto_tree_add_item(v_tree, hf_bootp_option_vi_class_cl_address_mode, tvb, optoff, optlen, ENC_BIG_ENDIAN);
2484                         break;
2485                 }
2486
2487                 optleft = optlen;
2488
2489                 while (optleft > 0) {
2490
2491                         if (optleft < 5) {
2492                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length < 5");
2493                                 break;
2494                         }
2495
2496                         proto_tree_add_item(v_tree, hf_bootp_option_vi_class_enterprise, tvb, optoff, 4, ENC_BIG_ENDIAN);
2497                         proto_tree_add_item(v_tree, hf_bootp_option_vi_class_data_length, tvb, optoff, 1, ENC_BIG_ENDIAN);
2498                         data_len = tvb_get_guint8(tvb, optoff + 4);
2499
2500                         optoff += 5;
2501                         optleft -= 5;
2502
2503                         proto_tree_add_item(v_tree, hf_bootp_option_vi_class_data, tvb, optoff, data_len, ENC_ASCII|ENC_NA);
2504
2505                         /* look for next enterprise number */
2506                         optoff += data_len;
2507                         optleft -= data_len;
2508                 }
2509                 break;
2510         }
2511
2512         case 125: {     /* V-I Vendor-specific Information */
2513                 int enterprise = 0;
2514                 int s_end = 0;
2515                 int s_option_len = 0;
2516                 proto_tree *e_tree = 0;
2517
2518                 optend = optoff + optlen;
2519                 optleft = optlen;
2520
2521                 while (optleft > 0) {
2522
2523                         if (optleft < 5) {
2524                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length < 5");
2525                                 break;
2526                         }
2527
2528                         enterprise = tvb_get_ntohl(tvb, optoff);
2529                         vti = proto_tree_add_item(v_tree, hf_bootp_option125_enterprise, tvb, optoff, 4, ENC_BIG_ENDIAN);
2530
2531                         s_option_len = tvb_get_guint8(tvb, optoff + 4);
2532
2533                         optoff += 5;
2534                         optleft -= 5;
2535
2536                         /* Handle DSL Forum TR-111 Option 125 */
2537                         switch (enterprise) {
2538
2539                         case 3561: /* ADSL Forum */
2540                                 s_end = optoff + s_option_len;
2541                                 if ( s_end > optend ) {
2542                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_option125_enterprise_malformed, "no room left in option for enterprise %u data", enterprise);
2543                                         break;
2544                                 }
2545
2546                                 e_tree = proto_item_add_subtree(vti, ett_bootp_option);
2547                                 while (optoff < s_end) {
2548
2549                                 optoff = dissect_vendor_tr111_suboption(pinfo, vti, e_tree, tvb, optoff, s_end);
2550                         }
2551                         break;
2552
2553                         case 4491: /* CableLab */
2554                                 s_end = optoff + s_option_len;
2555                                 if ( s_end > optend ) {
2556                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_option125_enterprise_malformed, "no room left in option for enterprise %u data", enterprise);
2557                                         break;
2558                                 }
2559
2560                                 e_tree = proto_item_add_subtree(vti, ett_bootp_option);
2561                                 while (optoff < s_end) {
2562                                         optoff = dissect_vendor_cl_suboption(pinfo, vti, e_tree, tvb, optoff, s_end);
2563                         }
2564                         break;
2565
2566                         default:
2567                                 /* skip over the data and look for next enterprise number */
2568                                 optoff += s_option_len;
2569                         }
2570
2571                         optleft -= s_option_len;
2572                 }
2573                 break;
2574         }
2575
2576         case 212: {     /* 6RD option (RFC 5969) */
2577                 if (optlen < 22) {
2578                         expert_add_info(pinfo, vti, &ei_bootp_option_6RD_malformed);
2579                         break;
2580                 }
2581
2582                 proto_tree_add_item(v_tree, hf_bootp_option_6RD_ipv4_mask_len, tvb, optoff, 1, ENC_BIG_ENDIAN);
2583                 proto_tree_add_item(v_tree, hf_bootp_option_6RD_prefix_len, tvb, optoff+1, 1, ENC_BIG_ENDIAN);
2584                 proto_tree_add_item(v_tree, hf_bootp_option_6RD_prefix, tvb, optoff+2, 16, ENC_NA);
2585                 proto_tree_add_item(v_tree, hf_bootp_option_6RD_border_relay_ip, tvb, optoff+18, 4, ENC_BIG_ENDIAN);
2586
2587                 /* More Border Relay IPv4 addresses included */
2588                 if (optlen > 22) {
2589                         optoff += 22;
2590                         for (i = optoff, optleft = optlen - 22; optleft > 0; i += 4, optleft -= 4) {
2591                                 if (optleft < 4) {
2592                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "Option length isn't a multiple of 4");
2593                                         break;
2594                                 }
2595
2596                                 proto_tree_add_item(v_tree, hf_bootp_option_6RD_border_relay_ip, tvb, i, 4, ENC_BIG_ENDIAN);
2597                         }
2598                 }
2599                 break;
2600         }
2601
2602         default:        /* not special */
2603                 /* The PacketCable CCC option number can vary.  If this is a CCC option,
2604                    handle it as a special.
2605                  */
2606                 if (code == pkt_ccc_option) {
2607                         ftype = special;
2608                         proto_item_append_text(vti,
2609                                 "CableLabs Client Configuration (%d bytes)",
2610                                 optlen);
2611                         optend = optoff + optlen;
2612                         while (optoff < optend) {
2613                                 switch (pkt_ccc_protocol_version) {
2614
2615                                 case PACKETCABLE_CCC_I05:
2616                                         optoff = dissect_packetcable_i05_ccc(pinfo, vti, v_tree, tvb, optoff, optend);
2617                                         break;
2618                                 case PACKETCABLE_CCC_DRAFT5:
2619                                 case PACKETCABLE_CCC_RFC_3495:
2620                                         optoff = dissect_packetcable_ietf_ccc(pinfo, vti, v_tree, tvb, optoff, optend, pkt_ccc_protocol_version);
2621                                         break;
2622                                 default: /* XXX Should we do something here? */
2623                                         break;
2624                                 }
2625                         }
2626                 } else {
2627                         option_handled = FALSE;
2628                 }
2629
2630                 break;
2631         }
2632
2633         basictype_consumed = bootp_handle_basic_types(pinfo, v_tree, vti, tvb, ftype,
2634                                                       optoff, optlen, opt->phf, &default_hfs);
2635
2636         if ((basictype_consumed == 0) && (option_handled == FALSE) &&
2637             (opt->phf == NULL) && (optlen > 0)) {
2638                 proto_tree_add_item(v_tree, hf_bootp_option_value, tvb, voff+2, optlen, ENC_NA);
2639         }
2640
2641         return consumed;
2642 }
2643
2644 static const value_string option82_suboption_vals[] = {
2645         {  0, "Padding" },
2646         {  1, "Agent Circuit ID" },
2647         {  2, "Agent Remote ID" },
2648         {  3, "Reserved" },
2649         {  4, "DOCSIS Device Class" },
2650         {  5, "Link selection" },
2651         {  6, "Subscriber ID" },
2652         {  7, "RADIUS Attributes" },
2653         {  8, "Authentication" },
2654         {  9, "Vendor-Specific Information" },
2655         { 10, "Flags" },
2656         { 11, "Server ID Override" },
2657         { 150, "Link selection (Cisco proprietary)" },
2658         { 151, "VRF name/VPN ID" },
2659         { 152, "Server ID Override (Cisco proprietary)" },
2660         { 0, NULL }
2661 };
2662
2663 static int
2664 bootp_dhcp_decode_agent_info(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree, tvbuff_t *tvb, int optoff,
2665                              int optend)
2666 {
2667         int         suboptoff = optoff;
2668         guint8      subopt, idx, vs_opt, vs_len;
2669         int         subopt_len, subopt_end, datalen;
2670         guint32     enterprise;
2671         proto_item *vti, *ti;
2672         proto_tree *o82_v_tree, *o82_sub_tree;
2673         guint8      tag, tag_len;
2674
2675         struct basic_types_hfs default_hfs = {
2676                 &hf_bootp_option82_value,
2677                 &hf_bootp_option82_value_ip_address,
2678                 &hf_bootp_option82_value_ip_address,
2679                 &hf_bootp_option82_value_stringz,
2680                 NULL,
2681                 &hf_bootp_option82_value_8,
2682                 NULL,
2683                 NULL,
2684                 &hf_bootp_option82_value_32,
2685                 NULL,
2686                 NULL
2687         };
2688
2689         struct opt82_info {
2690                 int id;
2691                 struct opt_info info;
2692         };
2693         static struct opt82_info o82_opt[]= {
2694                 {0, {"nop", bytes, &hf_bootp_option82_padding}},        /* dummy */
2695                 {1, {"Agent Circuit ID", bytes, &hf_bootp_option82_agent_circuit_id}}, /* [RFC3046] */
2696                 {2, {"Agent Remote ID", bytes, &hf_bootp_option82_agent_remote_id}}, /* [RFC3046] */
2697                 {3, {"Reserved", bytes, &hf_bootp_option82_reserved}},
2698                 {4, {"DOCSIS Device Class", val_u_long, &hf_bootp_option82_docsis_device_class}}, /* [RFC3256] */
2699                 {5, {"Link selection", ipv4, &hf_bootp_option82_link_selection}}, /* [RFC3527] */
2700                 {6, {"Subscriber ID", string, &hf_bootp_option82_subscriber_id}},  /* [RFC3993] */ /***** CHECK STRING TYPE */
2701                 {7, {"RADIUS Attributes", bytes, &hf_bootp_option82_radius_attributes}}, /* [RFC4014] */
2702                 {8, {"Authentication", bytes, &hf_bootp_option82_authentication}}, /* [RFC4030] */
2703                 {9, {"Vendor-Specific Information", special, &hf_bootp_option82_vi}}, /* [RFC 4243] */
2704                 {10, {"Flags", val_u_byte, &hf_bootp_option82_flags}}, /* [RFC5010] */
2705                 {11, {"Server ID Override", ipv4, &hf_bootp_option82_server_id_override}}, /* [RFC 5107] */
2706                 {150, {"Link selection (Cisco proprietary)", ipv4, &hf_bootp_option82_link_selection_cisco}}, /* [RFC3527] */
2707                 {151, {"VRF name/VPN ID", special, &hf_bootp_option82_vrf_name_vpn_id}}, /* [RFC2685] */
2708                 {152, {"Server ID Override (Cisco proprietary)", ipv4, &hf_bootp_option82_server_id_override_cisco}} /* [RFC 5107] */
2709         };
2710
2711         subopt = tvb_get_guint8(tvb, optoff);
2712         suboptoff++;
2713
2714         if (suboptoff >= optend) {
2715                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
2716                                                                         "Suboption %d: no room left in option for suboption length", subopt);
2717                 return (optend);
2718         }
2719
2720         subopt_len = tvb_get_guint8(tvb, suboptoff);
2721         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option82_suboption,
2722                 tvb, optoff, subopt_len+2, subopt, "(%d) %s", subopt, val_to_str_const(subopt, option82_suboption_vals, "Unknown"));
2723
2724         o82_v_tree = proto_item_add_subtree(vti, ett_bootp_option82_suboption);
2725         proto_tree_add_item(o82_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2726         suboptoff++;
2727
2728         subopt_end = suboptoff+subopt_len;
2729         if (subopt_end > optend) {
2730                 expert_add_info_format_text(pinfo, vti, &ei_bootp_missing_subopt_value,
2731                                                 "Suboption %d: no room left in option for suboption value", subopt);
2732                 return (optend);
2733         }
2734
2735         for (idx = 0; idx < array_length(o82_opt); idx++) {
2736                 if (o82_opt[idx].id == subopt) {
2737                         break;
2738                 }
2739         }
2740
2741         ti = proto_tree_add_item(o82_v_tree, hf_bootp_option82_value, tvb, suboptoff, subopt_len, ENC_NA);
2742
2743         if ( (idx >= 1 ) && (idx < array_length(o82_opt)) ) {
2744                 PROTO_ITEM_SET_HIDDEN(ti);
2745                 if (o82_opt[idx].info.ftype == special) {
2746                         switch(subopt)
2747                         {
2748                         case 9:
2749                                 while (suboptoff < subopt_end) {
2750                                         enterprise = tvb_get_ntohl(tvb, suboptoff);
2751                                         vti = proto_tree_add_item(o82_v_tree, hf_bootp_option82_vi_enterprise, tvb, suboptoff, 4, ENC_BIG_ENDIAN);
2752                                         suboptoff += 4;
2753
2754                                         o82_sub_tree = proto_item_add_subtree(vti, ett_bootp_option82_suboption9);
2755                                         datalen = tvb_get_guint8(tvb, suboptoff);
2756                                         proto_tree_add_item(o82_sub_tree, hf_bootp_option82_vi_data_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2757                                         suboptoff++;
2758
2759                                         switch (enterprise) {
2760                                         case 4491: /* CableLab */
2761                                                 vs_opt = tvb_get_guint8(tvb, suboptoff);
2762                                                 proto_tree_add_item(o82_sub_tree, hf_bootp_option82_vi_cl_option, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2763                                                 suboptoff++;
2764                                                 vs_len = tvb_get_guint8(tvb, suboptoff);
2765                                                 proto_tree_add_item(o82_sub_tree, hf_bootp_option82_vi_cl_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2766                                                 suboptoff++;
2767
2768                                                 switch (vs_opt) {
2769
2770                                                 case 1:
2771                                                         if (vs_len == 4) {
2772                                                                 tag = tvb_get_guint8(tvb, suboptoff);
2773                                                                 proto_tree_add_item(o82_sub_tree, hf_bootp_option82_vi_cl_tag, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2774                                                                 tag_len = tvb_get_guint8(tvb, suboptoff+1);
2775                                                                 proto_tree_add_item(o82_sub_tree, hf_bootp_option82_vi_cl_tag_length, tvb, suboptoff+1, 1, ENC_BIG_ENDIAN);
2776                                                                 suboptoff+=2;
2777                                                                 if (tag == 1) {
2778                                                                         proto_tree_add_uint_format_value(o82_sub_tree, hf_bootp_option82_vi_cl_docsis_version,
2779                                                                                           tvb, suboptoff, 2, 0, "%d.%d",
2780                                                                                           tvb_get_guint8(tvb, suboptoff), tvb_get_guint8(tvb, suboptoff+1));
2781                                                                         suboptoff+=2;
2782                                                                 } else {
2783                                                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_option82_vi_cl_tag_unknown, "Unknown tag %d (%d bytes)", tag, tag_len);
2784                                                                         suboptoff += tag_len;
2785                                                                 }
2786                                                         } else {
2787                                                                 suboptoff += vs_len;
2788                                                         }
2789                                                         break;
2790
2791                                                 default:
2792                                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_suboption_invalid, "Invalid suboption %d (%d bytes)", vs_opt, vs_len);
2793                                                         suboptoff += vs_len;
2794                                                         break;
2795                                                 }
2796                                                 break;
2797                                         default:
2798                                                 proto_tree_add_item(o82_v_tree, hf_bootp_option82_value, tvb, suboptoff, datalen, ENC_NA);
2799                                                 suboptoff += datalen;
2800                                                 break;
2801                                         }
2802                                 }
2803                                 break;
2804                         case 151:
2805                                 if (subopt_len != 7) {
2806                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 7");
2807                                         break;
2808                                 }
2809                                 proto_tree_add_item(o82_v_tree, hf_bootp_option82_vrf_name_vpn_id_oui, tvb, suboptoff, 3, ENC_BIG_ENDIAN);
2810                                 proto_tree_add_item(o82_v_tree, hf_bootp_option82_vrf_name_vpn_id_index, tvb, suboptoff+3, 4, ENC_BIG_ENDIAN);
2811                                 break;
2812                         default:
2813                                 if (o82_opt[idx].info.phf != NULL)
2814                                         proto_tree_add_item(o82_v_tree, *o82_opt[idx].info.phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN);
2815                                 else
2816                                         proto_tree_add_item(o82_v_tree, hf_bootp_option82_value, tvb, suboptoff, subopt_len, ENC_NA);
2817                                 break;
2818                         }
2819                 }
2820                 else {
2821                         if (bootp_handle_basic_types(pinfo, o82_v_tree, vti, tvb, o82_opt[idx].info.ftype,
2822                                                      suboptoff, subopt_len, o82_opt[idx].info.phf, &default_hfs) == 0) {
2823                                 expert_add_info_format_text(pinfo, vti, &hf_bootp_subopt_unknown_type, "ERROR, please report: Unknown subopt type handler %d", subopt);
2824                         }
2825                 }
2826         }
2827
2828         optoff += (subopt_len + 2);
2829         return optoff;
2830 }
2831
2832 static const value_string option43_pxeclient_suboption_vals[] = {
2833         {  0, "Padding" },
2834         {  1, "PXE mtftp IP" },
2835         {  2, "PXE mtftp client port" },
2836         {  3, "PXE mtftp server port" },
2837         {  4, "PXE mtftp timeout" },
2838         {  5, "PXE mtftp delay" },
2839         {  6, "PXE discovery control" },
2840         {  7, "PXE multicast address" },
2841         {  8, "PXE boot servers" },
2842         {  9, "PXE boot menu" },
2843         { 10, "PXE menu prompt" },
2844         { 11, "PXE multicast address alloc", },
2845         { 12, "PXE credential types" },
2846         { 71, "PXE boot item" },
2847         { 255, "PXE End" },
2848         { 0, NULL}
2849 };
2850
2851 static int
2852 dissect_vendor_pxeclient_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
2853                                    tvbuff_t *tvb, int optoff, int optend)
2854 {
2855         int         suboptoff = optoff;
2856         guint8      subopt;
2857         guint8      subopt_len;
2858         proto_tree *o43pxeclient_v_tree;
2859         proto_item *vti, *ti;
2860
2861         struct basic_types_hfs default_hfs = {
2862                 NULL,
2863                 &hf_bootp_option43_value_ip_address,
2864                 &hf_bootp_option43_value_ip_address,
2865                 NULL,
2866                 NULL,
2867                 &hf_bootp_option43_value_8,
2868                 NULL,
2869                 NULL,
2870                 NULL,
2871                 NULL,
2872                 NULL
2873         };
2874
2875         static struct opt_info o43pxeclient_opt[]= {
2876                 /* 0 */ {"nop", special, &hf_bootp_option43_pxeclient_padding}, /* dummy */
2877                 /* 1 */ {"PXE mtftp IP", ipv4_list, &hf_bootp_option43_pxeclient_mtftp_ip},
2878                 /* 2 */ {"PXE mtftp client port", val_u_le_short, &hf_bootp_option43_pxeclient_mtftp_client_port},
2879                 /* 3 */ {"PXE mtftp server port",val_u_le_short, &hf_bootp_option43_pxeclient_mtftp_server_port},
2880                 /* 4 */ {"PXE mtftp timeout", val_u_byte, &hf_bootp_option43_pxeclient_mtftp_timeout},
2881                 /* 5 */ {"PXE mtftp delay", val_u_byte, &hf_bootp_option43_pxeclient_mtftp_delay},
2882                 /* 6 */ {"PXE discovery control", val_u_byte, &hf_bootp_option43_pxeclient_discovery_control},
2883                         /*
2884                          * Correct: b0 (lsb): disable broadcast discovery
2885                          *      b1: disable multicast discovery
2886                          *      b2: only use/accept servers in boot servers
2887                          *      b3: download bootfile without prompt/menu/disc
2888                          */
2889                 /* 7 */ {"PXE multicast address", ipv4_list, &hf_bootp_option43_pxeclient_multicast_address},
2890                 /* 8 */ {"PXE boot servers", special, &hf_bootp_option43_pxeclient_boot_servers},
2891                 /* 9 */ {"PXE boot menu", special, &hf_bootp_option43_pxeclient_boot_menu},
2892                 /* 10 */ {"PXE menu prompt", special, &hf_bootp_option43_pxeclient_menu_prompt},
2893                 /* 11 */ {"PXE multicast address alloc", special, &hf_bootp_option43_pxeclient_multicast_address_alloc},
2894                 /* 12 */ {"PXE credential types", special, &hf_bootp_option43_pxeclient_credential_types}
2895                 /* 71 {"PXE boot item", bytes, &hf_bootp_option43_pxeclient_boot_item}, */
2896                 /* 255 {"PXE end options", special, &hf_bootp_option43_pxeclient_end} */
2897         };
2898
2899         subopt = tvb_get_guint8(tvb, optoff);
2900         suboptoff++;
2901
2902         if (subopt == 0) {
2903                 proto_tree_add_item(v_tree, hf_bootp_option43_pxeclient_padding, tvb, optoff, 1, ENC_BIG_ENDIAN);
2904                 return (suboptoff);
2905         } else if (subopt == 255) {     /* End Option */
2906                 proto_tree_add_item(v_tree, hf_bootp_option43_pxeclient_end, tvb, optoff, 1, ENC_BIG_ENDIAN);
2907                 /* Make sure we skip any junk left this option */
2908                 return (optend);
2909         }
2910
2911         if (suboptoff >= optend) {
2912                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
2913                                                                         "Suboption %d: no room left in option for suboption length", subopt);
2914                 return (optend);
2915         }
2916
2917         subopt_len = tvb_get_guint8(tvb, suboptoff);
2918         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option43_pxeclient_suboption,
2919                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
2920                                 subopt, val_to_str_const(subopt, option43_pxeclient_suboption_vals, "Unknown"));
2921
2922         o43pxeclient_v_tree = proto_item_add_subtree(vti, ett_bootp_option43_suboption);
2923         proto_tree_add_item(o43pxeclient_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
2924         suboptoff++;
2925
2926         ti = proto_tree_add_item(o43pxeclient_v_tree, hf_bootp_option43_value, tvb, suboptoff, subopt_len, ENC_NA);
2927         PROTO_ITEM_SET_HIDDEN(ti);
2928
2929         if ( subopt == 71 ) {   /* 71 {"PXE boot item", special} */
2930                 /* case special */
2931                 /* I may need to decode that properly one day */
2932                 proto_tree_add_item(o43pxeclient_v_tree, hf_bootp_option43_pxeclient_boot_item, tvb, suboptoff, subopt_len, ENC_NA);
2933         } else if ((subopt < 1) || (subopt >= array_length(o43pxeclient_opt))) {
2934                 expert_add_info_format_text(pinfo, vti, &ei_bootp_suboption_invalid, "Unknown suboption %d (%d bytes)", subopt, subopt_len);
2935         } else if (o43pxeclient_opt[subopt].ftype == special) {
2936                 /* I may need to decode that properly one day */
2937                 if (o43pxeclient_opt[subopt].phf != NULL)
2938                         proto_tree_add_item(o43pxeclient_v_tree, *o43pxeclient_opt[subopt].phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN);
2939                 else
2940                         proto_tree_add_item(o43pxeclient_v_tree, hf_bootp_option43_value, tvb, suboptoff, subopt_len, ENC_NA);
2941         } else {
2942                 if (bootp_handle_basic_types(pinfo, o43pxeclient_v_tree, vti, tvb, o43pxeclient_opt[subopt].ftype,
2943                                                         suboptoff, subopt_len, o43pxeclient_opt[subopt].phf, &default_hfs) == 0)
2944                 {
2945                         expert_add_info_format_text(pinfo, vti, &hf_bootp_subopt_unknown_type, "ERROR, please report: Unknown subopt type handler %d", subopt);
2946                 }
2947         }
2948
2949         optoff += (subopt_len + 2);
2950         return optoff;
2951 }
2952
2953 /* RFC3825Decoder: http://www.enum.at/rfc3825encoder.529.0.html */
2954 static void
2955 rfc3825_lci_to_fixpoint(const unsigned char lci[16], struct rfc3825_location_fixpoint_t *fixpoint)
2956 {
2957         fixpoint->latitude_res = (lci[0]>>2) & 0x3F; /* make sure that right-shift does not copy sign bit */
2958         if (lci[0] & 2) { /* LSB<<1 contains the sign of the latitude */
2959                 /* Latitude is negative, expand two's complement */
2960                 fixpoint->latitude = (((gint64)lci[0] & 3)<<32) | ((gint64)lci[1]<<24) |
2961                                            ((gint64)lci[2]<<16) | ((gint64)lci[3]<<8)  |
2962                                             (gint64)lci[4]      | ((gint64)0x3FFFFFFF<<34);
2963
2964         } else {
2965                 /* Latitude is positive */
2966                 fixpoint->latitude = (((gint64)lci[0] & 3)<<32) | ((gint64)lci[1]<<24) |
2967                                            ((gint64)lci[2]<<16) | ((gint64)lci[3]<<8)  |
2968                                             (gint64)lci[4];
2969         }
2970         fixpoint->longitude_res = (lci[5]>>2) & 0x3F;  /* make sure that right-shift does not copy sign bit */
2971         if (lci[5] & 2) { /* LSB<<1 contains the sign of the latitude */
2972                 /* Longitude is negative, expand two's complement */
2973                 fixpoint->longitude = (((gint64)lci[5] & 3)<<32) | ((gint64)lci[6]<<24) |
2974                                             ((gint64)lci[7]<<16) | ((gint64)lci[8]<<8)  |
2975                                              (gint64)lci[9]      | ((gint64)0x3FFFFFFF<<34);
2976
2977         } else {
2978                 /* Longitude is positive */
2979                 fixpoint->longitude = (((gint64)lci[5] & 3)<<32) | ((gint64)lci[6]<<24) |
2980                                             ((gint64)lci[7]<<16) | ((gint64)lci[8]<<8)  |
2981                                              (gint64)lci[9];
2982         }
2983         fixpoint->altitude_type = (lci[10]>>4) & 0x0F;  /* make sure that right-shift does not copy sign bit */
2984         fixpoint->altitude_res  = ((lci[10] & 0x0F) << 2) | ((lci[11]>>6) & 0x03);
2985         if (lci[11] & 0x20) { /* LSB<<1 contains the sign of the latitude */
2986                 /* Altitude is negative, expand two's complement */
2987                 fixpoint->altitude = (((gint32)lci[11] & 0x3F)<<24) | ((gint32)lci[12]<<16) |
2988                                      ((gint32)lci[13]<<8) | ((gint32)lci[14]) |
2989                                       ((gint32)0x03<<30);
2990
2991         } else {
2992                 /* Altitude is positive */
2993                 fixpoint->altitude = (((gint32)lci[11] & 0x3F)<<24) | ((gint32)lci[12]<<16) |
2994                                      ((gint32)lci[13]<<8) | ((gint32)lci[14]);
2995         }
2996
2997         fixpoint->datum_type = lci[15];
2998
2999 }
3000
3001 /* RFC3825Decoder: http://www.enum.at/rfc3825encoder.529.0.html */
3002 static int
3003 rfc3825_fixpoint_to_decimal(struct rfc3825_location_fixpoint_t *fixpoint, struct rfc3825_location_decimal_t *decimal)
3004 {
3005         /* Latitude */
3006         decimal->latitude = (double) fixpoint->latitude / (1 << 25);
3007         if ((decimal->latitude > 90) || (decimal->latitude < -90)) {
3008                 return RFC3825_LATITUDE_OUTOFRANGE;
3009         }
3010
3011         /* Latitude Uncertainty */
3012         if (fixpoint->latitude_res > 34) {
3013                 return RFC3825_LATITUDE_UNCERTAINTY_OUTOFRANGE;
3014         }
3015         if (fixpoint->latitude_res > 8 ) {
3016                 decimal->latitude_res = (double) 1  / (1 << (fixpoint->latitude_res - 8));
3017         } else {
3018                 decimal->latitude_res = 1 << (8 - fixpoint->latitude_res);
3019         }
3020
3021         /* Longitude */
3022         decimal->longitude = (double) fixpoint->longitude / (1 << 25);
3023         if ((decimal->longitude > 180) || (decimal->longitude < -180)) {
3024                 return RFC3825_LONGITUDE_OUTOFRANGE;
3025         }
3026
3027         /* Longitude Uncertainty */
3028         if (fixpoint->longitude_res > 34) {
3029                 return RFC3825_LONGITUDE_UNCERTAINTY_OUTOFRANGE;
3030         }
3031         if (fixpoint->longitude_res > 8 ) {
3032                 decimal->longitude_res = (double) 1 / (1 << (fixpoint->longitude_res - 8));
3033         } else {
3034                 decimal->longitude_res = 1 << (8 - fixpoint->longitude_res);
3035         }
3036
3037         /* Altitude Type */
3038         decimal->altitude_type = fixpoint->altitude_type;
3039         decimal->altitude = 0;
3040         decimal->altitude_res = 0;
3041
3042         if (decimal->altitude_type == 0) { /* Unknown */
3043         } else if (decimal->altitude_type == 1) { /* Meters */
3044                 /* Altitude */
3045                 decimal->altitude = (double) fixpoint->altitude / (1 << 8);
3046                 if ((decimal->altitude > ((gint32) 1<<21)-1) || (decimal->altitude < ((gint32) -(1<<21))))
3047                         return RFC3825_ALTITUDE_OUTOFRANGE;
3048
3049                 /* Altitude Uncertainty */
3050                 if (fixpoint->altitude_res > 30) {
3051                         return RFC3825_ALTITUDE_UNCERTAINTY_OUTOFRANGE;
3052                 }
3053                 if (fixpoint->altitude_res > 21 ) {
3054                         decimal->altitude_res = (double) 1 / (1 << (fixpoint->altitude_res - 21));
3055                 } else {
3056                         decimal->altitude_res = 1 << (21 - fixpoint->altitude_res);
3057                 }
3058         } else if (decimal->altitude_type == 2) { /* Floors */
3059                 /* Altitude */
3060                 if ((fixpoint->altitude_res != 30) && (fixpoint->altitude_res != 0)) {
3061                         return RFC3825_ALTITUDE_UNCERTAINTY_OUTOFRANGE;
3062                 }
3063                 decimal->altitude = (double) fixpoint->altitude / (1 << 8);
3064         } else { /* invalid type */
3065                 return RFC3825_ALTITUDE_TYPE_OUTOFRANGE;
3066         }
3067
3068         /* Datum Type */
3069         decimal->datum_type = 0;
3070         if ((fixpoint->datum_type > 3) || (fixpoint->datum_type < 1)) {
3071                 return RFC3825_DATUM_TYPE_OUTOFRANGE;
3072         }
3073         decimal->datum_type = fixpoint->datum_type;
3074
3075         return RFC3825_NOERROR;
3076 }
3077
3078 static const value_string option43_cl_suboption_vals[] = {
3079         {  0, "Padding" },
3080         {  1, "Suboption Request List" },
3081         {  2, "Device Type" },
3082         {  3, "eSAFE Types" },
3083         {  4, "Serial Number" },
3084         {  5, "Hardware Version" },
3085         {  6, "Software Version" },
3086         {  7, "Boot ROM version" },
3087         {  8, "Organizationally Unique Identifier" },
3088         {  9, "Model Number" },
3089         { 10, "Vendor Name" },
3090         { 11, "Address Realm" },
3091         { 12, "CM/PS System Description" },
3092         { 13, "CM/PS Firmware Revision" },
3093         { 14, "Firewall Policy File Version" },
3094         { 15, "eSafe Config File Devices" },
3095         { 18, "Video Security Type" },
3096         { 31, "MTA MAC Address" },
3097         { 32, "Correlation ID" },
3098         { 51, "Vendor Name" },
3099         { 52, "CableCARD Capability" },
3100         { 53, "Device Identification (CA)" },
3101         { 54, "Device Identification (X.509)" },
3102         { 255, "CL End" },
3103         { 0, NULL}
3104 };
3105
3106 static const value_string cablehome_subopt11_vals[] = {
3107         { 1, "PS WAN-Man" },
3108         { 2, "PS WAN-Data" },
3109         { 0, NULL }
3110 };
3111
3112 static int
3113 dissect_vendor_cablelabs_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
3114                                    tvbuff_t *tvb, int optoff, int optend)
3115 {
3116         int         suboptoff = optoff;
3117         guint8      subopt;
3118         guint8      subopt_len;
3119         proto_tree *o43cl_v_tree;
3120         proto_item *vti;
3121
3122         struct basic_types_hfs default_hfs = {
3123                 &hf_bootp_option43_value,
3124                 NULL,
3125                 NULL,
3126                 &hf_bootp_option43_value_stringz,
3127                 NULL,
3128                 &hf_bootp_option43_value_8,
3129                 NULL,
3130                 NULL,
3131                 &hf_bootp_option43_value_32,
3132                 NULL,
3133                 NULL
3134         };
3135
3136         static struct opt_info o43cablelabs_opt[]= {
3137                 /*  0 */ {"nop", special, &hf_bootp_option43_cl_padding},       /* dummy */
3138                 /*  1 */ {"Suboption Request List", string, &hf_bootp_option43_cl_suboption_request_list},
3139                 /*  2 */ {"Device Type", string, &hf_bootp_option43_cl_device_type},
3140                 /*  3 */ {"eSAFE Types", string, &hf_bootp_option43_cl_esafe_type},
3141                 /*  4 */ {"Serial Number", string, &hf_bootp_option43_cl_serial_number},
3142                 /*  5 */ {"Hardware Version", string, &hf_bootp_option43_cl_hardware_version},
3143                 /*  6 */ {"Software Version", string, &hf_bootp_option43_cl_software_version},
3144                 /*  7 */ {"Boot ROM version", string, &hf_bootp_option43_cl_boot_rom_version},
3145                 /*  8 */ {"Organizationally Unique Identifier", special, &hf_bootp_option43_cl_oui_bytes},
3146                 /*  9 */ {"Model Number", string, &hf_bootp_option43_cl_model_number},
3147                 /* 10 */ {"Vendor Name", string, &hf_bootp_option43_cl_vendor_name10},
3148                 /* *** 11-30: CableHome *** */
3149                 /* 11 */ {"Address Realm", val_u_byte, &hf_bootp_option43_cl_address_realm},
3150                 /* 12 */ {"CM/PS System Description", string, &hf_bootp_option43_cl_cm_ps_system_desc},
3151                 /* 13 */ {"CM/PS Firmware Revision", string, &hf_bootp_option43_cl_cm_ps_firmware_revision},
3152                 /* 14 */ {"Firewall Policy File Version", string, &hf_bootp_option43_cl_firewall_policy_file_version},
3153                 /* 15 */ {"eSafe Config File Devices", string, &hf_bootp_option43_cl_esafe_config_file_devices},
3154                 /* 16 */ {"Unassigned (CableHome)", special, NULL},
3155                 /* 17 */ {"Unassigned (CableHome)", special, NULL},
3156                 /* 18 */ {"Video Security Type", string, &hf_bootp_option43_cl_video_security_tape},
3157                 /* 19 */ {"Unassigned (CableHome)", special, NULL},
3158                 /* 20 */ {"Unassigned (CableHome)", special, NULL},
3159                 /* 21 */ {"Unassigned (CableHome)", special, NULL},
3160                 /* 22 */ {"Unassigned (CableHome)", special, NULL},
3161                 /* 23 */ {"Unassigned (CableHome)", special, NULL},
3162                 /* 24 */ {"Unassigned (CableHome)", special, NULL},
3163                 /* 25 */ {"Unassigned (CableHome)", special, NULL},
3164                 /* 26 */ {"Unassigned (CableHome)", special, NULL},
3165                 /* 27 */ {"Unassigned (CableHome)", special, NULL},
3166                 /* 28 */ {"Unassigned (CableHome)", special, NULL},
3167                 /* 29 */ {"Unassigned (CableHome)", special, NULL},
3168                 /* 30 */ {"Unassigned (CableHome)", special, NULL},
3169                 /* *** 31-50: PacketCable *** */
3170                 /* 31 */ {"MTA MAC Address", special, &hf_bootp_option43_cl_mta_mac_address},
3171                 /* 32 */ {"Correlation ID", val_u_long, &hf_bootp_option43_cl_correlation_ID},
3172                 /* 33 */ {"Unassigned (PacketCable)", special, NULL},
3173                 /* 34 */ {"Unassigned (PacketCable)", special, NULL},
3174                 /* 35 */ {"Unassigned (PacketCable)", special, NULL},
3175                 /* 36 */ {"Unassigned (PacketCable)", special, NULL},
3176                 /* 37 */ {"Unassigned (PacketCable)", special, NULL},
3177                 /* 38 */ {"Unassigned (PacketCable)", special, NULL},
3178                 /* 39 */ {"Unassigned (PacketCable)", special, NULL},
3179                 /* 40 */ {"Unassigned (PacketCable)", special, NULL},
3180                 /* 41 */ {"Unassigned (PacketCable)", special, NULL},
3181                 /* 42 */ {"Unassigned (PacketCable)", special, NULL},
3182                 /* 43 */ {"Unassigned (PacketCable)", special, NULL},
3183                 /* 44 */ {"Unassigned (PacketCable)", special, NULL},
3184                 /* 45 */ {"Unassigned (PacketCable)", special, NULL},
3185                 /* 46 */ {"Unassigned (PacketCable)", special, NULL},
3186                 /* 47 */ {"Unassigned (PacketCable)", special, NULL},
3187                 /* 48 */ {"Unassigned (PacketCable)", special, NULL},
3188                 /* 49 */ {"Unassigned (PacketCable)", special, NULL},
3189                 /* 50 */ {"Unassigned (PacketCable)", special, NULL},
3190                 /* *** 51-127: CableLabs *** */
3191                 /* 51 */ {"Vendor Name", string, &hf_bootp_option43_cl_vendor_name51},
3192                 /* 52 */ {"CableCARD Capability", special, &hf_bootp_option43_cl_cablecard_capability},
3193                 /* 53 */ {"Device Identification (CA)", special, &hf_bootp_option43_cl_device_id_ca},
3194                 /* 54 */ {"Device Identification (X.509)", string, &hf_bootp_option43_cl_device_id_x509},
3195                 /* 55 */ {"Unassigned (CableLabs)", special, NULL},
3196                 /* *** 128-254: Vendors *** */
3197                 /* 128-254 {"Unassigned (Vendors)", special, NULL}, */
3198                 /* 255 {"end options", special, &hf_bootp_option43_cl_end} */
3199         };
3200
3201         subopt = tvb_get_guint8(tvb, optoff);
3202         suboptoff++;
3203
3204         if (subopt == 0) {
3205                 proto_tree_add_item(v_tree, hf_bootp_option43_cl_padding, tvb, optoff, 1, ENC_BIG_ENDIAN);
3206                 return (suboptoff);
3207         } else if (subopt == 255) {     /* End Option */
3208                 proto_tree_add_item(v_tree, hf_bootp_option43_cl_end, tvb, optoff, 1, ENC_BIG_ENDIAN);
3209                 /* Make sure we skip any junk left this option */
3210                 return (optend);
3211         }
3212
3213         if (suboptoff >= optend) {
3214                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
3215                                                                         "Suboption %d: no room left in option for suboption length", subopt);
3216                 return (optend);
3217         }
3218
3219         subopt_len = tvb_get_guint8(tvb, suboptoff);
3220         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option43_cl_suboption,
3221                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
3222                                 subopt, val_to_str_const(subopt, option43_cl_suboption_vals, "Unknown"));
3223
3224         o43cl_v_tree = proto_item_add_subtree(vti, ett_bootp_option43_suboption);
3225         proto_tree_add_item(o43cl_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3226         suboptoff++;
3227
3228         if (suboptoff+subopt_len > optend) {
3229                 expert_add_info_format_text(pinfo, vti, &ei_bootp_missing_subopt_value,
3230                                                 "Suboption %d: no room left in option for suboption value", subopt);
3231                 return (optend);
3232         }
3233
3234         if ( (subopt < 1 ) || (subopt >= array_length(o43cablelabs_opt)) ) {
3235                 proto_tree_add_item(o43cl_v_tree, hf_bootp_option43_value, tvb, suboptoff, subopt_len, ENC_NA);
3236         } else if (o43cablelabs_opt[subopt].ftype == special) {
3237                 switch(subopt)
3238                 {
3239                 case 8:/* OUI */
3240                         /* CableLabs specs treat 43.8 inconsistently
3241                          * as either binary (3b) or string (6b) */
3242                         if (subopt_len == 3) {
3243                                 proto_tree_add_bytes_format_value(o43cl_v_tree, hf_bootp_option43_cl_oui_bytes, tvb, suboptoff, subopt_len, NULL,
3244                                         "%02x:%02x:%02x", tvb_get_guint8(tvb, suboptoff), tvb_get_guint8(tvb, suboptoff+1), tvb_get_guint8(tvb, suboptoff+2));
3245                         } else if (subopt_len == 6) {
3246                                 proto_tree_add_item(o43cl_v_tree, hf_bootp_option43_cl_oui_string, tvb, suboptoff, subopt_len, ENC_ASCII|ENC_NA);
3247                         } else {
3248                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 3 or 6");
3249                         }
3250                         break;
3251                 case 31: /* MTA MAC address */
3252                         if (subopt_len != 6) {
3253                                 expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 6");
3254                                 break;
3255                         }
3256
3257                         proto_tree_add_item(o43cl_v_tree, hf_bootp_option43_cl_mta_mac_address, tvb, suboptoff, 6, ENC_NA);
3258                         break;
3259                 default:
3260                         if (o43cablelabs_opt[subopt].phf != NULL)
3261                                 proto_tree_add_item(o43cl_v_tree, *o43cablelabs_opt[subopt].phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN);
3262                         else
3263                                 proto_tree_add_item(o43cl_v_tree, hf_bootp_option43_value, tvb, suboptoff, subopt_len, ENC_NA);
3264                 }
3265         }
3266         else {
3267                 if (bootp_handle_basic_types(pinfo, o43cl_v_tree, vti, tvb, o43cablelabs_opt[subopt].ftype,
3268                                                         suboptoff, subopt_len, o43cablelabs_opt[subopt].phf, &default_hfs) == 0) {
3269                         expert_add_info_format_text(pinfo, vti, &hf_bootp_subopt_unknown_type, "ERROR, please report: Unknown subopt type handler %d", subopt);
3270                 }
3271         }
3272
3273         optoff += (subopt_len + 2);
3274         return optoff;
3275 }
3276
3277 static const value_string option43_alcatel_suboption_vals[] = {
3278         {  0, "Padding" },
3279         { 58, "Voice VLAN ID" },
3280         { 64, "Spatial Redundancy TFTP1" },
3281         { 65, "Spatial Redundancy TFTP2" },
3282         { 66, "Application Type" },
3283         { 67, "SIP URL" },
3284         { 255, "Alcatel-Lucent End" },
3285         { 0, NULL}
3286 };
3287
3288 static const value_string option43_alcatel_app_type_vals[] = {
3289         { 0, "NOE" },
3290         { 1, "SIP" },
3291         { 0, NULL}
3292 };
3293
3294 static int
3295 dissect_vendor_alcatel_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
3296                                  tvbuff_t *tvb, int optoff, int optend)
3297 {
3298         int         suboptoff = optoff;
3299         guint8      subopt;
3300         guint8      subopt_len;
3301         proto_item *vti;
3302         proto_tree *o43alcatel_v_tree;
3303
3304         subopt = tvb_get_guint8(tvb, optoff);
3305         suboptoff++;
3306
3307         if (subopt == 0) {
3308                 proto_tree_add_item(v_tree, hf_bootp_option43_alcatel_padding, tvb, optoff, 1, ENC_BIG_ENDIAN);
3309                 return (suboptoff);
3310         } else if (subopt == 255) {     /* End Option */
3311                 proto_tree_add_item(v_tree, hf_bootp_option43_alcatel_end, tvb, optoff, 1, ENC_BIG_ENDIAN);
3312                 /* Make sure we skip any junk left this option */
3313                 return (optend);
3314         }
3315
3316         if (suboptoff >= optend) {
3317                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
3318                                                                         "Suboption %d: no room left in option for suboption length", subopt);
3319                 return (optend);
3320         }
3321
3322         subopt_len = tvb_get_guint8(tvb, suboptoff);
3323         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option43_alcatel_suboption,
3324                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
3325                                 subopt, val_to_str_const(subopt, option43_alcatel_suboption_vals, "Unknown"));
3326
3327         o43alcatel_v_tree = proto_item_add_subtree(vti, ett_bootp_option43_suboption);
3328         proto_tree_add_item(o43alcatel_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3329         suboptoff++;
3330
3331         if (suboptoff+subopt_len > optend) {
3332                 expert_add_info_format_text(pinfo, vti, &ei_bootp_missing_subopt_value,
3333                                                 "Suboption %d: no room left in option for suboption value", subopt);
3334                 return (optend);
3335         }
3336
3337         switch (subopt)
3338         {
3339         case 58: /* 0x3A - Alcatel-Lucent AVA VLAN Id */
3340                 if (subopt_len != 2) {
3341                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 2");
3342                         return (optend);
3343                 }
3344
3345                 proto_tree_add_item(o43alcatel_v_tree, hf_bootp_option43_alcatel_vlan_id, tvb, suboptoff, 2, ENC_BIG_ENDIAN);
3346                 break;
3347         case 64: /* 0x40 - Alcatel-Lucent TFTP1 */
3348                 if (subopt_len != 4) {
3349                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 4");
3350                         return (optend);
3351                 }
3352
3353                 proto_tree_add_item(o43alcatel_v_tree, hf_bootp_option43_alcatel_tftp1, tvb, suboptoff, 4, ENC_BIG_ENDIAN);
3354                 break;
3355         case 65: /* 0x41 - Alcatel-Lucent TFTP2 */
3356                 if (subopt_len != 4) {
3357                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 4");
3358                         return (optend);
3359                 }
3360
3361                 proto_tree_add_item(o43alcatel_v_tree, hf_bootp_option43_alcatel_tftp2, tvb, suboptoff, 4, ENC_BIG_ENDIAN);
3362                 break;
3363         case 66: /* 0x42 - Alcatel-Lucent APPLICATION TYPE */
3364                 if (subopt_len != 1) {
3365                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 1");
3366                         return (optend);
3367                 }
3368                 proto_tree_add_item(o43alcatel_v_tree, hf_bootp_option43_alcatel_app_type, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3369                 break;
3370         case 67: /* 0x43 - Alcatel-Lucent SIP URL */
3371                 proto_tree_add_item(o43alcatel_v_tree, hf_bootp_option43_alcatel_sip_url, tvb, suboptoff, subopt_len, ENC_ASCII|ENC_NA);
3372                 break;
3373         default:
3374                 expert_add_info_format_text(pinfo, vti, &hf_bootp_subopt_unknown_type, "ERROR, please report: Unknown subopt type handler %d", subopt);
3375                 return optend;
3376         }
3377
3378         optoff += (subopt_len + 2);
3379         return optoff;
3380 }
3381
3382 static const value_string option63_suboption_vals[] = {
3383         { 1, "NWIP does not exist on subnet" },
3384         { 2, "NWIP exists in options area" },
3385         { 3, "NWIP exists in sname/file" },
3386         { 4, "NWIP exists, but too big" },
3387         { 5, "Broadcast for nearest Netware server" },
3388         { 6, "Preferred DSS server" },
3389         { 7, "Nearest NWIP server" },
3390         { 8, "Autoretries" },
3391         { 9, "Autoretry delay, secs" },
3392         { 10, "Support NetWare/IP v1.1" },
3393         { 11, "Primary DSS" },
3394         { 0, NULL }
3395 };
3396
3397 static int
3398 dissect_netware_ip_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
3399                              tvbuff_t *tvb, int optoff, int optend)
3400 {
3401         int         suboptoff = optoff;
3402         guint8      subopt, subopt_len;
3403         proto_tree *o63_v_tree;
3404         proto_item *vti, *ti;
3405
3406         struct basic_types_hfs default_hfs = {
3407                 NULL,
3408                 &hf_bootp_option63_value_ip_address,
3409                 &hf_bootp_option63_value_ip_address,
3410                 NULL,
3411                 &hf_bootp_option63_value_boolean,
3412                 &hf_bootp_option63_value_8,
3413                 NULL,
3414                 NULL,
3415                 NULL,
3416                 NULL,
3417                 NULL
3418         };
3419
3420         static struct opt_info o63_opt[]= {
3421                 /* 0 */ {"",none,NULL},
3422                 /* 1 */ {"NWIP does not exist on subnet",presence,NULL},
3423                 /* 2 */ {"NWIP exists in options area",presence,NULL},
3424                 /* 3 */ {"NWIP exists in sname/file",presence,NULL},
3425                 /* 4 */ {"NWIP exists, but too big",presence,NULL},
3426                 /* 5 */ {"Broadcast for nearest Netware server",val_boolean, &hf_bootp_option63_broadcast},
3427                 /* 6 */ {"Preferred DSS server",ipv4_list,&hf_bootp_option63_preferred_dss_server},
3428                 /* 7 */ {"Nearest NWIP server",ipv4_list,&hf_bootp_option63_nearest_nwip_server},
3429                 /* 8 */ {"Autoretries",val_u_byte,&hf_bootp_option63_autoretries},
3430                 /* 9 */ {"Autoretry delay, secs",val_u_byte,&hf_bootp_option63_autoretry_delay},
3431                 /* 10*/ {"Support NetWare/IP v1.1",val_boolean,&hf_bootp_option63_support_netware_v1_1},
3432                 /* 11*/ {"Primary DSS",ipv4,&hf_bootp_option63_primary_dss}
3433         };
3434
3435         subopt = tvb_get_guint8(tvb, optoff);
3436         suboptoff++;
3437
3438         if (suboptoff >= optend) {
3439                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
3440                                                                         "Suboption %d: no room left in option for suboption length", subopt);
3441                 return (optend);
3442         }
3443
3444         subopt_len = tvb_get_guint8(tvb, suboptoff);
3445         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option63_suboption,
3446                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
3447                                 subopt, val_to_str_const(subopt, option63_suboption_vals, "Unknown"));
3448
3449         o63_v_tree = proto_item_add_subtree(vti, ett_bootp_option63_suboption);
3450         proto_tree_add_item(o63_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3451         suboptoff++;
3452
3453         ti = proto_tree_add_item(o63_v_tree, hf_bootp_option63_value, tvb, suboptoff, subopt_len, ENC_NA);
3454         PROTO_ITEM_SET_HIDDEN(ti);
3455
3456         if (subopt < array_length(o63_opt)) {
3457                 if (bootp_handle_basic_types(pinfo, o63_v_tree, vti, tvb, o63_opt[subopt].ftype,
3458                                                         suboptoff, subopt_len, o63_opt[subopt].phf, &default_hfs) == 0) {
3459                         switch(o63_opt[subopt].ftype)
3460                         {
3461                         case presence:
3462                                 if (subopt_len != 0) {
3463                                         expert_add_info_format_text(pinfo, vti, &ei_bootp_bad_length, "length isn't 0");
3464                                 }
3465                                 break;
3466                         default:
3467                                 if (o63_opt[subopt].phf == NULL)
3468                                         proto_tree_add_item(o63_v_tree, hf_bootp_option63_value, tvb, suboptoff, subopt_len, ENC_NA);
3469                                 break;
3470                         }
3471                 }
3472         }
3473         optoff += (subopt_len + 2);
3474         return optoff;
3475 }
3476
3477 static const value_string option125_tr111_suboption_vals[] = {
3478         { 1, "DeviceManufacturerOUI" },
3479         { 2, "DeviceSerialNumber" },
3480         { 3, "DeviceProductClass" },
3481         { 4, "GatewayManufacturerOUI" },
3482         { 5, "GatewaySerialNumber" },
3483         { 6, "GatewayProductClass" },
3484         { 0, NULL }
3485 };
3486
3487 static int
3488 dissect_vendor_tr111_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
3489                                tvbuff_t *tvb, int optoff, int optend)
3490 {
3491         int         suboptoff = optoff;
3492         proto_tree *o125_v_tree;
3493         proto_item *vti, *ti;
3494         guint8      subopt, subopt_len;
3495
3496         struct basic_types_hfs default_hfs = {
3497                 NULL,
3498                 NULL,
3499                 NULL,
3500                 &hf_bootp_option125_value_stringz,
3501                 NULL,
3502                 NULL,
3503                 NULL,
3504                 NULL,
3505                 NULL,
3506                 NULL,
3507                 NULL
3508         };
3509
3510         /* Reference: TR-111 DHCP Option 125 Sub-Option Data Fields
3511            Page 10.
3512         */
3513
3514         static struct opt_info o125_tr111_opt[]= {
3515                 /* 0 */ {"nop", special, NULL}, /* dummy */
3516                 /* 1 */ {"DeviceManufacturerOUI", string, &hf_bootp_option125_tr111_device_manufacturer_oui},
3517                 /* 2 */ {"DeviceSerialNumber", string, &hf_bootp_option125_tr111_device_serial_number},
3518                 /* 3 */ {"DeviceProductClass", string, &hf_bootp_option125_tr111_device_product_class},
3519                 /* 4 */ {"GatewayManufacturerOUI", string, &hf_bootp_option125_tr111_gateway_manufacturer_oui},
3520                 /* 5 */ {"GatewaySerialNumber", string, &hf_bootp_option125_tr111_gateway_serial_number},
3521                 /* 6 */ {"GatewayProductClass", string, &hf_bootp_option125_tr111_gateway_product_class},
3522         };
3523
3524         subopt = tvb_get_guint8(tvb, optoff);
3525         suboptoff++;
3526
3527         if (suboptoff >= optend) {
3528                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
3529                                                                         "Suboption %d: no room left in option for suboption length", subopt);
3530                 return (optend);
3531         }
3532
3533         subopt_len = tvb_get_guint8(tvb, suboptoff);
3534         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option125_tr111_suboption,
3535                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
3536                                 subopt, val_to_str_const(subopt, option125_tr111_suboption_vals, "Unknown"));
3537
3538         o125_v_tree = proto_item_add_subtree(vti, hf_bootp_option125_tr111_suboption);
3539         proto_tree_add_item(o125_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3540         suboptoff++;
3541
3542         if (suboptoff+subopt_len > optend) {
3543                 expert_add_info_format_text(pinfo, vti, &ei_bootp_missing_subopt_value,
3544                                                 "Suboption %d: no room left in option for suboption value", subopt);
3545                 return (optend);
3546         }
3547
3548         ti = proto_tree_add_item(v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA);
3549         PROTO_ITEM_SET_HIDDEN(ti);
3550
3551         if (subopt < array_length(o125_tr111_opt)) {
3552                 if (bootp_handle_basic_types(pinfo, o125_v_tree, vti, tvb, o125_tr111_opt[subopt].ftype,
3553                                                         suboptoff, subopt_len, o125_tr111_opt[subopt].phf, &default_hfs) == 0) {
3554                         if (o125_tr111_opt[subopt].ftype == special) {
3555                                 if (o125_tr111_opt[subopt].phf != NULL)
3556                                    proto_tree_add_item(v_tree, *o125_tr111_opt[subopt].phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN);
3557                                 else
3558                                    proto_tree_add_item(v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA);
3559                         } else if (o125_tr111_opt[subopt].phf == NULL)
3560                                 proto_tree_add_item(v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA);
3561                 }
3562         }
3563
3564         optoff += (subopt_len + 2);
3565         return optoff;
3566 }
3567
3568 static const value_string option125_cl_suboption_vals[] = {
3569         { 1, "Option Request" },
3570         { 2, "TFTP Server Addresses" },
3571         { 3, "eRouter Container Option" },
3572         { 4, "MIB Environment Indicator Option" },
3573         { 5, "Modem Capabilities" },
3574         { 0, NULL }
3575 };
3576
3577 static const value_string pkt_mib_env_ind_opt_vals[] = {
3578         { 0x00, "Reserved" },
3579         { 0x01, "CableLabs" },
3580         { 0x02, "IETF" },
3581         { 0x03, "EuroCableLabs" },
3582         { 0, NULL }
3583 };
3584
3585 static int
3586 dissect_vendor_cl_suboption(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
3587                             tvbuff_t *tvb, int optoff, int optend)
3588 {
3589         int         suboptoff = optoff;
3590         guint8      subopt, subopt_len;
3591         proto_tree *o125_v_tree;
3592         proto_item *vti;
3593
3594         struct basic_types_hfs default_hfs = {
3595                 &hf_bootp_option125_value,
3596                 &hf_bootp_option125_value_ip_address,
3597                 &hf_bootp_option125_value_ip_address,
3598                 &hf_bootp_option125_value_stringz,
3599                 NULL,
3600                 &hf_bootp_option125_value_8,
3601                 &hf_bootp_option125_value_16,
3602                 NULL,
3603                 NULL,
3604                 NULL,
3605                 NULL
3606         };
3607
3608         static struct opt_info o125_cl_opt[]= {
3609                 /* 0 */ {"nop", special, NULL}, /* dummy */
3610                 /* 1 */ {"Option Request = ", val_u_byte, &hf_bootp_option125_cl_option_request},
3611                 /* 2 */ {"TFTP Server Addresses : ", ipv4_list, &hf_bootp_option125_cl_tftp_server_addresses},
3612                 /* 3 */ {"eRouter Container Option : ", bytes, &hf_bootp_option125_cl_erouter_container_option},
3613                 /* 4 */ {"MIB Environment Indicator Option = ", val_u_byte, &hf_bootp_option125_cl_mib_environment_indicator_option},
3614                 /* 5 */ {"Modem Capabilities : ", special, &hf_bootp_option125_cl_modem_capabilities},
3615         };
3616
3617         subopt = tvb_get_guint8(tvb, optoff);
3618         suboptoff++;
3619
3620         if (suboptoff >= optend) {
3621                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
3622                                                                         "Suboption %d: no room left in option for suboption length", subopt);
3623                 return (optend);
3624         }
3625
3626         subopt_len = tvb_get_guint8(tvb, suboptoff);
3627         vti = proto_tree_add_uint_format_value(v_tree, hf_bootp_option125_cl_suboption,
3628                                 tvb, optoff, subopt_len+2, subopt, "(%d) %s",
3629                                 subopt, val_to_str_const(subopt, option125_cl_suboption_vals, "Unknown"));
3630
3631         o125_v_tree = proto_item_add_subtree(vti, hf_bootp_option125_cl_suboption);
3632         proto_tree_add_item(o125_v_tree, hf_bootp_suboption_length, tvb, suboptoff, 1, ENC_BIG_ENDIAN);
3633         suboptoff++;
3634
3635         if (suboptoff+subopt_len > optend) {
3636                 expert_add_info_format_text(pinfo, vti, &ei_bootp_missing_subopt_value,
3637                                                 "Suboption %d: no room left in option for suboption value", subopt);
3638                 return (optend);
3639         }
3640
3641         if (subopt < array_length(o125_cl_opt)) {
3642                 if (bootp_handle_basic_types(pinfo, o125_v_tree, vti, tvb, o125_cl_opt[subopt].ftype,
3643                                                         suboptoff, subopt_len, o125_cl_opt[subopt].phf, &default_hfs) == 0) {
3644
3645                         switch(o125_cl_opt[subopt].ftype) {
3646                         case special:
3647                                 if (o125_cl_opt[subopt].phf != NULL)
3648                                    proto_tree_add_item(o125_v_tree, *o125_cl_opt[subopt].phf, tvb, suboptoff, subopt_len, ENC_BIG_ENDIAN);
3649                                 else
3650                                    proto_tree_add_item(o125_v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA);
3651
3652                                         dissect_docsis_cm_cap(o125_v_tree, tvb, optoff, subopt_len+2, TRUE);
3653                                 break;
3654                         default:
3655                                 if (o125_cl_opt[subopt].phf == NULL)
3656                                    proto_tree_add_item(o125_v_tree, hf_bootp_option125_value, tvb, suboptoff, subopt_len, ENC_NA);
3657                                 break;
3658                         }
3659                 }
3660         }
3661
3662         optoff += (subopt_len + 2);
3663         return optoff;
3664 }
3665
3666 /* PacketCable Multimedia Terminal Adapter device capabilities (option 60).
3667    Ref: PKT-SP-I05-021127 sections 8.2 and 10 */
3668
3669 #define PKT_MDC_TLV_OFF 10
3670
3671
3672 /* These are ASCII-encoded hexadecimal digits.  We use the raw hex equivalent for
3673    convenience. */
3674 #define PKT_MDC_VERSION                 0x3031  /* "01" */
3675 #define PKT_MDC_TEL_END                 0x3032  /* "02" */
3676 #define PKT_MDC_TGT                     0x3033  /* "03" */
3677 #define PKT_MDC_HTTP_ACC                0x3034  /* "04" */
3678 #define PKT_MDC_SYSLOG                  0x3035  /* "05" */
3679 #define PKT_MDC_NCS                     0x3036  /* "06" */
3680 #define PKT_MDC_PRI_LINE                0x3037  /* "07" */
3681 #define PKT_MDC_VENDOR_TLV              0x3038  /* "08" */
3682 #define PKT_MDC_NVRAM_STOR              0x3039  /* "09" */
3683 #define PKT_MDC_PROV_REP                0x3041  /* "0A" */
3684 #define PKT_MDC_PROV_REP_LC             0x3061  /* "0a" */
3685 #define PKT_MDC_SUPP_CODECS             0x3042  /* "0B" */
3686 #define PKT_MDC_SUPP_CODECS_LC          0x3062  /* "0b" */
3687 #define PKT_MDC_SILENCE                 0x3043  /* "0C" */
3688 #define PKT_MDC_SILENCE_LC              0x3063  /* "0c" */
3689 #define PKT_MDC_ECHO_CANCEL             0x3044  /* "0D" */
3690 #define PKT_MDC_ECHO_CANCEL_LC          0x3064  /* "0d" */
3691 #define PKT_MDC_RSVP                    0x3045  /* "0E" */
3692 #define PKT_MDC_RSVP_LC                 0x3065  /* "0e" */
3693 #define PKT_MDC_UGS_AD                  0x3046  /* "0F" */
3694 #define PKT_MDC_UGS_AD_LC               0x3066  /* "0f" */
3695 #define PKT_MDC_IF_INDEX                0x3130  /* "10" */
3696 #define PKT_MDC_FLOW_LOG                0x3131  /* "11" */
3697 #define PKT_MDC_PROV_FLOWS              0x3132  /* "12" */
3698 /* PacketCable 1.5: */
3699 #define PKT_MDC_T38_VERSION             0x3133  /* "13" */
3700 #define PKT_MDC_T38_EC                  0x3134  /* "14" */
3701 #define PKT_MDC_RFC2833_DTMF            0x3135  /* "15" */
3702 #define PKT_MDC_VOICE_METRICS           0x3136  /* "16" */
3703 #define PKT_MDC_MIBS                    0x3137  /* "17" */
3704 #define PKT_MDC_MGPI                    0x3138  /* "18" */
3705 #define PKT_MDC_V152                    0x3139  /* "19" */
3706 #define PKT_MDC_CBS                     0x3141  /* "1A" */
3707 #define PKT_MDC_CBS_LC                  0x3161  /* "1a" */
3708
3709 static const value_string pkt_mdc_type_vals[] = {
3710         { PKT_MDC_VERSION,              "PacketCable Version" },
3711         { PKT_MDC_TEL_END,              "Number Of Telephony Endpoints" },
3712         { PKT_MDC_TGT,                  "TGT Support" },
3713         { PKT_MDC_HTTP_ACC,             "HTTP Download File Access Method Support" },
3714         { PKT_MDC_SYSLOG,               "MTA-24 Event SYSLOG Notification Support" },
3715         { PKT_MDC_NCS,                  "NCS Service Flow Support" },
3716         { PKT_MDC_PRI_LINE,             "Primary Line Support" },
3717         { PKT_MDC_VENDOR_TLV,           "Vendor Specific TLV Type(s)" },
3718         { PKT_MDC_NVRAM_STOR,           "NVRAM Ticket/Session Keys Storage Support" },
3719         { PKT_MDC_PROV_REP,             "Provisioning Event Reporting Support" },
3720         { PKT_MDC_PROV_REP_LC,          "Provisioning Event Reporting Support" },
3721         { PKT_MDC_SUPP_CODECS,          "Supported CODEC(s)" },
3722         { PKT_MDC_SUPP_CODECS_LC,       "Supported CODEC(s)" },
3723         { PKT_MDC_SILENCE,              "Silence Suppression Support" },
3724         { PKT_MDC_SILENCE_LC,           "Silence Suppression Support" },
3725         { PKT_MDC_ECHO_CANCEL,          "Echo Cancellation Support" },
3726         { PKT_MDC_ECHO_CANCEL_LC,       "Echo Cancellation Support" },
3727         { PKT_MDC_RSVP,                 "RSVP Support/ Reserved" },
3728         { PKT_MDC_RSVP_LC,              "RSVP Support/ Reserved" },
3729         { PKT_MDC_UGS_AD,               "UGS-AD Support" },
3730         { PKT_MDC_UGS_AD_LC,            "UGS-AD Support" },
3731         { PKT_MDC_IF_INDEX,             "MTA's \"ifIndex\" starting number in \"ifTable\"" },
3732         { PKT_MDC_FLOW_LOG,             "Provisioning Flow Logging Support" },
3733         { PKT_MDC_PROV_FLOWS,           "Supported Provisioning Flows" },
3734         /* PacketCable 1.5: */
3735         { PKT_MDC_T38_VERSION,          "T38 Version Support" },
3736         { PKT_MDC_T38_EC,               "T38 Error Correction Support" },
3737         { PKT_MDC_RFC2833_DTMF,         "RFC 2833 DTMF Support" },
3738         { PKT_MDC_VOICE_METRICS,        "Voice Metrics Support" },
3739         { PKT_MDC_MIBS,                 "MIB Support" },
3740         { PKT_MDC_MGPI,                 "Multiple Grants Per Interval Support" },
3741         { PKT_MDC_V152,                 "V.152 Support" },
3742         /* PacketCable 2.0: */
3743         { PKT_MDC_CBS,                  "Certificate Bootstrapping Support" },
3744         { PKT_MDC_CBS_LC,               "Certificate Bootstrapping Support" },
3745         { 0,                            NULL }
3746 };
3747
3748 static const value_string pkt_mdc_version_vals[] = {
3749         { 0x3030,       "PacketCable 1.0" },
3750         { 0x3031,       "PacketCable 1.1/1.5" }, /* 1.5 replaces 1.1-1.3 */
3751         { 0x3032,       "PacketCable 2.0" },
3752         { 0,            NULL }
3753 };
3754
3755 static const value_string pkt_mdc_boolean_vals[] = {
3756         { 0x3030,       "No" },
3757         { 0x3031,       "Yes" },
3758         { 0,            NULL }
3759 };
3760
3761 static const value_string pkt_mdc_codec_vals[] = {
3762         { 0x3031,       "other" },           /* "01" */
3763         { 0x3032,       "unknown" },
3764         { 0x3033,       "G.729" },
3765         { 0x3034,       "reserved" },
3766         { 0x3035,       "G.729E" },
3767         { 0x3036,       "PCMU" },
3768         { 0x3037,       "G.726-32" },
3769         { 0x3038,       "G.728" },
3770         { 0x3039,       "PCMA" },            /* "09" */
3771         { 0x3041,       "G.726-16" },        /* "0A" */
3772         { 0x3042,       "G.726-24" },
3773         { 0x3043,       "G.726-40" },
3774         { 0x3044,       "iLBC" },
3775         { 0x3045,       "BV16" },
3776         { 0x3046,       "telephone-event" }, /* "0F" */
3777         { 0,            NULL }
3778 };
3779
3780 static const value_string pkt_mdc_t38_version_vals[] = {
3781         { 0x3030,       "Unsupported" },
3782         { 0x3031,       "T.38 Version Zero" }, /* default */
3783         { 0x3032,       "T.38 Version One" },
3784         { 0x3033,       "T.38 Version Two" },
3785         { 0x3035,       "T.38 Version Three" },
3786         { 0,            NULL }
3787 };
3788
3789 static const value_string pkt_mdc_t38_ec_vals[] = {
3790         { 0x3030,       "None" },
3791         { 0x3031,       "Redundancy" }, /* default */
3792         { 0x3032,       "FEC" },
3793         { 0,            NULL }
3794 };
3795
3796 static const value_string pkt_mdc_mib_orgs[] = {
3797         { 0x3030,       "CableLabs" },
3798         { 0x3031,       "IETF" },
3799         { 0x3032,       "EuroCableLabs" },
3800         { 0x3033,       "Reserved" },
3801         { 0x3034,       "Reserved" },
3802         { 0x3035,       "Reserved" },
3803         { 0x3036,       "Reserved" },
3804         { 0x3037,       "Reserved" },
3805         { 0x3038,       "Reserved" },
3806         { 0x3039,       "Reserved" },
3807         { 0,            NULL }
3808 };
3809
3810 static const value_string pkt_mdc_supp_flow_vals[] = {
3811         { 1 << 0, "Secure Flow (Full Secure Provisioning Flow)" },
3812         { 1 << 1, "Hybrid Flow" },
3813         { 1 << 2, "Basic Flow" },
3814         { 0, NULL }
3815 };
3816
3817 #define PKT_MDC_MIB_CL 0x3030
3818 static const value_string pkt_mdc_cl_mib_vals[] = {
3819         { 1 << 0, "PacketCable 1.5 MTA MIB" },
3820         { 1 << 1, "PacketCable 1.5 Signaling MIB" },
3821         { 1 << 2, "PacketCable 1.5 Management Event MIB" },
3822         { 1 << 3, "PacketCable 1.5 MTA Extension MIB" },
3823         { 1 << 4, "PacketCable 1.5 Signaling Extension MIB" },
3824         { 1 << 5, "PacketCable 1.5 MEM Extension MIB" },
3825         { 1 << 6, "Reserved" },
3826         { 1 << 7, "Reserved" },
3827         { 0, NULL }
3828 };
3829
3830 #define PKT_MDC_MIB_IETF 0x3031
3831 static const value_string pkt_mdc_ietf_mib_vals[] = {
3832         { 1 << 0, "IETF MTA MIB" },
3833         { 1 << 1, "IETF Signaling MIB" },
3834         { 1 << 2, "IETF Management Event MIB" },
3835         { 1 << 3, "Reserved" },
3836         { 1 << 4, "Reserved" },
3837         { 1 << 5, "Reserved" },
3838         { 1 << 6, "Reserved" },
3839         { 1 << 7, "Reserved" },
3840         { 0, NULL }
3841 };
3842
3843 #define PKT_MDC_MIB_EURO 0x3032
3844 static const value_string pkt_mdc_euro_mib_vals[] = {
3845         { 1 << 0, "PacketCable 1.5 MTA MIB" },
3846         { 1 << 1, "PacketCable 1.5 Signaling MIB" },
3847         { 1 << 2, "PacketCable 1.5 Management Event MIB" },
3848         { 1 << 3, "PacketCable 1.5 MTA Extension MIB" },
3849         { 1 << 4, "PacketCable 1.5 Signaling Extension MIB" },
3850         { 1 << 5, "PacketCable 1.5 MEM Extension MIB" },
3851         { 1 << 6, "Reserved" },
3852         { 1 << 7, "Reserved" },
3853         { 0, NULL }
3854 };
3855
3856
3857 static void
3858 dissect_packetcable_mta_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len)
3859 {
3860         guint16        raw_val;
3861         unsigned long  flow_val   = 0;
3862         int            off        = PKT_MDC_TLV_OFF + voff;
3863         int            subopt_off, max_len;
3864         guint          tlv_len, i, mib_val;
3865         guint8         asc_val[3] = "  ", flow_val_str[5];
3866         char           bit_fld[64];
3867         proto_item    *ti, *mib_ti;
3868         proto_tree    *subtree, *subtree2;
3869
3870         tvb_memcpy (tvb, asc_val, off, 2);
3871         if (sscanf((gchar*)asc_val, "%x", &tlv_len) != 1 || tlv_len > 0xff) {
3872                 proto_tree_add_text(v_tree, tvb, off, len - off,
3873                         "Bogus length: %s", asc_val);
3874                 return;
3875         } else {
3876                 proto_tree_add_uint_format_value(v_tree, hf_bootp_pkt_mta_cap_len, tvb, off, 2,
3877                                 tlv_len, "%d", tlv_len);
3878                 off += 2;
3879
3880                 while (off - voff < len) {
3881                         /* Type */
3882                         raw_val = tvb_get_ntohs (tvb, off);
3883
3884                         /* Length */
3885                         tvb_memcpy(tvb, asc_val, off + 2, 2);
3886                         if (sscanf((gchar*)asc_val, "%x", &tlv_len) != 1
3887                             || tlv_len < 1 || tlv_len > G_MAXUINT16) {
3888                                 proto_tree_add_text(v_tree, tvb, off, len - off,
3889                                                     "[Bogus length: %s]", asc_val);
3890                                 return;
3891                         } else {
3892                                 /* Value(s) */
3893
3894                                 ti = proto_tree_add_text(v_tree,
3895                                     tvb, off, (tlv_len * 2) + 4,
3896                                     "0x%s: %s = ",
3897                                     tvb_format_text(tvb, off, 2),
3898                                     val_to_str_const(raw_val, pkt_mdc_type_vals, "unknown"));
3899                                 switch (raw_val) {
3900
3901                                 case PKT_MDC_VERSION:
3902                                         raw_val = tvb_get_ntohs(tvb, off + 4);
3903                                         proto_item_append_text(ti,
3904                                                                "%s (%s)",
3905                                                                val_to_str_const(raw_val, pkt_mdc_version_vals, "Reserved"),
3906                                                                tvb_format_stringzpad(tvb, off + 4, 2) );
3907                                         break;
3908
3909                                 case PKT_MDC_TEL_END:
3910                                 case PKT_MDC_IF_INDEX:
3911                                         proto_item_append_text(ti,
3912                                                                "%s",
3913                                                                tvb_format_stringzpad(tvb, off + 4, 2) );
3914                                         break;
3915
3916                                 case PKT_MDC_TGT:
3917                                 case PKT_MDC_HTTP_ACC:
3918                                 case PKT_MDC_SYSLOG:
3919                                 case PKT_MDC_NCS:
3920                                 case PKT_MDC_PRI_LINE:
3921                                 case PKT_MDC_NVRAM_STOR:
3922                                 case PKT_MDC_PROV_REP:
3923                                 case PKT_MDC_PROV_REP_LC:
3924                                 case PKT_MDC_SILENCE:
3925                                 case PKT_MDC_SILENCE_LC:
3926                                 case PKT_MDC_ECHO_CANCEL:
3927                                 case PKT_MDC_ECHO_CANCEL_LC:
3928                                 case PKT_MDC_RSVP:
3929                                 case PKT_MDC_RSVP_LC:
3930                                 case PKT_MDC_UGS_AD:
3931                                 case PKT_MDC_UGS_AD_LC:
3932                                 case PKT_MDC_FLOW_LOG:
3933                                 case PKT_MDC_RFC2833_DTMF:
3934                                 case PKT_MDC_VOICE_METRICS:
3935                                 case PKT_MDC_MGPI:
3936                                 case PKT_MDC_V152:
3937                                 case PKT_MDC_CBS:
3938                                 case PKT_MDC_CBS_LC:
3939                                         raw_val = tvb_get_ntohs(tvb, off + 4);
3940                                         proto_item_append_text(ti,
3941                                                                "%s (%s)",
3942                                                                val_to_str_const(raw_val, pkt_mdc_boolean_vals, "unknown"),
3943                                                                tvb_format_stringzpad(tvb, off + 4, 2) );
3944                                         break;
3945
3946                                 case PKT_MDC_SUPP_CODECS:
3947                                 case PKT_MDC_SUPP_CODECS_LC:
3948                                         for (i = 0; i < tlv_len; i++) {
3949                                                 raw_val = tvb_get_ntohs(tvb, off + 4 + (i * 2) );
3950                                                 proto_item_append_text(ti,
3951                                                                        "%s%s (%s)",
3952                                                                        plurality(i + 1, "", ", "),
3953                                                                        val_to_str_const(raw_val, pkt_mdc_codec_vals, "unknown"),
3954                                                                        tvb_format_stringzpad(tvb, off + 4 + (i * 2), 2) );
3955                                         }
3956                                         break;
3957
3958                                 case PKT_MDC_PROV_FLOWS:
3959                                         tvb_memcpy(tvb, flow_val_str, off + 4, 4);
3960                                         flow_val_str[4] = '\0';
3961                                         flow_val = strtoul((gchar*)flow_val_str, NULL, 16);
3962                                         proto_item_append_text(ti,
3963                                                                "0x%04lx", flow_val);
3964                                         break;
3965
3966                                 case PKT_MDC_T38_VERSION:
3967                                         raw_val = tvb_get_ntohs(tvb, off + 4);
3968                                         proto_item_append_text(ti,
3969                                                                "%s (%s)",
3970                                                                val_to_str_const(raw_val, pkt_mdc_t38_version_vals, "unknown"),
3971                                                                tvb_format_stringzpad(tvb, off + 4, 2) );
3972                                         break;
3973
3974                                 case PKT_MDC_T38_EC:
3975                                         raw_val = tvb_get_ntohs(tvb, off + 4);
3976                                         proto_item_append_text(ti,
3977                                                                "%s (%s)",
3978                                                                val_to_str_const(raw_val, pkt_mdc_t38_ec_vals, "unknown"),
3979                                                                tvb_format_stringzpad(tvb, off + 4, 2) );
3980                                         break;
3981
3982                                 case PKT_MDC_MIBS:
3983                                         break;
3984
3985                                 case PKT_MDC_VENDOR_TLV:
3986                                 default:
3987                                         proto_item_append_text(ti,
3988                                                                "%s",
3989                                                                tvb_format_stringzpad(tvb, off + 4, tlv_len * 2) );
3990                                         break;
3991                                 }
3992                         }
3993                         subtree = proto_item_add_subtree(ti, ett_bootp_option);
3994                         if (raw_val == PKT_MDC_PROV_FLOWS) {
3995                                 for (i = 0 ; i < 3; i++) {
3996                                         if (flow_val & pkt_mdc_supp_flow_vals[i].value) {
3997                                                 decode_bitfield_value(bit_fld, (guint32)flow_val, pkt_mdc_supp_flow_vals[i].value, 16);
3998                                                 proto_tree_add_text(subtree, tvb, off + 4, 4, "%s%s",
3999                                                         bit_fld, pkt_mdc_supp_flow_vals[i].strptr);
4000                                         }
4001                                 }
4002                         } else if (raw_val == PKT_MDC_MIBS) {
4003                         /* 17 06 02 00 38 02 01 07 */
4004                                 subopt_off = off + 4;
4005                                 max_len = subopt_off + (tlv_len * 2);
4006                                 while (subopt_off < max_len) {
4007                                         raw_val = tvb_get_ntohs(tvb, subopt_off);
4008                                         if (raw_val != 0x3032) { /* We only know how to handle a length of 2 */
4009                                                 tvb_memcpy(tvb, asc_val, subopt_off, 2);
4010                                                 proto_tree_add_text(subtree, tvb, subopt_off, 2,
4011                                                                         "[Bogus length: %s]", asc_val);
4012                                                 return;
4013                                         }
4014
4015                                         subopt_off += 2;
4016                                         raw_val = tvb_get_ntohs(tvb, subopt_off);
4017                                         tvb_memcpy(tvb, asc_val, subopt_off, 2);
4018
4019                                         mib_ti = proto_tree_add_text(subtree, tvb, subopt_off, 2, "%s (%s)",
4020                                                 val_to_str_const(raw_val, pkt_mdc_mib_orgs, "Unknown"), asc_val);
4021                                         if (subopt_off > off + 4 + 2) {
4022                                                 proto_item_append_text(ti, ", ");
4023                                         }
4024                                         proto_item_append_text(ti, "%s", val_to_str_const(raw_val, pkt_mdc_mib_orgs, "Unknown"));
4025
4026                                         subopt_off += 2;
4027                                         tvb_memcpy(tvb, asc_val, subopt_off, 2);
4028                                         if (sscanf((gchar*)asc_val, "%x", &mib_val) != 1) {
4029                                                 proto_tree_add_text(v_tree, tvb, subopt_off, 2,
4030                                                                         "[Bogus bitfield: %s]", asc_val);
4031                                                 return;
4032                                         }
4033                                         switch (raw_val) {
4034
4035                                         case PKT_MDC_MIB_CL:
4036                                                 subtree2 = proto_item_add_subtree(mib_ti, ett_bootp_option);
4037
4038                                                 for (i = 0; i < 8; i++) {
4039                                                         if (mib_val & pkt_mdc_cl_mib_vals[i].value) {
4040                                                                 decode_bitfield_value(bit_fld, mib_val, pkt_mdc_cl_mib_vals[i].value, 8);
4041                                                                 proto_tree_add_text(subtree2, tvb, subopt_off, 2,
4042                                                                                     "%s%s", bit_fld, pkt_mdc_cl_mib_vals[i].strptr);
4043                                                         }
4044                                                 }
4045                                                 break;
4046
4047                                         case PKT_MDC_MIB_IETF:
4048                                                 subtree2 = proto_item_add_subtree(mib_ti, ett_bootp_option);
4049
4050                                                 for (i = 0; i < 8; i++) {
4051                                                         if (mib_val & pkt_mdc_ietf_mib_vals[i].value) {
4052                                                                 decode_bitfield_value(bit_fld, mib_val, pkt_mdc_ietf_mib_vals[i].value, 8);
4053                                                                 proto_tree_add_text(subtree2, tvb, subopt_off, 2,
4054                                                                                     "%s%s", bit_fld, pkt_mdc_ietf_mib_vals[i].strptr);
4055                                                         }
4056                                                 }
4057                                                 break;
4058
4059                                         case PKT_MDC_MIB_EURO:
4060                                                 subtree2 = proto_item_add_subtree(mib_ti, ett_bootp_option);
4061
4062                                                 for (i = 0; i < 8; i++) {
4063                                                         if (mib_val & pkt_mdc_euro_mib_vals[i].value) {
4064                                                                 decode_bitfield_value(bit_fld, mib_val, pkt_mdc_euro_mib_vals[i].value, 8);
4065                                                                 proto_tree_add_text(subtree2, tvb, subopt_off, 2,
4066                                                                                     "%s%s", bit_fld, pkt_mdc_euro_mib_vals[i].strptr);
4067                                                         }
4068                                                 }
4069                                                 break;
4070
4071                                         default:
4072                                                 break;
4073                                         }
4074                                         subopt_off += 2;
4075                                 }
4076
4077                         }
4078                         off += (tlv_len * 2) + 4;
4079                 }
4080         }
4081 }
4082
4083 /* DOCSIS Cable Modem device capabilities (option 60/option 125). */
4084 #define DOCSIS_CM_CAP_TLV_OFF 12
4085
4086 #define DOCSIS_CM_CAP_CONCAT_SUP        0x01
4087 #define DOCSIS_CM_CAP_DOCSIS_VER        0x02
4088 #define DOCSIS_CM_CAP_FRAG_SUP          0x03
4089 #define DOCSIS_CM_CAP_PHS_SUP           0x04
4090 #define DOCSIS_CM_CAP_IGMP_SUP          0x05
4091 #define DOCSIS_CM_CAP_PRIV_SUP          0x06
4092 #define DOCSIS_CM_CAP_DSAID_SUP         0x07
4093 #define DOCSIS_CM_CAP_USSF_SUP          0x08
4094 #define DOCSIS_CM_CAP_FILT_SUP          0x09
4095 #define DOCSIS_CM_CAP_TET_MI            0x0a
4096 #define DOCSIS_CM_CAP_TET               0x0b
4097 #define DOCSIS_CM_CAP_DCC_SUP           0x0c
4098 #define DOCSIS_CM_CAP_IPFILT_SUP        0x0d
4099 #define DOCSIS_CM_CAP_LLCFILT_SUP       0x0e
4100 #define DOCSIS_CM_CAP_EXPUNI_SPACE      0x0f
4101 #define DOCSIS_CM_CAP_RNGHLDOFF_SUP     0x10
4102 #define DOCSIS_CM_CAP_L2VPN_SUP         0x11
4103 #define DOCSIS_CM_CAP_L2VPN_HOST_SUP    0x12
4104 #define DOCSIS_CM_CAP_DUTFILT_SUP       0x13
4105 #define DOCSIS_CM_CAP_USFREQRNG_SUP     0x14
4106 #define DOCSIS_CM_CAP_USSYMRATE_SUP     0x15
4107 #define DOCSIS_CM_CAP_SACM2_SUP         0x16
4108 #define DOCSIS_CM_CAP_SACM2HOP_SUP      0x17
4109 #define DOCSIS_CM_CAP_MULTTXCHAN_SUP    0x18
4110 #define DOCSIS_CM_CAP_512USTXCHAN_SUP   0x19
4111 #define DOCSIS_CM_CAP_256USTXCHAN_SUP   0x1a
4112 #define DOCSIS_CM_CAP_TOTALSIDCLU_SUP   0x1b
4113 #define DOCSIS_CM_CAP_SIDCLUPERSF_SUP   0x1c
4114 #define DOCSIS_CM_CAP_MULTRXCHAN_SUP    0x1d
4115 #define DOCSIS_CM_CAP_TOTALDSID_SUP     0x1e
4116 #define DOCSIS_CM_CAP_RESEQDSID_SUP     0x1f
4117 #define DOCSIS_CM_CAP_MULTDSID_SUP      0x20
4118 #define DOCSIS_CM_CAP_MULTDSIDFW_SUP    0x21
4119 #define DOCSIS_CM_CAP_FCTF_SUP          0x22
4120 #define DOCSIS_CM_CAP_DPV_SUP           0x23
4121 #define DOCSIS_CM_CAP_UGSPERUSFLOW_SUP  0x24
4122 #define DOCSIS_CM_CAP_MAPUCDRECEIPT_SUP 0x25
4123 #define DOCSIS_CM_CAP_USDROPCLASSIF_SUP 0x26
4124 #define DOCSIS_CM_CAP_IPV6_SUP          0x27
4125 #define DOCSIS_CM_CAP_ExUsTrPow         0x28
4126 #define DOCSIS_CM_CAP_Opt802MPLSSup             0x29
4127 #define DOCSIS_CM_CAP_DounEnc           0x2a
4128 #define DOCSIS_CM_CAP_EnrgMang          0x2c
4129
4130 static const value_string docsis_cm_cap_type_vals[] = {
4131         { DOCSIS_CM_CAP_CONCAT_SUP,             "Concatenation Support" },
4132         { DOCSIS_CM_CAP_DOCSIS_VER,             "DOCSIS Version" },
4133         { DOCSIS_CM_CAP_FRAG_SUP,               "Fragmentation Support" },
4134         { DOCSIS_CM_CAP_PHS_SUP,                "Payload Header Suppression Support" },
4135         { DOCSIS_CM_CAP_IGMP_SUP,               "IGMP Support" },
4136         { DOCSIS_CM_CAP_PRIV_SUP,               "Privacy Support" },
4137         { DOCSIS_CM_CAP_DSAID_SUP,              "Downstream SAID Support" },
4138         { DOCSIS_CM_CAP_USSF_SUP,               "Upstream Service Flow Support" },
4139         { DOCSIS_CM_CAP_FILT_SUP,               "Optional Filtering Support" },
4140         { DOCSIS_CM_CAP_TET_MI,                 "Transmit Equalizer Taps per Modulation Interval" },
4141         { DOCSIS_CM_CAP_TET,                    "Number of Transmit Equalizer Taps" },
4142         { DOCSIS_CM_CAP_DCC_SUP,                "DCC Support" },
4143         { DOCSIS_CM_CAP_IPFILT_SUP,             "IP Filters Support" },
4144         { DOCSIS_CM_CAP_LLCFILT_SUP,            "LLC Filters Support" },
4145         { DOCSIS_CM_CAP_EXPUNI_SPACE,           "Expanded Unicast SID Space" },
4146         { DOCSIS_CM_CAP_RNGHLDOFF_SUP,          "Ranging Hold-Off Support" },
4147         { DOCSIS_CM_CAP_L2VPN_SUP,              "L2VPN Capability" },
4148         { DOCSIS_CM_CAP_L2VPN_HOST_SUP,         "L2VPN eSAFE Host Capability" },
4149         { DOCSIS_CM_CAP_DUTFILT_SUP,            "Downstream Unencrypted Traffic (DUT) Filtering" },
4150         { DOCSIS_CM_CAP_USFREQRNG_SUP,          "Upstream Frequency Range Support" },
4151         { DOCSIS_CM_CAP_USSYMRATE_SUP,          "Upstream Symbol Rate Support" },
4152         { DOCSIS_CM_CAP_SACM2_SUP,              "Selectable Active Code Mode 2 Support" },
4153         { DOCSIS_CM_CAP_SACM2HOP_SUP,           "Code Hopping Mode 2 Support" },
4154         { DOCSIS_CM_CAP_MULTTXCHAN_SUP,         "Multiple Transmit Channel Support" },
4155         { DOCSIS_CM_CAP_512USTXCHAN_SUP,        "5.12 Msps Upstream Transmit Channel Support" },
4156         { DOCSIS_CM_CAP_256USTXCHAN_SUP,        "2.56 Msps Upstream Transmit Channel Support" },
4157         { DOCSIS_CM_CAP_TOTALSIDCLU_SUP,        "Total SID Cluster Support" },
4158         { DOCSIS_CM_CAP_SIDCLUPERSF_SUP,        "SID Clusters per Service Flow Support" },
4159         { DOCSIS_CM_CAP_MULTRXCHAN_SUP,         "Multiple Receive Channel Support" },
4160         { DOCSIS_CM_CAP_TOTALDSID_SUP,          "Total Downstream Service ID (DSID) Support" },
4161         { DOCSIS_CM_CAP_RESEQDSID_SUP,          "Resequencing Downstream Service ID (DSID) Support" },
4162         { DOCSIS_CM_CAP_MULTDSID_SUP,           "Multicast Downstream Service ID (DSID) Support" },
4163         { DOCSIS_CM_CAP_MULTDSIDFW_SUP,         "Multicast DSID Forwarding" },
4164         { DOCSIS_CM_CAP_FCTF_SUP,               "Frame Control Type Forwarding Capability" },
4165         { DOCSIS_CM_CAP_DPV_SUP,                "DPV Capability" },
4166         { DOCSIS_CM_CAP_UGSPERUSFLOW_SUP,       "Unsolicited Grant Service/Upstream Service Flow Support" },
4167         { DOCSIS_CM_CAP_MAPUCDRECEIPT_SUP,      "MAP and UCD Receipt Support" },
4168         { DOCSIS_CM_CAP_USDROPCLASSIF_SUP,      "Upstream Drop Classifier Support" },
4169         { DOCSIS_CM_CAP_IPV6_SUP,               "IPv6 Support" },
4170         { DOCSIS_CM_CAP_ExUsTrPow,              "Extended Upstream Transmit Power Capability (1/4 dB)" },
4171         { DOCSIS_CM_CAP_Opt802MPLSSup,          "Optional 802.1ad, 802.1ah, MPLS Classification Support" },
4172         { DOCSIS_CM_CAP_DounEnc,                "D-ONU Capabilities Encoding" },
4173         { DOCSIS_CM_CAP_EnrgMang,               "Energy Management Capabilities" },
4174         { 0, NULL }
4175 };
4176
4177 static const value_string docsis_cm_cap_supported_vals[] = {
4178         { 0x00, "Not Support" },
4179         { 0x01, "Supported" },
4180         { 0,            NULL }
4181 };
4182
4183 static const value_string docsis_cm_cap_version_vals[] = {
4184         { 0x00, "DOCSIS 1.0" },
4185         { 0x01, "DOCSIS 1.1" },
4186         { 0x02, "DOCSIS 2.0" },
4187         { 0x03, "DOCSIS 3.0" },
4188         { 0,            NULL }
4189 };
4190
4191 static const value_string docsis_cm_cap_privacy_vals[] = {
4192         { 0x00, "BPI Support" },
4193         { 0x01, "BPI Plus Support" },
4194         { 0,            NULL }
4195 };
4196
4197 static const value_string docsis_cm_cap_ranging_hold_off_vals[] = {
4198         { 1 << 0, "CM" },
4199         { 1 << 1, "ePS or eRouter" },
4200         { 1 << 2, "EMTA or EDVA" },
4201         { 1 << 3, "DSG/eSTB" },
4202         { 0, NULL }
4203 };
4204
4205 static const value_string docsis_cm_cap_l2vpn_vals[] = {
4206         { 0x00, "CM not compliant with DOCSIS L2VPN Section 7 (default)" },
4207         { 0x01, "CM compliant with DOCSIS L2VPN Section 7" },
4208         { 0,            NULL }
4209 };
4210
4211 static const value_string docsis_cm_cap_filt_vals[] = {
4212         { 0x00, "802.1P Filtering" },
4213         { 0x01, "802.1Q Filtering" },
4214         { 0,            NULL }
4215 };
4216
4217 static const value_string docsis_cm_cap_mpls_vals[] = {
4218         { 1 << 0,       "[IEEE 802.1ad] S-TPID" },
4219         { 1 << 1,       "[IEEE 802.1ad] S-VID" },
4220         { 1 << 2,       "[IEEE 802.1ad] S-PCP" },
4221         { 1 << 3, "[IEEE 802.1ad] S-DEI" },
4222         { 1 << 4,       "[IEEE 802.1ad] C-TPID" },
4223         { 1 << 5,       "[IEEE 802.1ad] C-VID" },
4224         { 1 << 6,       "[IEEE 802.1ad] C-PCP" },
4225         { 1 << 7,       "[IEEE 802.1ad] C-CFI" },
4226         { 1 << 8,       "[IEEE 802.1ad] S-TCI" },
4227         { 1 << 9,       "[IEEE 802.1ad] C-TCI" },
4228         { 1 << 10,      "[IEEE 802.1ah] I-TPID" },
4229         { 1 << 11,      "[IEEE 802.1ah] I-SID" },
4230         { 1 << 12,      "[IEEE 802.1ah] I-TCI" },
4231         { 1 << 13,      "[IEEE 802.1ah] I-PCP" },
4232         { 1 << 14,      "[IEEE 802.1ah] I-DEI" },
4233         { 1 << 15,      "[IEEE 802.1ah] I-UCA" },
4234         { 1 << 16,      "[IEEE 802.1ah] B-TPID" },
4235         { 1 << 17,      "[IEEE 802.1ah] B-TCI" },
4236         { 1 << 18,      "[IEEE 802.1ah] B-PCP" },
4237         { 1 << 19,      "[IEEE 802.1ah] B-DEI" },
4238         { 1 << 20,      "[IEEE 802.1ah] B-VID" },
4239         { 1 << 21,      "[IEEE 802.1ah] B-DA" },
4240         { 1 << 22,      "[IEEE 802.1ah] B-SA" },
4241         { 1 << 23,      "MPLS TC" },
4242         { 1 << 24,      "MPLS Label" },
4243         { 0,            NULL }
4244 };
4245
4246 static const value_string docsis_cm_cap_enrgmang_vals[] = {
4247         { 0x00, "Energy Management 1x1 Feature" },
4248         { 0,            NULL }
4249 };
4250
4251 static const value_string docsis_cm_cap_usfreqrng_vals[] = {
4252         { 0x00, "Standard Upstream Frequency Range" },
4253         { 0x01, "Standard Upstream Frequency Range and Extended Upstream Frequency Range" },
4254         { 0,            NULL }
4255 };
4256
4257 static const value_string docsis_cm_cap_map_ucd_receipt_vals[] = {
4258         { 0x00, "CM cannot support the receipt of MAPs and UCDs on downstreams other than the Primary Downstream Channel" },
4259         { 0x01, "CM can support the receipt of MAPs and UCDs on downstreams other than the Primary Downstream Channel" },
4260         { 0,            NULL }
4261 };
4262
4263 static const value_string docsis_cm_cap_map_dpv_support_vals[] = {
4264         { 0x00, "U1 supported as a Start Reference Point for DPV per Path" },
4265         { 0x01, "U1 supported as a Start Reference Point for DPV per Packet" },
4266         { 0,            NULL }
4267 };
4268
4269 static const value_string docsis_cm_cap_map_multDsidForward_support_vals[] = {
4270         { 0x00, "No support for multicast DSID forwarding" },
4271         { 0x01, "Support for GMAC explicit multicast DSID forwarding" },
4272         { 0x02, "Support for GMAC promiscuous multicast DSID forwarding" },
4273         { 0,            NULL }
4274 };
4275
4276 static const value_string docsis_cm_cap_map_fctfc_support_vals[] = {
4277         { 0x00, "Isolation Packet PDU MAC Header (FC_Type of 10) is not forwarded" },
4278         { 0x01, "Isolation Packet PDU MAC Header (FC_Type of 10) is forwarded" },
4279         { 0,            NULL }
4280 };
4281
4282 static const value_string docsis_cm_cap_map_l2vpn_esafe_index_support_vals[] = {
4283         { 0x01, "ePs or eRouter" },
4284         { 0x10, "eMTA" },
4285         { 0x11, "eSTB-IP" },
4286         { 0x12, "eSTB-DSG" },
4287         { 0x13, "eTEA" },
4288         { 0,            NULL }
4289 };
4290
4291 static const value_string docsis_cm_cap_ussymrate_vals[] = {
4292         { 1 << 0, "160  ksps symbol rate supported" },
4293         { 1 << 1, "320  ksps symbol rate supported" },
4294         { 1 << 2, "640  ksps symbol rate supported" },
4295         { 1 << 3, "1280 ksps symbol rate supported" },
4296         { 1 << 4, "2560 ksps symbol rate supported" },
4297         { 1 << 5, "5120 ksps symbol rate supported" },
4298         { 0, NULL }
4299 };
4300
4301 static void
4302 display_uint_with_range_checking(proto_item *ti, guint8 val_byte, guint16 val_uint16, int min_value, int max_value)
4303 {
4304         guint16 value;
4305
4306         if (0 != val_byte)
4307         {
4308                 value = val_byte;
4309         }
4310         else
4311         {
4312                 value = val_uint16;
4313         }
4314         proto_item_append_text(ti, "%i", value);
4315         if ((value < min_value) ||
4316             (value > max_value))
4317         {
4318                 proto_item_append_text(ti, " (Value Out-of-Range [%i..%i])", min_value, max_value);
4319         }
4320 }
4321
4322 static void get_opt125_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
4323 {
4324         /* Type */
4325         *tlvtype = tvb_get_guint8(tvb, off);
4326         /* Length */
4327         *tlvlen  = tvb_get_guint8(tvb, off+1);
4328         /* Value */
4329         *value = (guint8 *)ep_tvb_memdup(tvb, off + 2, *tlvlen);
4330 }
4331
4332 static void get_opt60_tlv(tvbuff_t *tvb, guint off, guint8 *tlvtype, guint8 *tlvlen, guint8 **value)
4333 {
4334         guint   i;
4335         guint8 *val_asc;
4336
4337         val_asc = (guint8 *)ep_alloc0(4);
4338         /* Type */
4339         tvb_memcpy(tvb, val_asc, off, 2);
4340         *tlvtype = (guint8)strtoul((gchar*)val_asc, NULL, 16);
4341         /* Length */
4342         tvb_memcpy(tvb, val_asc, off + 2, 2);
4343         *tlvlen = (guint8)strtoul((gchar*)val_asc, NULL, 16);
4344         /* Value */
4345         *value = (guint8 *)ep_alloc0(*tlvlen);
4346         for (i=0; i<*tlvlen; i++)
4347         {
4348                 memset(val_asc, 0, 4);
4349                 tvb_memcpy(tvb, val_asc, off + ((i*2) + 4), 2);
4350                 (*value)[i] = (guint8)strtoul((gchar*)val_asc, NULL, 16);
4351         }
4352 }
4353
4354 static void
4355 dissect_docsis_cm_cap(proto_tree *v_tree, tvbuff_t *tvb, int voff, int len, gboolean opt125)
4356 {
4357         guint8     *asc_val;
4358         guint       i;
4359         proto_item *ti;
4360         proto_tree *subtree;
4361         char        bit_fld[64];
4362         guint8      tlv_type;
4363         guint8      tlv_len;
4364         guint8      val_byte   = 0;
4365         guint16     val_uint16 = 0;
4366         guint8     *val_other  = NULL;
4367         guint       off        = voff;
4368
4369         asc_val = (guint8*)ep_alloc0(4);
4370
4371         if (opt125)
4372         {
4373                 /* Option 125 is formatted as uint8's */
4374                 /* Type */
4375                 tlv_type = tvb_get_guint8(tvb, off);
4376                 /* Length */
4377                 tlv_len  = tvb_get_guint8(tvb, off+1);
4378                 proto_tree_add_uint_format_value(v_tree, hf_bootp_docsis_cm_cap_len, tvb, off+1, 1,
4379                                                  tlv_len, "%d", tlv_len);
4380         }
4381         else
4382         {
4383                 /* Option 60 is formatted as an ASCII string.
4384                    Since the capabilities are the same for both options
4385                    I am converting the Option 60 values from ASCII to
4386                    uint8s to allow the same parser to work for both */
4387                 off += DOCSIS_CM_CAP_TLV_OFF;
4388                 tvb_memcpy (tvb, asc_val, off, 2);
4389                 tlv_len = (guint8)strtoul((gchar*)asc_val, NULL, 16);
4390                 proto_tree_add_uint_format_value(v_tree, hf_bootp_docsis_cm_cap_len, tvb, off+2, 2,
4391                                                  tlv_len, "%d", tlv_len);
4392         }
4393
4394         off+=2;
4395
4396         while (off - ((guint) voff) < ((guint) len))
4397         {
4398                 tlv_type = 0;
4399                 tlv_len = 0;
4400                 val_byte = 0;
4401                 val_uint16 = 0;
4402
4403                 if (opt125)
4404                 {
4405                         get_opt125_tlv(tvb, off, &tlv_type, &tlv_len, &val_other);
4406                         ti =  proto_tree_add_uint_format(v_tree, hf_bootp_docsis_cm_cap_type, tvb, off,
4407                                                          tlv_len + 2,
4408                                                          tlv_type,
4409                                                          "0x%02x: %s = ",
4410                                                          tlv_type,
4411                                                          val_to_str_const(tlv_type, docsis_cm_cap_type_vals, "unknown"));
4412                 }
4413                 else
4414                 {
4415                         /* Option 60 is formatted as an ASCII string.  Since the capabilities
4416                            are the same for both options I am converting the Option 60 values
4417                            from ASCII to uint8s to allow the same parser to work for both */
4418                         get_opt60_tlv(tvb, off, &tlv_type, &tlv_len, &val_other);
4419                         ti =  proto_tree_add_uint_format(v_tree, hf_bootp_docsis_cm_cap_type, tvb, off,
4420                                                          (tlv_len * 2) + 4,
4421                                                          tlv_type,
4422                                                          "0x%02x: %s = ",
4423                                                          tlv_type,
4424                                                          val_to_str_const(tlv_type, docsis_cm_cap_type_vals, "unknown"));
4425                 }
4426
4427                 if (tlv_len == 1)
4428                 {
4429                         /* The value refers to a byte. */
4430                         val_byte = val_other[0];
4431                 }
4432                 else
4433                 {
4434                         if (tlv_len == 2)
4435                         {
4436                                 /* The value refers to a uint16. */
4437                                 val_uint16 = (val_other[0] << 8) + val_other[1];
4438                         }
4439                 }
4440
4441                 switch (tlv_type)
4442                 {
4443                 case DOCSIS_CM_CAP_CONCAT_SUP:
4444                 case DOCSIS_CM_CAP_FRAG_SUP:
4445                 case DOCSIS_CM_CAP_PHS_SUP:
4446                 case DOCSIS_CM_CAP_IGMP_SUP:
4447                 case DOCSIS_CM_CAP_DCC_SUP:
4448                 case DOCSIS_CM_CAP_EXPUNI_SPACE:
4449                 case DOCSIS_CM_CAP_DUTFILT_SUP:
4450                 case DOCSIS_CM_CAP_SACM2_SUP:
4451                 case DOCSIS_CM_CAP_SACM2HOP_SUP:
4452                 case DOCSIS_CM_CAP_IPV6_SUP:
4453                         proto_item_append_text(ti,
4454                                                "%s",
4455                                                val_to_str_const(val_byte, docsis_cm_cap_supported_vals, "Reserved"));
4456                         break;
4457                 case DOCSIS_CM_CAP_DOCSIS_VER:
4458                         proto_item_append_text(ti,
4459                                                "%s",
4460                                                val_to_str_const(val_byte, docsis_cm_cap_version_vals, "Reserved"));
4461                         break;
4462                 case DOCSIS_CM_CAP_PRIV_SUP:
4463                         proto_item_append_text(ti,
4464                                                "%s",
4465                                                val_to_str_const(val_byte, docsis_cm_cap_privacy_vals, "Reserved"));
4466                         break;
4467                 case DOCSIS_CM_CAP_FILT_SUP:
4468                         proto_item_append_text(ti,
4469                                                "%s",
4470                                                val_to_str_const(val_byte, docsis_cm_cap_filt_vals, "Reserved"));
4471                         break;
4472                 case DOCSIS_CM_CAP_L2VPN_SUP:
4473                         proto_item_append_text(ti,
4474                                                "%s",
4475                                                val_to_str_const(val_byte, docsis_cm_cap_l2vpn_vals, "Reserved"));
4476                         break;
4477                 case DOCSIS_CM_CAP_L2VPN_HOST_SUP:
4478                         if (tlv_len == 7) {
4479                                 proto_item_append_text(ti,
4480                                                        "eSAFE ifIndex %s (%i)/eSAFE MAC %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",
4481                                                        val_to_str_const(val_other[0], docsis_cm_cap_map_l2vpn_esafe_index_support_vals, "Reserved"),
4482                                                        val_other[0],
4483                                                        val_other[1],
4484                                                        val_other[2],
4485                                                        val_other[3],
4486                                                        val_other[4],
4487                                                        val_other[5],
4488                                                        val_other[6]);
4489                         } else {
4490                                 proto_item_append_text(ti,
4491                                                        "Invalid (length should be 7, is %d)",
4492                                                        tlv_len);
4493                         }
4494                         break;
4495                 case DOCSIS_CM_CAP_USFREQRNG_SUP:
4496                         proto_item_append_text(ti,
4497                                                "%s",
4498                                                val_to_str_const(val_byte, docsis_cm_cap_usfreqrng_vals, "Reserved"));
4499                         break;
4500                 case DOCSIS_CM_CAP_MAPUCDRECEIPT_SUP:
4501                         proto_item_append_text(ti,
4502                                                "%s",
4503                                                val_to_str_const(val_byte, docsis_cm_cap_map_ucd_receipt_vals, "Reserved"));
4504                         break;
4505                 case DOCSIS_CM_CAP_DPV_SUP:
4506                         proto_item_append_text(ti,
4507                                                "%s",
4508                                                val_to_str_const(val_byte, docsis_cm_cap_map_dpv_support_vals, "Reserved"));
4509                         break;
4510                 case DOCSIS_CM_CAP_DSAID_SUP:
4511                 case DOCSIS_CM_CAP_MULTTXCHAN_SUP:
4512                 case DOCSIS_CM_CAP_512USTXCHAN_SUP:
4513                 case DOCSIS_CM_CAP_256USTXCHAN_SUP:
4514                 case DOCSIS_CM_CAP_TOTALSIDCLU_SUP:
4515                 case DOCSIS_CM_CAP_MULTRXCHAN_SUP:
4516                 case DOCSIS_CM_CAP_UGSPERUSFLOW_SUP:
4517                 case DOCSIS_CM_CAP_USSF_SUP:
4518                         display_uint_with_range_checking(ti, val_byte, val_uint16, 0, 255);
4519                         break;
4520                 case DOCSIS_CM_CAP_RESEQDSID_SUP:
4521                 case DOCSIS_CM_CAP_MULTDSID_SUP:
4522                         display_uint_with_range_checking(ti, val_byte, val_uint16, 16, 255);
4523                         break;
4524                 case DOCSIS_CM_CAP_SIDCLUPERSF_SUP:
4525                         display_uint_with_range_checking(ti, val_byte, val_uint16, 2, 8);
4526                         break;
4527                 case DOCSIS_CM_CAP_TOTALDSID_SUP:
4528                         display_uint_with_range_checking(ti, val_byte, val_uint16, 32, 255);
4529                         break;
4530                 case DOCSIS_CM_CAP_TET:
4531                         display_uint_with_range_checking(ti, val_byte, val_uint16, 8, 64);
4532                         break;
4533                 case DOCSIS_CM_CAP_TET_MI:
4534                         if ((val_byte == 1) ||
4535                             (val_byte == 2) ||
4536                             (val_byte == 4))
4537                         {
4538                                 proto_item_append_text(ti,
4539                                                        " %i",
4540                                                        val_byte);
4541                         }
4542                         else
4543                         {
4544                                 proto_item_append_text(ti,
4545                                                        " (Invalid Value %i : Should be [1,2,4]",
4546                                                        val_byte);
4547                         }
4548                         break;
4549                 case DOCSIS_CM_CAP_IPFILT_SUP:
4550                 case DOCSIS_CM_CAP_USDROPCLASSIF_SUP:
4551                         display_uint_with_range_checking(ti, val_byte, val_uint16, 64, 65535);
4552                         break;
4553                 case DOCSIS_CM_CAP_LLCFILT_SUP:
4554                         display_uint_with_range_checking(ti, val_byte, val_uint16, 10, 65535);
4555                         break;
4556                 case DOCSIS_CM_CAP_ExUsTrPow:
4557                         if (val_byte == 0)
4558                         {
4559                                 proto_item_append_text(ti, "%i", val_byte);
4560                         }
4561                         else
4562                         {
4563                                 display_uint_with_range_checking(ti, val_byte, val_uint16, 205, 244);
4564                         }
4565                         break;
4566                 case DOCSIS_CM_CAP_Opt802MPLSSup:
4567                         proto_item_append_text(ti,
4568                                                "0x%02x", val_byte);
4569                 case DOCSIS_CM_CAP_DounEnc:
4570                         /* TODO: add D-ONU Capabilities Encoding according DPoE-SP-MULPIv1.0-I02-120607 */
4571                         break;
4572                 case DOCSIS_CM_CAP_EnrgMang:
4573                         proto_item_append_text(ti,
4574                                                "%s",
4575                                                val_to_str_const(val_byte, docsis_cm_cap_enrgmang_vals, "Reserved"));
4576                         break;
4577                 case DOCSIS_CM_CAP_RNGHLDOFF_SUP:
4578                         proto_item_append_text(ti,
4579                                                "Ranging ID ");
4580                         proto_item_append_text(ti,
4581                                                "(0x%04x)", (val_other[0] << sizeof(guint8)) + val_other[1]);
4582                         proto_item_append_text(ti,
4583                                                " Component Bit Mask ");
4584                         proto_item_append_text(ti,
4585                                                "(0x%04x)", (val_other[2] << sizeof(guint8)) + val_other[3]);
4586                         break;
4587                 case DOCSIS_CM_CAP_USSYMRATE_SUP:
4588                         proto_item_append_text(ti,
4589                                                "0x%02x", val_byte);
4590                         break;
4591                 case DOCSIS_CM_CAP_FCTF_SUP:
4592                         proto_item_append_text(ti,
4593                                                "%s",
4594                                                val_to_str_const(val_byte, docsis_cm_cap_map_fctfc_support_vals, "Reserved"));
4595                         break;
4596                 case DOCSIS_CM_CAP_MULTDSIDFW_SUP:
4597                         proto_item_append_text(ti,
4598                                                "%s",
4599                                                val_to_str_const(val_byte, docsis_cm_cap_map_multDsidForward_support_vals, "Reserved"));
4600                         break;
4601                 }
4602
4603                 subtree = proto_item_add_subtree(ti, ett_bootp_option);
4604                 if (tlv_type == DOCSIS_CM_CAP_RNGHLDOFF_SUP)
4605                 {
4606                         for (i = 0 ; i < 4; i++)
4607                         {
4608                                 decode_bitfield_value(bit_fld,
4609                                                       (val_other[2] << sizeof(guint8)) + val_other[3],
4610                                                       docsis_cm_cap_ranging_hold_off_vals[i].value,
4611                                                       16);
4612                                 proto_tree_add_text(subtree, tvb, off + 2, 4, "%s%s",
4613                                                     bit_fld, docsis_cm_cap_ranging_hold_off_vals[i].strptr);
4614                         }
4615                 }
4616                 if (tlv_type == DOCSIS_CM_CAP_USSYMRATE_SUP)
4617                 {
4618                         for (i = 0 ; i < 6; i++)
4619                         {
4620                                 decode_bitfield_value(bit_fld, val_byte,docsis_cm_cap_ussymrate_vals[i].value, 8);
4621                                 proto_tree_add_text(subtree, tvb, off + 2, 1, "%s%s",
4622                                                     bit_fld, docsis_cm_cap_ussymrate_vals[i].strptr);
4623
4624                         }
4625                 }
4626                 if (tlv_type == DOCSIS_CM_CAP_Opt802MPLSSup)
4627                 {
4628                         for (i = 0 ; i < 25; i++)
4629                         {
4630                                 decode_bitfield_value(bit_fld,
4631                                                       (val_other[2] << sizeof(guint8)) + val_other[3],
4632                                                       docsis_cm_cap_mpls_vals[i].value,
4633                                                       32);
4634                                 proto_tree_add_text(subtree, tvb, off + 2, 4, "%s%s",
4635                                                     bit_fld, docsis_cm_cap_mpls_vals[i].strptr);
4636                         }
4637                 }
4638                 if (opt125)
4639                 {
4640                         off += (tlv_len) + 2;
4641                 }
4642                 else
4643                 {
4644                         off += (tlv_len *2) + 4;
4645                 }
4646
4647         }
4648 }
4649
4650 /* Definitions specific to PKT-SP-PROV-I05-021127 begin with "PKT_CCC_I05".
4651    Definitions specific to IETF draft 5 and RFC 3495 begin with "PKT_CCC_IETF".
4652    Shared definitions begin with "PKT_CCC".
4653  */
4654 #define PKT_CCC_PRI_DHCP       1
4655 #define PKT_CCC_SEC_DHCP       2
4656 #define PKT_CCC_I05_SNMP       3
4657 #define PKT_CCC_IETF_PROV_SRV  3
4658 #define PKT_CCC_I05_PRI_DNS    4
4659 #define PKT_CCC_IETF_AS_KRB    4
4660 #define PKT_CCC_I05_SEC_DNS    5
4661 #define PKT_CCC_IETF_AP_KRB    5
4662 #define PKT_CCC_KRB_REALM      6
4663 #define PKT_CCC_TGT_FLAG       7
4664 #define PKT_CCC_PROV_TIMER     8
4665 #define PKT_CCC_CMS_FQDN       9
4666 #define PKT_CCC_IETF_SEC_TKT   9
4667 #define PKT_CCC_AS_KRB        10
4668 #define PKT_CCC_AP_KRB        11
4669 #define PKT_CCC_MTA_KRB_CLEAR 12
4670
4671 static const value_string pkt_i05_ccc_opt_vals[] = {
4672         { PKT_CCC_PRI_DHCP,             "Primary DHCP Server" },
4673         { PKT_CCC_SEC_DHCP,             "Secondary DHCP Server" },
4674         { PKT_CCC_I05_SNMP,             "SNMP Entity" },
4675         { PKT_CCC_I05_PRI_DNS,          "Primary DNS Server" },
4676         { PKT_CCC_I05_SEC_DNS,          "Secondary DNS Server" },
4677         { PKT_CCC_KRB_REALM,            "Kerberos Realm" },
4678         { PKT_CCC_TGT_FLAG,             "MTA should fetch TGT?" },
4679         { PKT_CCC_PROV_TIMER,           "Provisioning Timer" },
4680         { PKT_CCC_CMS_FQDN,             "CMS FQDN" },
4681         { PKT_CCC_AS_KRB,               "AS-REQ/AS-REP Backoff and Retry" },
4682         { PKT_CCC_AP_KRB,               "AP-REQ/AP-REP Backoff and Retry" },
4683         { PKT_CCC_MTA_KRB_CLEAR,        "MTA should clear Kerberos tickets?" },
4684         { 0, NULL },
4685 };
4686
4687 static const value_string pkt_draft5_ccc_opt_vals[] = {
4688         { PKT_CCC_PRI_DHCP,             "TSP's Primary DHCP Server" },
4689         { PKT_CCC_SEC_DHCP,             "TSP's Secondary DHCP Server" },
4690         { PKT_CCC_IETF_PROV_SRV,        "TSP's Provisioning Server" },
4691         { PKT_CCC_IETF_AS_KRB,          "TSP's AS-REQ/AS-REP Backoff and Retry" },
4692         { PKT_CCC_IETF_AP_KRB,          "TSP's AP-REQ/AP-REP Backoff and Retry" },
4693         { PKT_CCC_KRB_REALM,            "TSP's Kerberos Realm Name" },
4694         { PKT_CCC_TGT_FLAG,             "TSP's Ticket Granting Server Utilization" },
4695         { PKT_CCC_PROV_TIMER,           "TSP's Provisioning Timer Value" },
4696         { PKT_CCC_IETF_SEC_TKT,         "PacketCable Security Ticket Control" },
4697         { 0, NULL },
4698 };
4699
4700 static const value_string pkt_i05_ccc_ticket_ctl_vals[] = {
4701         { 1, "Invalidate Provisioning Application Server's ticket" },
4702         { 2, "Invalidate all CMS Application Server tickets" },
4703         { 3, "Invalidate all Application Server tickets" },
4704         { 0, NULL },
4705 };
4706
4707 static int
4708 dissect_packetcable_i05_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
4709                             tvbuff_t *tvb, int optoff, int optend)
4710 {
4711         int         suboptoff = optoff;
4712         guint8      subopt, subopt_len, fetch_tgt, timer_val, ticket_ctl;
4713         proto_tree *pkt_s_tree;
4714         proto_item *vti;
4715
4716         subopt = tvb_get_guint8(tvb, optoff);
4717         suboptoff++;
4718
4719         if (suboptoff >= optend) {
4720                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
4721                                                                         "Suboption %d: no room left in option for suboption length", subopt);
4722                 return (optend);
4723         }
4724
4725         subopt_len = tvb_get_guint8(tvb, optoff);
4726         suboptoff++;
4727
4728         vti = proto_tree_add_text(v_tree, tvb, optoff, subopt_len + 2,
4729                 "Suboption %u: %s: ", subopt,
4730                 val_to_str_const(subopt, pkt_i05_ccc_opt_vals, "unknown/reserved") );
4731
4732         switch (subopt) {
4733
4734         case PKT_CCC_PRI_DHCP:  /* String values */
4735         case PKT_CCC_SEC_DHCP:
4736         case PKT_CCC_I05_SNMP:
4737         case PKT_CCC_I05_PRI_DNS:
4738         case PKT_CCC_I05_SEC_DNS:
4739         case PKT_CCC_KRB_REALM:
4740         case PKT_CCC_CMS_FQDN:
4741                 proto_item_append_text(vti, "%s (%u byte%s)",
4742                                        tvb_format_stringzpad(tvb, suboptoff, subopt_len),
4743                                        subopt_len,
4744                                        plurality(subopt_len, "", "s") );
4745                 suboptoff += subopt_len;
4746                 break;
4747
4748         case PKT_CCC_TGT_FLAG:
4749                 if (suboptoff+1 > optend) {
4750                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4751                         return (optend);
4752                 }
4753                 fetch_tgt = tvb_get_guint8(tvb, suboptoff);
4754                 proto_item_append_text(vti, "%s (%u byte%s%s)",
4755                                        fetch_tgt ? "Yes" : "No",
4756                                        subopt_len,
4757                                        plurality(subopt_len, "", "s"),
4758                                        subopt_len != 1 ? " [Invalid]" : "");
4759                 suboptoff += subopt_len;
4760                 break;
4761
4762         case PKT_CCC_PROV_TIMER:
4763                 if (suboptoff+1 > optend) {
4764                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4765                         return (optend);
4766                 }
4767                 timer_val = tvb_get_guint8(tvb, suboptoff);
4768                 proto_item_append_text(vti, "%u%s (%u byte%s%s)", timer_val,
4769                                        timer_val > 30 ? " [Invalid]" : "",
4770                                        subopt_len,
4771                                        plurality(subopt_len, "", "s"),
4772                                        subopt_len != 1 ? " [Invalid]" : "");
4773                 suboptoff += subopt_len;
4774                 break;
4775
4776         case PKT_CCC_AS_KRB:
4777                 if (suboptoff+12 > optend) {
4778                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4779                         return (optend);
4780                 }
4781                 proto_item_append_text(vti, "(%u byte%s%s)", subopt_len,
4782                                        plurality(subopt_len, "", "s"),
4783                                        subopt_len != 12 ? " [Invalid]" : "");
4784                 if (subopt_len == 12) {
4785                         pkt_s_tree = proto_item_add_subtree(vti, ett_bootp_option);
4786                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff, 4,
4787                                             "pktcMtaDevRealmUnsolicitedKeyNomTimeout: %u",
4788                                             tvb_get_ntohl(tvb, suboptoff));
4789                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 4, 4,
4790                                             "pktcMtaDevRealmUnsolicitedKeyMaxTimeout: %u",
4791                                             tvb_get_ntohl(tvb, suboptoff + 4));
4792                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 8, 4,
4793                                             "pktcMtaDevRealmUnsolicitedKeyMaxRetries: %u",
4794                                             tvb_get_ntohl(tvb, suboptoff + 8));
4795                 }
4796                 suboptoff += subopt_len;
4797                 break;
4798
4799         case PKT_CCC_AP_KRB:
4800                 if (suboptoff+12 > optend) {
4801                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4802                         return (optend);
4803                 }
4804                 proto_item_append_text(vti, "(%u byte%s%s)", subopt_len,
4805                                        plurality(subopt_len, "", "s"),
4806                                        subopt_len != 12 ? " [Invalid]" : "");
4807                 if (subopt_len == 12) {
4808                         pkt_s_tree = proto_item_add_subtree(vti, ett_bootp_option);
4809                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff, 4,
4810                                             "pktcMtaDevProvUnsolicitedKeyNomTimeout: %u",
4811                                             tvb_get_ntohl(tvb, suboptoff));
4812                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 4, 4,
4813                                             "pktcMtaDevProvUnsolicitedKeyMaxTimeout: %u",
4814                                             tvb_get_ntohl(tvb, suboptoff + 4));
4815                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 8, 4,
4816                                             "pktcMtaDevProvUnsolicitedKeyMaxRetries: %u",
4817                                             tvb_get_ntohl(tvb, suboptoff + 8));
4818                 }
4819                 suboptoff += subopt_len;
4820                 break;
4821
4822         case PKT_CCC_MTA_KRB_CLEAR:
4823                 if (suboptoff+1 > optend) {
4824                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4825                         return (optend);
4826                 }
4827                 ticket_ctl = tvb_get_guint8(tvb, suboptoff);
4828                 proto_item_append_text(vti, "%s (%u) (%u byte%s%s)",
4829                                        val_to_str_const (ticket_ctl, pkt_i05_ccc_ticket_ctl_vals, "unknown/invalid"),
4830                                        ticket_ctl,
4831                                        subopt_len,
4832                                        plurality(subopt_len, "", "s"),
4833                                        subopt_len != 1 ? " [Invalid]" : "");
4834                 suboptoff += subopt_len;
4835                 break;
4836
4837         default:
4838                 suboptoff += subopt_len;
4839                 break;
4840
4841         }
4842         return suboptoff;
4843 }
4844
4845
4846 static const value_string sec_tcm_vals[] = {
4847         { 1 << 0, "PacketCable Provisioning Server" },
4848         { 1 << 1, "All PacketCable Call Management Servers" },
4849         { 0, NULL }
4850 };
4851
4852 static int
4853 dissect_packetcable_ietf_ccc(packet_info *pinfo, proto_item *v_ti, proto_tree *v_tree,
4854                              tvbuff_t *tvb, int optoff, int optend, int revision)
4855 {
4856         int           suboptoff     = optoff;
4857         guint8        subopt, subopt_len;
4858         guint32       ipv4addr;
4859         guint8        prov_type, fetch_tgt, timer_val;
4860         guint16       sec_tcm;
4861         proto_tree   *pkt_s_tree;
4862         proto_item   *vti;
4863         int           max_timer_val = 255, i;
4864         const guchar *dns_name;
4865         char          bit_fld[24];
4866
4867         subopt = tvb_get_guint8(tvb, suboptoff);
4868         suboptoff++;
4869
4870         if (suboptoff >= optend) {
4871                 expert_add_info_format_text(pinfo, v_ti, &ei_bootp_missing_subopt_length,
4872                                                                         "Suboption %d: no room left in option for suboption length", subopt);
4873                 return (optend);
4874         }
4875         subopt_len = tvb_get_guint8(tvb, suboptoff);
4876         suboptoff++;
4877
4878         vti = proto_tree_add_text(v_tree, tvb, optoff, subopt_len + 2,
4879             "Suboption %u: %s: ", subopt,
4880             val_to_str_const(subopt, pkt_draft5_ccc_opt_vals, "unknown/reserved") );
4881
4882         switch (subopt) {
4883
4884         case PKT_CCC_PRI_DHCP:  /* IPv4 values */
4885         case PKT_CCC_SEC_DHCP:
4886                 if (suboptoff+4 > optend) {
4887                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4888                         return (optend);
4889                 }
4890                 ipv4addr = tvb_get_ipv4(tvb, suboptoff);
4891                 proto_item_append_text(vti, "%s (%u byte%s%s)",
4892                                        ip_to_str((guint8 *)&ipv4addr),
4893                                        subopt_len,
4894                                        plurality(subopt_len, "", "s"),
4895                                        subopt_len != 4 ? " [Invalid]" : "");
4896                 suboptoff += subopt_len;
4897                 break;
4898
4899         case PKT_CCC_IETF_PROV_SRV:
4900                 if (suboptoff+1 > optend) {
4901                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4902                         return (optend);
4903                 }
4904                 prov_type = tvb_get_guint8(tvb, suboptoff);
4905                 suboptoff += 1;
4906                 switch (prov_type) {
4907
4908                 case 0:
4909                         get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name);
4910                         proto_item_append_text(vti, "%s (%u byte%s)", dns_name,
4911                                                subopt_len - 1, plurality(subopt_len, "", "s") );
4912                         break;
4913
4914                 case 1:
4915                         if (suboptoff+4 > optend) {
4916                                 expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4917                                 return (optend);
4918                         }
4919                         ipv4addr = tvb_get_ipv4(tvb, suboptoff);
4920                         proto_item_append_text(vti, "%s (%u byte%s%s)",
4921                                                ip_to_str((guint8 *)&ipv4addr),
4922                                                subopt_len,
4923                                                plurality(subopt_len, "", "s"),
4924                                                subopt_len != 5 ? " [Invalid]" : "");
4925                         break;
4926
4927                 default:
4928                         proto_item_append_text(vti, "Invalid type: %u (%u byte%s)",
4929                                                prov_type,
4930                                                subopt_len,
4931                                                plurality(subopt_len, "", "s") );
4932                         break;
4933                 }
4934                 suboptoff += subopt_len - 1;
4935                 break;
4936
4937         case PKT_CCC_IETF_AS_KRB:
4938                 if (suboptoff+12 > optend) {
4939                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4940                         return (optend);
4941                 }
4942                 proto_item_append_text(vti, "(%u byte%s%s)", subopt_len,
4943                                        plurality(subopt_len, "", "s"),
4944                                        subopt_len != 12 ? " [Invalid]" : "");
4945                 if (subopt_len == 12) {
4946                         pkt_s_tree = proto_item_add_subtree(vti, ett_bootp_option);
4947                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff, 4,
4948                                             "pktcMtaDevRealmUnsolicitedKeyNomTimeout: %u",
4949                                             tvb_get_ntohl(tvb, suboptoff));
4950                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 4, 4,
4951                                             "pktcMtaDevRealmUnsolicitedKeyMaxTimeout: %u",
4952                                             tvb_get_ntohl(tvb, suboptoff + 4));
4953                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 8, 4,
4954                                             "pktcMtaDevRealmUnsolicitedKeyMaxRetries: %u",
4955                                             tvb_get_ntohl(tvb, suboptoff + 8));
4956                 }
4957                 suboptoff += subopt_len;
4958                 break;
4959
4960         case PKT_CCC_IETF_AP_KRB:
4961                 proto_item_append_text(vti, "(%u byte%s%s)", subopt_len,
4962                                        plurality(subopt_len, "", "s"),
4963                                        subopt_len != 12 ? " [Invalid]" : "");
4964                 if (subopt_len == 12) {
4965                         pkt_s_tree = proto_item_add_subtree(vti, ett_bootp_option);
4966                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff, 4,
4967                                             "pktcMtaDevProvUnsolicitedKeyNomTimeout: %u",
4968                                             tvb_get_ntohl(tvb, suboptoff));
4969                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 4, 4,
4970                                             "pktcMtaDevProvUnsolicitedKeyMaxTimeout: %u",
4971                                             tvb_get_ntohl(tvb, suboptoff + 4));
4972                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff + 8, 4,
4973                                             "pktcMtaDevProvUnsolicitedKeyMaxRetries: %u",
4974                                             tvb_get_ntohl(tvb, suboptoff + 8));
4975                 }
4976                 suboptoff += subopt_len;
4977                 break;
4978
4979         case PKT_CCC_KRB_REALM: /* String values */
4980                 get_dns_name(tvb, suboptoff, subopt_len, suboptoff, &dns_name);
4981                 proto_item_append_text(vti, "%s (%u byte%s)", dns_name,
4982                                        subopt_len, plurality(subopt_len, "", "s") );
4983                 suboptoff += subopt_len;
4984                 break;
4985
4986         case PKT_CCC_TGT_FLAG:
4987                 if (suboptoff+1 > optend) {
4988                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
4989                         return (optend);
4990                 }
4991                 fetch_tgt = tvb_get_guint8(tvb, suboptoff);
4992                 proto_item_append_text(vti, "%s (%u byte%s%s)",
4993                                        fetch_tgt ? "Yes" : "No",
4994                                        subopt_len,
4995                                        plurality(subopt_len, "", "s"),
4996                                        subopt_len != 1 ? " [Invalid]" : "");
4997                 suboptoff += 1;
4998                 break;
4999
5000         case PKT_CCC_PROV_TIMER:
5001                 if (suboptoff+1 > optend) {
5002                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
5003                         return (optend);
5004                 }
5005                 if (revision == PACKETCABLE_CCC_DRAFT5)
5006                         max_timer_val = 30;
5007                 timer_val = tvb_get_guint8(tvb, suboptoff);
5008                 proto_item_append_text(vti, "%u%s (%u byte%s%s)", timer_val,
5009                                        timer_val > max_timer_val ? " [Invalid]" : "",
5010                                        subopt_len,
5011                                        plurality(subopt_len, "", "s"),
5012                                        subopt_len != 1 ? " [Invalid]" : "");
5013                 suboptoff += 1;
5014                 break;
5015
5016         case PKT_CCC_IETF_SEC_TKT:
5017                 if (suboptoff+2 > optend) {
5018                         expert_add_info(pinfo, vti, &ei_bootp_missing_subopt_value);
5019                         return (optend);
5020                 }
5021                 sec_tcm = tvb_get_ntohs(tvb, suboptoff);
5022                 proto_item_append_text(vti, "0x%04x (%u byte%s%s)", sec_tcm, subopt_len,
5023                                        plurality(subopt_len, "", "s"),
5024                                        subopt_len != 2 ? " [Invalid]" : "");
5025                 if (subopt_len == 2) {
5026                         pkt_s_tree = proto_item_add_subtree(vti, ett_bootp_option);
5027                         for (i = 0; i < 2; i++) {
5028                                 if (sec_tcm & sec_tcm_vals[i].value) {
5029                                         decode_bitfield_value(bit_fld, sec_tcm, sec_tcm_vals[i].value, 16);
5030                                         proto_tree_add_text(pkt_s_tree, tvb, suboptoff, 2, "%sInvalidate %s",
5031                                                             bit_fld, sec_tcm_vals[i].strptr);
5032                                 }
5033                         }
5034                 }
5035                 suboptoff += subopt_len;
5036                 break;
5037
5038         default:
5039                 suboptoff += subopt_len;
5040                 break;
5041         }
5042         return suboptoff;
5043 }
5044
5045 #define BOOTREQUEST     1
5046 #define BOOTREPLY       2
5047
5048 static const value_string op_vals[] = {
5049         { BOOTREQUEST,  "Boot Request" },
5050         { BOOTREPLY,    "Boot Reply" },
5051         { 0,            NULL }
5052 };
5053
5054 static void
5055 dissect_bootp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
5056 {
5057         proto_tree   *bp_tree;
5058         proto_item   *ti;
5059         proto_tree   *flag_tree;
5060         proto_item   *fi, *hidden_item;
5061         guint8        op;
5062         guint8        htype, hlen;
5063         int           voff, eoff, tmpvoff; /* vendor offset, end offset */
5064         guint32       ip_addr;
5065         gboolean      at_end;
5066         const char   *dhcp_type                              = NULL;
5067         const guint8 *vendor_class_id                        = NULL;
5068         guint16       flags, secs;
5069         int           offset_delta;
5070         guint8        overload                               = 0; /* DHCP option overload */
5071         rfc3396_dns_domain_search_list.total_number_of_block = 0;
5072         rfc3396_dns_domain_search_list.tvb_composite         = NULL;
5073         rfc3396_sip_server.total_number_of_block             = 0;
5074         rfc3396_sip_server.tvb_composite                     = NULL;
5075
5076         col_set_str(pinfo->cinfo, COL_PROTOCOL, "BOOTP");
5077         /*
5078          * In case we throw an exception fetching the opcode, etc.
5079          */
5080         col_clear(pinfo->cinfo, COL_INFO);
5081
5082         op = tvb_get_guint8(tvb, 0);
5083         htype = tvb_get_guint8(tvb, 1);
5084         hlen = tvb_get_guint8(tvb, 2);
5085         switch (op) {
5086
5087         case BOOTREQUEST:
5088                 if ((htype == ARPHRD_ETHER || htype == ARPHRD_IEEE802)
5089                     && hlen == 6) {
5090                         col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s (%s)",
5091                                      tvb_arphrdaddr_to_str(tvb, 28, hlen, htype),
5092                                      get_ether_name(tvb_get_ptr(tvb, 28, hlen)));
5093                 }
5094                 else {
5095                         col_add_fstr(pinfo->cinfo, COL_INFO, "Boot Request from %s",
5096                                      tvb_arphrdaddr_to_str(tvb, 28, hlen, htype));
5097                 }
5098                 break;
5099
5100         case BOOTREPLY:
5101                 col_set_str(pinfo->cinfo, COL_INFO, "Boot Reply");
5102                 break;
5103
5104         default:
5105                 col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown BOOTP message type (%u)", op);
5106                 break;
5107         }
5108
5109         voff = VENDOR_INFO_OFFSET;
5110
5111         /* rfc2132 says it SHOULD exist, not that it MUST exist */
5112         if (tvb_bytes_exist(tvb, voff, 4) &&
5113             (tvb_get_ntohl(tvb, voff) == 0x63825363)) {
5114                 voff += 4;
5115         } else {
5116                 voff += 64;
5117         }
5118         eoff = tvb_reported_length(tvb);
5119
5120         /*
5121          * In the first pass, we just look for the DHCP message type
5122          * and Vendor class identifier options.
5123          */
5124         tmpvoff = voff;
5125         at_end = FALSE;
5126         rfc3396_dns_domain_search_list.index_current_block = 0;
5127         rfc3396_sip_server.index_current_block = 0;
5128         while (tmpvoff < eoff && !at_end) {
5129                 offset_delta = bootp_option(tvb, pinfo, 0, tmpvoff, eoff, TRUE, &at_end,
5130                     &dhcp_type, &vendor_class_id, &overload);
5131                 if (offset_delta <= 0) {
5132                         THROW(ReportedBoundsError);
5133                 }
5134                 tmpvoff += offset_delta;
5135         }
5136
5137         /*
5138          * If there was a DHCP message type option, flag this packet
5139          * as DHCP.
5140          */
5141         if (dhcp_type != NULL) {
5142                 /*
5143                  * Yes, this is a DHCP packet, and "dhcp_type" is the
5144                  * packet type.
5145                  */
5146                 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DHCP");
5147
5148                 col_add_fstr(pinfo->cinfo, COL_INFO, "DHCP %-8s - Transaction ID 0x%x",
5149                              dhcp_type, tvb_get_ntohl(tvb, 4));
5150                 tap_queue_packet( bootp_dhcp_tap, pinfo, dhcp_type);
5151         }
5152
5153         /*
5154          * OK, now build the protocol tree.
5155          */
5156
5157         ti = proto_tree_add_item(tree, proto_bootp, tvb, 0, -1, ENC_NA);
5158         bp_tree = proto_item_add_subtree(ti, ett_bootp);
5159
5160         proto_tree_add_uint(bp_tree, hf_bootp_type, tvb,
5161                                    0, 1,
5162                                    op);
5163         proto_tree_add_item(bp_tree, hf_bootp_hw_type, tvb,
5164                                          1, 1, ENC_BIG_ENDIAN);
5165         proto_tree_add_uint(bp_tree, hf_bootp_hw_len, tvb,
5166                             2, 1, hlen);
5167         proto_tree_add_item(bp_tree, hf_bootp_hops, tvb,
5168                             3, 1, ENC_BIG_ENDIAN);
5169         proto_tree_add_item(bp_tree, hf_bootp_id, tvb,
5170                             4, 4, ENC_BIG_ENDIAN);
5171         /*
5172          * Windows (98, XP and Vista tested) sends the "secs" value on
5173          * the wire formatted as little-endian. See if the LE value
5174          * makes sense.
5175          */
5176         secs = tvb_get_letohs(tvb, 8);
5177         if (secs > 0 && secs <= 0xff) {
5178                 ti = proto_tree_add_uint_format_value(bp_tree, hf_bootp_secs, tvb,
5179                             8, 2, secs, "%u", secs);
5180                 expert_add_info_format_text(pinfo, ti, &ei_bootp_secs_le, "Seconds elapsed appears to be encoded as little-endian");
5181         } else {
5182                 proto_tree_add_item(bp_tree, hf_bootp_secs, tvb,
5183                             8, 2, ENC_BIG_ENDIAN);
5184         }
5185         flags = tvb_get_ntohs(tvb, 10);
5186         fi = proto_tree_add_uint(bp_tree, hf_bootp_flags, tvb,
5187                             10, 2, flags);
5188         proto_item_append_text(fi, " (%s)",
5189             (flags & BOOTP_BC) ? "Broadcast" : "Unicast");
5190         flag_tree = proto_item_add_subtree(fi, ett_bootp_flags);
5191         proto_tree_add_boolean(flag_tree, hf_bootp_flags_broadcast, tvb,
5192                             10, 2, flags);
5193         proto_tree_add_uint(flag_tree, hf_bootp_flags_reserved, tvb,
5194                             10, 2, flags);
5195         proto_tree_add_item(bp_tree, hf_bootp_ip_client, tvb,
5196                             12, 4, ENC_BIG_ENDIAN);
5197         proto_tree_add_item(bp_tree, hf_bootp_ip_your, tvb,
5198                             16, 4, ENC_BIG_ENDIAN);
5199         proto_tree_add_item(bp_tree, hf_bootp_ip_server, tvb,
5200                             20, 4, ENC_BIG_ENDIAN);
5201         proto_tree_add_item(bp_tree, hf_bootp_ip_relay, tvb,
5202                             24, 4, ENC_BIG_ENDIAN);
5203
5204         if (hlen > 0 && hlen <= 16) {
5205                 if ((htype == ARPHRD_ETHER || htype == ARPHRD_IEEE802)
5206                     && hlen == 6)
5207                         proto_tree_add_item(bp_tree, hf_bootp_hw_ether_addr, tvb, 28, 6, ENC_NA);
5208                 else
5209                         /* The chaddr element is 16 bytes in length,
5210                            although only the first hlen bytes are used */
5211                         proto_tree_add_bytes_format_value(bp_tree, hf_bootp_hw_addr, tvb, 28, 16,
5212                                            NULL, "%s", tvb_arphrdaddr_to_str(tvb, 28, hlen, htype));
5213                 if ((16 - hlen) > 0)
5214                         proto_tree_add_item(bp_tree, hf_bootp_hw_addr_padding, tvb, 28+hlen, 16-hlen, ENC_NA);
5215         } else {
5216                 proto_tree_add_text(bp_tree,  tvb,
5217                                            28, 16, "Client address not given");
5218         }
5219
5220         if (overload & OPT_OVERLOAD_SNAME) {
5221                 proto_tree_add_text (bp_tree, tvb,
5222                         SERVER_NAME_OFFSET, SERVER_NAME_LEN,
5223                         "Server name option overloaded by DHCP");
5224         } else {
5225                 /* The server host name is optional */
5226                 if (tvb_get_guint8(tvb, SERVER_NAME_OFFSET) != '\0') {
5227                         proto_tree_add_item(bp_tree, hf_bootp_server, tvb,
5228                                            SERVER_NAME_OFFSET,
5229                                            SERVER_NAME_LEN, ENC_ASCII|ENC_NA);
5230
5231                 } else {
5232                         proto_tree_add_string_format(bp_tree, hf_bootp_server, tvb,
5233                                                    SERVER_NAME_OFFSET,
5234                                                    SERVER_NAME_LEN,
5235                                                    "", "Server host name not given");
5236                 }
5237         }
5238
5239         if (overload & OPT_OVERLOAD_FILE) {
5240                 proto_tree_add_text (bp_tree, tvb,
5241                         FILE_NAME_OFFSET, FILE_NAME_LEN,
5242                         "Boot file name option overloaded by DHCP");
5243         } else {
5244                 /* Boot file is optional */
5245                 if (tvb_get_guint8(tvb, FILE_NAME_OFFSET) != '\0') {
5246                         proto_tree_add_item(bp_tree, hf_bootp_file, tvb,
5247                                            FILE_NAME_OFFSET,
5248                                            FILE_NAME_LEN, ENC_ASCII|ENC_NA);
5249                 } else {
5250                         proto_tree_add_string_format(bp_tree, hf_bootp_file, tvb,
5251                                                    FILE_NAME_OFFSET,
5252                                                    FILE_NAME_LEN,
5253                                                    "", "Boot file name not given");
5254                 }
5255         }
5256
5257         voff = VENDOR_INFO_OFFSET;
5258         if (dhcp_type != NULL) {
5259                 hidden_item = proto_tree_add_boolean(bp_tree, hf_bootp_dhcp, tvb, 0, 0, 1);
5260                 PROTO_ITEM_SET_HIDDEN(hidden_item);
5261         }
5262         if (tvb_bytes_exist(tvb, voff, 4) &&
5263             (tvb_get_ntohl(tvb, voff) == 0x63825363)) {
5264                 ip_addr = tvb_get_ipv4(tvb, voff);
5265                 proto_tree_add_ipv4_format_value(bp_tree, hf_bootp_cookie, tvb,
5266                         voff, 4, ip_addr, "DHCP");
5267                 voff += 4;
5268         } else {
5269                 proto_tree_add_text(bp_tree,  tvb,
5270                         voff, 64, "Bootp vendor specific options");
5271                 voff += 64;
5272         }
5273
5274         at_end = FALSE;
5275         rfc3396_dns_domain_search_list.index_current_block = 0;
5276         rfc3396_sip_server.index_current_block = 0;
5277         while (voff < eoff && !at_end) {
5278                 offset_delta = bootp_option(tvb, pinfo, bp_tree, voff, eoff, FALSE, &at_end,
5279                     &dhcp_type, &vendor_class_id, &overload);
5280                 if (offset_delta <= 0) {
5281                         THROW(ReportedBoundsError);
5282                 }
5283                 voff += offset_delta;
5284         }
5285         if ((dhcp_type != NULL) && (!at_end))
5286         {
5287                 expert_add_info(pinfo, ti, &ei_bootp_end_option_missing);
5288         }
5289         if (voff < eoff) {
5290                 /*
5291                  * Padding after the end option.
5292                  */
5293                 proto_tree_add_text(bp_tree, tvb, voff, eoff - voff, "Padding");
5294         }
5295 }
5296
5297 static void
5298 bootp_init_protocol(void)
5299 {
5300         guint i;
5301
5302         /* first copy default_bootp_opt[] to bootp_opt[].  This resets all values to default */
5303         for(i=0; i<BOOTP_OPT_NUM; i++)
5304         {
5305                 bootp_opt[i].text = default_bootp_opt[i].text;
5306                 bootp_opt[i].ftype = default_bootp_opt[i].ftype;
5307                 bootp_opt[i].phf = default_bootp_opt[i].phf;
5308         }
5309
5310         /* Now apply the custom options */
5311         for (i = 0; i < num_bootp_records_uat; i++)
5312         {
5313                 bootp_opt[uat_bootp_records[i].opt].text = se_strdup(uat_bootp_records[i].text);
5314                 bootp_opt[uat_bootp_records[i].opt].ftype = uat_bootp_records[i].ftype;
5315                 bootp_opt[uat_bootp_records[i].opt].phf = NULL;
5316         }
5317 }
5318
5319 void
5320 proto_register_bootp(void)
5321 {
5322         static const value_string bootp_custom_type_vals[] = {
5323                 { ipv4,             "IP Address"},
5324                 { ipv4_list,        "IP Address List" },
5325                 { string,           "string" },
5326                 { bytes,            "bytes" },
5327                 { val_boolean,      "boolean" },
5328                 { val_u_byte,       "byte" },
5329                 { val_u_short,      "unsigned short" },
5330                 { val_u_short_list, "unsigned short list" },
5331                 { val_u_long,       "unsigned long" },
5332                 { time_in_s_secs,   "integer time in seconds" },
5333                 { time_in_u_secs,   "unsigned integer time in seconds" },
5334                 { 0x00, NULL }
5335         };
5336
5337         static hf_register_info hf[] = {
5338                 { &hf_bootp_dhcp,
5339                   { "Frame is DHCP", "bootp.dhcp",
5340                     FT_BOOLEAN, BASE_NONE, NULL, 0x0,
5341                     NULL, HFILL }},
5342
5343                 { &hf_bootp_type,
5344                   { "Message type", "bootp.type",
5345                     FT_UINT8, BASE_DEC, VALS(op_vals), 0x0,
5346                     NULL, HFILL }},
5347
5348                 { &hf_bootp_hw_type,
5349                   { "Hardware type", "bootp.hw.type",
5350                     FT_UINT8, BASE_HEX, VALS(arp_hrd_vals), 0x0,
5351                     NULL, HFILL }},
5352
5353                 { &hf_bootp_hw_len,
5354                   { "Hardware address length", "bootp.hw.len",
5355                     FT_UINT8, BASE_DEC, NULL, 0x0,
5356                     NULL, HFILL }},
5357
5358                 { &hf_bootp_hops,
5359                   { "Hops", "bootp.hops",
5360                     FT_UINT8, BASE_DEC, NULL, 0x0,
5361                     NULL, HFILL }},
5362
5363                 { &hf_bootp_id,
5364                   { "Transaction ID", "bootp.id",
5365                     FT_UINT32, BASE_HEX, NULL, 0x0,
5366                     NULL, HFILL }},
5367
5368                 { &hf_bootp_secs,
5369                   { "Seconds elapsed", "bootp.secs",
5370                     FT_UINT16, BASE_DEC, NULL, 0x0,
5371                     NULL, HFILL }},
5372
5373                 { &hf_bootp_flags,
5374                   { "Bootp flags", "bootp.flags",
5375                     FT_UINT16, BASE_HEX, NULL, 0x0,
5376                     NULL, HFILL }},
5377
5378                 { &hf_bootp_flags_broadcast,
5379                   { "Broadcast flag", "bootp.flags.bc",
5380                     FT_BOOLEAN, 16, TFS(&flag_set_broadcast), BOOTP_BC,
5381                     NULL, HFILL }},
5382
5383                 { &hf_bootp_flags_reserved,
5384                   { "Reserved flags", "bootp.flags.reserved",
5385                     FT_UINT16, BASE_HEX, NULL, BOOTP_MBZ,
5386                     NULL, HFILL }},
5387
5388                 { &hf_bootp_ip_client,
5389                   { "Client IP address", "bootp.ip.client",
5390                     FT_IPv4, BASE_NONE, NULL, 0x0,
5391                     NULL, HFILL }},
5392
5393                 { &hf_bootp_ip_your,
5394                   { "Your (client) IP address", "bootp.ip.your",
5395                     FT_IPv4, BASE_NONE, NULL, 0x0,
5396                     NULL, HFILL }},
5397
5398                 { &hf_bootp_ip_server,
5399                   { "Next server IP address", "bootp.ip.server",
5400                     FT_IPv4, BASE_NONE, NULL, 0x0,
5401                     NULL, HFILL }},
5402
5403                 { &hf_bootp_ip_relay,
5404                   { "Relay agent IP address", "bootp.ip.relay",
5405                     FT_IPv4, BASE_NONE, NULL, 0x0,
5406                     NULL, HFILL }},
5407
5408                 { &hf_bootp_hw_addr,
5409                   { "Client hardware address", "bootp.hw.addr",
5410                     FT_BYTES, BASE_NONE, NULL, 0x0,
5411                     NULL, HFILL }},
5412
5413                 { &hf_bootp_hw_addr_padding,
5414                   { "Client hardware address padding", "bootp.hw.addr_padding",
5415                     FT_BYTES, BASE_NONE, NULL, 0x0,
5416                     NULL, HFILL }},
5417
5418                 { &hf_bootp_hw_ether_addr,
5419                   { "Client MAC address", "bootp.hw.mac_addr",
5420                     FT_ETHER, BASE_NONE, NULL, 0x0,
5421                     NULL, HFILL }},
5422
5423                 { &hf_bootp_server,
5424                   { "Server host name", "bootp.server",
5425                     FT_STRING, BASE_NONE, NULL, 0x0,
5426                     NULL, HFILL }},
5427
5428                 { &hf_bootp_file,
5429                   { "Boot file name", "bootp.file",
5430                     FT_STRING, BASE_NONE, NULL, 0x0,
5431                     NULL, HFILL }},
5432
5433                 { &hf_bootp_cookie,
5434                   { "Magic cookie", "bootp.cookie",
5435                     FT_IPv4, BASE_NONE, NULL, 0x0,
5436                     NULL, HFILL }},
5437
5438                 { &hf_bootp_fqdn_s,
5439                   { "Server", "bootp.fqdn.s",
5440                     FT_BOOLEAN, 8, TFS(&tfs_fqdn_s), F_FQDN_S,
5441                     "If true, server should do DDNS update", HFILL }},
5442
5443                 { &hf_bootp_fqdn_o,
5444                   { "Server overrides", "bootp.fqdn.o",
5445                     FT_BOOLEAN, 8, TFS(&tfs_fqdn_o), F_FQDN_O,
5446                     "If true, server insists on doing DDNS update", HFILL }},
5447
5448                 { &hf_bootp_fqdn_e,
5449                   { "Encoding", "bootp.fqdn.e",
5450                     FT_BOOLEAN, 8, TFS(&tfs_fqdn_e), F_FQDN_E,
5451                     "If true, name is binary encoded", HFILL }},
5452
5453                 { &hf_bootp_fqdn_n,
5454                   { "Server DDNS", "bootp.fqdn.n",
5455                     FT_BOOLEAN, 8, TFS(&tfs_fqdn_n), F_FQDN_N,
5456                     "If true, server should not do any DDNS updates", HFILL }},
5457
5458                 { &hf_bootp_fqdn_mbz,
5459                   { "Reserved flags", "bootp.fqdn.mbz",
5460                     FT_UINT8, BASE_HEX, NULL, F_FQDN_MBZ,
5461                     NULL, HFILL }},
5462
5463                 { &hf_bootp_fqdn_rcode1,
5464                   { "A-RR result", "bootp.fqdn.rcode1",
5465                     FT_UINT8, BASE_DEC, NULL, 0x0,
5466                     "Result code of A-RR update", HFILL }},
5467
5468                 { &hf_bootp_fqdn_rcode2,
5469                   { "PTR-RR result", "bootp.fqdn.rcode2",
5470                     FT_UINT8, BASE_DEC, NULL, 0x0,
5471                     "Result code of PTR-RR update", HFILL }},
5472
5473                 { &hf_bootp_fqdn_name,
5474                   { "Client name", "bootp.fqdn.name",
5475                     FT_STRING, BASE_NONE, NULL, 0x0,
5476                     "Name to register via DDNS", HFILL }},
5477
5478                 { &hf_bootp_fqdn_asciiname,
5479                   { "Client name", "bootp.fqdn.name",
5480                     FT_STRING, BASE_NONE, NULL, 0x0,
5481                     "Name to register via DDNS", HFILL }},
5482
5483                 { &hf_bootp_pkt_mta_cap_len,
5484                   { "MTA DC Length", "bootp.vendor.pktc.mta_cap_len",
5485                     FT_UINT8, BASE_DEC, NULL, 0x0,
5486                     "PacketCable MTA Device Capabilities Length", HFILL }},
5487
5488                 { &hf_bootp_docsis_cm_cap_len,
5489                   { "CM DC Length", "bootp.vendor.docsis.cm_cap_len",
5490                     FT_UINT8, BASE_DEC, NULL, 0x0,
5491                     "DOCSIS Cable Modem Device Capabilities Length", HFILL }},
5492
5493                 { &hf_bootp_docsis_cm_cap_type,
5494                   { "CM DC Type", "bootp.docsis_cm_cap_type",
5495                     FT_UINT16, BASE_DEC, VALS(docsis_cm_cap_type_vals), 0x0,
5496                     "Docsis Cable Modem Device Capability type", HFILL }},
5497
5498                 { &hf_bootp_client_identifier_uuid,
5499                   { "Client Identifier (UUID)", "bootp.client_id_uuid",
5500                     FT_GUID, BASE_NONE, NULL, 0x0,
5501                     "Client Machine Identifier (UUID)", HFILL }},
5502
5503                 { &hf_bootp_client_identifier_duid_llt_hw_type,
5504                   { "Hardware type", "bootp.client_id_duid_llt_hw_type",
5505                     FT_UINT16, BASE_DEC, VALS(arp_hrd_vals), 0x0,
5506                     "Client Identifier DUID LLT Hardware type", HFILL }},
5507
5508                 { &hf_bootp_client_identifier_duid_ll_hw_type,
5509                   { "Hardware type", "bootp.client_id_duid_ll_hw_type",
5510                     FT_UINT16, BASE_DEC, VALS(arp_hrd_vals), 0x0,
5511                     "Client Identifier DUID LL Hardware type", HFILL }},
5512
5513                 { &hf_bootp_option_type,
5514                   { "Option", "bootp.option.type",
5515                     FT_UINT8, BASE_DEC, NULL, 0x0,
5516                     "Bootp/Dhcp option type", HFILL }},
5517
5518                 { &hf_bootp_option_length,
5519                   { "Length", "bootp.option.length",
5520                     FT_UINT8, BASE_DEC, NULL, 0x0,
5521                     "Bootp/Dhcp option length", HFILL }},
5522
5523                 { &hf_bootp_suboption_length,
5524                   { "Length", "bootp.option.suboption_length",
5525                     FT_UINT8, BASE_DEC, NULL, 0x0,
5526                     "Suboption length", HFILL }},
5527
5528                 { &hf_bootp_option_value,
5529                   { "Value", "bootp.option.value",
5530                     FT_BYTES, BASE_NONE, NULL, 0x0,
5531                     "Bootp/Dhcp option value", HFILL }},
5532
5533                 { &hf_bootp_option_value_8,
5534                   { "Value", "bootp.option.value.uint",
5535                     FT_UINT8, BASE_DEC, NULL, 0x0,
5536                     "8-bit Bootp/Dhcp option value", HFILL }},
5537
5538                 { &hf_bootp_option_value_16,
5539                   { "Value", "bootp.option.value.uint",
5540                     FT_UINT16, BASE_DEC, NULL, 0x0,
5541                     "16-bit Bootp/Dhcp option value", HFILL }},
5542
5543                 { &hf_bootp_option_value_u32,
5544                   { "Value", "bootp.option.value.uint",
5545                     FT_UINT32, BASE_HEX, NULL, 0x0,
5546                     "32-bit Bootp/Dhcp option value", HFILL }},
5547
5548                 { &hf_bootp_option_value_i32,
5549                   { "Value", "bootp.option.value.int",
5550                     FT_INT32, BASE_DEC, NULL, 0x0,
5551                     "32-bit Bootp/Dhcp option value", HFILL }},
5552
5553                 { &hf_bootp_option_value_stringz,
5554                   { "Value", "bootp.option.value.string",
5555                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5556                     "Z-String Bootp/Dhcp option value", HFILL }},
5557
5558                 { &hf_bootp_option_value_ip_address,
5559                   { "Value", "bootp.option.value.address",
5560                     FT_IPv4, BASE_NONE, NULL, 0x00,
5561                     "IP address Bootp/Dhcp option value", HFILL }},
5562
5563                 { &hf_bootp_option_value_boolean,
5564                   { "Value", "bootp.option.value.bool",
5565                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_true_false), 0x00,
5566                     "Boolean Bootp/Dhcp option value", HFILL }},
5567
5568                 { &hf_bootp_option_padding,
5569                   { "Padding", "bootp.option.padding",
5570                     FT_BYTES, BASE_NONE, NULL, 0x0,
5571                     "Option 0: Padding", HFILL }},
5572
5573                 { &hf_bootp_option_subnet_mask,
5574                   { "Subnet Mask", "bootp.option.subnet_mask",
5575                     FT_IPv4, BASE_NONE, NULL, 0x00,
5576                     "Option 1: Subnet Mask", HFILL }},
5577
5578                 { &hf_bootp_option_time_offset,
5579                   { "Time Offset", "bootp.option.time_offset",
5580                     FT_INT32, BASE_DEC, NULL, 0x00,
5581                     "Option 2: Time Offset", HFILL }},
5582
5583                 { &hf_bootp_option_router,
5584                   { "Router", "bootp.option.router",
5585                     FT_IPv4, BASE_NONE, NULL, 0x00,
5586                     "Option 3: Router", HFILL }},
5587
5588                 { &hf_bootp_option_time_server,
5589                   { "Time Server", "bootp.option.time_server",
5590                     FT_IPv4, BASE_NONE, NULL, 0x00,
5591                     "Option 4: Time Server", HFILL }},
5592
5593                 { &hf_bootp_option_name_server,
5594                   { "Name Server", "bootp.option.name_server",
5595                     FT_IPv4, BASE_NONE, NULL, 0x00,
5596                     "Option 5: Name Server", HFILL }},
5597
5598                 { &hf_bootp_option_domain_name_server,
5599                   { "Domain Name Server", "bootp.option.domain_name_server",
5600                     FT_IPv4, BASE_NONE, NULL, 0x00,
5601                     "Option 6: Domain Name Server", HFILL }},
5602
5603                 { &hf_bootp_option_log_server,
5604                   { "Log Server", "bootp.option.log_server",
5605                     FT_IPv4, BASE_NONE, NULL, 0x00,
5606                     "Option 7: Log Server", HFILL }},
5607
5608                 { &hf_bootp_option_quotes_server,
5609                   { "Quotes Server", "bootp.option.quotes_server",
5610                     FT_IPv4, BASE_NONE, NULL, 0x00,
5611                     "Option 8: Quotes Server", HFILL }},
5612
5613                 { &hf_bootp_option_lpr_server,
5614                   { "LPR Server", "bootp.option.lpr_server",
5615                     FT_IPv4, BASE_NONE, NULL, 0x00,
5616                     "Option 9: LPR Server", HFILL }},
5617
5618                 { &hf_bootp_option_impress_server,
5619                   { "Impress Server", "bootp.option.impress_server",
5620                     FT_IPv4, BASE_NONE, NULL, 0x00,
5621                     "Option 10: Impress Server", HFILL }},
5622
5623                 { &hf_bootp_option_resource_location_server,
5624                   { "Resource Location Server", "bootp.option.resource_location_server",
5625                     FT_IPv4, BASE_NONE, NULL, 0x00,
5626                     "Option 11: Resource Location Server", HFILL }},
5627
5628                 { &hf_bootp_option_hostname,
5629                   { "Host Name", "bootp.option.hostname",
5630                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5631                     "Option 12: Host Name", HFILL }},
5632
5633                 { &hf_bootp_option_boot_file_size,
5634                   { "Boot File Size", "bootp.option.boot_file_size",
5635                     FT_UINT16, BASE_DEC, NULL, 0x0,
5636                     "Option 13: Boot File Size", HFILL }},
5637
5638                 { &hf_bootp_option_merit_dump_file,
5639                   { "Merit Dump File", "bootp.option.merit_dump_file",
5640                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5641                     "Option 14: Merit Dump File", HFILL }},
5642
5643                 { &hf_bootp_option_domain_name,
5644                   { "Domain Name", "bootp.option.domain_name",
5645                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5646                     "Option 15: Domain Name", HFILL }},
5647
5648                 { &hf_bootp_option_swap_server,
5649                   { "Swap Server", "bootp.option.swap_server",
5650                     FT_IPv4, BASE_NONE, NULL, 0x00,
5651                     "Option 16: Swap Server", HFILL }},
5652
5653                 { &hf_bootp_option_root_path,
5654                   { "Root Path", "bootp.option.root_path",
5655                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5656                     "Option 17: Root Path", HFILL }},
5657
5658                 { &hf_bootp_option_extension_path,
5659                   { "Extensions Path", "bootp.option.extension_path",
5660                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5661                     "Option 18: Extensions Path", HFILL }},
5662
5663                 { &hf_bootp_option_ip_forwarding,
5664                   { "IP Forwarding", "bootp.option.ip_forwarding",
5665                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5666                     "Option 19: IP Forwarding", HFILL }},
5667
5668                 { &hf_bootp_option_policy_filter_ip,
5669                   { "IP Address", "bootp.option.policy_filter.ip",
5670                     FT_IPv4, BASE_NONE, NULL, 0x00,
5671                     "Option 21: IP address", HFILL }},
5672
5673                 { &hf_bootp_option_policy_filter_subnet_mask,
5674                   { "Subnet Mask", "bootp.option.policy_filter.subnet_mask",
5675                     FT_IPv4, BASE_NONE, NULL, 0x00,
5676                     "Option 21: Subnet Mask", HFILL }},
5677
5678                 { &hf_bootp_option_non_local_source_routing,
5679                   { "Non-Local Source Routing", "bootp.option.non_local_source_routing",
5680                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5681                     "Option 20: Non-Local Source Routing", HFILL }},
5682
5683                 { &hf_bootp_option_max_datagram_reassembly_size,
5684                   { "Maximum Datagram Reassembly Size", "bootp.option.max_datagram_reassembly_size",
5685                     FT_UINT16, BASE_DEC, NULL, 0x0,
5686                     "Option 22: Maximum Datagram Reassembly Size", HFILL }},
5687
5688                 { &hf_bootp_option_default_ip_ttl,
5689                   { "Default IP Time-to-Live", "bootp.option.default_ip_ttl",
5690                     FT_UINT8, BASE_DEC, NULL, 0x0,
5691                     "Option 23: Default IP Time-to-Live", HFILL }},
5692
5693                 { &hf_bootp_option_path_mtu_aging_timeout,
5694                   { "Path MTU Aging Timeout", "bootp.option.path_mtu_aging_timeout",
5695                     FT_UINT32, BASE_DEC, NULL, 0x00,
5696                     "Option 24: Path MTU Aging Timeout", HFILL }},
5697
5698                 { &hf_bootp_option_path_mtu_plateau_table_item,
5699                   { "Path MTU Plateau Table Item", "bootp.option.path_mtu_plateau_table_item",
5700                     FT_UINT16, BASE_DEC, NULL, 0x0,
5701                     "Option 25: Path MTU Plateau Table Item", HFILL }},
5702
5703                 { &hf_bootp_option_interface_mtu,
5704                   { "Interface MTU", "bootp.option.interface_mtu",
5705                     FT_UINT16, BASE_DEC, NULL, 0x0,
5706                     "Option 26: Interface MTU", HFILL }},
5707
5708                 { &hf_bootp_option_all_subnets_are_local,
5709                   { "All Subnets are Local", "bootp.option.all_subnets_are_local",
5710                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x00,
5711                     "Option 27: All Subnets are Local", HFILL }},
5712
5713                 { &hf_bootp_option_broadcast_address,
5714                   { "Broadcast Address", "bootp.option.broadcast_address",
5715                     FT_IPv4, BASE_NONE, NULL, 0x00,
5716                     "Option 28: Broadcast Address", HFILL }},
5717
5718                 { &hf_bootp_option_perform_mask_discovery,
5719                   { "Perform Mask Discovery", "bootp.option.perform_mask_discovery",
5720                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5721                     "Option 29: Perform Mask Discovery", HFILL }},
5722
5723                 { &hf_bootp_option_mask_supplier,
5724                   { "Mask Supplier", "bootp.option.mask_supplier",
5725                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x00,
5726                     "Option 30: Mask Supplier", HFILL }},
5727
5728                 { &hf_bootp_option_perform_router_discover,
5729                   { "Perform Router Discover", "bootp.option.perform_router_discover",
5730                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5731                     "Option 31: Perform Router Discover", HFILL }},
5732
5733                 { &hf_bootp_option_router_solicitation_address,
5734                   { "Router Solicitation Address", "bootp.option.router_solicitation_address",
5735                     FT_IPv4, BASE_NONE, NULL, 0x00,
5736                     "Option 32: Router Solicitation Address", HFILL }},
5737
5738                 { &hf_bootp_option_static_route_ip,
5739                   { "Destination IP Address", "bootp.option.static_route.ip",
5740                     FT_IPv4, BASE_NONE, NULL, 0x00,
5741                     "Option 33: Destination IP address", HFILL }},
5742
5743                 { &hf_bootp_option_static_route_router,
5744                   { "Destination Router", "bootp.option.static_route.router",
5745                     FT_IPv4, BASE_NONE, NULL, 0x00,
5746                     "Option 33: Destination Router", HFILL }},
5747
5748                 { &hf_bootp_option_trailer_encapsulation,
5749                   { "Trailer Encapsulation", "bootp.option.trailer_encapsulation",
5750                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5751                     "Option 34: Trailer Encapsulation", HFILL }},
5752
5753                 { &hf_bootp_option_arp_cache_timeout,
5754                   { "ARP Cache Timeout", "bootp.option.arp_cache_timeout",
5755                     FT_UINT32, BASE_DEC, NULL, 0x00,
5756                     "Option 35: ARP Cache Timeout", HFILL }},
5757
5758                 { &hf_bootp_option_ethernet_encapsulation,
5759                   { "Ethernet Encapsulation", "bootp.option.ethernet_encapsulation",
5760                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5761                     "Option 36: Ethernet Encapsulation", HFILL }},
5762
5763                 { &hf_bootp_option_tcp_default_ttl,
5764                   { "TCP Default TTL", "bootp.option.tcp_default_ttl",
5765                     FT_UINT8, BASE_DEC, NULL, 0x0,
5766                     "Option 37: TCP Default TTL", HFILL }},
5767
5768                 { &hf_bootp_option_tcp_keepalive_interval,
5769                   { "TCP Keepalive Interval", "bootp.option.tcp_keepalive_interval",
5770                     FT_UINT32, BASE_DEC, NULL, 0x00,
5771                     "Option 38: TCP Keepalive Interval", HFILL }},
5772
5773                 { &hf_bootp_option_tcp_keepalive_garbage,
5774                   { "TCP Keepalive Garbage", "bootp.option.tcp_keepalive_garbage",
5775                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_enabled_disabled), 0x00,
5776                     "Option 39: TCP Keepalive Garbage", HFILL }},
5777
5778                 { &hf_bootp_option_nis_domain,
5779                   { "Network Information Service Domain", "bootp.option.nis_domain",
5780                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5781                     "Option 40: Network Information Service Domain", HFILL }},
5782
5783                 { &hf_bootp_option_nis_server,
5784                   { "Network Information Service Server", "bootp.option.nis_server",
5785                     FT_IPv4, BASE_NONE, NULL, 0x00,
5786                     "Option 41: Network Information Service Server", HFILL }},
5787
5788                 { &hf_bootp_option_ntp_server,
5789                   { "Network Time Protocol Server", "bootp.option.ntp_server",
5790                     FT_IPv4, BASE_NONE, NULL, 0x00,
5791                     "Option 42: Network Time Protocol Server", HFILL }},
5792
5793
5794                 { &hf_bootp_option43_value,
5795                   { "Value", "bootp.option.vendor.value",
5796                     FT_BYTES, BASE_NONE, NULL, 0x0,
5797                     "Option 43: Suboption value", HFILL }},
5798
5799                 { &hf_bootp_option43_value_8,
5800                   { "Value", "bootp.option.vendor.value.uint",
5801                     FT_UINT8, BASE_DEC, NULL, 0x0,
5802                     "Option 43: Suboption 8-bit value", HFILL }},
5803
5804                 { &hf_bootp_option43_value_32,
5805                   { "Value", "bootp.option.vendor.value.uint",
5806                     FT_UINT32, BASE_DEC, NULL, 0x0,
5807                     "Option 43: Suboption 32-bit value", HFILL }},
5808
5809                 { &hf_bootp_option43_value_stringz,
5810                   { "Value", "bootp.option.vendor.value.string",
5811                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5812                     "Option 43: Suboption Z-String value", HFILL }},
5813
5814                 { &hf_bootp_option43_value_ip_address,
5815                   { "Value", "bootp.option.vendor.value.address",
5816                     FT_IPv4, BASE_NONE, NULL, 0x00,
5817                     "Option 43: Suboption IP address", HFILL }},
5818
5819
5820                 { &hf_bootp_option43_pxeclient_suboption,
5821                   { "Option 43 Suboption", "bootp.option.vendor.pxeclient.suboption",
5822                     FT_UINT8, BASE_DEC, VALS(option43_pxeclient_suboption_vals), 0x0,
5823                     "Option 43:PXE Client Suboption", HFILL }},
5824
5825                 { &hf_bootp_option43_pxeclient_padding,
5826                   { "Padding", "bootp.option.vendor.pxeclient.padding",
5827                     FT_UINT8, BASE_DEC, NULL, 0x0,
5828                     "Option 43:PXE Client 0 Padding", HFILL }},
5829
5830                 { &hf_bootp_option43_pxeclient_mtftp_ip,
5831                   { "mtftp IP", "bootp.option.vendor.pxeclient.mtftp_ip",
5832                     FT_IPv4, BASE_NONE, NULL, 0x00,
5833                     "Option 43:PXE Client 1 mtftp IP", HFILL }},
5834
5835                 { &hf_bootp_option43_pxeclient_mtftp_client_port,
5836                   { "mtftp IP", "bootp.option.vendor.pxeclient.mtftp_client_port",
5837                     FT_UINT16, BASE_DEC, NULL, 0x00,
5838                     "Option 43:PXE Client 2 mtftp client port", HFILL }},
5839
5840                 { &hf_bootp_option43_pxeclient_mtftp_server_port,
5841                   { "mtftp IP", "bootp.option.vendor.pxeclient.mtftp_server_port",
5842                     FT_UINT16, BASE_DEC, NULL, 0x00,
5843                     "Option 43:PXE Client 3 mtftp server port", HFILL }},
5844
5845                 { &hf_bootp_option43_pxeclient_mtftp_timeout,
5846                   { "mtftp timeout", "bootp.option.vendor.pxeclient.mtftp_timeout",
5847                     FT_UINT8, BASE_DEC, NULL, 0x0,
5848                     "Option 43:PXE Client 4 mtftp timeout", HFILL }},
5849
5850                 { &hf_bootp_option43_pxeclient_mtftp_delay,
5851                   { "mtftp delay", "bootp.option.vendor.pxeclient.mtftp_delay",
5852                     FT_UINT8, BASE_DEC, NULL, 0x0,
5853                     "Option 43:PXE Client 5 mtftp delay", HFILL }},
5854
5855                 { &hf_bootp_option43_pxeclient_discovery_control,
5856                   { "discovery control", "bootp.option.vendor.pxeclient.discovery_control",
5857                     FT_UINT8, BASE_HEX, NULL, 0x0,
5858                     "Option 43:PXE Client 6 discovery control", HFILL }},
5859
5860                 { &hf_bootp_option43_pxeclient_multicast_address,
5861                   { "multicast address", "bootp.option.vendor.pxeclient.multicast_address",
5862                     FT_IPv4, BASE_NONE, NULL, 0x00,
5863                     "Option 43:PXE Client 7 multicast address", HFILL }},
5864
5865                 { &hf_bootp_option43_pxeclient_boot_servers,
5866                   { "boot servers", "bootp.option.vendor.pxeclient.boot_servers",
5867                     FT_BYTES, BASE_NONE, NULL, 0x0,
5868                     "Option 43:PXE Client 8 boot servers", HFILL }},
5869
5870                 { &hf_bootp_option43_pxeclient_boot_menu,
5871                   { "boot menu", "bootp.option.vendor.pxeclient.boot_menu",
5872                     FT_BYTES, BASE_NONE, NULL, 0x0,
5873                     "Option 43:PXE Client 9 boot menu", HFILL }},
5874
5875                 { &hf_bootp_option43_pxeclient_menu_prompt,
5876                   { "menu prompt", "bootp.option.vendor.pxeclient.menu_prompt",
5877                     FT_BYTES, BASE_NONE, NULL, 0x0,
5878                     "Option 43:PXE Client 10 menu prompt", HFILL }},
5879
5880                 { &hf_bootp_option43_pxeclient_multicast_address_alloc,
5881                   { "multicast address alloc", "bootp.option.vendor.pxeclient.multicast_address_alloc",
5882                     FT_BYTES, BASE_NONE, NULL, 0x0,
5883                     "Option 43:PXE Client 11 multicast address alloc", HFILL }},
5884
5885                 { &hf_bootp_option43_pxeclient_credential_types,
5886                   { "credential types", "bootp.option.vendor.pxeclient.credential_types",
5887                     FT_BYTES, BASE_NONE, NULL, 0x0,
5888                     "Option 43:PXE Client 12 credential types", HFILL }},
5889
5890                 { &hf_bootp_option43_pxeclient_boot_item,
5891                   { "boot item", "bootp.option.vendor.pxeclient.boot_item",
5892                     FT_BYTES, BASE_NONE, NULL, 0x0,
5893                     "Option 43:PXE Client 71 boot item", HFILL }},
5894
5895                 { &hf_bootp_option43_pxeclient_end,
5896                   { "PXE Client End", "bootp.option.vendor.pxeclient.end",
5897                     FT_UINT8, BASE_DEC, NULL, 0x0,
5898                     "Option 43:PXE Client 255 End", HFILL }},
5899
5900
5901                 { &hf_bootp_option43_cl_suboption,
5902                   { "Option 43 Suboption", "bootp.option.vendor.cl.suboption",
5903                     FT_UINT8, BASE_DEC, VALS(option43_cl_suboption_vals), 0x0,
5904                     "Option 43:CL Suboption", HFILL }},
5905
5906                 { &hf_bootp_option43_cl_padding,
5907                   { "Padding", "bootp.option.vendor.cl.padding",
5908                     FT_UINT8, BASE_DEC, NULL, 0x0,
5909                     "Option 43:CL 0 Padding", HFILL }},
5910
5911                 { &hf_bootp_option43_cl_suboption_request_list,
5912                   { "Suboption Request List", "bootp.option.vendor.cl.suboption_request_list",
5913                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5914                     "Option 43:CL 1 Suboption Request List", HFILL }},
5915
5916                 { &hf_bootp_option43_cl_device_type,
5917                   { "Device Type", "bootp.option.vendor.cl.device_type",
5918                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5919                     "Option 43:CL 2 Device Type", HFILL }},
5920
5921                 { &hf_bootp_option43_cl_esafe_type,
5922                   { "eSAFE Types", "bootp.option.vendor.cl.esafe_type",
5923                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5924                     "Option 43:CL 3 eSAFE Types", HFILL }},
5925
5926                 { &hf_bootp_option43_cl_serial_number,
5927                   { "Serial Number", "bootp.option.vendor.cl.serial_number",
5928                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5929                     "Option 43:CL 4 Serial Number", HFILL }},
5930
5931                 { &hf_bootp_option43_cl_hardware_version,
5932                   { "Hardware Version", "bootp.option.vendor.cl.hardware_version",
5933                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5934                     "Option 43:CL 5 Hardware Version", HFILL }},
5935
5936                 { &hf_bootp_option43_cl_software_version,
5937                   { "Software Version", "bootp.option.vendor.cl.software_version",
5938                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5939                     "Option 43:CL 6 Software Version", HFILL }},
5940
5941                 { &hf_bootp_option43_cl_boot_rom_version,
5942                   { "Boot ROM version", "bootp.option.vendor.cl.boot_rom_version",
5943                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5944                     "Option 43:CL 7 Boot ROM version", HFILL }},
5945
5946                 { &hf_bootp_option43_cl_oui_string,
5947                   { "Organizationally Unique Identifier", "bootp.option.vendor.cl.oui_string",
5948                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5949                     "Option 43:CL 8 Organizationally Unique Identifier", HFILL }},
5950
5951                 { &hf_bootp_option43_cl_oui_bytes,
5952                   { "Organizationally Unique Identifier", "bootp.option.vendor.cl.oui_bytes",
5953                     FT_BYTES, BASE_NONE, NULL, 0x0,
5954                     "Option 43:CL 8 Organizationally Unique Identifier", HFILL }},
5955
5956                 { &hf_bootp_option43_cl_model_number,
5957                   { "Model Number", "bootp.option.vendor.cl.model_number",
5958                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5959                     "Option 43:CL 9 Model Number", HFILL }},
5960
5961                 { &hf_bootp_option43_cl_vendor_name10,
5962                   { "Vendor Name", "bootp.option.vendor.cl.vendor_name10",
5963                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5964                     "Option 43:CL 10 Vendor Name", HFILL }},
5965
5966                 { &hf_bootp_option43_cl_address_realm,
5967                   { "Address Realm", "bootp.option.vendor.cl.address_realm",
5968                     FT_UINT8, BASE_DEC, VALS(cablehome_subopt11_vals), 0x0,
5969                     "Option 43:CL 11 Address Realm", HFILL }},
5970
5971                 { &hf_bootp_option43_cl_cm_ps_system_desc,
5972                   { "CM/PS System Description", "bootp.option.vendor.cl.cm_ps_system_desc",
5973                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5974                     "Option 43:CL 12 CM/PS System Description", HFILL }},
5975
5976                 { &hf_bootp_option43_cl_cm_ps_firmware_revision,
5977                   { "CM/PS Firmware Revision", "bootp.option.vendor.cl.cm_ps_firmware_revision",
5978                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5979                     "Option 43:CL 13 CM/PS Firmware Revision", HFILL }},
5980
5981                 { &hf_bootp_option43_cl_firewall_policy_file_version,
5982                   { "Firewall Policy File Version", "bootp.option.vendor.cl.firewall_policy_file_version",
5983                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5984                     "Option 43:CL 14 Firewall Policy File Version", HFILL }},
5985
5986                 { &hf_bootp_option43_cl_esafe_config_file_devices,
5987                   { "eSafe Config File Devices", "bootp.option.vendor.cl.esafe_config_file_devices",
5988                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5989                     "Option 43:CL 15 eSafe Config File Devices", HFILL }},
5990
5991                 { &hf_bootp_option43_cl_video_security_tape,
5992                   { "Video Security Type", "bootp.option.vendor.cl.video_security_tape",
5993                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
5994                     "Option 43:CL 18 Video Security Type", HFILL }},
5995
5996                 { &hf_bootp_option43_cl_mta_mac_address,
5997                   { "MTA MAC Address", "bootp.option.vendor.cl.mta_mac_address",
5998                     FT_ETHER, BASE_NONE, NULL, 0x0,
5999                     "Option 43:CL 31 MTA MAC Address", HFILL }},
6000
6001                 { &hf_bootp_option43_cl_correlation_ID,
6002                   { "Correlation ID", "bootp.option.vendor.cl.correlation_ID",
6003                     FT_UINT32, BASE_DEC, NULL, 0x0,
6004                     "Option 43: CL 32 Correlation ID", HFILL }},
6005
6006                 { &hf_bootp_option43_cl_vendor_name51,
6007                   { "Vendor Name", "bootp.option.vendor.cl.vendor_name51",
6008                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6009                     "Option 43:CL 51 Vendor Name", HFILL }},
6010
6011                 { &hf_bootp_option43_cl_cablecard_capability,
6012                   { "CableCARD Capability", "bootp.option.vendor.cl.cablecard_capability",
6013                     FT_BYTES, BASE_NONE, NULL, 0x0,
6014                     "Option 43:CL 52 CableCARD Capability", HFILL }},
6015
6016                 { &hf_bootp_option43_cl_device_id_ca,
6017                   { "Device Identification (CA)", "bootp.option.vendor.cl.device_id_ca",
6018                     FT_BYTES, BASE_NONE, NULL, 0x0,
6019                     "Option 43:CL 53 Device Identification (CA)", HFILL }},
6020
6021                 { &hf_bootp_option43_cl_device_id_x509,
6022                   { "Device Identification (X.509)", "bootp.option.vendor.cl.device_id_x509",
6023                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6024                     "Option 43:CL 54 Device Identification (X.509)", HFILL }},
6025
6026                 { &hf_bootp_option43_cl_end,
6027                   { "CL End", "bootp.option.vendor.cl.end",
6028                     FT_UINT8, BASE_DEC, NULL, 0x0,
6029                     "Option 43:CL 255 End", HFILL }},
6030
6031
6032                 { &hf_bootp_option43_alcatel_suboption,
6033                   { "Option 43 Suboption", "bootp.option.vendor.alu.suboption",
6034                     FT_UINT8, BASE_DEC, VALS(option43_alcatel_suboption_vals), 0x0,
6035                     "Option 43:Alcatel Suboption", HFILL }},
6036
6037                 { &hf_bootp_option43_alcatel_padding,
6038                   { "Padding", "bootp.option.vendor.alu.padding",
6039                     FT_UINT8, BASE_DEC, NULL, 0x0,
6040                     "Option 43:Alcatel 0 Padding", HFILL }},
6041
6042                 { &hf_bootp_option43_alcatel_vlan_id,
6043                   { "Voice VLAN ID", "bootp.option.vendor.alu.vid",
6044                     FT_UINT16, BASE_DEC, NULL, 0x0,
6045                     "Option 43:Alcatel 58 Voice VLAN ID", HFILL }},
6046
6047                 { &hf_bootp_option43_alcatel_tftp1,
6048                   { "Spatial Redundancy TFTP1", "bootp.option.vendor.alu.tftp1",
6049                     FT_IPv4, BASE_NONE, NULL, 0x0,
6050                     "Option 43:Alcatel 64 Spatial Redundancy TFTP1", HFILL }},
6051
6052                 { &hf_bootp_option43_alcatel_tftp2,
6053                   { "Spatial Redundancy TFTP2", "bootp.option.vendor.alu.tftp2",
6054                     FT_IPv4, BASE_NONE, NULL, 0x0,
6055                     "Option 43:Alcatel 65 Spatial Redundancy TFTP2", HFILL }},
6056
6057                 { &hf_bootp_option43_alcatel_app_type,
6058                   { "Application Type", "bootp.option.vendor.alu.app_type",
6059                     FT_UINT8, BASE_DEC, VALS(option43_alcatel_app_type_vals), 0x0,
6060                     "Option 43:Alcatel 66 Application Type", HFILL }},
6061
6062                 { &hf_bootp_option43_alcatel_sip_url,
6063                   { "SIP URL", "bootp.option.vendor.alu.sip_url",
6064                     FT_STRING, BASE_NONE, NULL, 0x0,
6065                     "Option 43:Alcatel 67 SIP URL", HFILL }},
6066
6067                 { &hf_bootp_option43_alcatel_end,
6068                   { "Alcatel End", "bootp.option.vendor.alu.end",
6069                     FT_UINT8, BASE_DEC, NULL, 0x0,
6070                     "Option 43:Alcatel 255 End", HFILL }},
6071
6072
6073                 { &hf_bootp_option_netbios_over_tcpip_name_server,
6074                   { "NetBIOS over TCP/IP Name Server", "bootp.option.netbios_over_tcpip_name_server",
6075                     FT_IPv4, BASE_NONE, NULL, 0x00,
6076                     "Option 44: NetBIOS over TCP/IP Name Server", HFILL }},
6077
6078                 { &hf_bootp_option_netbios_over_tcpip_dd_name_server,
6079                   { "NetBIOS over TCP/IP Datagram Distribution Name Server", "bootp.option.netbios_over_tcpip_dd_name_server",
6080                     FT_IPv4, BASE_NONE, NULL, 0x00,
6081                     "Option 45: NetBIOS over TCP/IP Datagram Distribution Name Server", HFILL }},
6082
6083                 { &hf_bootp_option_netbios_over_tcpip_node_type,
6084                   { "NetBIOS over TCP/IP Node Type", "bootp.option.netbios_over_tcpip_node_type",
6085                     FT_UINT8, BASE_DEC, VALS(bootp_nbnt_vals), 0x0,
6086                     "Option 46: NetBIOS over TCP/IP Node Type", HFILL }},
6087
6088                 { &hf_bootp_option_netbios_over_tcpip_scope,
6089                   { "NetBIOS over TCP/IP Scope", "bootp.option.netbios_over_tcpip_scope",
6090                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6091                     "Option 47: NetBIOS over TCP/IP Scope", HFILL }},
6092
6093                 { &hf_bootp_option_xwindows_system_font_server,
6094                   { "X Window System Font Server", "bootp.option.xwindows_system_font_server",
6095                     FT_IPv4, BASE_NONE, NULL, 0x00,
6096                     "Option 48: X Window System Font Server", HFILL }},
6097
6098                 { &hf_bootp_option_xwindows_system_display_manager,
6099                   { "X Window System Display Manager", "bootp.option.xwindows_system_display_manager",
6100                     FT_IPv4, BASE_NONE, NULL, 0x00,
6101                     "Option 49: X Window System Display Manager", HFILL }},
6102
6103                 { &hf_bootp_option_requested_ip_address,
6104                   { "Requested IP Address", "bootp.option.requested_ip_address",
6105                     FT_IPv4, BASE_NONE, NULL, 0x00,
6106                     "Option 50: Requested IP Address", HFILL }},
6107
6108                 { &hf_bootp_option_ip_address_lease_time,
6109                   { "IP Address Lease Time", "bootp.option.ip_address_lease_time",
6110                     FT_UINT32, BASE_DEC, NULL, 0x00,
6111                     "Option 51: IP Address Lease Time", HFILL }},
6112
6113                 { &hf_bootp_option_option_overload,
6114                   { "Option Overload", "bootp.option.option_overload",
6115                     FT_UINT8, BASE_DEC, VALS(opt_overload_vals), 0x0,
6116                     "Option 52: Option Overload", HFILL }},
6117
6118                 { &hf_bootp_option_dhcp,
6119                   { "DHCP", "bootp.option.dhcp",
6120                     FT_UINT8, BASE_DEC, VALS(opt53_text), 0x0,
6121                     "Option 53: DHCP option", HFILL }},
6122
6123                 { &hf_bootp_option_dhcp_server_id,
6124                   { "DHCP Server Identifier", "bootp.option.dhcp_server_id",
6125                     FT_IPv4, BASE_NONE, NULL, 0x00,
6126                     "Option 54: DHCP Server Identifier", HFILL }},
6127
6128                 { &hf_bootp_option_parameter_request_list_item,
6129                   { "Parameter Request List Item", "bootp.option.request_list_item",
6130                     FT_UINT8, BASE_DEC, NULL, 0x0,
6131                     "Option 55: Parameter Request List Item", HFILL }},
6132
6133                 { &hf_bootp_option_message,
6134                   { "Message", "bootp.option.message",
6135                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6136                     "Option 56: Option message", HFILL }},
6137
6138                 { &hf_bootp_option_dhcp_max_message_size,
6139                   { "Maximum DHCP Message Size", "bootp.option.dhcp_max_message_size",
6140                     FT_UINT16, BASE_DEC, NULL, 0x0,
6141                     "Option 57: Maximum DHCP Message Size", HFILL }},
6142
6143                 { &hf_bootp_option_renewal_time_value,
6144                   { "Renewal Time Value", "bootp.option.renewal_time_value",
6145                     FT_UINT32, BASE_DEC, NULL, 0x00,
6146                     "Option 58: Renewal Time Value", HFILL }},
6147
6148                 { &hf_bootp_option_rebinding_time_value,
6149                   { "Rebinding Time Value", "bootp.option.rebinding_time_value",
6150                     FT_UINT32, BASE_DEC, NULL, 0x00,
6151                     "Option 59: Rebinding Time Value", HFILL }},
6152
6153                 { &hf_bootp_option_vendor_class_id,
6154                   { "Vendor class identifier", "bootp.option.vendor_class_id",
6155                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6156                     "Option 60: Vendor class identifier", HFILL }},
6157
6158                 { &hf_bootp_option_novell_netware_ip_domain,
6159                   { "Novell/Netware IP domain", "bootp.option.novell_netware_ip_domain",
6160                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6161                     "Option 62: Novell/Netware IP domain", HFILL }},
6162
6163                 { &hf_bootp_option63_suboption,
6164                   { "Option 63 Suboption", "bootp.option.novell_options.suboption",
6165                     FT_UINT8, BASE_DEC, VALS(option63_suboption_vals), 0x0,
6166                     "Option 63: Suboption", HFILL }},
6167
6168                 { &hf_bootp_option63_value,
6169                   { "Value", "bootp.option.novell_options.value",
6170                     FT_BYTES, BASE_NONE, NULL, 0x0,
6171                     "Option 63: Suboption value", HFILL }},
6172
6173                 { &hf_bootp_option63_value_8,
6174                   { "Value", "bootp.option.novell_options.value.uint",
6175                     FT_UINT8, BASE_DEC, NULL, 0x0,
6176                     "Option 63: Suboption 8-bit value", HFILL }},
6177
6178                 { &hf_bootp_option63_value_ip_address,
6179                   { "Value", "bootp.option.novell_options.value.address",
6180                     FT_IPv4, BASE_NONE, NULL, 0x00,
6181                     "Option 63: Suboption IP address", HFILL }},
6182
6183                 { &hf_bootp_option63_value_boolean,
6184                   { "Value", "bootp.option.novell_options.value.bool",
6185                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_true_false), 0x00,
6186                     "Option 63: Suboption Boolean value", HFILL }},
6187
6188                 { &hf_bootp_option63_broadcast,
6189                   { "Broadcast for nearest Netware server", "bootp.option.novell_options.broadcast",
6190                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x00,
6191                     "Option 63:5 Broadcast for nearest Netware server", HFILL }},
6192
6193                 { &hf_bootp_option63_preferred_dss_server,
6194                   { "Preferred DSS server", "bootp.option.novell_options.preferred_dss_server",
6195                     FT_IPv4, BASE_NONE, NULL, 0x00,
6196                     "Option 63:6 Preferred DSS server", HFILL }},
6197
6198                 { &hf_bootp_option63_nearest_nwip_server,
6199                   { "Nearest NWIP server", "bootp.option.novell_options.nearest_nwip_server",
6200                     FT_IPv4, BASE_NONE, NULL, 0x00,
6201                     "Option 63:7 Nearest NWIP server", HFILL }},
6202
6203                 { &hf_bootp_option63_autoretries,
6204                   { "Autoretries", "bootp.option.novell_options.autoretries",
6205                     FT_UINT8, BASE_DEC, NULL, 0x0,
6206                     "Option 63:8 Autoretries", HFILL }},
6207
6208                 { &hf_bootp_option63_autoretry_delay,
6209                   { "Autoretry delay, sec",
6210                     "bootp.option.novell_options.autoretry_delay", FT_UINT8, BASE_DEC, NULL,
6211                     0x0, "Option 63:9 Autoretry delay, sec", HFILL }},
6212
6213                 { &hf_bootp_option63_support_netware_v1_1,
6214                   { "Broadcast for nearest Netware server", "bootp.option.novell_options.support_netware_v1_1",
6215                     FT_BOOLEAN, BASE_NONE, TFS(&tfs_yes_no), 0x00,
6216                     "Option 63:10 Broadcast for nearest Netware server", HFILL }},
6217
6218                 { &hf_bootp_option63_primary_dss,
6219                   { "Primary DSS", "bootp.option.novell_options.primary_dss",
6220                     FT_IPv4, BASE_NONE, NULL, 0x00,
6221                     "Option 63:11 Primary DSS", HFILL }},
6222
6223
6224                 { &hf_bootp_option_nis_plus_domain,
6225                   { "Network Information Service+ Domain", "bootp.option.nis_plus_domain",
6226                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6227                     "Option 64: Network Information Service+ Domain", HFILL }},
6228
6229                 { &hf_bootp_option_nis_plus_server,
6230                   { "Network Information Service+ Server", "bootp.option.nis_plus_server",
6231                     FT_IPv4, BASE_NONE, NULL, 0x00,
6232                     "Option 65: Network Information Service+ Server", HFILL }},
6233
6234                 { &hf_bootp_option_tftp_server_name,
6235                   { "TFTP Server Name", "bootp.option.tftp_server_name",
6236                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6237                     "Option 66: TFTP Server Name", HFILL }},
6238
6239                 { &hf_bootp_option_bootfile_name,
6240                   { "Bootfile name", "bootp.option.bootfile_name",
6241                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6242                     "Option 67: Bootfile name", HFILL }},
6243
6244                 { &hf_bootp_option_mobile_ip_home_agent,
6245                   { "Mobile IP Home Agent", "bootp.option.mobile_ip_home_agent",
6246                     FT_IPv4, BASE_NONE, NULL, 0x00,
6247                     "Option 68: Mobile IP Home Agent", HFILL }},
6248
6249                 { &hf_bootp_option_smtp_server,
6250                   { "SMTP Server", "bootp.option.smtp_server",
6251                     FT_IPv4, BASE_NONE, NULL, 0x00,
6252                     "Option 69: SMTP Server", HFILL }},
6253
6254                 { &hf_bootp_option_pop3_server,
6255                   { "POP3 Server", "bootp.option.pop3_server",
6256                     FT_IPv4, BASE_NONE, NULL, 0x00,
6257                     "Option 70: POP3 Server", HFILL }},
6258
6259                 { &hf_bootp_option_nntp_server,
6260                   { "NNTP Server", "bootp.option.nntp_server",
6261                     FT_IPv4, BASE_NONE, NULL, 0x00,
6262                     "Option 71: NNTP Server", HFILL }},
6263
6264                 { &hf_bootp_option_default_www_server,
6265                   { "Default WWW Server", "bootp.option.default_www_server",
6266                     FT_IPv4, BASE_NONE, NULL, 0x00,
6267                     "Option 72: Default WWW Server", HFILL }},
6268
6269                 { &hf_bootp_option_default_finger_server,
6270                   { "Default Finger Server", "bootp.option.default_finger_server",
6271                     FT_IPv4, BASE_NONE, NULL, 0x00,
6272                     "Option 73: Default Finger Server", HFILL }},
6273
6274                 { &hf_bootp_option_default_irc_server,
6275                   { "Default IRC Server", "bootp.option.default_irc_server",
6276                     FT_IPv4, BASE_NONE, NULL, 0x00,
6277                     "Option 74: Default IRC Server", HFILL }},
6278
6279                 { &hf_bootp_option_streettalk_server,
6280                   { "StreetTalk Server", "bootp.option.streettalk_server",
6281                     FT_IPv4, BASE_NONE, NULL, 0x00,
6282                     "Option 75: StreetTalk Server", HFILL }},
6283
6284                 { &hf_bootp_option_streettalk_da_server,
6285                   { "StreetTalk Directory Assistance Server", "bootp.option.streettalk_da_server",
6286                     FT_IPv4, BASE_NONE, NULL, 0x00,
6287                     "Option 76: StreetTalk Directory Assistance Server", HFILL }},
6288
6289                 { &hf_bootp_option77_user_class,
6290                   { "Instance of User Class", "bootp.option.user_class",
6291                     FT_UINT8, BASE_DEC, NULL, 0x0,
6292                     NULL, HFILL }},
6293
6294                 { &hf_bootp_option77_user_class_length,
6295                   { "User Class Length", "bootp.option.user_class.length",
6296                     FT_UINT8, BASE_DEC, NULL, 0x0,
6297                     "Length of User Class Instance", HFILL }},
6298
6299                 { &hf_bootp_option77_user_class_data,
6300                   { "User Class Data", "bootp.option.user_class.data",
6301                     FT_BYTES, BASE_NONE, NULL, 0x0,
6302                     "Data of User Class Instance", HFILL }},
6303
6304                 { &hf_bootp_option_slp_directory_agent_value,
6305                   { "Value", "bootp.option.slp_directory_agent.value",
6306                     FT_UINT8, BASE_DEC, VALS(slpda_vals), 0x0,
6307                     "Option 78: SLPDA Value", HFILL }},
6308
6309                 { &hf_bootp_option_slp_directory_agent_slpda_address,
6310                   { "IP Address", "bootp.option.slp_directory_agent.slpda_address",
6311                     FT_IPv4, BASE_NONE, NULL, 0x00,
6312                     "Option 78: SLPDA Address", HFILL }},
6313
6314                 { &hf_bootp_option_slp_service_scope_value,
6315                   { "Value", "bootp.option.slp_service_scope.value",
6316                     FT_UINT8, BASE_DEC, VALS(slp_scope_vals), 0x0,
6317                     "Option 79: SLP Service Scope Value", HFILL }},
6318
6319                 { &hf_bootp_option_slp_service_scope_string,
6320                   { "SLP Service Scope", "bootp.option.slp_service_scope.string",
6321                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6322                     "Option 79: SLP Service Scope", HFILL }},
6323
6324
6325                 { &hf_bootp_option82_suboption,
6326                   { "Option 82 Suboption", "bootp.option.agent_information_option.suboption",
6327                     FT_UINT8, BASE_DEC, VALS(option82_suboption_vals), 0x0,
6328                     "Option 82: Suboption", HFILL }},
6329
6330                 { &hf_bootp_option82_value,
6331                   { "Value", "bootp.option.agent_information_option.value",
6332                     FT_BYTES, BASE_NONE, NULL, 0x0,
6333                     "Option 82: Suboption value", HFILL }},
6334
6335                 { &hf_bootp_option82_value_8,
6336                   { "Value", "bootp.option.agent_information_option.value.uint",
6337                     FT_UINT8, BASE_DEC, NULL, 0x0,
6338                     "Option 82: Suboption 8-bit value", HFILL }},
6339
6340                 { &hf_bootp_option82_value_32,
6341                   { "Value", "bootp.option.agent_information_option.value.uint",
6342                     FT_UINT32, BASE_DEC, NULL, 0x0,
6343                     "Option 82: Suboption 32-bit value", HFILL }},
6344
6345                 { &hf_bootp_option82_value_ip_address,
6346                   { "Value", "bootp.option.agent_information_option.value.address",
6347                     FT_IPv4, BASE_NONE, NULL, 0x00,
6348                     "Option 82: Suboption IP address", HFILL }},
6349
6350                 { &hf_bootp_option82_value_stringz,
6351                   { "Value", "bootp.option.agent_information_option.value.string",
6352                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6353                     "Option 82: Suboption Z-String value", HFILL }},
6354
6355                 { &hf_bootp_option82_padding,
6356                   { "Padding", "bootp.option.agent_information_option.padding",
6357                     FT_UINT8, BASE_DEC, NULL, 0x0,
6358                     "Option 82:0 Padding", HFILL }},
6359
6360                 { &hf_bootp_option82_agent_circuit_id,
6361                   { "Agent Circuit ID", "bootp.option.agent_information_option.agent_circuit_id",
6362                     FT_BYTES, BASE_NONE, NULL, 0x0,
6363                     "Option 82:1 Agent Circuit ID", HFILL }},
6364
6365                 { &hf_bootp_option82_agent_remote_id,
6366                   { "Agent Remote ID", "bootp.option.agent_information_option.agent_remote_id",
6367                     FT_BYTES, BASE_NONE, NULL, 0x0,
6368                     "Option 82:2 Agent Remote ID", HFILL }},
6369
6370                 { &hf_bootp_option82_reserved,
6371                   { "Reserved", "bootp.option.agent_information_option.reserved",
6372                     FT_BYTES, BASE_NONE, NULL, 0x0,
6373                     "Option 82:3 Reserved", HFILL }},
6374
6375                 { &hf_bootp_option82_docsis_device_class,
6376                   { "DOCSIS Device Class", "bootp.option.agent_information_option.docsis_device_class",
6377                     FT_UINT32, BASE_HEX, NULL, 0x0,
6378                     "Option 82:4 DOCSIS Device Class", HFILL }},
6379
6380                 { &hf_bootp_option82_link_selection,
6381                   { "Link selection", "bootp.option.agent_information_option.link_selection",
6382                     FT_IPv4, BASE_NONE, NULL, 0x00,
6383                     "Option 82:5 Link selection", HFILL }},
6384
6385                 { &hf_bootp_option82_subscriber_id,
6386                   { "Subscriber ID", "bootp.option.agent_information_option.subscriber_id",
6387                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6388                     "Option 82:6 Subscriber ID", HFILL }},
6389
6390                 { &hf_bootp_option82_radius_attributes,
6391                   { "RADIUS Attributes", "bootp.option.agent_information_option.radius_attributes",
6392                     FT_BYTES, BASE_NONE, NULL, 0x0,
6393                     "Option 82:7 RADIUS Attributes", HFILL }},
6394
6395                 { &hf_bootp_option82_authentication,
6396                   { "Authentication", "bootp.option.agent_information_option.authentication",
6397                     FT_BYTES, BASE_NONE, NULL, 0x0,
6398                     "Option 82:8 Authentication", HFILL }},
6399
6400                 { &hf_bootp_option82_vi,
6401                   { "Vendor-Specific Information", "bootp.option.agent_information_option.vi",
6402                     FT_BYTES, BASE_NONE, NULL, 0x0,
6403                     "Option 82:9 Vendor-Specific Information", HFILL }},
6404
6405                 { &hf_bootp_option82_vi_enterprise,
6406                   { "Enterprise", "bootp.option.agent_information_option.vi.enterprise",
6407                     FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x0,
6408                     "Option 82:9 VI Enterprise", HFILL }},
6409
6410                 { &hf_bootp_option82_vi_data_length,
6411                   { "Data Length", "bootp.option.agent_information_option.vi.data_length",
6412                     FT_UINT8, BASE_DEC, NULL, 0x0,
6413                     "Option 82:9 VI Data Length", HFILL }},
6414
6415                 { &hf_bootp_option82_vi_cl_option,
6416                   { "Option", "bootp.option.agent_information_option.vi.cl.option",
6417                     FT_UINT8, BASE_DEC, NULL, 0x0,
6418                     "Option 82:9 VI CL Option", HFILL }},
6419
6420                 { &hf_bootp_option82_vi_cl_length,
6421                   { "Length", "bootp.option.agent_information_option.vi.cl.length",
6422                     FT_UINT8, BASE_DEC, NULL, 0x0,
6423                     "Option 82:9 VI CL Length", HFILL }},
6424
6425                 { &hf_bootp_option82_vi_cl_tag,
6426                   { "Tag", "bootp.option.agent_information_option.vi.cl.tag",
6427                     FT_UINT8, BASE_DEC, NULL, 0x0,
6428                     "Option 82:9 VI CL Tag", HFILL }},
6429
6430                 { &hf_bootp_option82_vi_cl_tag_length,
6431                   { "Tag Length", "bootp.option.agent_information_option.vi.cl.tag_length",
6432                     FT_UINT8, BASE_DEC, NULL, 0x0,
6433                     "Option 82:9 VI CL Tag Length", HFILL }},
6434
6435                 { &hf_bootp_option82_vi_cl_docsis_version,
6436                   { "DOCSIS Version Number", "bootp.option.agent_information_option.vi.cl.docsis_version",
6437                     FT_UINT16, BASE_HEX, NULL, 0x0,
6438                     "Option 82:9 VI CL DOCSIS Version Number", HFILL }},
6439
6440                 { &hf_bootp_option82_flags,
6441                   { "Flags", "bootp.option.agent_information_option.flags",
6442                     FT_UINT8, BASE_HEX, NULL, 0x0,
6443                     "Option 82:10 Flags", HFILL }},
6444
6445                 { &hf_bootp_option82_server_id_override,
6446                   { "Server ID Override", "bootp.option.agent_information_option.server_id_override",
6447                     FT_IPv4, BASE_NONE, NULL, 0x00,
6448                     "Option 82:11 Server ID Override", HFILL }},
6449
6450                 { &hf_bootp_option82_link_selection_cisco,
6451                   { "Link selection (Cisco proprietary)", "bootp.option.agent_information_option.link_selection_cisco",
6452                     FT_IPv4, BASE_NONE, NULL, 0x00,
6453                     "Option 82:150 Link selection (Cisco proprietary)", HFILL }},
6454
6455                 { &hf_bootp_option82_vrf_name_vpn_id,
6456                   { "VRF name/VPN ID", "bootp.option.agent_information_option.vrf_name_vpn_id",
6457                     FT_BYTES, BASE_NONE, NULL, 0x00,
6458                     "Option 82:151 VRF name/VPN ID", HFILL }},
6459
6460                 { &hf_bootp_option82_vrf_name_vpn_id_oui,
6461                   { "VRF name/VPN ID OUI", "bootp.option.agent_information_option.vrf_name_vpn_id_oui",
6462                     FT_UINT24, BASE_HEX, NULL, 0x00,
6463                     "Option 82:151 VRF name/VPN ID OUI", HFILL }},
6464
6465                 { &hf_bootp_option82_vrf_name_vpn_id_index,
6466                   { "VRF name/VPN ID Index", "bootp.option.agent_information_option.vrf_name_vpn_id_index",
6467                     FT_UINT32, BASE_HEX, NULL, 0x00,
6468                     "Option 82:151 VRF name/VPN ID Index", HFILL }},
6469
6470                 { &hf_bootp_option82_server_id_override_cisco,
6471                   { "Server ID Override (Cisco proprietary)", "bootp.option.agent_information_option.server_id_override_cisco",
6472                     FT_IPv4, BASE_NONE, NULL, 0x00,
6473                     "Option 82:152 Server ID Override (Cisco proprietary)", HFILL }},
6474
6475
6476                 { &hf_bootp_option_novell_dss_string,
6477                   { "Novell Directory Services Servers String", "bootp.option.novell_dss.string",
6478                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6479                     "Option 85: Novell Directory Services Servers String", HFILL }},
6480
6481                 { &hf_bootp_option_novell_dss_ip,
6482                   { "IP Address", "bootp.option.novell_dss.ip",
6483                     FT_IPv4, BASE_NONE, NULL, 0x00,
6484                     "Option 85: Novell Directory Services Servers IP Address", HFILL }},
6485
6486                 { &hf_bootp_option_novell_ds_tree_name,
6487                   { "Novell Directory Services Tree Name", "bootp.option.novell_ds_tree_name",
6488                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6489                     "Option 86: Novell Directory Services Tree Name", HFILL }},
6490
6491                 { &hf_bootp_option_novell_ds_context,
6492                   { "Novell Directory Services Context", "bootp.option.novell_ds_context",
6493                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6494                     "Option 87: Novell Directory Services Context", HFILL }},
6495
6496                 { &hf_bootp_option_dhcp_authentication_protocol,
6497                   { "Protocol", "bootp.option.dhcp_authentication.protocol",
6498                     FT_UINT8, BASE_DEC, VALS(authen_protocol_vals), 0x0,
6499                     "Option 90: Authentication Protocol", HFILL }},
6500
6501                 { &hf_bootp_option_dhcp_authentication_alg_delay,
6502                   { "Delay Algorithm", "bootp.option.dhcp_authentication.alg_delay",
6503                     FT_UINT8, BASE_DEC, VALS(authen_da_algo_vals), 0x0,
6504                     "Option 90: Delayed Authentication Algorithm", HFILL }},
6505
6506                 { &hf_bootp_option_dhcp_authentication_algorithm,
6507                   { "Algorithm", "bootp.option.dhcp_authentication.algorithm",
6508                     FT_UINT8, BASE_DEC, NULL, 0x0,
6509                     "Option 90: Authentication Algorithm", HFILL }},
6510
6511                 { &hf_bootp_option_dhcp_authentication_rdm,
6512                   { "Replay Detection Method", "bootp.option.dhcp_authentication.rdm",
6513                     FT_UINT8, BASE_DEC, VALS(authen_rdm_vals), 0x0,
6514                     "Option 90: Replay Detection Method", HFILL }},
6515
6516                 { &hf_bootp_option_dhcp_authentication_rdm_replay_detection,
6517                   { "RDM Replay Detection Value", "bootp.option.dhcp_authentication.rdm_replay_detection",
6518                     FT_UINT64, BASE_HEX, NULL, 0x0,
6519                     "Option 90: RDM Replay Detection Value", HFILL }},
6520
6521                 { &hf_bootp_option_dhcp_authentication_rdm_rdv,
6522                   { "Replay Detection Value", "bootp.option.dhcp_authentication.rdm_rdv",
6523                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6524                     "Option 90: Replay Detection Value", HFILL }},
6525
6526                 { &hf_bootp_option_dhcp_authentication_secret_id,
6527                   { "Secret ID", "bootp.option.dhcp_authentication.secret_id",
6528                     FT_UINT32, BASE_HEX, NULL, 0x0,
6529                     "Option 90: Secret ID", HFILL }},
6530
6531                 { &hf_bootp_option_dhcp_authentication_hmac_md5_hash,
6532                   { "HMAC MD5 Hash", "bootp.option.dhcp_authentication.hmac_md5_hash",
6533                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6534                     "Option 90: HMAC MD5 Hash", HFILL }},
6535
6536                 { &hf_bootp_option_dhcp_authentication_information,
6537                   { "Authentication Information", "bootp.option.dhcp_authentication.information",
6538                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6539                     "Option 90: Authentication Information", HFILL }},
6540
6541                 { &hf_bootp_option_client_last_transaction_time,
6542                   { "Client last transaction time", "bootp.option.client_last_transaction_time",
6543                     FT_UINT32, BASE_DEC, NULL, 0x00,
6544                     "Option 91: Client last transaction time", HFILL }},
6545
6546                 { &hf_bootp_option_associated_ip_option,
6547                   { "Associated IP option", "bootp.option.associated_ip_option",
6548                     FT_IPv4, BASE_NONE, NULL, 0x00,
6549                     "Option 92: Associated IP option", HFILL }},
6550
6551                 { &hf_bootp_option_client_system_architecture,
6552                   { "Client System Architecture", "bootp.option.client_system_architecture",
6553                     FT_UINT16, BASE_DEC, VALS(bootp_client_arch), 0x0,
6554                     "Option 93: Client System Architecture", HFILL }},
6555
6556                 { &hf_bootp_option_client_network_id_major_ver,
6557                   { "Major Version", "bootp.client_network_id_major",
6558                     FT_UINT8, BASE_DEC, NULL, 0x0,
6559                     "Option 94: Major Version", HFILL }},
6560
6561                 { &hf_bootp_option_client_network_id_minor_ver,
6562                   { "Minor Version", "bootp.client_network_id_minor",
6563                     FT_UINT8, BASE_DEC, NULL, 0x0,
6564                     "Option 94: Minor Version", HFILL }},
6565
6566                 { &hf_bootp_option_civic_location_what,
6567                   { "What", "bootp.option.civic_location.what",
6568                     FT_UINT8, BASE_DEC, VALS(civic_address_what_values), 0x0,
6569                     "Option 99: What", HFILL }},
6570
6571                 { &hf_bootp_option_civic_location_country,
6572                   { "Country", "bootp.option.civic_location.country",
6573                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6574                     "Option 99: Country", HFILL }},
6575
6576                 { &hf_bootp_option_civic_location_ca_type,
6577                   { "CA Type", "bootp.option.civic_location.ca_type",
6578                     FT_UINT8, BASE_DEC, VALS(civic_address_type_values), 0x0,
6579                     "Option 99: CA Type", HFILL }},
6580
6581                 { &hf_bootp_option_civic_location_ca_length,
6582                   { "CA Length", "bootp.option.civic_location.ca_length",
6583                     FT_UINT8, BASE_DEC, NULL, 0x0,
6584                     "Option 99: CA Length", HFILL }},
6585
6586                 { &hf_bootp_option_civic_location_ca_value,
6587                   { "CA Value", "bootp.option.civic_location.ca_value",
6588                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6589                     "Option 99: CA Value", HFILL }},
6590
6591                 { &hf_bootp_option_netinfo_parent_server_address,
6592                   { "NetInfo Parent Server Address", "bootp.option.netinfo_parent_server_address",
6593                     FT_IPv4, BASE_NONE, NULL, 0x00,
6594                     "Option 112: NetInfo Parent Server Address", HFILL }},
6595
6596                 { &hf_bootp_option_netinfo_parent_server_tag,
6597                   { "NetInfo Parent Server Tag", "bootp.option.netinfo_parent_server_tag",
6598                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6599                     "Option 113: NetInfo Parent Server Tag", HFILL }},
6600
6601                 { &hf_bootp_option_dhcp_auto_configuration,
6602                   { "DHCP Auto-Configuration", "bootp.option.dhcp_auto_configuration",
6603                     FT_UINT8, BASE_DEC, VALS(dhcp_autoconfig), 0x0,
6604                     "Option 116: DHCP Auto-Configuration", HFILL }},
6605
6606                 { &hf_bootp_option_dhcp_name_service_search_option,
6607                   { "Name Service", "bootp.option.dhcp_name_service_search_option",
6608                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6609                     "Option 117: Name Service", HFILL }},
6610
6611                 { &hf_bootp_option_dhcp_dns_domain_search_list_rfc_3396_detected,
6612                   { "Encoding Long Options detected (RFC 3396)", "bootp.option.dhcp_dns_domain_search_list_rfc_3396_detected",
6613                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6614                     "Option 119: Encoding Long Options detected (RFC 3396)", HFILL }},
6615
6616                 { &hf_bootp_option_dhcp_dns_domain_search_list_refer_last_option,
6617                   { "For the data, please refer to last option 119", "bootp.option.dhcp_dns_domain_search_list_refer_last_option",
6618                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6619                     "Option 119: For the data, please refer to last option 119", HFILL }},
6620
6621                 { &hf_bootp_option_dhcp_dns_domain_search_list_fqdn,
6622                   { "FQDN", "bootp.option.dhcp_dns_domain_search_list_fqdn",
6623                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6624                     "Option 119: FQDN", HFILL }},
6625
6626                 { &hf_bootp_option_sip_server_rfc_3396_detected,
6627                   { "Encoding Long Options detected (RFC 3396)", "bootp.option.sip_server.rfc_3396_detected",
6628                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6629                     "Option 120: Encoding Long Options detected (RFC 3396)", HFILL }},
6630
6631                 { &hf_bootp_option_sip_server_refer_last_option,
6632                   { "For the data, please refer to last option 120", "bootp.option.sip_server.refer_last_option",
6633                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6634                     "Option 120: For the data, please refer to last option 120", HFILL }},
6635
6636                 { &hf_bootp_option_sip_server_enc,
6637                   { "SIP Server Encoding", "bootp.option.sip_server.encoding",
6638                     FT_UINT8, BASE_DEC, VALS(sip_server_enc_vals), 0x0,
6639                     "Option 120: SIP Server encoding", HFILL }},
6640
6641                 { &hf_bootp_option_sip_server_name,
6642                   { "SIP Server Name", "bootp.option.sip_server.name",
6643                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6644                     "Option 120: SIP Server Name", HFILL }},
6645
6646                 { &hf_bootp_option_sip_server_address,
6647                   { "SIP Server Address", "bootp.option.sip_server.address",
6648                     FT_IPv4, BASE_NONE, NULL, 0x0,
6649                     "Option 120: SIP Server Address", HFILL }},
6650
6651                 { &hf_bootp_option_sip_server_address_stringz,
6652                   { "SIP Server Address", "bootp.option.sip_server.address.stringz",
6653                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6654                     "Option 120: SIP Server Address", HFILL }},
6655
6656                 { &hf_bootp_option_cl_dss_id_option,
6657                   { "DSS_ID Type", "bootp.option.cl_dss_id.option",
6658                     FT_UINT8, BASE_DEC, VALS(cl_dss_id_type_vals), 0x0,
6659                     "Option 123:CL DSS_ID Type", HFILL }},
6660
6661                 { &hf_bootp_option_cl_dss_id_len,
6662                   { "DSS_ID Length", "bootp.option.cl_dss_id.len",
6663                     FT_UINT8, BASE_DEC, NULL, 0x0,
6664                     "Option 123:CL DSS_ID Length", HFILL }},
6665
6666                 { &hf_bootp_option_cl_dss_id,
6667                   { "Country", "bootp.option.cl_dss_id",
6668                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6669                     "Option 123:CL DSS_ID", HFILL }},
6670
6671                 { &hf_bootp_option_vi_class_cl_address_mode,
6672                   { "CableLab Address Mode", "bootp.option.vi_class.cl_address_mode",
6673                     FT_UINT8, BASE_DEC, VALS(cablelab_ipaddr_mode_vals), 0x0,
6674                     "Option 124: CableLab Address Mode", HFILL }},
6675
6676                 { &hf_bootp_option_vi_class_enterprise,
6677                   { "Enterprise", "bootp.option.vi_class.enterprise",
6678                     FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
6679                     "Option 124: Enterprise", HFILL }},
6680
6681                 { &hf_bootp_option_vi_class_data_length,
6682                   { "CableLab Address Mode", "bootp.option.vi_class.length",
6683                     FT_UINT8, BASE_DEC, NULL, 0x0,
6684                     "Option 124: Length", HFILL }},
6685
6686                 { &hf_bootp_option_vi_class_data,
6687                   { "NetInfo Parent Server Tag", "bootp.option.vi_class.data",
6688                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6689                     "Option 124: Data", HFILL }},
6690
6691                 { &hf_bootp_option125_enterprise,
6692                   { "Enterprise", "bootp.option.vi.enterprise",
6693                     FT_UINT32, BASE_DEC|BASE_EXT_STRING, &sminmpec_values_ext, 0x00,
6694                     "Option 125: Enterprise", HFILL }},
6695
6696                 { &hf_bootp_option125_value,
6697                   { "Value", "bootp.option.vi.value",
6698                     FT_BYTES, BASE_NONE, NULL, 0x0,
6699                     "Option 125: Suboption value", HFILL }},
6700
6701                 { &hf_bootp_option125_value_8,
6702                   { "Value", "bootp.option.vi.value.uint",
6703                     FT_UINT8, BASE_DEC, NULL, 0x0,
6704                     "Option 125: Suboption 8-bit value", HFILL }},
6705
6706                 { &hf_bootp_option125_value_16,
6707                   { "Value", "bootp.option.vi.value.uint",
6708                     FT_UINT16, BASE_DEC, NULL, 0x0,
6709                     "Option 125: Suboption 16-bit value", HFILL }},
6710
6711                 { &hf_bootp_option125_value_ip_address,
6712                   { "Value", "bootp.option.vi.value.address",
6713                     FT_IPv4, BASE_NONE, NULL, 0x00,
6714                     "Option 125: Suboption IP address value", HFILL }},
6715
6716                 { &hf_bootp_option125_value_stringz,
6717                   { "Value", "bootp.option.vi.value.string",
6718                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6719                     "Option 125: Suboption Z-String value", HFILL }},
6720
6721                 { &hf_bootp_option125_tr111_suboption,
6722                   { "Option 125 Suboption", "bootp.option.vi.tr111.suboption",
6723                     FT_UINT8, BASE_DEC, VALS(option125_tr111_suboption_vals), 0x0,
6724                     "Option 125:TR 111 Suboption", HFILL }},
6725
6726                 { &hf_bootp_option125_tr111_device_manufacturer_oui,
6727                   { "DeviceManufacturerOUI", "bootp.option.vi.tr111.device_manufacturer_oui",
6728                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6729                     "Option 125:TR 111 1 DeviceManufacturerOUI", HFILL }},
6730
6731                 { &hf_bootp_option125_tr111_device_serial_number,
6732                   { "DeviceSerialNumber", "bootp.option.vi.tr111.device_serial_number",
6733                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6734                     "Option 125:TR 111 2 DeviceSerialNumber", HFILL }},
6735
6736                 { &hf_bootp_option125_tr111_device_product_class,
6737                   { "DeviceProductClass", "bootp.option.vi.tr111.device_product_class",
6738                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6739                     "Option 125:TR 111 3 DeviceProductClass", HFILL }},
6740
6741                 { &hf_bootp_option125_tr111_gateway_manufacturer_oui,
6742                   { "GatewayManufacturerOUI", "bootp.option.vi.tr111.gateway_manufacturer_oui",
6743                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6744                     "Option 125:TR 111 4 GatewayManufacturerOUI", HFILL }},
6745
6746                 { &hf_bootp_option125_tr111_gateway_serial_number,
6747                   { "GatewaySerialNumber", "bootp.option.vi.tr111.gateway_serial_number",
6748                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6749                     "Option 125:TR 111 5 GatewaySerialNumber", HFILL }},
6750
6751                 { &hf_bootp_option125_tr111_gateway_product_class,
6752                   { "GatewayProductClass", "bootp.option.vi.tr111.gateway_product_class",
6753                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6754                     "Option 125:TR 111 6 GatewayProductClass", HFILL }},
6755
6756                 { &hf_bootp_option125_cl_suboption,
6757                   { "Option 125 Suboption", "bootp.option.vi.cl.suboption",
6758                     FT_UINT8, BASE_DEC, VALS(option125_cl_suboption_vals), 0x0,
6759                     "Option 125:CL Suboption", HFILL }},
6760
6761                 { &hf_bootp_option125_cl_option_request,
6762                   { "Option Request", "bootp.option.vi.cl.option_request",
6763                     FT_UINT8, BASE_DEC, NULL, 0x0,
6764                     "Option 125:CL 1 Option Request", HFILL }},
6765
6766                 { &hf_bootp_option125_cl_tftp_server_addresses,
6767                   { "TFTP Server Addresses", "bootp.option.vi.cl.tftp_server_addresses",
6768                     FT_IPv4, BASE_NONE, NULL, 0x00,
6769                     "Option 125:CL 2 TFTP Server Addresses", HFILL }},
6770
6771                 { &hf_bootp_option125_cl_erouter_container_option,
6772                   { "eRouter Container Option", "bootp.option.vi.cl.erouter_container_option",
6773                     FT_BYTES, BASE_NONE, NULL, 0x0,
6774                     "Option 125:CL 3 eRouter Container Option", HFILL }},
6775
6776                 { &hf_bootp_option125_cl_mib_environment_indicator_option,
6777                   { "MIB Environment Indicator Option", "bootp.option.vi.cl.suboption",
6778                     FT_UINT8, BASE_DEC, VALS(pkt_mib_env_ind_opt_vals), 0x0,
6779                     "Option 125:CL 4 MIB Environment Indicator Option", HFILL }},
6780
6781                 { &hf_bootp_option125_cl_modem_capabilities,
6782                   { "Modem Capabilities", "bootp.option.vi.cl.modem_capabilities",
6783                     FT_BYTES, BASE_NONE, NULL, 0x0,
6784                     "Option 125:CL 5 Modem Capabilities", HFILL }},
6785
6786                 { &hf_bootp_option_subnet_selection_option,
6787                   { "Subnet Selection Option", "bootp.option.subnet_selection_option",
6788                     FT_IPv4, BASE_NONE, NULL, 0x00,
6789                     "Option 118: Subnet Selection Option", HFILL }},
6790
6791                 { &hf_bootp_option_lost_server_domain_name,
6792                   { "LoST Server Domain Name", "bootp.option.lost_server_domain_name",
6793                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6794                     "Option 137: LoST Server Domain Name", HFILL }},
6795
6796                 { &hf_bootp_option_capwap_access_controller,
6797                   { "CAPWAP Access Controllers", "bootp.option.capwap_access_controller",
6798                     FT_IPv4, BASE_NONE, NULL, 0x00,
6799                     "Option 138: CAPWAP Access Controllers", HFILL }},
6800
6801                 { &hf_bootp_option_tftp_server_address,
6802                   { "TFTP Server Address", "bootp.option.tftp_server_address",
6803                     FT_IPv4, BASE_NONE, NULL, 0x00,
6804                     "Option 150: TFTP Server Address", HFILL }},
6805
6806                 { &hf_bootp_option_6RD_ipv4_mask_len,
6807                   { "6RD IPv4 Mask Length", "bootp.option.6RD.ipv4_mask_len",
6808                     FT_UINT8, BASE_DEC, NULL, 0x0,
6809                     "Option 212: 6RD IPv4 Mask Length", HFILL }},
6810
6811                 { &hf_bootp_option_6RD_prefix_len,
6812                   { "6RD Prefix Length", "bootp.option.6RD.prefix_len",
6813                     FT_UINT8, BASE_DEC, NULL, 0x0,
6814                     "Option 212: 6RD Prefix Length", HFILL }},
6815
6816                 { &hf_bootp_option_6RD_prefix,
6817                   { "6RD Prefix", "bootp.option.6RD.prefix",
6818                     FT_IPv6, BASE_NONE, NULL, 0x00,
6819                     "Option 212: 6RD Prefix", HFILL }},
6820
6821                 { &hf_bootp_option_6RD_border_relay_ip,
6822                   { "Border Relay IP", "bootp.option.6RD.border_relay_ip",
6823                     FT_IPv4, BASE_NONE, NULL, 0x00,
6824                     "Option 212: Border Relay IP", HFILL }},
6825
6826                 { &hf_bootp_option_private_proxy_autodiscovery,
6827                   { "Private/Proxy autodiscovery", "bootp.option.private_proxy_autodiscovery",
6828                     FT_STRINGZ, BASE_NONE, NULL, 0x0,
6829                     "Option 252: Private/Proxy autodiscovery", HFILL }},
6830
6831                 { &hf_bootp_option_end,
6832                   { "Option End", "bootp.option.end",
6833                     FT_UINT8, BASE_DEC, NULL, 0x0,
6834                     "Option 255: End", HFILL }},
6835
6836                 { &hf_bootp_option_end_overload,
6837                   { "Option End (Overload)", "bootp.option.end",
6838                     FT_UINT8, BASE_DEC, NULL, 0x0,
6839                     "Option 255: End (Overload)", HFILL }},
6840
6841         };
6842
6843         static uat_field_t bootp_uat_flds[] = {
6844                 UAT_FLD_DEC(uat_bootp_records, opt, "Option number", "Custom Option Number"),
6845                 UAT_FLD_CSTRING(uat_bootp_records, text, "Option Name", "Custom Option Name"),
6846                 UAT_FLD_VS(uat_bootp_records, ftype, "Option type", bootp_custom_type_vals, "Option datatype"),
6847                 UAT_END_FIELDS
6848         };
6849
6850         static gint *ett[] = {
6851                 &ett_bootp,
6852                 &ett_bootp_flags,
6853                 &ett_bootp_option,
6854                 &ett_bootp_option43_suboption,
6855                 &ett_bootp_option63_suboption,
6856                 &ett_bootp_option77_instance,
6857                 &ett_bootp_option82_suboption,
6858                 &ett_bootp_option82_suboption9,
6859                 &ett_bootp_option125_suboption,
6860                 &ett_bootp_fqdn,
6861         };
6862
6863         static ei_register_info ei[] = {
6864                 { &ei_bootp_bad_length, { "bootp.bad_length", PI_PROTOCOL, PI_ERROR, "length isn't 0", EXPFILL }},
6865                 { &ei_bootp_missing_subopt_length, { "bootp.missing_subopt_length", PI_PROTOCOL, PI_ERROR, "no room left in option for suboption length", EXPFILL }},
6866                 { &ei_bootp_missing_subopt_value, { "bootp.missing_subopt_value", PI_PROTOCOL, PI_ERROR, "no room left in option for suboption value", EXPFILL }},
6867                 { &ei_bootp_mal_duid, { "bootp.malformed.duid", PI_PROTOCOL, PI_ERROR, "DUID: malformed option", EXPFILL }},
6868                 { &hf_bootp_opt_overload_file_end_missing, { "bootp.option.option_overload.file_end_missing", PI_PROTOCOL, PI_ERROR, "file overload end option missing", EXPFILL }},
6869                 { &hf_bootp_opt_overload_sname_end_missing, { "bootp.option.option_overload.sname_end_missing", PI_PROTOCOL, PI_ERROR, "sname overload end option missing", EXPFILL }},
6870                 { &hf_bootp_subopt_unknown_type, { "bootp.subopt.unknown_type", PI_PROTOCOL, PI_ERROR, "ERROR, please report: Unknown subopt type handler", EXPFILL }},
6871                 { &ei_bootp_option77_user_class_malformed, { "bootp.option.user_class.malformed", PI_PROTOCOL, PI_ERROR, "User Class Information: malformed option", EXPFILL }},
6872                 { &ei_bootp_option_civic_location_bad_cattype, { "bootp.option.civic_location.bad_cattype", PI_PROTOCOL, PI_ERROR, "Error with CAType", EXPFILL }},
6873                 { &ei_bootp_option_dhcp_name_service_invalid, { "bootp.option.dhcp_name_service.invalid", PI_PROTOCOL, PI_ERROR, "Invalid Name Service", EXPFILL }},
6874                 { &ei_bootp_option_sip_server_address_encoding, { "bootp.option.sip_server_address.encoding", PI_PROTOCOL, PI_ERROR, "RFC 3361 defines only 0 and 1 for Encoding byte", EXPFILL }},
6875                 { &ei_bootp_option_classless_static_route, { "bootp.option.classless_static.route", PI_PROTOCOL, PI_ERROR, "Mask width > 32", EXPFILL }},
6876                 { &ei_bootp_option125_enterprise_malformed, { "bootp.option.enterprise.malformed", PI_PROTOCOL, PI_ERROR, "no room left in option for enterprise data", EXPFILL }},
6877                 { &ei_bootp_option_6RD_malformed, { "bootp.option.6RD.malformed", PI_PROTOCOL, PI_ERROR, "6RD: malformed option", EXPFILL }},
6878                 { &ei_bootp_option82_vi_cl_tag_unknown, { "bootp.option.option.vi.cl.tag_unknown", PI_PROTOCOL, PI_ERROR, "Unknown tag", EXPFILL }},
6879                 { &ei_bootp_suboption_invalid, { "bootp.suboption_invalid", PI_PROTOCOL, PI_ERROR, "Invalid suboption", EXPFILL }},
6880                 { &ei_bootp_secs_le, { "bootp.secs_le", PI_PROTOCOL, PI_NOTE, "Seconds elapsed appears to be encoded as little-endian", EXPFILL }},
6881                 { &ei_bootp_end_option_missing, { "bootp.end_option_missing", PI_PROTOCOL, PI_ERROR, "End option missing", EXPFILL }},
6882         };
6883
6884         module_t *bootp_module;
6885         expert_module_t* expert_bootp;
6886
6887         proto_bootp = proto_register_protocol("Bootstrap Protocol", "BOOTP/DHCP",
6888                                               "bootp");
6889         proto_register_field_array(proto_bootp, hf, array_length(hf));
6890         proto_register_subtree_array(ett, array_length(ett));
6891         bootp_dhcp_tap = register_tap("bootp");
6892
6893         expert_bootp = expert_register_protocol(proto_bootp);
6894         expert_register_field_array(expert_bootp, ei, array_length(ei));
6895
6896         /* register init routine to setup the custom bootp options */
6897         register_init_routine(&bootp_init_protocol);
6898
6899         /* Allow dissector to find be found by name. */
6900         bootp_handle = register_dissector("bootp", dissect_bootp, proto_bootp);
6901
6902         bootp_module = prefs_register_protocol(proto_bootp, NULL);
6903
6904         prefs_register_bool_preference(bootp_module, "novellserverstring",
6905                                        "Decode Option 85 as String",
6906                                        "Novell Servers option 85 can be configured as a string instead of address",
6907                                        &novell_string);
6908
6909         prefs_register_enum_preference(bootp_module, "pkt.ccc.protocol_version",
6910                                        "PacketCable CCC protocol version",
6911                                        "The PacketCable CCC protocol version",
6912                                        &pkt_ccc_protocol_version,
6913                                        pkt_ccc_protocol_versions,
6914                                        FALSE);
6915
6916         prefs_register_uint_preference(bootp_module, "pkt.ccc.option",
6917                                        "PacketCable CCC option",
6918                                        "Option Number for PacketCable CableLabs Client Configuration",
6919                                        10,
6920                                        &pkt_ccc_option);
6921
6922         prefs_register_obsolete_preference(bootp_module, "displayasstring");
6923
6924         bootp_uat = uat_new("Custom BootP/DHCP Options (Excl. suboptions)",
6925                         sizeof(uat_bootp_record_t), /* record size           */
6926                         "custom_bootp",             /* filename              */
6927                         TRUE,                       /* from_profile          */
6928                         (void**) &uat_bootp_records,/* data_ptr              */
6929                         &num_bootp_records_uat,     /* numitems_ptr          */
6930                         UAT_AFFECTS_DISSECTION,     /* affects dissection of packets, but not set of named fields */
6931                         NULL,                       /* help                  */
6932                         uat_bootp_record_copy_cb,   /* copy callback         */
6933                         uat_bootp_record_update_cb, /* update callback       */
6934                         uat_bootp_record_free_cb,   /* free callback         */
6935                         NULL,                       /* post update callback  */
6936                         bootp_uat_flds);            /* UAT field definitions */
6937
6938         prefs_register_uat_preference(bootp_module,
6939                                       "custom_bootp_table",
6940                                       "Custom BootP/DHCP Options (Excl. suboptions)",
6941                                       "Custom BootP/DHCP Options (Excl. suboptions)",
6942                                       bootp_uat);
6943 }
6944
6945 void
6946 proto_reg_handoff_bootp(void)
6947 {
6948         dissector_add_uint("udp.port", UDP_PORT_BOOTPS, bootp_handle);
6949         dissector_add_uint("udp.port", UDP_PORT_BOOTPC, bootp_handle);
6950 }