Permalink
Browse files

Support for decoding datalink types

The code was moved from procket.
  • Loading branch information...
1 parent 5988ba5 commit ddaaa483151b3c59e1dff107cffc852df7ea9455 @msantos committed Apr 23, 2011
Showing with 86 additions and 1 deletion.
  1. +25 −0 include/pkt.hrl
  2. +61 −1 src/pkt.erl
View
@@ -15,9 +15,34 @@
-define(ARPOP_InREPLY, 9). % InARP reply
-define(ARPOP_NAK, 10). % (ATM)ARP NAK
+%% Datalink types
-define(DLT_NULL, 0). % BSD loopback
-define(DLT_EN10MB, 1). % Ethernet
-define(DLT_LINUX_SLL, 113). % Linux cooked sockets fake hdr
+-define(DLT_EN3MB, 2).
+-define(DLT_AX25, 3).
+-define(DLT_PRONET, 4).
+-define(DLT_CHAOS, 5).
+-define(DLT_IEEE802, 6).
+-define(DLT_ARCNET, 7).
+-define(DLT_SLIP, 8).
+-define(DLT_PPP, 9).
+-define(DLT_FDDI, 10).
+-define(DLT_ATM_RFC1483, 11).
+-define(DLT_RAW, 12).
+-define(DLT_SLIP_BSDOS, 15).
+-define(DLT_PPP_BSDOS, 16).
+-define(DLT_PFSYNC, 18).
+-define(DLT_ATM_CLIP, 19).
+-define(DLT_PPP_SERIAL, 50).
+-define(DLT_C_HDLC, 104).
+-define(DLT_CHDLC, ?DLT_C_HDLC).
+-define(DLT_IEEE802_11, 105).
+-define(DLT_LOOP, 108).
+-define(DLT_PFLOG, 117).
+-define(DLT_IEEE802_11_RADIO, 127).
+-define(DLT_APPLE_IP_OVER_IEEE1394, 138).
+-define(DLT_IEEE802_11_RADIO_AVS, 163).
-ifndef(PF_UNSPEC).
-define(PF_UNSPEC,0). % Unspecified.
View
@@ -56,7 +56,8 @@
ipv6/1,
proto/1,
tcp/1,
- udp/1
+ udp/1,
+ dlt/1
]).
@@ -537,3 +538,62 @@ compl(N,S) -> compl(N+S).
valid(16#FFFF) -> true;
valid(_) -> false.
+
+%%
+%% Datalink types
+%%
+dlt(?DLT_NULL) -> null;
+dlt(?DLT_EN10MB) -> en10mb;
+dlt(?DLT_EN3MB) -> en3mb;
+dlt(?DLT_AX25) -> ax25;
+dlt(?DLT_PRONET) -> pronet;
+dlt(?DLT_CHAOS) -> chaos;
+dlt(?DLT_IEEE802) -> ieee802;
+dlt(?DLT_ARCNET) -> arcnet;
+dlt(?DLT_SLIP) -> slip;
+dlt(?DLT_PPP) -> ppp;
+dlt(?DLT_FDDI) -> fddi;
+dlt(?DLT_ATM_RFC1483) -> atm_rfc1483;
+dlt(?DLT_RAW) -> raw;
+dlt(?DLT_SLIP_BSDOS) -> slip_bsdos;
+dlt(?DLT_PPP_BSDOS) -> ppp_bsdos;
+dlt(?DLT_PFSYNC) -> pfsync;
+dlt(?DLT_ATM_CLIP) -> atm_clip;
+dlt(?DLT_PPP_SERIAL) -> ppp_serial;
+%dlt(?DLT_C_HDLC) -> c_hdlc;
+dlt(?DLT_CHDLC) -> chdlc;
+dlt(?DLT_IEEE802_11) -> ieee802_11;
+dlt(?DLT_LOOP) -> loop;
+dlt(?DLT_LINUX_SLL) -> linux_sll;
+dlt(?DLT_PFLOG) -> pflog;
+dlt(?DLT_IEEE802_11_RADIO) -> ieee802_11_radio;
+dlt(?DLT_APPLE_IP_OVER_IEEE1394) -> apple_ip_over_ieee1394;
+dlt(?DLT_IEEE802_11_RADIO_AVS) -> ieee802_11_radio_avs;
+
+dlt(null) -> ?DLT_NULL;
+dlt(en10mb) -> ?DLT_EN10MB;
+dlt(en3mb) -> ?DLT_EN3MB;
+dlt(ax25) -> ?DLT_AX25;
+dlt(pronet) -> ?DLT_PRONET;
+dlt(chaos) -> ?DLT_CHAOS;
+dlt(ieee802) -> ?DLT_IEEE802;
+dlt(arcnet) -> ?DLT_ARCNET;
+dlt(slip) -> ?DLT_SLIP;
+dlt(ppp) -> ?DLT_PPP;
+dlt(fddi) -> ?DLT_FDDI;
+dlt(atm_rfc1483) -> ?DLT_ATM_RFC1483;
+dlt(raw) -> ?DLT_RAW;
+dlt(slip_bsdos) -> ?DLT_SLIP_BSDOS;
+dlt(ppp_bsdos) -> ?DLT_PPP_BSDOS;
+dlt(pfsync) -> ?DLT_PFSYNC;
+dlt(atm_clip) -> ?DLT_ATM_CLIP;
+dlt(ppp_serial) -> ?DLT_PPP_SERIAL;
+dlt(c_hdlc) -> ?DLT_C_HDLC;
+dlt(chdlc) -> ?DLT_CHDLC;
+dlt(ieee802_11) -> ?DLT_IEEE802_11;
+dlt(loop) -> ?DLT_LOOP;
+dlt(linux_sll) -> ?DLT_LINUX_SLL;
+dlt(pflog) -> ?DLT_PFLOG;
+dlt(ieee802_11_radio) -> ?DLT_IEEE802_11_RADIO;
+dlt(apple_ip_over_ieee1394) -> ?DLT_APPLE_IP_OVER_IEEE1394;
+dlt(ieee802_22_radio_avs) -> ?DLT_IEEE802_11_RADIO_AVS.

0 comments on commit ddaaa48

Please sign in to comment.