1 | /* ERF META PACKET */ |
---|
2 | #include "libtrace.h" |
---|
3 | #include "libpacketdump.h" |
---|
4 | #include "format_erf.h" |
---|
5 | |
---|
6 | DLLEXPORT void decode(int link_type UNUSED, const char *packet UNUSED, unsigned len UNUSED) { |
---|
7 | } |
---|
8 | |
---|
9 | static void print_section(libtrace_meta_t *meta) { |
---|
10 | int i; |
---|
11 | for (i=0; i<meta->num; i++) { |
---|
12 | printf(" Option ID: %u Option Value: %s\n", |
---|
13 | meta->items[i].option, (char *)meta->items[i].data); |
---|
14 | } |
---|
15 | } |
---|
16 | |
---|
17 | DLLEXPORT void decode_meta(int link_type UNUSED, const char *packet UNUSED, unsigned len UNUSED, |
---|
18 | libtrace_packet_t *p) { |
---|
19 | |
---|
20 | printf(" ERF Provenance Packet\n"); |
---|
21 | |
---|
22 | /* Try to find each section from the meta packet */ |
---|
23 | libtrace_meta_t *sec_cap = trace_get_section(p, ERF_PROV_SECTION_CAPTURE); |
---|
24 | libtrace_meta_t *sec_host = trace_get_section(p, ERF_PROV_SECTION_HOST); |
---|
25 | libtrace_meta_t *sec_module = trace_get_section(p, ERF_PROV_SECTION_MODULE); |
---|
26 | libtrace_meta_t *sec_interface = trace_get_section(p, ERF_PROV_SECTION_INTERFACE); |
---|
27 | |
---|
28 | if (sec_cap != NULL) { |
---|
29 | printf(" Capture Section\n"); |
---|
30 | print_section(sec_cap); |
---|
31 | trace_destroy_meta(sec_cap); |
---|
32 | } |
---|
33 | |
---|
34 | if (sec_host != NULL) { |
---|
35 | printf(" Host Section\n"); |
---|
36 | print_section(sec_host); |
---|
37 | trace_destroy_meta(sec_host); |
---|
38 | } |
---|
39 | |
---|
40 | if (sec_module != NULL) { |
---|
41 | printf(" Module Section\n"); |
---|
42 | print_section(sec_module); |
---|
43 | trace_destroy_meta(sec_module); |
---|
44 | } |
---|
45 | |
---|
46 | if (sec_interface != NULL) { |
---|
47 | printf(" Interface Section\n"); |
---|
48 | print_section(sec_interface); |
---|
49 | trace_destroy_meta(sec_interface); |
---|
50 | } |
---|
51 | |
---|
52 | } |
---|