forked from osmocom/wireshark
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:
parent
4cf9a1dca0
commit
a1af188aed
|
@ -30,77 +30,77 @@
|
|||
#include <wsutil/inet_addr.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IFADDRS_H
|
||||
#include <ifaddrs.h>
|
||||
#include <ifaddrs.h>
|
||||
#endif
|
||||
|
||||
GSList *local_interfaces_to_list(void)
|
||||
{
|
||||
GSList *interfaces = NULL;
|
||||
GSList *interfaces = NULL;
|
||||
#ifdef HAVE_GETIFADDRS
|
||||
struct ifaddrs *ifap;
|
||||
struct ifaddrs *ifa;
|
||||
int family;
|
||||
char ip[INET6_ADDRSTRLEN];
|
||||
struct ifaddrs *ifap;
|
||||
struct ifaddrs *ifa;
|
||||
int family;
|
||||
char ip[INET6_ADDRSTRLEN];
|
||||
|
||||
if (getifaddrs(&ifap)) {
|
||||
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;
|
||||
if (getifaddrs(&ifap)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* skip loopback addresses */
|
||||
if (!g_strcmp0(ip, "127.0.0.1") || !g_strcmp0(ip, "::1"))
|
||||
continue;
|
||||
for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
|
||||
if (ifa->ifa_addr == NULL)
|
||||
continue;
|
||||
|
||||
if (*ip) {
|
||||
interfaces = g_slist_prepend(interfaces, g_strdup(ip));
|
||||
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 */
|
||||
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:
|
||||
#endif /* HAVE_GETIFADDRS */
|
||||
return interfaces;
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue