diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2016-03-22 03:24:35 +0000 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2016-04-08 20:49:22 +0000 |
commit | c5782e0d412c38a7338a3f8862dee0c248aab227 (patch) | |
tree | 6d61f80782cfb65fd19ec05f31cb2eb4f192413e | |
parent | 57b2a84f3d900eb0b98157095c6aac07cec54fd9 (diff) | |
download | wireshark-c5782e0d412c38a7338a3f8862dee0c248aab227.tar.gz wireshark-c5782e0d412c38a7338a3f8862dee0c248aab227.tar.bz2 wireshark-c5782e0d412c38a7338a3f8862dee0c248aab227.zip |
Replace and remove host_ip_af() function
Change-Id: I932c156cbc6883d1d63bf0457fd62cfb67c3340e
Reviewed-on: https://code.wireshark.org/review/14750
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r-- | debian/libwireshark0.symbols | 1 | ||||
-rw-r--r-- | epan/addr_resolv.c | 28 | ||||
-rw-r--r-- | epan/addr_resolv.h | 8 | ||||
-rw-r--r-- | ui/cli/tap-follow.c | 24 | ||||
-rw-r--r-- | ui/util.c | 15 |
5 files changed, 25 insertions, 51 deletions
diff --git a/debian/libwireshark0.symbols b/debian/libwireshark0.symbols index 033ffa79bf..d173656d4c 100644 --- a/debian/libwireshark0.symbols +++ b/debian/libwireshark0.symbols @@ -784,7 +784,6 @@ libwireshark.so.0 libwireshark0 #MINVER# hex_str_to_bytes_encoding@Base 1.12.0~rc1 hf_text_only@Base 1.9.1 hfinfo_bitshift@Base 1.12.0~rc1 - host_ip_af@Base 1.9.1 host_name_lookup_process@Base 1.9.1 hostlist_table_set_gui_info@Base 1.99.0 http_dissector_add@Base 1.9.1 diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c index 7d541c29d2..87762fdb9f 100644 --- a/epan/addr_resolv.c +++ b/epan/addr_resolv.c @@ -3236,34 +3236,6 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp) return FALSE; } -/* - * Find out whether a hostname resolves to an ip or ipv6 address - * Return "ip6" if it is IPv6, "ip" otherwise (including the case - * that we don't know) - */ -const char * -#ifdef HAVE_GETADDRINFO -host_ip_af(const char *host) -#else -host_ip_af(const char *host _U_) -#endif -{ - const char *af = "ip"; - -#ifdef HAVE_GETADDRINFO - struct addrinfo hint, *result = NULL; - memset(&hint, 0, sizeof(hint)); - hint.ai_family = AF_UNSPEC; - if (getaddrinfo(host, NULL, &hint, &result) == 0) { - if (result->ai_family == AF_INET6) { - af = "ip6"; - } - freeaddrinfo(result); - } -#endif - return af; -} - GHashTable * get_manuf_hashtable(void) { diff --git a/epan/addr_resolv.h b/epan/addr_resolv.h index 678dd8d9d5..4d265e394c 100644 --- a/epan/addr_resolv.h +++ b/epan/addr_resolv.h @@ -323,14 +323,6 @@ gboolean get_host_ipaddr(const char *host, guint32 *addrp); WS_DLL_PUBLIC gboolean get_host_ipaddr6(const char *host, struct e_in6_addr *addrp); -/* - * Find out whether a hostname resolves to an ip or ipv6 address - * Return "ip6" if it is IPv6, "ip" otherwise (including the case - * that we don't know) - */ -WS_DLL_PUBLIC -const char* host_ip_af(const char *host); - WS_DLL_PUBLIC GHashTable *get_manuf_hashtable(void); diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c index c6a4ed0014..9d2b2d0cc9 100644 --- a/ui/cli/tap-follow.c +++ b/ui/cli/tap-follow.c @@ -63,7 +63,7 @@ typedef struct _cli_follow_info { #define STR_EBCDIC ",ebcdic" #define STR_RAW ",raw" -static void follow_exit(const char *strp) +WS_NORETURN static void follow_exit(const char *strp) { fprintf(stderr, "tshark: follow - %s\n", strp); exit(1); @@ -343,6 +343,7 @@ follow_arg_filter(const char **opt_argp, follow_info_t *follow_info) unsigned int ii; char addr[ADDR_LEN]; cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data; + gboolean is_ipv6; if (sscanf(*opt_argp, ",%u%n", &cli_follow_info->stream_index, &len) == 1 && ((*opt_argp)[len] == 0 || (*opt_argp)[len] == ',')) @@ -353,14 +354,25 @@ follow_arg_filter(const char **opt_argp, follow_info_t *follow_info) { for (ii = 0; ii < sizeof cli_follow_info->addr/sizeof *cli_follow_info->addr; ii++) { - if ((sscanf(*opt_argp, ADDRv6_FMT, addr, &cli_follow_info->port[ii], &len) != 2 && - sscanf(*opt_argp, ADDRv4_FMT, addr, &cli_follow_info->port[ii], &len) != 2) || - cli_follow_info->port[ii] <= 0 || cli_follow_info->port[ii] > G_MAXUINT16) + if (sscanf(*opt_argp, ADDRv6_FMT, addr, &cli_follow_info->port[ii], &len) == 2) { - follow_exit("Invalid address:port pair."); + is_ipv6 = TRUE; + } + else if (sscanf(*opt_argp, ADDRv4_FMT, addr, &cli_follow_info->port[ii], &len) == 2) + { + is_ipv6 = FALSE; + } + else + { + follow_exit("Invalid address."); + } + + if (cli_follow_info->port[ii] <= 0 || cli_follow_info->port[ii] > G_MAXUINT16) + { + follow_exit("Invalid port."); } - if (strcmp("ip6", host_ip_af(addr)) == 0) + if (is_ipv6) { if (!get_host_ipaddr6(addr, (struct e_in6_addr *)cli_follow_info->addrBuf[ii])) { @@ -169,9 +169,9 @@ const gchar *get_conn_cfilter(void) { if (g_strv_length(tokens) == 4) { remip = sanitize_filter_ip(tokens[0]); locip = sanitize_filter_ip(tokens[2]); - g_string_printf(filter_str, "not (tcp port %s and %s host %s " - "and tcp port %s and %s host %s)", tokens[1], host_ip_af(remip), remip, - tokens[3], host_ip_af(locip), locip); + g_string_printf(filter_str, "not (tcp port %s and host %s " + "and tcp port %s and host %s)", tokens[1], remip, + tokens[3], locip); g_free(remip); g_free(locip); } @@ -180,8 +180,8 @@ const gchar *get_conn_cfilter(void) { tokens = g_strsplit(env, " ", 3); if (g_strv_length(tokens) == 3) { remip = sanitize_filter_ip(tokens[2]); - g_string_printf(filter_str, "not (tcp port %s and %s host %s " - "and tcp port %s)", tokens[1], host_ip_af(remip), tokens[0], remip); + g_string_printf(filter_str, "not (tcp port %s and host %s " + "and tcp port %s)", tokens[1], tokens[0], remip); g_free(remip); } g_strfreev(tokens); @@ -193,7 +193,7 @@ const gchar *get_conn_cfilter(void) { return ""; } remip = sanitize_filter_ip(env); - g_string_printf(filter_str, "not %s host %s", host_ip_af(remip), remip); + g_string_printf(filter_str, "not host %s", remip); g_free(remip); } else if ((env = getenv("DISPLAY")) != NULL) { /* @@ -322,8 +322,7 @@ const gchar *get_conn_cfilter(void) { } } - g_string_printf(filter_str, "not %s host %s", - host_ip_af(phostname), phostname); + g_string_printf(filter_str, "not host %s", phostname); g_free(phostname); #ifdef _WIN32 } else if (GetSystemMetrics(SM_REMOTESESSION)) { |