Change in openvpn[master]: dhcp: Replace DHCP Option types with defines
A message that is not in the archive (sent off-list or not yet received): gerrit.1760136547000.Ie41101bd00d038fa6fb906f3d30d44bf65788b96@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email
to review the following change.
Change subject: dhcp: Replace DHCP Option types with defines
......................................................................
dhcp: Replace DHCP Option types with defines
Just nicer. Verified against
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
---
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
2 files changed, 22 insertions(+), 13 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1266/1
src/openvpn/dhcp.c +9 -9
@@ -342,27 +342,27 @@bool error = false;if (o->domain) { -write_dhcp_str (buf,15 , o->domain, &error); +write_dhcp_str (buf,DHCP_DOMAIN_NAME , o->domain, &error); }if (o->netbios_scope) { -write_dhcp_str (buf,47 , o->netbios_scope, &error); +write_dhcp_str (buf,DHCP_NETBIOS_SCOPE , o->netbios_scope, &error); }if (o->netbios_node_type) { -write_dhcp_u8 (buf,46 , o->netbios_node_type, &error); +write_dhcp_u8 (buf,DHCP_NETBIOS_NODE_TYPE , o->netbios_node_type, &error); } -write_dhcp_u32_array (buf,6 , (uint32_t *)o->dns, o->dns_len, &error); -write_dhcp_u32_array (buf,44 , (uint32_t *)o->wins, o->wins_len, &error); -write_dhcp_u32_array (buf,42 , (uint32_t *)o->ntp, o->ntp_len, &error); -write_dhcp_u32_array (buf,45 , (uint32_t *)o->nbdd, o->nbdd_len, &error); +write_dhcp_u32_array (buf,DHCP_DOMAIN_SERVER , (uint32_t *)o->dns, o->dns_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DOMAIN_SERVER , (uint32_t *)o->wins, o->wins_len, &error); +write_dhcp_u32_array (buf,DHCP_NTP_SERVER , (uint32_t *)o->ntp, o->ntp_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DIST_SERVER , (uint32_t *)o->nbdd, o->nbdd_len, &error);if (o->domain_search_list_len >0 ) { -write_dhcp_search_str (buf,119 , o->domain_search_list, o->domain_search_list_len, &error); +write_dhcp_search_str (buf,DHCP_DOMAIN_SEARCH , o->domain_search_list, o->domain_search_list_len, &error); }/* the MS DHCP server option 'Disable Netbios-over-TCP/IP
@@ -375,7 +375,7 @@msg (M_WARN ,"build_dhcp_options_string: buffer overflow building DHCP options" );return false; } -buf_write_u8 (buf,43 ); +buf_write_u8 (buf,DHCP_VENDOR );buf_write_u8 (buf,6 );/* total length field */ buf_write_u8 (buf,0x001 );buf_write_u8 (buf,4 );/* length of the vendor specified field */
src/openvpn/dhcp.h +13 -4
@@ -30,10 +30,19 @@#pragma pack(1)/* DHCP Option types */ -#define DHCP_PAD 0 -#define DHCP_ROUTER 3 -#define DHCP_MSG_TYPE 53/* message type (u8) */ -#define DHCP_END 255 +#define DHCP_PAD 0 +#define DHCP_ROUTER 3 +#define DHCP_DOMAIN_SERVER 6 +#define DHCP_DOMAIN_NAME 15 +#define DHCP_NTP_SERVER 42 +#define DHCP_VENDOR 43 +#define DHCP_NETBIOS_DOMAIN_SERVER 44 +#define DHCP_NETBIOS_DIST_SERVER 45 +#define DHCP_NETBIOS_NODE_TYPE 46 +#define DHCP_NETBIOS_SCOPE 47 +#define DHCP_MSG_TYPE 53 +#define DHCP_DOMAIN_SEARCH 119 +#define DHCP_END 255/* DHCP Messages types */ #define DHCPDISCOVER 1
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96
Gerrit-Change-Number: 1266
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email )
Change subject: dhcp: Replace DHCP Option types with defines
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96
Gerrit-Change-Number: 1266
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 11 Oct 2025 08:20:30 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH 1/1 dhcp: Replace DHCP Option types with defines
In reply to a message not in the archiveFrom: Frank Lichtenheld <[email protected]...>
Just nicer. Verified against
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/dhcp.c +9 -9
@@ -342,27 +342,27 @@bool error = false;if (o->domain) { -write_dhcp_str (buf,15 , o->domain, &error); +write_dhcp_str (buf,DHCP_DOMAIN_NAME , o->domain, &error); }if (o->netbios_scope) { -write_dhcp_str (buf,47 , o->netbios_scope, &error); +write_dhcp_str (buf,DHCP_NETBIOS_SCOPE , o->netbios_scope, &error); }if (o->netbios_node_type) { -write_dhcp_u8 (buf,46 , o->netbios_node_type, &error); +write_dhcp_u8 (buf,DHCP_NETBIOS_NODE_TYPE , o->netbios_node_type, &error); } -write_dhcp_u32_array (buf,6 , (uint32_t *)o->dns, o->dns_len, &error); -write_dhcp_u32_array (buf,44 , (uint32_t *)o->wins, o->wins_len, &error); -write_dhcp_u32_array (buf,42 , (uint32_t *)o->ntp, o->ntp_len, &error); -write_dhcp_u32_array (buf,45 , (uint32_t *)o->nbdd, o->nbdd_len, &error); +write_dhcp_u32_array (buf,DHCP_DOMAIN_SERVER , (uint32_t *)o->dns, o->dns_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DOMAIN_SERVER , (uint32_t *)o->wins, o->wins_len, &error); +write_dhcp_u32_array (buf,DHCP_NTP_SERVER , (uint32_t *)o->ntp, o->ntp_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DIST_SERVER , (uint32_t *)o->nbdd, o->nbdd_len, &error);if (o->domain_search_list_len >0 ) { -write_dhcp_search_str (buf,119 , o->domain_search_list, o->domain_search_list_len, &error); +write_dhcp_search_str (buf,DHCP_DOMAIN_SEARCH , o->domain_search_list, o->domain_search_list_len, &error); }/* the MS DHCP server option 'Disable Netbios-over-TCP/IP
@@ -375,7 +375,7 @@msg (M_WARN ,"build_dhcp_options_string: buffer overflow building DHCP options" );return false; } -buf_write_u8 (buf,43 ); +buf_write_u8 (buf,DHCP_VENDOR );buf_write_u8 (buf,6 );/* total length field */ buf_write_u8 (buf,0x001 );buf_write_u8 (buf,4 );/* length of the vendor specified field */
src/openvpn/dhcp.h +13 -4
@@ -30,10 +30,19 @@#pragma pack(1)/* DHCP Option types */ -#define DHCP_PAD 0 -#define DHCP_ROUTER 3 -#define DHCP_MSG_TYPE 53/* message type (u8) */ -#define DHCP_END 255 +#define DHCP_PAD 0 +#define DHCP_ROUTER 3 +#define DHCP_DOMAIN_SERVER 6 +#define DHCP_DOMAIN_NAME 15 +#define DHCP_NTP_SERVER 42 +#define DHCP_VENDOR 43 +#define DHCP_NETBIOS_DOMAIN_SERVER 44 +#define DHCP_NETBIOS_DIST_SERVER 45 +#define DHCP_NETBIOS_NODE_TYPE 46 +#define DHCP_NETBIOS_SCOPE 47 +#define DHCP_MSG_TYPE 53 +#define DHCP_DOMAIN_SEARCH 119 +#define DHCP_END 255/* DHCP Messages types */ #define DHCPDISCOVER 1
[Openvpn-devel] [PATCH applied] Re: dhcp: Replace DHCP Option types with defines
"Because it makes sense". Magic numbers are never good.
Verified that the new constants match the old magic number (not checked the RFC, but "the old numbers" are what we had, so those should be fine).
Your patch has been applied to the master branch.
commit e03d53842b5494d8caf19fc47ea788a32a3544c7
Author: Frank Lichtenheld Date: Sat Oct 11 10:22:26 2025 +0200
dhcp: Replace DHCP Option types with defines
Signed-off-by: Frank Lichtenheld <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245241/
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: dhcp: Replace DHCP Option types with defines
......................................................................
dhcp: Replace DHCP Option types with defines
Just nicer. Verified against
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245241/
---
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
2 files changed, 22 insertions(+), 13 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1266/2
src/openvpn/dhcp.c +9 -9
@@ -342,27 +342,27 @@bool error = false;if (o->domain) { -write_dhcp_str (buf,15 , o->domain, &error); +write_dhcp_str (buf,DHCP_DOMAIN_NAME , o->domain, &error); }if (o->netbios_scope) { -write_dhcp_str (buf,47 , o->netbios_scope, &error); +write_dhcp_str (buf,DHCP_NETBIOS_SCOPE , o->netbios_scope, &error); }if (o->netbios_node_type) { -write_dhcp_u8 (buf,46 , o->netbios_node_type, &error); +write_dhcp_u8 (buf,DHCP_NETBIOS_NODE_TYPE , o->netbios_node_type, &error); } -write_dhcp_u32_array (buf,6 , (uint32_t *)o->dns, o->dns_len, &error); -write_dhcp_u32_array (buf,44 , (uint32_t *)o->wins, o->wins_len, &error); -write_dhcp_u32_array (buf,42 , (uint32_t *)o->ntp, o->ntp_len, &error); -write_dhcp_u32_array (buf,45 , (uint32_t *)o->nbdd, o->nbdd_len, &error); +write_dhcp_u32_array (buf,DHCP_DOMAIN_SERVER , (uint32_t *)o->dns, o->dns_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DOMAIN_SERVER , (uint32_t *)o->wins, o->wins_len, &error); +write_dhcp_u32_array (buf,DHCP_NTP_SERVER , (uint32_t *)o->ntp, o->ntp_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DIST_SERVER , (uint32_t *)o->nbdd, o->nbdd_len, &error);if (o->domain_search_list_len >0 ) { -write_dhcp_search_str (buf,119 , o->domain_search_list, o->domain_search_list_len, &error); +write_dhcp_search_str (buf,DHCP_DOMAIN_SEARCH , o->domain_search_list, o->domain_search_list_len, &error); }/* the MS DHCP server option 'Disable Netbios-over-TCP/IP
@@ -375,7 +375,7 @@msg (M_WARN ,"build_dhcp_options_string: buffer overflow building DHCP options" );return false; } -buf_write_u8 (buf,43 ); +buf_write_u8 (buf,DHCP_VENDOR );buf_write_u8 (buf,6 );/* total length field */ buf_write_u8 (buf,0x001 );buf_write_u8 (buf,4 );/* length of the vendor specified field */
src/openvpn/dhcp.h +13 -4
@@ -30,10 +30,19 @@#pragma pack(1)/* DHCP Option types */ -#define DHCP_PAD 0 -#define DHCP_ROUTER 3 -#define DHCP_MSG_TYPE 53/* message type (u8) */ -#define DHCP_END 255 +#define DHCP_PAD 0 +#define DHCP_ROUTER 3 +#define DHCP_DOMAIN_SERVER 6 +#define DHCP_DOMAIN_NAME 15 +#define DHCP_NTP_SERVER 42 +#define DHCP_VENDOR 43 +#define DHCP_NETBIOS_DOMAIN_SERVER 44 +#define DHCP_NETBIOS_DIST_SERVER 45 +#define DHCP_NETBIOS_NODE_TYPE 46 +#define DHCP_NETBIOS_SCOPE 47 +#define DHCP_MSG_TYPE 53 +#define DHCP_DOMAIN_SEARCH 119 +#define DHCP_END 255/* DHCP Messages types */ #define DHCPDISCOVER 1
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96
Gerrit-Change-Number: 1266
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email )
Change subject: dhcp: Replace DHCP Option types with defines
......................................................................
dhcp: Replace DHCP Option types with defines
Just nicer. Verified against
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1266
Message-Id: <[email protected]...>
URL: https://sourceforge.net/p/openvpn/mailman/message/59245241/
---
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h
2 files changed, 22 insertions(+), 13 deletions(-)
src/openvpn/dhcp.c +9 -9
@@ -342,27 +342,27 @@bool error = false;if (o->domain) { -write_dhcp_str (buf,15 , o->domain, &error); +write_dhcp_str (buf,DHCP_DOMAIN_NAME , o->domain, &error); }if (o->netbios_scope) { -write_dhcp_str (buf,47 , o->netbios_scope, &error); +write_dhcp_str (buf,DHCP_NETBIOS_SCOPE , o->netbios_scope, &error); }if (o->netbios_node_type) { -write_dhcp_u8 (buf,46 , o->netbios_node_type, &error); +write_dhcp_u8 (buf,DHCP_NETBIOS_NODE_TYPE , o->netbios_node_type, &error); } -write_dhcp_u32_array (buf,6 , (uint32_t *)o->dns, o->dns_len, &error); -write_dhcp_u32_array (buf,44 , (uint32_t *)o->wins, o->wins_len, &error); -write_dhcp_u32_array (buf,42 , (uint32_t *)o->ntp, o->ntp_len, &error); -write_dhcp_u32_array (buf,45 , (uint32_t *)o->nbdd, o->nbdd_len, &error); +write_dhcp_u32_array (buf,DHCP_DOMAIN_SERVER , (uint32_t *)o->dns, o->dns_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DOMAIN_SERVER , (uint32_t *)o->wins, o->wins_len, &error); +write_dhcp_u32_array (buf,DHCP_NTP_SERVER , (uint32_t *)o->ntp, o->ntp_len, &error); +write_dhcp_u32_array (buf,DHCP_NETBIOS_DIST_SERVER , (uint32_t *)o->nbdd, o->nbdd_len, &error);if (o->domain_search_list_len >0 ) { -write_dhcp_search_str (buf,119 , o->domain_search_list, o->domain_search_list_len, &error); +write_dhcp_search_str (buf,DHCP_DOMAIN_SEARCH , o->domain_search_list, o->domain_search_list_len, &error); }/* the MS DHCP server option 'Disable Netbios-over-TCP/IP
@@ -375,7 +375,7 @@msg (M_WARN ,"build_dhcp_options_string: buffer overflow building DHCP options" );return false; } -buf_write_u8 (buf,43 ); +buf_write_u8 (buf,DHCP_VENDOR );buf_write_u8 (buf,6 );/* total length field */ buf_write_u8 (buf,0x001 );buf_write_u8 (buf,4 );/* length of the vendor specified field */
src/openvpn/dhcp.h +13 -4
@@ -30,10 +30,19 @@#pragma pack(1)/* DHCP Option types */ -#define DHCP_PAD 0 -#define DHCP_ROUTER 3 -#define DHCP_MSG_TYPE 53/* message type (u8) */ -#define DHCP_END 255 +#define DHCP_PAD 0 +#define DHCP_ROUTER 3 +#define DHCP_DOMAIN_SERVER 6 +#define DHCP_DOMAIN_NAME 15 +#define DHCP_NTP_SERVER 42 +#define DHCP_VENDOR 43 +#define DHCP_NETBIOS_DOMAIN_SERVER 44 +#define DHCP_NETBIOS_DIST_SERVER 45 +#define DHCP_NETBIOS_NODE_TYPE 46 +#define DHCP_NETBIOS_SCOPE 47 +#define DHCP_MSG_TYPE 53 +#define DHCP_DOMAIN_SEARCH 119 +#define DHCP_END 255/* DHCP Messages types */ #define DHCPDISCOVER 1
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1266?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96
Gerrit-Change-Number: 1266
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>