eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit b6236255d2eddd480bd25cc872eab59f1e26d881
parent 19e5cc9b0d1b03b0414b6951a38504edf24ba517
Author: Michael Johnson <mjohnson459@gmail.com>
Date:   Fri, 18 Jun 2021 18:40:46 +0100

Send hostname as part of DHCP request.

This is based on a previous patch by Roberto Santalla Fernández.

A new config is introduced into the network config file under IPv4
called SendHostname. If this is set to true then we add the hostname
into all DHCP requests. The default is false.

Diffstat:
Msrc/iwd.network.rst | 6++++++
Msrc/netconfig.c | 16++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/iwd.network.rst b/src/iwd.network.rst @@ -322,6 +322,12 @@ network configuration with the static addresses. `optional`. DomainName setting can be used to override the DomainName value obtained from the DHCP server. + * - SendHostname + - Values: true, **false** + + Configures DHCP to include the hostname in the request. This setting + is disabled by default. + The group ``[IPv6]`` contains settings for Internet Protocol version 6 (IPv6) network configuration. diff --git a/src/netconfig.c b/src/netconfig.c @@ -1004,6 +1004,8 @@ bool netconfig_configure(struct netconfig *netconfig, netconfig_notify_func_t notify, void *user_data) { char *mdns; + char hostname[HOST_NAME_MAX + 1]; + bool send_hostname; netconfig->dns4_overrides = l_settings_get_string_list(active_settings, "IPv4", "DNS", ' '); @@ -1044,6 +1046,20 @@ bool netconfig_configure(struct netconfig *netconfig, l_dhcp6_client_set_address(netconfig->dhcp6_client, ARPHRD_ETHER, mac_address, ETH_ALEN); + if (!l_settings_get_bool(active_settings, + "IPv4", "SendHostname", &send_hostname)) + send_hostname = false; + + if (send_hostname) { + if (gethostname(hostname, sizeof(hostname)) == 0) { + l_dhcp_client_set_hostname( + netconfig->dhcp_client, hostname); + } else { + l_warn("netconfig: Unable to get hostname. " + "Error %d: %s", errno, strerror(errno)); + } + } + netconfig_ipv4_select_and_install(netconfig); netconfig_ipv6_select_and_install(netconfig);