3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 06:29:23 +01:00

netconfig: Implement netconfig_get_dhcp_server_ipv4

This uses l_dhcp_lease_get_server_id to get the IP of the server that
offered us our current lease.  l_dhcp_lease_get_server_id returns the
vaue of the L_DHCP_OPTION_SERVER_IDENTIFIER option, which is the address
that any unicast DHCP frames are supposed to be sent to so it seems to
be the best way to get the P2P group owner's IP address as a P2P-client.
This commit is contained in:
Andrew Zaborowski 2020-07-11 03:00:50 +02:00 committed by Denis Kenzior
parent 66f4981650
commit bafd604834
2 changed files with 15 additions and 0 deletions

View File

@ -1149,6 +1149,20 @@ bool netconfig_reset(struct netconfig *netconfig)
return true;
}
char *netconfig_get_dhcp_server_ipv4(struct netconfig *netconfig)
{
const struct l_dhcp_lease *lease;
if (!netconfig->dhcp_client)
return NULL;
lease = l_dhcp_client_get_lease(netconfig->dhcp_client);
if (!lease)
return NULL;
return l_dhcp_lease_get_server_id(lease);
}
struct netconfig *netconfig_new(uint32_t ifindex)
{
struct netconfig *netconfig;

View File

@ -36,6 +36,7 @@ bool netconfig_configure(struct netconfig *netconfig,
void *user_data);
bool netconfig_reconfigure(struct netconfig *netconfig);
bool netconfig_reset(struct netconfig *netconfig);
char *netconfig_get_dhcp_server_ipv4(struct netconfig *netconfig);
struct netconfig *netconfig_new(uint32_t ifindex);
void netconfig_destroy(struct netconfig *netconfig);