summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorJoão Valverde <joao.valverde@tecnico.ulisboa.pt>2016-03-22 03:24:35 +0000
committerPeter Wu <peter@lekensteyn.nl>2016-04-08 20:49:22 +0000
commitc5782e0d412c38a7338a3f8862dee0c248aab227 (patch)
tree6d61f80782cfb65fd19ec05f31cb2eb4f192413e /ui
parent57b2a84f3d900eb0b98157095c6aac07cec54fd9 (diff)
downloadwireshark-c5782e0d412c38a7338a3f8862dee0c248aab227.tar.gz
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>
Diffstat (limited to 'ui')
-rw-r--r--ui/cli/tap-follow.c24
-rw-r--r--ui/util.c15
2 files changed, 25 insertions, 14 deletions
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]))
{
diff --git a/ui/util.c b/ui/util.c
index 29a6811321..907f778f39 100644
--- a/ui/util.c
+++ b/ui/util.c
@@ -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)) {