Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: [Ethereal-dev] Patch from Suse 9.1

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Joerg Mayer <jmayer@xxxxxxxxx>
Date: Thu, 29 Apr 2004 12:08:45 +0200
Hello,

the following patch is part of the sources of Suse 9.1. Would it be
interesting for general use?

 Ciao
  Jörg
-- 
Joerg Mayer                                           <jmayer@xxxxxxxxx>
We are stuck with technology when what we really want is just stuff that
works. Some say that should read Microsoft instead of technology.
--- util.c
+++ util.c
@@ -66,6 +66,8 @@
 #include <windows.h>
 #endif
 
+#include <netdb.h>
+
 #include "util.h"
 
 /*
@@ -409,6 +411,12 @@
    CLIENTNAME (terminal server): <remote name>
  */
 
+
+char *getipforfilter(gchar *ip) {
+	struct hostent *h;
+	return (h = gethostbyname2(ip, AF_INET6)) && h->h_addrtype == AF_INET6 ? "ip6" : "ip";
+}	
+
 gchar *get_conn_cfilter(void) {
 	static GString *filter_str = NULL;
 	gchar *env, **tokens;
@@ -419,21 +427,21 @@
 	if ((env = getenv("SSH_CONNECTION")) != NULL) {
 		tokens = g_strsplit(env, " ", 4);
 		if (tokens[3]) {
-			g_string_sprintf(filter_str, "not (tcp port %s and ip host %s "
-				"and tcp port %s and ip host %s)", tokens[1], tokens[0],
-				tokens[3], tokens[2]);
+			g_string_sprintf(filter_str, "not (tcp port %s and %s host %s "
+							 "and tcp port %s and %s host %s)", tokens[1], getipforfilter(tokens[0]), tokens[0],
+				tokens[3], getipforfilter(tokens[2]), tokens[2]);
 			return filter_str->str;
 		}
 	} else if ((env = getenv("SSH_CLIENT")) != NULL) {
 		tokens = g_strsplit(env, " ", 3);
-		g_string_sprintf(filter_str, "not (tcp port %s and ip host %s "
-			"and tcp port %s)", tokens[1], tokens[0], tokens[2]);
+		g_string_sprintf(filter_str, "not (tcp port %s and %s host %s "
+			"and tcp port %s)", tokens[1], getipforfilter(tokens[0]), tokens[0], tokens[2]);
 		return filter_str->str;
 	} else if ((env = getenv("REMOTEHOST")) != NULL) {
 		if (strcasecmp(env, "localhost") == 0 || strcmp(env, "127.0.0.1") == 0) {
 			return "";
 		}
-		g_string_sprintf(filter_str, "not ip host %s", env);
+		g_string_sprintf(filter_str, "not %s host %s", getipforfilter(env), env);
 		return filter_str->str;
 	} else if ((env = getenv("DISPLAY")) != NULL) {
 		tokens = g_strsplit(env, ":", 2);
@@ -442,13 +450,13 @@
 					strcmp(tokens[0], "127.0.0.1") == 0) {
 				return "";
 			}
-			g_string_sprintf(filter_str, "not ip host %s",
-				tokens[0]);
+			g_string_sprintf(filter_str, "not %s host %s",
+				getipforfilter(tokens[0]), tokens[0]);
 			return filter_str->str;
 		}
 	} else if ((env = getenv("CLIENTNAME")) != NULL) {
 		if (g_strcasecmp("console", env) != 0) {
-			g_string_sprintf(filter_str, "not ip host %s", env);
+			g_string_sprintf(filter_str, "not %s host %s", getipforfilter(env), env);
 			return filter_str->str;
 		}
 	}