Fix bug #1212: Follow SSL/UDP Stream gets direction wrong ...
authorsfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 22 Mar 2008 05:50:19 +0000 (05:50 +0000)
committersfisher <sfisher@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 22 Mar 2008 05:50:19 +0000 (05:50 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24715 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/follow_ssl.c
gtk/follow_stream.c
gtk/follow_stream.h
gtk/follow_udp.c

index e18c796129a94dfde01795d2d7a9be6e6bb1f92e..fbd9e71a5c0637f3a40274072604bfcf3d706d92 100644 (file)
@@ -103,12 +103,11 @@ ssl_queue_packet_data(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_
 
     if (follow_info->client_port == 0) {
         follow_info->client_port = pinfo->srcport;
-        memcpy(follow_info->client_ip, pinfo->src.data, pinfo->src.len);
+        COPY_ADDRESS(&follow_info->client_ip, &pinfo->src);
     }
-    if (memcmp(follow_info->client_ip, pinfo->src.data, pinfo->src.len) == 0 &&
-        follow_info->client_port == pinfo->srcport) {
+    if (ADDRESSES_EQUAL(&follow_info->client_ip, &pinfo->src) &&
+        follow_info->client_port == pinfo->srcport)
         rec->is_server = 0;
-    }
     else 
         rec->is_server = 1;
 
@@ -247,20 +246,32 @@ follow_ssl_stream_cb(GtkWidget * w, gpointer data _U_)
    /* Both Stream Directions */
     both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]);
     
-    /* Host 0 --> Host 1 */
-    server_to_client_string =
-           g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
-                           hostname0, port0,
-                           hostname1, port1,
-                           follow_info->bytes_written[0]);
-
-    /* Host 1 --> Host 0 */
-    client_to_server_string =
-           g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
-                           hostname1, port1,
-                           hostname0, port0,
-                           follow_info->bytes_written[1]);
-
+    if(follow_info->client_port == stats.port[0]) {
+           server_to_client_string =
+                   g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                   hostname0, port0,
+                                   hostname1, port1,
+                                   follow_info->bytes_written[0]);
+           
+           client_to_server_string =
+                   g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                   hostname1, port1,
+                                   hostname0, port0,
+                                   follow_info->bytes_written[1]);
+    } else {
+           server_to_client_string =
+                   g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                   hostname1, port1,
+                                   hostname0, port0,
+                                   follow_info->bytes_written[0]);
+           
+           client_to_server_string =
+                   g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                   hostname0, port0,
+                                   hostname1, port1,
+                                   follow_info->bytes_written[1]);
+    }
+    
     follow_stream("Follow SSL Stream", follow_info, both_directions_string,
                  server_to_client_string, client_to_server_string);
 
@@ -312,8 +323,7 @@ follow_read_ssl_stream(follow_info_t *follow_info,
            if (follow_info->show_stream == FROM_SERVER) {
                skip = TRUE;
            }
-       }
-       else {
+       } else {
            global_pos = &global_server_pos;
            if (follow_info->show_stream == FROM_CLIENT) {
                skip = TRUE;
index 47342590d141d0121b9244b63ea2ad3ffa8f481a..0f07bc616f49cb71645a61be9d9149b0f111e5b7 100644 (file)
@@ -992,6 +992,7 @@ follow_destroy_cb(GtkWidget *w, gpointer data _U_)
        }
 
        g_free(follow_info->filter_out_filter);
+       g_free((gpointer)follow_info->client_ip.data);
        forget_follow_info(follow_info);
        g_free(follow_info);
 }
index e7fece56cb33441c96dfd75d4b79c9124139775d..a2a78806b60e151fb1a0c3ed4d21cbb6cd54ae2b 100644 (file)
@@ -86,7 +86,7 @@ typedef struct {
         GList           *payload;
         guint           bytes_written[2];
         guint           client_port;
-        char            client_ip[MAX_IPADDR_LEN];
+        address         client_ip;
 } follow_info_t;
 
 #define E_FOLLOW_INFO_KEY "follow_info_key"
index 775d9b8b47aa26467f18385008644a186ce5646b..c9accfe8e9a8822e37891c259792411e7bea1616 100644 (file)
@@ -62,11 +62,11 @@ udp_queue_packet_data(void *tapdata, packet_info *pinfo,
 
        if (follow_info->client_port == 0) {
                follow_info->client_port = pinfo->srcport;
-               memcpy(follow_info->client_ip, pinfo->src.data, pinfo->src.len);
+               COPY_ADDRESS(&follow_info->client_ip, &pinfo->src);
        }
 
-       if (memcmp(follow_info->client_ip, pinfo->src.data, pinfo->src.len) ==
-           0 && follow_info->client_port == pinfo->srcport)
+       if (ADDRESSES_EQUAL(&follow_info->client_ip, &pinfo->src) &&
+           follow_info->client_port == pinfo->srcport)
                follow_record->is_server = FALSE;
        else 
                follow_record->is_server = TRUE;
@@ -193,19 +193,31 @@ follow_udp_stream_cb(GtkWidget *w, gpointer data _U_)
        /* Both Stream Directions */
        both_directions_string = g_strdup_printf("Entire conversation (%u bytes)", follow_info->bytes_written[0] + follow_info->bytes_written[1]);
     
-       /* Host 0 --> Host 1 */
-       server_to_client_string =
-               g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
-                               hostname0, port0,
-                               hostname1, port1,
-                               follow_info->bytes_written[0]);
-
-       /* Host 1 --> Host 0 */
-       client_to_server_string =
-               g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
-                               hostname1, port1,
-                               hostname0, port0,
-                               follow_info->bytes_written[1]);
+       if(follow_info->client_port == stats.port[0]) {
+               server_to_client_string =
+                       g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                       hostname0, port0,
+                                       hostname1, port1,
+                                       follow_info->bytes_written[0]);
+               
+               client_to_server_string =
+                       g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                       hostname1, port1,
+                                       hostname0, port0,
+                                       follow_info->bytes_written[1]);
+       } else {
+               server_to_client_string =
+                       g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                       hostname1, port1,
+                                       hostname0, port0,
+                                       follow_info->bytes_written[0]);
+               
+               client_to_server_string =
+                       g_strdup_printf("%s:%s --> %s:%s (%u bytes)",
+                                       hostname0, port0,
+                                       hostname1, port1,
+                                       follow_info->bytes_written[1]);
+       }
 
        follow_stream("Follow UDP Stream", follow_info, both_directions_string,
                      server_to_client_string, client_to_server_string);
@@ -260,8 +272,7 @@ follow_read_udp_stream(follow_info_t *follow_info,
                        if(follow_info->show_stream == FROM_SERVER) {
                                skip = TRUE;
                        }
-               }
-               else {
+               } else {
                        global_pos = &global_server_pos;
                        if (follow_info->show_stream == FROM_CLIENT) {
                                skip = TRUE;