Check whether any input files were specified, and print an error for
[obnox/wireshark/wip.git] / follow.c
index 6e1e7e439de3725abbf0c61ff9e87b0aa2193bc1..19e14303b27c012eaeed504ce16ce029f7445de3 100644 (file)
--- a/follow.c
+++ b/follow.c
@@ -1,6 +1,6 @@
 /* follow.c
  *
- * $Id: follow.c,v 1.31 2002/08/28 21:00:06 jmayer Exp $
+ * $Id$
  *
  * Copyright 1998 Mike Hall <mlh@io.com>
  *
 #include <epan/packet.h>
 #include "follow.h"
 
+#define MAX_IPADDR_LEN  16
+
+typedef struct _tcp_frag {
+  gulong              seq;
+  gulong              len;
+  gulong              data_len;
+  gchar              *data;
+  struct _tcp_frag   *next;
+} tcp_frag;
+
 FILE* data_out_file = NULL;
 
 gboolean incomplete_tcp_stream = FALSE;
@@ -88,8 +98,8 @@ build_follow_filter( packet_info *pi ) {
     /* TCP over IPv6 */
     sprintf( buf,
             "(ipv6.addr eq %s and ipv6.addr eq %s) and (tcp.port eq %d and tcp.port eq %d)",
-            ip6_to_str((struct e_in6_addr *)pi->net_src.data),
-            ip6_to_str((struct e_in6_addr *)pi->net_dst.data),
+            ip6_to_str((const struct e_in6_addr *)pi->net_src.data),
+            ip6_to_str((const struct e_in6_addr *)pi->net_dst.data),
             pi->srcport, pi->destport );
     len = 16;
     is_ipv6 = TRUE;
@@ -140,12 +150,20 @@ reassemble_tcp( gulong sequence, gulong length, const char* data,
   /* Now check if the packet is for this connection. */
   memcpy(srcx, net_src->data, len);
   memcpy(dstx, net_dst->data, len);
-  if ((memcmp(srcx, ip_address[0], len) != 0 &&
-       memcmp(srcx, ip_address[1], len) != 0) ||
-      (memcmp(dstx, ip_address[0], len) != 0 &&
-       memcmp(dstx, ip_address[1], len) != 0) ||
-      (srcport != tcp_port[0] && srcport != tcp_port[1]) ||
-      (dstport != tcp_port[0] && dstport != tcp_port[1]))
+  if (
+      ! (
+        memcmp(srcx, ip_address[0], len) == 0 &&
+        memcmp(dstx, ip_address[1], len) == 0 &&
+        srcport == tcp_port[0] &&
+        dstport == tcp_port[1]
+       ) &&
+      ! (
+        memcmp(srcx, ip_address[1], len) == 0 &&
+        memcmp(dstx, ip_address[0], len) == 0 &&
+        srcport == tcp_port[1] &&
+        dstport == tcp_port[0]
+       )
+     )
     return;
 
   /* Initialize our stream chunk.  This data gets written to disk. */