diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-03 15:52:39 +0200 |
commit | a6a7d6ce079cabdaf2fa502b2e2cf15e5428ac6f (patch) | |
tree | b88cc7a8457658d67e0321718556ac807f6bccf3 /src/ipme.c | |
parent | 00be7622c428f279872f84569f098ce16150f8a8 (diff) |
format files
Diffstat (limited to 'src/ipme.c')
-rw-r--r-- | src/ipme.c | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -1,19 +1,21 @@ -#include <sys/types.h> -#include <sys/param.h> -#include <sys/time.h> -#include <sys/ioctl.h> -#include <sys/socket.h> +#include <ifaddrs.h> + #include <net/if.h> #include <netinet/in.h> -#include <ifaddrs.h> +#include <sys/ioctl.h> +#include <sys/param.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <sys/types.h> #ifndef SIOCGIFCONF /* whatever works */ -#include <sys/sockio.h> + #include <sys/sockio.h> #endif -#include "hassalen.h" #include "byte.h" #include "ip.h" -#include "ipalloc.h" #include "stralloc.h" + +#include "hassalen.h" +#include "ipalloc.h" #include "ipme.h" /** @file ipme.c @@ -30,8 +32,7 @@ int ipme_is4(struct ip4_address *ip) if (ipme_init() != 1) return -1; for (i = 0; i < ipme.len; ++i) - if (ipme.ix[i].af == AF_INET && byte_equal(&ipme.ix[i].addr,4,ip)) - return 1; + if (ipme.ix[i].af == AF_INET && byte_equal(&ipme.ix[i].addr, 4, ip)) return 1; return 0; } @@ -42,8 +43,7 @@ int ipme_is6(struct ip6_address *ip) if (ipme_init() != 1) return -1; for (i = 0; i < ipme.len; ++i) - if (ipme.ix[i].af == AF_INET6 && byte_equal(&ipme.ix[i].addr,16,ip)) - return 1; + if (ipme.ix[i].af == AF_INET6 && byte_equal(&ipme.ix[i].addr, 16, ip)) return 1; return 0; } @@ -66,26 +66,26 @@ int ipme_init() struct ip_mx ix; if (ipmeok) return 1; - if (!ipalloc_readyplus(&ipme,0)) return 0; + if (!ipalloc_readyplus(&ipme, 0)) return 0; ipme.len = 0; ix.pref = 0; if (getifaddrs(&ifap)) return 0; - for (ifa = ifap; ifa; ifa = ifa->ifa_next) + for (ifa = ifap; ifa; ifa = ifa->ifa_next) if (ifa->ifa_addr) { if (ifa->ifa_addr->sa_family == AF_INET) { - sin = (struct sockaddr_in *) ifa->ifa_addr; - byte_copy(&ix.addr.ip4,4,&sin->sin_addr); + sin = (struct sockaddr_in *)ifa->ifa_addr; + byte_copy(&ix.addr.ip4, 4, &sin->sin_addr); ix.af = AF_INET; - if (!ipalloc_append(&ipme,&ix)) return 0; + if (!ipalloc_append(&ipme, &ix)) return 0; } if (ifa->ifa_addr->sa_family == AF_INET6) { - sin6 = (struct sockaddr_in6 *) ifa->ifa_addr; - byte_copy(&ix.addr.ip6,16,&sin6->sin6_addr); + sin6 = (struct sockaddr_in6 *)ifa->ifa_addr; + byte_copy(&ix.addr.ip6, 16, &sin6->sin6_addr); ix.af = AF_INET6; - if (!ipalloc_append(&ipme,&ix)) return 0; - } + if (!ipalloc_append(&ipme, &ix)) return 0; + } } freeifaddrs(ifap); |