wsutil: fix indentation of interface.c

Change-Id: Icf0c0c4ce1e3763eb385de24dc608a120e0f4af2
Reviewed-on: https://code.wireshark.org/review/17307
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Dario Lombardo 2016-08-24 16:54:02 +02:00 committed by Michael Mann
parent 4cf9a1dca0
commit a1af188aed
1 changed files with 47 additions and 47 deletions

View File

@ -30,77 +30,77 @@
#include <wsutil/inet_addr.h> #include <wsutil/inet_addr.h>
#ifdef HAVE_SYS_TYPES_H #ifdef HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif #endif
#ifdef HAVE_IFADDRS_H #ifdef HAVE_IFADDRS_H
#include <ifaddrs.h> #include <ifaddrs.h>
#endif #endif
GSList *local_interfaces_to_list(void) GSList *local_interfaces_to_list(void)
{ {
GSList *interfaces = NULL; GSList *interfaces = NULL;
#ifdef HAVE_GETIFADDRS #ifdef HAVE_GETIFADDRS
struct ifaddrs *ifap; struct ifaddrs *ifap;
struct ifaddrs *ifa; struct ifaddrs *ifa;
int family; int family;
char ip[INET6_ADDRSTRLEN]; char ip[INET6_ADDRSTRLEN];
if (getifaddrs(&ifap)) { if (getifaddrs(&ifap)) {
goto end; goto end;
}
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (ifa->ifa_addr == NULL)
continue;
family = ifa->ifa_addr->sa_family;
memset(ip, 0x0, INET6_ADDRSTRLEN);
switch (family) {
case AF_INET:
{
struct sockaddr_in *addr4 = (struct sockaddr_in *)ifa->ifa_addr;
ws_inet_ntop4(&addr4->sin_addr, ip, sizeof(ip));
break;
}
case AF_INET6:
{
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)ifa->ifa_addr;
ws_inet_ntop6(&addr6->sin6_addr, ip, sizeof(ip));
break;
}
default:
break;
} }
/* skip loopback addresses */ for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
if (!g_strcmp0(ip, "127.0.0.1") || !g_strcmp0(ip, "::1")) if (ifa->ifa_addr == NULL)
continue; continue;
if (*ip) { family = ifa->ifa_addr->sa_family;
interfaces = g_slist_prepend(interfaces, g_strdup(ip));
memset(ip, 0x0, INET6_ADDRSTRLEN);
switch (family) {
case AF_INET:
{
struct sockaddr_in *addr4 = (struct sockaddr_in *)ifa->ifa_addr;
ws_inet_ntop4(&addr4->sin_addr, ip, sizeof(ip));
break;
}
case AF_INET6:
{
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)ifa->ifa_addr;
ws_inet_ntop6(&addr6->sin6_addr, ip, sizeof(ip));
break;
}
default:
break;
}
/* skip loopback addresses */
if (!g_strcmp0(ip, "127.0.0.1") || !g_strcmp0(ip, "::1"))
continue;
if (*ip) {
interfaces = g_slist_prepend(interfaces, g_strdup(ip));
}
} }
} freeifaddrs(ifap);
freeifaddrs(ifap);
end: end:
#endif /* HAVE_GETIFADDRS */ #endif /* HAVE_GETIFADDRS */
return interfaces; return interfaces;
} }
/* /*