diff options
author | Dmitry Shmidt <dimitrysh@google.com> | 2012-07-23 15:59:31 -0700 |
---|---|---|
committer | Dmitry Shmidt <dimitrysh@google.com> | 2012-07-23 15:59:31 -0700 |
commit | 2af699ea51cca49bd0f19080c9d73170e5bdadbc (patch) | |
tree | 21eee57fc5420fc1b5ebbda9aa42dd4d7d9626df | |
parent | 0333eee26904f3edc0cecf5dd00226dc9b670d08 (diff) | |
download | external_dhcpcd-2af699ea51cca49bd0f19080c9d73170e5bdadbc.zip external_dhcpcd-2af699ea51cca49bd0f19080c9d73170e5bdadbc.tar.gz external_dhcpcd-2af699ea51cca49bd0f19080c9d73170e5bdadbc.tar.bz2 |
Fix netmask retrival from ifc_get_info()
Change-Id: I67b06887a72869d48e0c6c2fcacf8c99153d7f82
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
-rw-r--r-- | ifaddrs.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -32,14 +32,15 @@ struct ifaddrs *get_interface(const char *name, sa_family_t family) { - unsigned addr, mask, flags; + unsigned addr, flags; + int masklen; struct ifaddrs *ifa; struct sockaddr_in *saddr = NULL; struct sockaddr_in *smask = NULL; struct sockaddr_ll *hwaddr = NULL; unsigned char hwbuf[ETH_ALEN]; - if(ifc_get_info(name, &addr, &mask, &flags)) + if (ifc_get_info(name, &addr, &masklen, &flags)) return NULL; if ((family == AF_INET) && (addr == 0)) @@ -66,10 +67,10 @@ struct ifaddrs *get_interface(const char *name, sa_family_t family) } ifa->ifa_addr = (struct sockaddr *)saddr; - if (mask != 0) { + if (masklen != 0) { smask = malloc(sizeof(struct sockaddr_in)); if (smask) { - smask->sin_addr.s_addr = mask; + smask->sin_addr.s_addr = prefixLengthToIpv4Netmask(masklen); smask->sin_family = family; } } |