diff options
author | Oleksij Rempel <o.rempel@pengutronix.de> | 2021-09-14 08:30:01 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-10-05 13:51:11 +0200 |
commit | 4472f8a714f68078788e58b3b8fc164ae1459585 (patch) | |
tree | 2a14d265e0383e82ed4b32455ca00957083eefa8 /net | |
parent | 906f602b7c8a0fa2ff6e405fa391f85be512ece1 (diff) | |
download | barebox-4472f8a714f68078788e58b3b8fc164ae1459585.tar.gz barebox-4472f8a714f68078788e58b3b8fc164ae1459585.tar.xz |
net: dhcp: send current hostname as part of the DHCP request
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>
Link: https://lore.barebox.org/20210914063001.2803749-1-o.rempel@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/dhcp.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/dhcp.c b/net/dhcp.c index e701a5f717..427985eca1 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); |