codecs/libcodec.a \
wiretap/libwiretap.la \
epan/libwireshark.la \
+ @INET_PTON_LO@ \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
@PCRE_LIBS@ \
$(wireshark_optional_objects) \
wiretap/libwiretap.la \
epan/libwireshark.la \
+ @INET_PTON_LO@ \
@SNMP_LIBS@ @SSL_LIBS@ \
$(plugin_ldadd) \
@PCRE_LIBS@ \
# Libraries with which to link dumpcap.
dumpcap_LDADD = \
wiretap/libwiretap.la \
+ @INET_NTOP_LO@ \
@GLIB_LIBS@ \
@PCAP_LIBS@ @SOCKET_LIBS@ @NSL_LIBS@ \
@LIBGCRYPT_LIBS@
# helpers already available on some platforms (and on others not)
EXTRA_wireshark_SOURCES = \
getopt.c \
+ inet_ntop.c \
+ inet_pton.c \
mkstemp.c \
strerror.c \
strcasecmp.c \
# corresponding headers
EXTRA_wireshark_INCLUDES = \
getopt.h \
+ inet_v6defs.h \
mkstemp.h \
strerror.h \
strptime.h
randpkt_OBJECTS = $(randpkt_SOURCES:.c=.obj)
EXTRA_OBJECTS = \
+ getopt.obj \
+ inet_ntop.obj \
+ inet_pton.obj \
mkstemp.obj \
strptime.obj
!IFNDEF GTK1_DIR
wireshark.exe :
!ELSE
-wireshark.exe : config.h svnversion.h $(wireshark_OBJECTS) getopt.obj codecs epan gtk image\wireshark.res wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk\libui.lib plugins
+wireshark.exe : config.h svnversion.h $(wireshark_OBJECTS) getopt.obj inet_ntop.obj inet_pton.obj codecs epan gtk image\wireshark.res wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk\libui.lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) getopt.obj $(GTK1_LIBS) codecs\codecs.lib gtk\libui.lib $(wireshark_OBJECTS) image\wireshark.res
+ /OUT:wireshark.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) getopt.obj inet_ntop.obj inet_pton.obj $(GTK1_LIBS) codecs\codecs.lib gtk\libui.lib $(wireshark_OBJECTS) image\wireshark.res
<<
!IF "$(MSVC_VARIANT)" == "MSVC2005" || "$(MSVC_VARIANT)" == "MSVC2005EE" || "$(MSVC_VARIANT)" == "DOTNET20"
mt.exe -nologo -manifest "wireshark.exe.manifest" -outputresource:wireshark.exe;1
!IFNDEF GTK2_DIR
wireshark-gtk2.exe :
!ELSE
-wireshark-gtk2.exe : config.h svnversion.h $(wireshark_OBJECTS) getopt.obj codecs epan gtk2 image\wireshark.res wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk2.tmp\libui.lib plugins
+wireshark-gtk2.exe : config.h svnversion.h $(wireshark_OBJECTS) getopt.obj inet_ntop.obj inet_pton.obj codecs epan gtk2 image\wireshark.res wiretap\wiretap-$(WTAP_VERSION).lib codecs\codecs.lib gtk2.tmp\libui.lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:wireshark-gtk2.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) getopt.obj $(GTK2_LIBS) codecs\codecs.lib gtk2.tmp\libui.lib $(wireshark_OBJECTS) image\wireshark.res
+ /OUT:wireshark-gtk2.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:windows $(wireshark_LIBS) getopt.obj inet_ntop.obj inet_pton.obj $(GTK2_LIBS) codecs\codecs.lib gtk2.tmp\libui.lib $(wireshark_OBJECTS) image\wireshark.res
<<
!IF "$(MSVC_VARIANT)" == "MSVC2005" || "$(MSVC_VARIANT)" == "MSVC2005EE" || "$(MSVC_VARIANT)" == "DOTNET20"
mt.exe -nologo -manifest "wireshark-gtk2.exe.manifest" -outputresource:wireshark-gtk2.exe;1
!ENDIF
!ENDIF
-tshark.exe : config.h svnversion.h $(tshark_OBJECTS) getopt.obj epan image\tshark.res wiretap\wiretap-$(WTAP_VERSION).lib plugins
+tshark.exe : config.h svnversion.h $(tshark_OBJECTS) getopt.obj inet_ntop.obj epan image\tshark.res wiretap\wiretap-$(WTAP_VERSION).lib plugins
@echo Linking $@
$(LINK) @<<
- /OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(tshark_LIBS) $(tshark_OBJECTS) getopt.obj image\tshark.res
+ /OUT:tshark.exe $(conflags) $(conlibsdll) $(LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console $(tshark_LIBS) $(tshark_OBJECTS) getopt.obj inet_ntop.obj image\tshark.res
<<
!IF "$(MSVC_VARIANT)" == "MSVC2005" || "$(MSVC_VARIANT)" == "MSVC2005EE" || "$(MSVC_VARIANT)" == "DOTNET20"
mt.exe -nologo -manifest "tshark.exe.manifest" -outputresource:tshark.exe;1
mt.exe -nologo -manifest "randpkt.exe.manifest" -outputresource:randpkt.exe;1
!ENDIF
-dumpcap.exe : config.h svnversion.h $(dumpcap_OBJECTS) getopt.obj mkstemp.obj wiretap\wiretap-$(WTAP_VERSION).lib image\dumpcap.res
+dumpcap.exe : config.h svnversion.h $(dumpcap_OBJECTS) getopt.obj inet_ntop.obj mkstemp.obj wiretap\wiretap-$(WTAP_VERSION).lib image\dumpcap.res
@echo Linking $@
$(LINK) @<<
- /OUT:dumpcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dumpcap_LIBS) $(dumpcap_OBJECTS) getopt.obj mkstemp.obj image\dumpcap.res
+ /OUT:dumpcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dumpcap_LIBS) $(dumpcap_OBJECTS) getopt.obj inet_ntop.obj mkstemp.obj image\dumpcap.res
<<
!IF "$(MSVC_VARIANT)" == "MSVC2005" || "$(MSVC_VARIANT)" == "MSVC2005EE" || "$(MSVC_VARIANT)" == "DOTNET20"
mt.exe -nologo -manifest "dumpcap.exe.manifest" -outputresource:dumpcap.exe;1
clean: clean_gtk2.tmp clean-deps
rm -f $(wireshark_OBJECTS) $(tshark_OBJECTS) $(EXTRA_OBJECTS) \
$(EXECUTABLES) *.pdb *.exe.manifest \
- capinfos.obj editcap.obj mergecap.obj text2pcap.obj getopt.obj\
+ capinfos.obj editcap.obj mergecap.obj text2pcap.obj \
text2pcap-scanner.obj text2pcap-scanner.c rdps.obj \
rdps.pdb rdps.exe rdps.ilk config.h ps.c AUTHORS-SHORT \
AUTHORS-SHORT-FORMAT \
#include <sys/socket.h>
#endif
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h> /* needed to define AF_ values on UNIX */
+#endif
+
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h> /* needed to define AF_ values on Windows */
+#endif
+
+#ifdef NEED_INET_V6DEFS_H
+# include "inet_v6defs.h"
#endif
#include <signal.h>
gchar *name;
if_info_t *if_info;
if_addr_t *if_addr;
- struct addrinfo *ai;
- struct sockaddr_in *sa4;
- struct sockaddr_in6 *sa6;
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ...");
if_info->description = g_strdup(if_parts[1]);
addr_parts = g_strsplit(if_parts[2], ",", 0);
for (j = 0; addr_parts[j] != NULL; j++) {
- /* XXX - We're failing to convert IPv6 addresses (on Ubuntu, at least) */
- if (getaddrinfo(addr_parts[j], NULL, NULL, &ai) == 0) {
+ if_addr = g_malloc0(sizeof(if_addr_t));
+ if (inet_pton(AF_INET, addr_parts[j], &if_addr->ip_addr.ip4_addr)) {
+ if_addr->type = AT_IPv4;
+ } else if (inet_pton(AF_INET6, addr_parts[j],
+ &if_addr->ip_addr.ip6_addr)) {
+ if_addr->type = AT_IPv6;
+ } else {
+ g_free(if_addr);
if_addr = NULL;
- switch (ai->ai_family) {
- case AF_INET:
- if_addr = g_malloc0(sizeof(if_addr_t));
- if_addr->type = AT_IPv4;
- sa4 = (struct sockaddr_in *) ai->ai_addr;
- if_addr->ip_addr.ip4_addr = sa4->sin_addr.s_addr;
- break;
- case AF_INET6:
- if_addr = g_malloc0(sizeof(if_addr_t));
- if_addr->type = AT_IPv6;
- sa6 = (struct sockaddr_in6 *) ai->ai_addr;
- memcpy(&if_addr->ip_addr.ip6_addr, sa6->sin6_addr.s6_addr, 16);
- break;
- }
- if (if_addr) {
- if_info->ip_addr = g_slist_append(if_info->ip_addr, if_addr);
- }
- freeaddrinfo(ai);
+ }
+ if (if_addr) {
+ if_info->ip_addr = g_slist_append(if_info->ip_addr, if_addr);
}
}
if (strcmp(if_parts[3], "loopback") == 0)
#include <string.h>
#include <ctype.h>
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h> /* needed to define AF_ values on UNIX */
+#endif
+
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h> /* needed to define AF_ values on Windows */
+#endif
+
+#ifdef NEED_INET_V6DEFS_H
+# include "inet_v6defs.h"
#endif
#include <glib.h>
}
/* Return an ASCII-formatted list of interfaces. */
+#define ADDRSTRLEN 46 /* Covers IPv4 & IPv6 */
int
capture_opts_list_interfaces(gboolean verbose)
{
int i;
GSList *ip_addr;
if_addr_t *if_addr;
- char addr_str[NI_MAXHOST];
- struct sockaddr_in sa4;
- struct sockaddr_in6 sa6;
+ char addr_str[ADDRSTRLEN];
if_list = get_interface_list(&err, &err_str);
if (if_list == NULL) {
if_addr = ip_addr->data;
switch(if_addr->type) {
case AT_IPv4:
- sa4.sin_family = AF_INET;
- sa4.sin_addr.s_addr = if_addr->ip_addr.ip4_addr;
- if (getnameinfo((struct sockaddr *) &sa4, sizeof(sa4),
- addr_str, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) {
+ if (inet_ntop(AF_INET, &if_addr->ip_addr.ip4_addr, addr_str,
+ ADDRSTRLEN)) {
printf(addr_str);
} else {
printf("<unknown IPv4>");
}
break;
case AT_IPv6:
- sa6.sin6_family = AF_INET6;
- memcpy(&sa6.sin6_addr.s6_addr, &if_addr->ip_addr.ip6_addr, 16);
- if (getnameinfo((struct sockaddr *) &sa6, sizeof(sa6),
- addr_str, NI_MAXHOST, NULL, 0, NI_NUMERICHOST) == 0) {
+ if (inet_ntop(AF_INET6, &if_addr->ip_addr.ip6_addr,
+ addr_str, ADDRSTRLEN)) {
printf(addr_str);
} else {
printf("<unknown IPv6>");
#
distclean: clean
rm -f config.h register.c mkstemp.c strptime.c \
+ inet_ntop.c inet_pton.c \
$(LIBWIRESHARK_DISTCLEAN_GENERATED_SRC) \
$(LIBWIRESHARK_NODISTCLEAN_GENERATED_SRC) \
dtd_grammar.out dtd_grammar.h sminmpec.c
strptime.c: ..\strptime.c
xcopy ..\strptime.c . /d
+inet_ntop.c: ..\inet_ntop.c
+ xcopy ..\inet_ntop.c . /d
+
+inet_pton.c: ..\inet_pton.c
+ xcopy ..\inet_pton.c . /d
+
radius_dict.c : radius_dict.l
$(LEX) radius_dict.l