source: lib/linktypes.c @ da22687

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since da22687 was da22687, checked in by Perry Lorier <perry@…>, 15 years ago

Remove wrong svn:executable
Remove default:

  • Property mode set to 100644
File size: 2.0 KB
Line 
1#include "libtrace.h"
2#include "config.h"
3#ifdef HAVE_PCAP
4#include <pcap.h>
5#endif
6#include "dagformat.h"
7#include "rt_protocol.h"
8#include <assert.h>
9
10/* This file maps libtrace types to/from pcap DLT and erf types
11 *
12 * When adding a new linktype to libtrace, add the mapping(s) here,
13 * and add the understanding of the type to get_ip(), and perhaps
14 * get_{source,destination}_mac (if your linklayer has mac's)
15 */
16
17libtrace_linktype_t pcap_dlt_to_libtrace(libtrace_dlt_t dlt)
18{
19        switch(dlt) {
20                case TRACE_DLT_NULL: return TRACE_TYPE_NONE;
21                case TRACE_DLT_EN10MB: return TRACE_TYPE_ETH;
22                case TRACE_DLT_ATM_RFC1483: return TRACE_TYPE_ATM;
23                case TRACE_DLT_IEEE802_11: return TRACE_TYPE_80211;
24                case TRACE_DLT_LINUX_SLL: return TRACE_TYPE_LINUX_SLL;
25                case TRACE_DLT_PFLOG: return TRACE_TYPE_PFLOG;
26        }
27        return -1;
28}
29
30int libtrace_to_pcap_dlt(libtrace_linktype_t type)
31{
32        switch(type) {
33                case TRACE_TYPE_NONE: return TRACE_DLT_NULL;
34                case TRACE_TYPE_ETH: return TRACE_DLT_EN10MB;
35                case TRACE_TYPE_ATM: return TRACE_DLT_ATM_RFC1483;
36                case TRACE_TYPE_80211: return TRACE_DLT_IEEE802_11;
37                case TRACE_TYPE_LINUX_SLL: return TRACE_DLT_LINUX_SLL;
38                case TRACE_TYPE_PFLOG: return TRACE_DLT_PFLOG;
39        }
40        return -1;
41}
42
43enum rt_field_t pcap_dlt_to_rt(int dlt) 
44{
45        /* For pcap the rt type is just the dlt + a fixed value */
46        return dlt + RT_DATA_PCAP;
47}
48
49int rt_to_pcap_dlt(enum rt_field_t rt_type)
50{
51        assert(rt_type >= RT_DATA_PCAP);
52        return rt_type - RT_DATA_PCAP;
53}
54
55libtrace_linktype_t erf_type_to_libtrace(char erf)
56{
57        switch (erf) {
58                case TYPE_HDLC_POS:     return TRACE_TYPE_HDLC_POS;
59                case TYPE_ETH:          return TRACE_TYPE_ETH;
60                case TYPE_ATM:          return TRACE_TYPE_ATM;
61                case TYPE_AAL5:         return TRACE_TYPE_AAL5;
62        }
63        return -1;
64}
65
66char libtrace_to_erf_type(libtrace_linktype_t linktype)
67{
68        switch(linktype) {
69                case TRACE_TYPE_HDLC_POS: return TYPE_HDLC_POS;
70                case TRACE_TYPE_ETH:    return TYPE_ETH;
71                case TRACE_TYPE_ATM:    return TYPE_ATM;
72                case TRACE_TYPE_AAL5:   return TYPE_AAL5;
73        }
74        return -1;
75}
Note: See TracBrowser for help on using the repository browser.