diff options
author | Robert Greenwalt <rgreenwalt@google.com> | 2011-02-01 15:21:21 -0800 |
---|---|---|
committer | Robert Greenwalt <rgreenwalt@google.com> | 2011-02-02 14:18:44 -0800 |
commit | 09dd819d2794caf1a17cd03592c100755fb25577 (patch) | |
tree | 9bf2c60804977ff55db33a1f4f5f501859ba822c /libnetutils/dhcpclient.c | |
parent | 120b57a3d9703bccba534af335aa94dd3a41be2f (diff) | |
download | system_core-09dd819d2794caf1a17cd03592c100755fb25577.zip system_core-09dd819d2794caf1a17cd03592c100755fb25577.tar.gz system_core-09dd819d2794caf1a17cd03592c100755fb25577.tar.bz2 |
Stop using netmask in the framework
This pushes prefixLength down as far as we can.
bug:2542681
Change-Id: I94b7cde9d10e97ee2c071d92f25555cff5934f0b
Diffstat (limited to 'libnetutils/dhcpclient.c')
-rw-r--r-- | libnetutils/dhcpclient.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/libnetutils/dhcpclient.c b/libnetutils/dhcpclient.c index ff00432..5039e26 100644 --- a/libnetutils/dhcpclient.c +++ b/libnetutils/dhcpclient.c @@ -93,6 +93,8 @@ const char *ipaddr(in_addr_t addr) return inet_ntoa(in_addr); } +extern int ipv4NetmaskToPrefixLength(in_addr_t mask); + typedef struct dhcp_info dhcp_info; struct dhcp_info { @@ -100,7 +102,7 @@ struct dhcp_info { uint32_t ipaddr; uint32_t gateway; - uint32_t netmask; + uint32_t prefixLength; uint32_t dns1; uint32_t dns2; @@ -111,13 +113,13 @@ struct dhcp_info { dhcp_info last_good_info; -void get_dhcp_info(uint32_t *ipaddr, uint32_t *gateway, uint32_t *mask, +void get_dhcp_info(uint32_t *ipaddr, uint32_t *gateway, uint32_t *prefixLength, uint32_t *dns1, uint32_t *dns2, uint32_t *server, uint32_t *lease) { *ipaddr = last_good_info.ipaddr; *gateway = last_good_info.gateway; - *mask = last_good_info.netmask; + *prefixLength = last_good_info.prefixLength; *dns1 = last_good_info.dns1; *dns2 = last_good_info.dns2; *server = last_good_info.serveraddr; @@ -127,7 +129,7 @@ void get_dhcp_info(uint32_t *ipaddr, uint32_t *gateway, uint32_t *mask, static int dhcp_configure(const char *ifname, dhcp_info *info) { last_good_info = *info; - return ifc_configure(ifname, info->ipaddr, info->netmask, info->gateway, + return ifc_configure(ifname, info->ipaddr, info->prefixLength, info->gateway, info->dns1, info->dns2); } @@ -153,8 +155,7 @@ void dump_dhcp_info(dhcp_info *info) dhcp_type_to_name(info->type), info->type); strcpy(addr, ipaddr(info->ipaddr)); strcpy(gway, ipaddr(info->gateway)); - strcpy(mask, ipaddr(info->netmask)); - LOGD("ip %s gw %s mask %s", addr, gway, mask); + LOGD("ip %s gw %s prefixLength %d", addr, gway, info->prefixLength); if (info->dns1) LOGD("dns1: %s", ipaddr(info->dns1)); if (info->dns2) LOGD("dns2: %s", ipaddr(info->dns2)); LOGD("server %s, lease %d seconds", @@ -196,7 +197,7 @@ int decode_dhcp_msg(dhcp_msg *msg, int len, dhcp_info *info) } switch(opt) { case OPT_SUBNET_MASK: - if (optlen >= 4) memcpy(&info->netmask, x, 4); + if (optlen >= 4) info->prefixLength = ipv4NetmaskToPrefixLength((int)x); break; case OPT_GATEWAY: if (optlen >= 4) memcpy(&info->gateway, x, 4); |