mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v1] net: dhcp: send current hostname as part of the DHCP request
Date: Tue, 14 Sep 2021 08:30:01 +0200	[thread overview]
Message-ID: <20210914063001.2803749-1-o.rempel@pengutronix.de> (raw)

To be able to use more advanced DHCP server configurations, for example
host name pattern matching, barebox should send some name.

With this patch, barebox will send barebox_hostname, if dhcp.hostname is
not configured.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 net/dhcp.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/dhcp.c b/net/dhcp.c
index e701a5f71..427985eca 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -444,6 +444,7 @@ static char *global_dhcp_user_class;
 static char *global_dhcp_vendor_id;
 static char *global_dhcp_client_uuid;
 static char *global_dhcp_client_id;
+static char *global_dhcp_hostname;
 static char *global_dhcp_bootfile;
 static char *global_dhcp_oftree_file;
 static char *global_dhcp_rootpath;
@@ -482,6 +483,12 @@ int dhcp_request(struct eth_device *edev, const struct dhcp_req_param *param,
 		dhcp_param.client_uuid = global_dhcp_client_uuid;
 	if (!dhcp_param.client_id)
 		dhcp_param.client_id = global_dhcp_client_id;
+	if (!dhcp_param.hostname) {
+		if (global_dhcp_hostname && strlen(global_dhcp_hostname))
+			dhcp_param.hostname = global_dhcp_hostname;
+		else
+			dhcp_param.hostname = (char *)barebox_get_hostname();
+	}
 	if (!dhcp_param.option224)
 		dhcp_param.option224 = global_dhcp_option224;
 	if (!dhcp_param.retries)
@@ -636,6 +643,7 @@ static int dhcp_global_init(void)
 	globalvar_add_simple_string("dhcp.vendor_id", &global_dhcp_vendor_id);
 	globalvar_add_simple_string("dhcp.client_uuid", &global_dhcp_client_uuid);
 	globalvar_add_simple_string("dhcp.client_id", &global_dhcp_client_id);
+	globalvar_add_simple_string("dhcp.hostname", &global_dhcp_hostname);
 	globalvar_add_simple_string("dhcp.user_class", &global_dhcp_user_class);
 	globalvar_add_simple_string("dhcp.oftree_file", &global_dhcp_oftree_file);
 	globalvar_add_simple_string("dhcp.tftp_server_name", &global_dhcp_tftp_server_name);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


             reply	other threads:[~2021-09-14  6:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  6:30 Oleksij Rempel [this message]
2021-10-02  9:30 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210914063001.2803749-1-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox