#!/usr/bin/perl -w
# Parses the bpf.h header file to generate the dlt_names.h header
# which maps the DLT types to the DLT string name
# run from the tcpreplay source base directory as:
# cat /usr/include/pcap-bpf.h | ./scripts/dlt2name.pl
use strict;
my $out_c = 'src/common/dlt_names.c';
my $out_h = 'src/common/dlt_names.h';
# open outfile
open(OUT_C, ">$out_c") or die("Unable to open $out_c for writing: $!");
open(OUT_H, ">$out_h") or die("Unable to open $out_h for writing: $!");
# read STDIN
# some DLT types aren't in a format we can parse easily or just doesn't
# exist in my /usr/include/net/bpf.h file so we list them here
my %known = (107 => 'BSD/OS Frame Relay',
108 => 'OpenBSD Loopback',
113 => 'Linux Cooked Sockets',
114 => 'Apple LocalTalk',
115 => 'Acorn Econet',
116 => 'OpenBSD IPFilter',
117 => 'OpenBSD PF Log/SuSE 6.3 LANE 802.3',
118 => 'Cisco IOS',
119 => '802.11 Prism Header',
120 => '802.11 Aironet Header',
121 => 'Siemens HiPath HDLC',
122 => 'IP over Fibre Channel'
);
my @names;
# put our known DLT types in names since the format of bpf.h is
# inconsistent
foreach my $dlt (keys %known) {
$names[$dlt]{name} = $known{$dlt};
}
while (my $line =