while (1) { my $hdr; my $len = read $handle, $hdr, $PKT_HDR_LEN; die "read failed: $!\n" if not defined $len; return undef if $len == 0; $TotalPkts++; my @vals = unpack "LLLL", $hdr; $pkt{secs} = $vals[0]; $pkt{usecs} = $vals[1]; $pkt{stamp} = ($vals[0] * 1.0) + ($vals[1] / 1000000); $pkt{len} = $vals[3]; $len = read $handle, $data, $vals[2]; die "read failed: $!\n" if not defined $len; die "file truncated: $!\n" if $len < $vals[2]; my $ipdata = eth_strip($data); $ip = NetPacket::IP->decode($ipdata); if ($$ip{proto} == 47) { $is_ce = ($$ip{tos} & 3 == 3); $ipdata = NetPacket::IP::strip($ipdata); $ipdata = substr $ipdata, 4; my $gre = NetPacket::IP->decode($ipdata); next if $$gre{src_ip} ne $ip1 && $$gre{src_ip} ne $ip2; $ip = $gre; }