From 9c3edeef88383ccbe6fa64fbcd888836b4cbe4d1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 17 May 2018 11:48:37 -0400 Subject: [PATCH] support cooked format in replay tool Change-Id: I3e1e991a5ef2492c958354dac309f0cec25ccb66 --- utils/kernel-intercept-pcap-replay.pl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/utils/kernel-intercept-pcap-replay.pl b/utils/kernel-intercept-pcap-replay.pl index 2d9d5b91a..067d7fd74 100755 --- a/utils/kernel-intercept-pcap-replay.pl +++ b/utils/kernel-intercept-pcap-replay.pl @@ -14,6 +14,7 @@ open($kfd, '+>', "/proc/rtpengine/$table/control") or die $!; my $err; my $p = pcap_open_offline($ARGV[0], \$err) or die $err; +my $linktype = pcap_datalink($p); my @packets; my %src_ips; @@ -77,7 +78,15 @@ exit; sub loop_cb { my ($user_data, $header, $packet) = @_; my %eth; - @eth{qw(src dst type rest)} = unpack('a6 a6 n a*', $packet); + if ($linktype == DLT_EN10MB) { + @eth{qw(src dst type rest)} = unpack('a6 a6 n a*', $packet); + } + elsif ($linktype == DLT_LINUX_SLL) { + @eth{qw(direction arphdr addrlen addr type rest)} = unpack('nnn a8 n a*', $packet); + } + else { + die($linktype); + } if ($eth{type} == 0x0800) { my $ip = ip($eth{rest}); my $rtp = rtp($ip->{udp}->{payload});