Just nicer. Verified against
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
Message-Id: <20251011082232.27602-1-gert@greenie.muc.de>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245241/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
| ... | ... |
@@ -342,27 +342,27 @@ build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o) |
| 342 | 342 |
bool error = false; |
| 343 | 343 |
if (o->domain) |
| 344 | 344 |
{
|
| 345 |
- write_dhcp_str(buf, 15, o->domain, &error); |
|
| 345 |
+ write_dhcp_str(buf, DHCP_DOMAIN_NAME, o->domain, &error); |
|
| 346 | 346 |
} |
| 347 | 347 |
|
| 348 | 348 |
if (o->netbios_scope) |
| 349 | 349 |
{
|
| 350 |
- write_dhcp_str(buf, 47, o->netbios_scope, &error); |
|
| 350 |
+ write_dhcp_str(buf, DHCP_NETBIOS_SCOPE, o->netbios_scope, &error); |
|
| 351 | 351 |
} |
| 352 | 352 |
|
| 353 | 353 |
if (o->netbios_node_type) |
| 354 | 354 |
{
|
| 355 |
- write_dhcp_u8(buf, 46, o->netbios_node_type, &error); |
|
| 355 |
+ write_dhcp_u8(buf, DHCP_NETBIOS_NODE_TYPE, o->netbios_node_type, &error); |
|
| 356 | 356 |
} |
| 357 | 357 |
|
| 358 |
- write_dhcp_u32_array(buf, 6, (uint32_t *)o->dns, o->dns_len, &error); |
|
| 359 |
- write_dhcp_u32_array(buf, 44, (uint32_t *)o->wins, o->wins_len, &error); |
|
| 360 |
- write_dhcp_u32_array(buf, 42, (uint32_t *)o->ntp, o->ntp_len, &error); |
|
| 361 |
- write_dhcp_u32_array(buf, 45, (uint32_t *)o->nbdd, o->nbdd_len, &error); |
|
| 358 |
+ write_dhcp_u32_array(buf, DHCP_DOMAIN_SERVER, (uint32_t *)o->dns, o->dns_len, &error); |
|
| 359 |
+ write_dhcp_u32_array(buf, DHCP_NETBIOS_DOMAIN_SERVER, (uint32_t *)o->wins, o->wins_len, &error); |
|
| 360 |
+ write_dhcp_u32_array(buf, DHCP_NTP_SERVER, (uint32_t *)o->ntp, o->ntp_len, &error); |
|
| 361 |
+ write_dhcp_u32_array(buf, DHCP_NETBIOS_DIST_SERVER, (uint32_t *)o->nbdd, o->nbdd_len, &error); |
|
| 362 | 362 |
|
| 363 | 363 |
if (o->domain_search_list_len > 0) |
| 364 | 364 |
{
|
| 365 |
- write_dhcp_search_str(buf, 119, o->domain_search_list, o->domain_search_list_len, &error); |
|
| 365 |
+ write_dhcp_search_str(buf, DHCP_DOMAIN_SEARCH, o->domain_search_list, o->domain_search_list_len, &error); |
|
| 366 | 366 |
} |
| 367 | 367 |
|
| 368 | 368 |
/* the MS DHCP server option 'Disable Netbios-over-TCP/IP |
| ... | ... |
@@ -375,7 +375,7 @@ build_dhcp_options_string(struct buffer *buf, const struct tuntap_options *o) |
| 375 | 375 |
msg(M_WARN, "build_dhcp_options_string: buffer overflow building DHCP options"); |
| 376 | 376 |
return false; |
| 377 | 377 |
} |
| 378 |
- buf_write_u8(buf, 43); |
|
| 378 |
+ buf_write_u8(buf, DHCP_VENDOR); |
|
| 379 | 379 |
buf_write_u8(buf, 6); /* total length field */ |
| 380 | 380 |
buf_write_u8(buf, 0x001); |
| 381 | 381 |
buf_write_u8(buf, 4); /* length of the vendor specified field */ |
| ... | ... |
@@ -30,10 +30,19 @@ |
| 30 | 30 |
#pragma pack(1) |
| 31 | 31 |
|
| 32 | 32 |
/* DHCP Option types */ |
| 33 |
-#define DHCP_PAD 0 |
|
| 34 |
-#define DHCP_ROUTER 3 |
|
| 35 |
-#define DHCP_MSG_TYPE 53 /* message type (u8) */ |
|
| 36 |
-#define DHCP_END 255 |
|
| 33 |
+#define DHCP_PAD 0 |
|
| 34 |
+#define DHCP_ROUTER 3 |
|
| 35 |
+#define DHCP_DOMAIN_SERVER 6 |
|
| 36 |
+#define DHCP_DOMAIN_NAME 15 |
|
| 37 |
+#define DHCP_NTP_SERVER 42 |
|
| 38 |
+#define DHCP_VENDOR 43 |
|
| 39 |
+#define DHCP_NETBIOS_DOMAIN_SERVER 44 |
|
| 40 |
+#define DHCP_NETBIOS_DIST_SERVER 45 |
|
| 41 |
+#define DHCP_NETBIOS_NODE_TYPE 46 |
|
| 42 |
+#define DHCP_NETBIOS_SCOPE 47 |
|
| 43 |
+#define DHCP_MSG_TYPE 53 |
|
| 44 |
+#define DHCP_DOMAIN_SEARCH 119 |
|
| 45 |
+#define DHCP_END 255 |
|
| 37 | 46 |
|
| 38 | 47 |
/* DHCP Messages types */ |
| 39 | 48 |
#define DHCPDISCOVER 1 |