4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since eeab9832 was
643105b,
checked in by Perry Lorier <perry@…>, 16 years ago
|
Add forgotten C file
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | #include "libtrace.h" |
---|
2 | #include <pcap.h> |
---|
3 | #include "dagformat.h" |
---|
4 | |
---|
5 | /* This file maps libtrace types to/from pcap DLT and erf types |
---|
6 | * |
---|
7 | * When adding a new linktype to libtrace, add the mapping(s) here, |
---|
8 | * and add the understanding of the type to get_ip(), and perhaps |
---|
9 | * get_{source,destination}_mac (if your linklayer has mac's) |
---|
10 | */ |
---|
11 | |
---|
12 | libtrace_linktype_t pcap_dlt_to_libtrace(int dlt) |
---|
13 | { |
---|
14 | switch(dlt) { |
---|
15 | case DLT_NULL: return TRACE_TYPE_NONE; |
---|
16 | case DLT_EN10MB: return TRACE_TYPE_ETH; |
---|
17 | case DLT_ATM_RFC1483: return TRACE_TYPE_ATM; |
---|
18 | case DLT_IEEE802_11: return TRACE_TYPE_80211; |
---|
19 | #ifdef DLT_LINUX_SLL |
---|
20 | case DLT_LINUX_SLL: return TRACE_TYPE_LINUX_SLL; |
---|
21 | #endif |
---|
22 | #ifdef DLT_PFLOG |
---|
23 | case DLT_PFLOG: return TRACE_TYPE_PFLOG; |
---|
24 | #endif |
---|
25 | default: |
---|
26 | return -1; |
---|
27 | } |
---|
28 | } |
---|
29 | |
---|
30 | int libtrace_to_pcap_dlt(libtrace_linktype_t type) |
---|
31 | { |
---|
32 | switch(type) { |
---|
33 | case TRACE_TYPE_NONE: return DLT_NULL; |
---|
34 | case TRACE_TYPE_ETH: return DLT_EN10MB; |
---|
35 | case TRACE_TYPE_ATM: return DLT_ATM_RFC1483; |
---|
36 | case TRACE_TYPE_80211: return DLT_IEEE802_11; |
---|
37 | #ifdef DLT_LINUX_SLL |
---|
38 | case TRACE_TYPE_LINUX_SLL: return DLT_LINUX_SLL; |
---|
39 | #endif |
---|
40 | #ifdef DLT_PFLOG |
---|
41 | case TRACE_TYPE_PFLOG: return DLT_PFLOG; |
---|
42 | #endif |
---|
43 | default: |
---|
44 | return -1; |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | libtrace_linktype_t erf_type_to_libtrace(char erf) |
---|
49 | { |
---|
50 | switch (erf) { |
---|
51 | case TYPE_LEGACY: return TRACE_TYPE_LEGACY; |
---|
52 | case TYPE_ETH: return TRACE_TYPE_ETH; |
---|
53 | case TYPE_ATM: return TRACE_TYPE_ATM; |
---|
54 | default: |
---|
55 | return -1; |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | char libtrace_to_erf_type(libtrace_linktype_t linktype) |
---|
60 | { |
---|
61 | switch(linktype) { |
---|
62 | case TRACE_TYPE_LEGACY: return TYPE_LEGACY; |
---|
63 | case TRACE_TYPE_ETH: return TYPE_ETH; |
---|
64 | case TRACE_TYPE_ATM: return TYPE_ATM; |
---|
65 | default: |
---|
66 | return -1; |
---|
67 | } |
---|
68 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.