From: "flichtenheld (Code Review)" Date: Fri, 10 Oct 2025 22:49:13 +0000 References: Reply-To: frank@...2641..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net Message-ID: <75b7417db42e39ca23c773b117b795edf499f947-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="zBjgPR4LY7g="; charset=UTF-8 Subject: [Openvpn-devel] [S] Change in openvpn[master]: dhcp: Replace DHCP Option types with defines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: plaisthos Cc: openvpn-devel --zBjgPR4LY7g= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=3Demail 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-parameter= s.xhtml Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96 Signed-off-by: Frank Lichtenheld --- 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 diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c index 653127d..56f03f2 100644 --- a/src/openvpn/dhcp.c +++ b/src/openvpn/dhcp.c @@ -342,27 +342,27 @@ bool error =3D 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->d= ns_len, &error); + write_dhcp_u32_array(buf, DHCP_NETBIOS_DOMAIN_SERVER, (uint32_t *)o->w= ins, 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->nbd= d, o->nbdd_len, &error); if (o->domain_search_list_len > 0) { - write_dhcp_search_str(buf, 119, o->domain_search_list, o->domain_s= earch_list_len, &error); + write_dhcp_search_str(buf, DHCP_DOMAIN_SEARCH, o->domain_search_li= st, 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 buildi= ng 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 */ diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h index 8e15a39..3fcd2b6 100644 --- a/src/openvpn/dhcp.h +++ b/src/openvpn/dhcp.h @@ -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=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings?usp=3Demail Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30d44bf65788b96 Gerrit-Change-Number: 1266 Gerrit-PatchSet: 1 Gerrit-Owner: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos --zBjgPR4LY7g= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is cur= rently required from: plaisthos.

flichtenheld would like plaisthos to review this change.

V= iew Change

dhcp: Replace DHCP Option types with define=
s

Just nicer. Verified against
https://www.iana.org/assignments/b= ootp-dhcp-parameters/bootp-dhcp-parameters.xhtml

Change-Id: Ie41101b= d00d038fa6fb906f3d30d44bf65788b96
Signed-off-by: Frank Lichtenheld <f= rank@...2641...>
---
M src/openvpn/dhcp.c
M src/openvpn/dhcp.h<= br>2 files changed, 22 insertions(+), 13 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/66/1266/=
1
diff --git a/src/openvpn/dhcp.c b/src/openvpn/dhcp.c
index 653127d..56f03f2 100644
--- a/src/openvpn/dhcp.c<= /span>
+++ b/src/openvpn/dhcp.c
@@ -342,27 +342,27= @@
bool error =3D false;
if (o-&= gt;domain)
{
- write_dhcp_str(buf, 15, o->domain, &error);
+ write_dhcp_str(b= uf, 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);
}
<= span>

if (o->netbios_node_type)
= {
- write_dhc= p_u8(buf, 46, o->netbios_node_type, &error);
+ write_dhcp_u8(buf, DHCP_NETBIOS_N= ODE_TYPE, o->netbios_node_type, &error);
}

- writ= e_dhcp_u32_array(buf, 6, (uint32_t *)o->dns, o->dns_len, &error);=
- write_dhcp_u32_ar= ray(buf, 44, (uint32_t *)o->wins, o->wins_len, &error);- write_dhcp_u32_array(buf, 4= 2, (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_DO= MAIN_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(b= uf, 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_l= ist, 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 D= HCP server option 'Disable Netbios-over-TCP/IP
@@ -375,= 7 +375,7 @@
msg(M_WARN, "build_dhcp_optio= ns_string: buffer overflow building DHCP options");
= return false;
}
- buf_write_u8(buf, 43);
+ buf_write_u8(buf, DHCP_V= ENDOR);

buf_write_u8(buf, 6); /* total length fiel= d */
buf_write_u8(buf, 0x001);
= buf_write_u8(buf, 4); /* length of the vendor specified field */
diff --git a/src/openvpn/dhcp.h b/src/openvpn/dhcp.h
= index 8e15a39..3fcd2b6 100644
--- a/src/openvpn/dhcp.= h
+++ b/src/openvpn/dhcp.h
@@ -30,10 +30,19= @@
#pragma pack(1)

/* = DHCP Option types */
-#= define DHCP_PAD 0
= -#define DHCP_ROUTER 3
-#define DHCP_END 255
+#define DHCP_PAD 0<= /span>
+#define DHCP_ROUTER = 3
+#de= fine DHCP_DOMAIN_SERVER 6
+#define DHCP_DOMAIN_NAME 15
+#define DHCP_NTP_SERVER 42
+#define DHCP_VENDOR = 43
+#defi= ne 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<= br>
/* DHCP Messages types */
#def= ine DHCPDISCOVER 1

To view, visit change 1266. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ie41101bd00d038fa6fb906f3d30= d44bf65788b96
Gerrit-Change-Number: 1266
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
= --zBjgPR4LY7g=--