+
+ /* First, check if this packet should be processed. */
+
+ if ((net_src->type != AT_IPv4 && net_src->type != AT_IPv6) ||
+ (net_dst->type != AT_IPv4 && net_dst->type != AT_IPv6))
+ return;
+
+ if (net_src->type == AT_IPv4)
+ len = 4;
+ else
+ len = 16;
+
+ /* 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(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. */
+ memcpy(sc.src_addr, srcx, len);
+ sc.src_port = srcport;
+ sc.dlen = data_length;
+
+ /* Check to see if we have seen this source IP and port before.
+ (Yes, we have to check both source IP and port; the connection
+ might be between two different ports on the same machine.) */