Skip to contentSkip to conversation

net: add support to parse the NIS domain for the dhcp options

PATCH Superseded Charles Hardin 2 participants 5 messages Apr 1, 2024 – Apr 19, 2024 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: add support to parse the NIS domain for the dhcp options

There is code in the bootp parsing for NIS domain and add the same support for the dhcp options as well. This allows the same usage of the data when the dhcp command is used in the boot command.

---
 net/bootp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/bootp.c +8 -0
index 6800290963..046caf3685 100644
@@ -883,6 +883,14 @@ static void dhcp_process_options(uchar *popt, uchar *end)
 			break;
 		case 28:	/* Ignore Broadcast Address Option */
 			break;
+		case 40:	/* NIS Domain name */
+			if (net_nis_domain[0] == 0) {
+				size = truncate_sz("NIS Domain Name",
+					sizeof(net_nis_domain), size);
+				memcpy(&net_nis_domain, ext + 2, size);
+				net_nis_domain[size] = 0;
+			}
+			break;
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
 		case 42:	/* NTP server IP */
 			net_copy_ip(&net_ntp_server, (popt + 2));
Signature · 1 line
2.39.3 (Apple Git-146)
#1 lore raw
Quoted 19 lines · Charles Hardin

There is code in the bootp parsing for NIS domain and add the same support for the dhcp options as well. This allows the same usage of the data when the dhcp command is used in the boot command.

---
 net/bootp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/bootp.c +1 -0
index 6800290963..046caf3685 100644
@@ -883,6 +883,14 @@ static void dhcp_process_options(uchar *popt, uchar *end)
 			break;
 		case 28:	/* Ignore Broadcast Address Option */
 			break;
+		case 40:	/* NIS Domain name */

net/bootp.c static void dhcp_process_options(uchar *popt, uchar *end) · line 896

Quoted 10 lines
net/bootp.c +7 -0
+			if (net_nis_domain[0] == 0) {
+				size = truncate_sz("NIS Domain Name",
+					sizeof(net_nis_domain), size);
+				memcpy(&net_nis_domain, ext + 2, size);
+				net_nis_domain[size] = 0;
+			}
+			break;
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
 		case 42:	/* NTP server IP */
 			net_copy_ip(&net_ntp_server, (popt + 2));

This fails to build:
net/bootp.c: In function 'dhcp_process_options':
net/bootp.c:890:57: error: 'ext' undeclared (first use in this function)
890 | memcpy(&net_nis_domain, ext + 2, size);
| ^~~
net/bootp.c:890:57: note: each undeclared identifier is reported only once for each function it appears in

Signature · 1 line
Tom
#2 lore raw

PATCH v2 1/1 net: add support to parse the NIS domain for the dhcp options

In reply to Charles Hardin

There is code in the bootp parsing for NIS domain and add the same support for the dhcp options as well. This allows the same usage of the data when the dhcp command is used in the boot command.

---
 net/bootp.c | 8 ++++++++
 1 file changed, 8 insertions(+)
net/bootp.c +8 -0
index 6800290963..c15472f5d3 100644
@@ -883,6 +883,14 @@ static void dhcp_process_options(uchar *popt, uchar *end)
 			break;
 		case 28:	/* Ignore Broadcast Address Option */
 			break;
+		case 40:	/* NIS Domain name */
+			if (net_nis_domain[0] == 0) {
+				size = truncate_sz("NIS Domain Name",
+					sizeof(net_nis_domain), size);
+				memcpy(&net_nis_domain, popt + 2, size);
+				net_nis_domain[size] = 0;
+			}
+			break;
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
 		case 42:	/* NTP server IP */
 			net_copy_ip(&net_ntp_server, (popt + 2));
Signature · 1 line
2.39.3 (Apple Git-146)
#3 lore raw
Quoted 6 lines · Charles Hardin

There is code in the bootp parsing for NIS domain and add the same support for the dhcp options as well. This allows the same usage of the data when the dhcp command is used in the boot command.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#4 lore raw
In reply to Charles Hardin
Quoted 6 lines · Charles Hardin

There is code in the bootp parsing for NIS domain and add the same support for the dhcp options as well. This allows the same usage of the data when the dhcp command is used in the boot command.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom