is_ipv6 = TRUE;
} else {
/* Not valid IPv6 - valid IPv4? */
- if (inet_pton(AF_INET, cp, &host_addr) <= 0)
+ if (!str_to_ip(cp, &host_addr))
continue; /* no */
is_ipv6 = FALSE;
}
is_ipv6 = TRUE;
} else {
/* Not valid IPv6 - valid IPv4? */
- if (inet_pton(AF_INET, addr, &host_addr) <= 0)
+ if (!str_to_ip(addr, &host_addr))
return FALSE; /* no */
is_ipv6 = FALSE;
}
++cp2 ;
/* Check if this is a valid IPv4 address */
- if (inet_pton(AF_INET, cp, &host_addr) <= 0) {
+ if (!str_to_ip(cp, &host_addr)) {
continue; /* no */
}
struct hostent *hp;
#endif /* HAVE_C_ARES */
- if (inet_pton(AF_INET6, host, addrp) > 0)
+ if (str_to_ip6(host, addrp))
return TRUE;
/* It's not a valid dotted-quad IP address; is it a valid
/*host_name_lookup_cleanup();*/
}
+gboolean
+str_to_ip(const char *str, void *dst)
+{
+ return inet_pton(AF_INET, str, dst) > 0;
+}
+
+gboolean
+str_to_ip6(const char *str, void *dst)
+{
+ return inet_pton(AF_INET6, str, dst) > 0;
+}
+
/*
* Editor modelines - http://www.wireshark.org/tools/modelines.html
*
WS_DLL_PUBLIC
void manually_resolve_cleanup(void);
+gboolean str_to_ip(const char *str, void *dst);
+gboolean str_to_ip6(const char *str, void *dst);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
*/
#include "config.h"
-/* Need to get headers for AF_INET6 and inet_pton() */
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-#ifdef NEED_INET_V6DEFS_H
-# include "wsutil/inet_v6defs.h"
-#endif
-
#include <glib.h>
#include <epan/packet.h>
#include <epan/prefs.h>
for (i = 0; i < LOWPAN_CONTEXT_MAX; i++) {
if (!lowpan_context_prefs[i]) continue;
- if (inet_pton(AF_INET6, lowpan_context_prefs[i], &prefix) <= 0) continue;
+ if (!str_to_ip6(lowpan_context_prefs[i], &prefix)) continue;
/* Set the prefix */
lowpan_context_insert(i, IEEE802154_BCAST_PAN, 64, &prefix, 0);
} /* for */
#include "packet-infiniband.h"
#include "packet-fc.h"
-#ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.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 "wsutil/inet_v6defs.h"
-#endif
-
void proto_register_fcoib(void);
void proto_reg_handoff_fcoib(void);
SET_ADDRESS(&manual_addr[i], AT_IB, sizeof(guint16), manual_addr_data[i]);
}
} else { /* GID */
- if (inet_pton(AF_INET6, gPREF_ID[i], manual_addr_data[i]) <= 0) {
+ if (!str_to_ip6( gPREF_ID[i], manual_addr_data[i])) {
error_occured = TRUE;
} else {
SET_ADDRESS(&manual_addr[i], AT_IB, GID_SIZE, manual_addr_data[i]);
#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/wmem/wmem.h>
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.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 "wsutil/inet_v6defs.h" /* if not a *NIX system */
-#endif
+#include <epan/addr_resolv.c>
void proto_register_ftp(void);
void proto_reg_handoff_ftp(void);
ip_str = wmem_strndup(wmem_packet_scope(), field, fieldlen);
if (*eprt_af == EPRT_AF_IPv4) {
- if (inet_pton(AF_INET, ip_str, eprt_ip) > 0)
+ if (str_to_ip(ip_str, eprt_ip))
ret = TRUE;
else
ret = FALSE;
}
else if (*eprt_af == EPRT_AF_IPv6) {
- if (inet_pton(AF_INET6, ip_str, eprt_ipv6) > 0)
+ if (str_to_ip6(ip_str, eprt_ipv6))
ret = TRUE;
else
ret = FALSE;
#include <stdlib.h>
#include <errno.h>
-#ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.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 "wsutil/inet_v6defs.h"
-#endif
-
#include "packet-infiniband.h"
void proto_register_ib_sdp(void);
SET_ADDRESS(&manual_addr[i], AT_IB, sizeof(guint16), manual_addr_data[i]);
}
} else { /* GID */
- if (inet_pton(AF_INET6, gPREF_ID[i], manual_addr_data[i]) <= 0) {
+ if (!str_to_ip6(gPREF_ID[i], manual_addr_data[i])) {
error_occured = TRUE;
} else {
SET_ADDRESS(&manual_addr[i], AT_IB, GID_SIZE, manual_addr_data[i]);
#include <epan/expert.h>
#include <epan/rtp_pt.h>
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h> /* needed to define AF_ values on Windows */
-#endif
-#ifdef NEED_INET_V6DEFS_H
-#include "wsutil/inet_v6defs.h"
-#endif
-
/* For setting up RTP/RTCP dissectors based on the RTPproxy's answers */
#include "packet-rtp.h"
#include "packet-rtcp.h"
/* Extract IP */
tmp = tvb_find_line_end(tvb, offset, -1, &new_offset, FALSE);
if (tvb_find_guint8(tvb, offset, -1, ':') == -1){
- inet_pton(AF_INET, (char*)tvb_get_string(wmem_packet_scope(), tvb, offset, tmp), ipaddr);
+ str_to_ip((char*)tvb_get_string(wmem_packet_scope(), tvb, offset, tmp), ipaddr);
addr.type = AT_IPv4;
addr.len = 4;
addr.data = wmem_memdup(wmem_packet_scope(), ipaddr, 4);
proto_tree_add_item(rtpproxy_tree, hf_rtpproxy_ipv4, tvb, offset, tmp, ENC_ASCII | ENC_NA);
}
else{
- inet_pton(AF_INET6, (char*)tvb_get_string(wmem_packet_scope(), tvb, offset, tmp), ipaddr);
+ str_to_ip6((char*)tvb_get_string(wmem_packet_scope(), tvb, offset, tmp), ipaddr);
addr.type = AT_IPv6;
addr.len = 16;
addr.data = wmem_memdup(wmem_packet_scope(), ipaddr, 16);
#include "config.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h> /* needed to define AF_ values on Windows */
-#endif
-
-#ifdef NEED_INET_V6DEFS_H
-# include "wsutil/inet_v6defs.h"
-#endif
-
#include <glib.h>
#include <epan/packet.h>
port_end_offset = tvb_find_guint8(tvb, port_offset, -1, ';');
}
/* Attempt to convert address */
- if (inet_pton(AF_INET,
- (char*)tvb_get_string(wmem_packet_scope(), tvb, address_offset, port_offset-address_offset),
- &media_info->msrp_ipaddr) > 0) {
+ if (str_to_ip((char*)tvb_get_string(wmem_packet_scope(), tvb, address_offset, port_offset-address_offset),
+ &media_info->msrp_ipaddr)) {
/* Get port number */
media_info->msrp_port_number = atoi((char*)tvb_get_string(wmem_packet_scope(), tvb, port_offset + 1, port_end_offset - port_offset - 1));
/* Set flag so this info can be used */
(media_info->connection_type != NULL)) {
if (strcmp(media_info->connection_type, "IP4") == 0) {
transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 4);
- if (inet_pton(AF_INET, media_info->connection_address, (void*)transport_info->src_addr[transport_index].data) > 0) {
+ if (str_to_ip(media_info->connection_address, (void*)transport_info->src_addr[transport_index].data)) {
/* connection_address could be converted to a valid ipv4 address*/
transport_info->proto_bitmask[transport_index] |= SDP_IPv4;
transport_info->src_addr[transport_index].type = AT_IPv4;
}
} else if (strcmp(media_info->connection_type, "IP6") == 0) {
transport_info->src_addr[transport_index].data = wmem_alloc(wmem_file_scope(), 16);
- if (inet_pton(AF_INET6, media_info->connection_address, (void*)transport_info->src_addr[transport_index].data) > 0) {
+ if (str_to_ip6(media_info->connection_address, (void*)transport_info->src_addr[transport_index].data)) {
/* connection_address could be converted to a valid ipv6 address*/
transport_info->proto_bitmask[transport_index] |= SDP_IPv6;
transport_info->src_addr[transport_index].type = AT_IPv6;
#include "config.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-# include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h> /* needed to define AF_ values on Windows */
-#endif
-
-#ifdef NEED_INET_V6DEFS_H
-# include "wsutil/inet_v6defs.h"
-#endif
-
#include <glib.h>
#include <wsutil/md5.h>
*addr=(address *)g_malloc( sizeof(address) );
addr_data=(char *)g_malloc( 4 );
- ret = inet_pton( AF_INET, str_addr, addr_data );
- if (ret==1)
+ ret = str_to_ip(str_addr, addr_data);
+ if (ret)
SET_ADDRESS(*addr, AT_IPv4, 4, addr_data);
else
SET_ADDRESS(*addr, AT_STRINGZ, (int)strlen(ADDR_INVLD)+1, ADDR_INVLD);
#include <string.h>
-#ifdef HAVE_ARPA_INET_H
-# include <arpa/inet.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 "wsutil/inet_v6defs.h"
-#endif
-
#include <glib.h>
#include "epan/packet.h"
}
if (strcmp(pref_proxy_ipaddr_s, "") != 0) {
- if (inet_pton(AF_INET, pref_proxy_ipaddr_s, proxy_ipaddr) > 0) {
+ if (str_to_ip(pref_proxy_ipaddr_s, proxy_ipaddr)) {
use_proxy_ipaddr = TRUE;
} else {
g_warning("uasip: Invalid 'Proxy IP Address': \"%s\"", pref_proxy_ipaddr_s);