47 fformat (ofp,
"static u8 __pcap_pkt%d [] = {\n ", i);
49 for (j = 0; j <
vec_len (pkt); j++)
51 if (((j + 1) % 8) == 0)
52 fformat (ofp,
"0x%02x,\n ", pkt[j]);
54 fformat (ofp,
"0x%02x, ", pkt[j]);
59 fformat (ofp,
"static u8 *__pcap_pkts [] = {\n");
62 fformat (ofp,
" __pcap_pkt%d, \n", i);
74 main (
int argc,
char **argv)
78 u8 *input_file = 0, *output_file = 0;
86 if (
unformat (&input,
"-i %s", &input_file)
87 ||
unformat (&input,
"input %s", &input_file))
89 else if (
unformat (&input,
"-o %s", &output_file)
90 ||
unformat (&input,
"output %s", &output_file))
96 "usage: pcap2pg -i <input-file> [-o <output-file>]\n");
115 ofp = fopen ((
char *) output_file,
"w+");
char * file_name
File name of pcap output.
int pcap2cinit(pcap_main_t *pm, FILE *ofp)
Conversion of PCAP file to u8 ** initializer stanzas.
PCAP utility definitions.
PCAP main state data structure.
clib_error_t * pcap_read(pcap_main_t *pm)
Read PCAP file.
#define clib_error_report(e)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define clib_unix_warning(format, args...)
u8 ** packets_read
Packets read from file.
int main(int argc, char **argv)
pcap2pg.