Skip to content

Commit f71ff0c

Browse files
author
Yury Shvedov
committed
Add all DLT values
Automated using dlt_genlua.sh script which generates part of C code for pcap_make_dlt function. Arguments are stored in linktypes.txt file which was generated from the source of http://www.tcpdump.org/linktypes.html WEB page with sed utility.
1 parent 0892d5a commit f71ff0c

File tree

3 files changed

+369
-2
lines changed

3 files changed

+369
-2
lines changed

dlt_genlua.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
4+
for dlt in $@; do
5+
DLT="$(awk '{print toupper($0)}' <<< "$dlt")"
6+
echo '#ifdef DLT_'"$DLT"
7+
echo ' pcap_dlt_set(L, "'"$DLT"'", DLT_'"$DLT"');'
8+
echo '#endif'
9+
done

linktypes.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
NULL
2+
EN10MB
3+
AX25
4+
IEEE802
5+
ARCNET
6+
SLIP
7+
PPP
8+
FDDI
9+
PPP_SERIAL
10+
PPP_ETHER
11+
ATM_RFC1483
12+
RAW
13+
C_HDLC
14+
IEEE802_11
15+
FRELAY
16+
LOOP
17+
LINUX_SLL
18+
LTALK
19+
PFLOG
20+
PRISM_HEADER
21+
IP_OVER_FC
22+
SUNATM
23+
IEEE802_11_RADIO
24+
ARCNET_LINUX
25+
APPLE_IP_OVER_IEEE1394
26+
MTP2_WITH_PHDR
27+
MTP2
28+
MTP3
29+
SCCP
30+
DOCSIS
31+
LINUX_IRDA
32+
USER0-DLT_USER15
33+
IEEE802_11_RADIO_AVS
34+
BACNET_MS_TP
35+
PPP_PPPD
36+
GPRS_LLC
37+
GPF_T
38+
GPF_F
39+
LINUX_LAPD
40+
BLUETOOTH_HCI_H4
41+
USB_LINUX
42+
PPI
43+
IEEE802_15_4
44+
SITA
45+
ERF
46+
BLUETOOTH_HCI_H4_WITH_PHDR
47+
AX25_KISS
48+
LAPD
49+
PPP_WITH_DIR
50+
C_HDLC_WITH_DIR
51+
FRELAY_WITH_DIR
52+
IPMB_LINUX
53+
IEEE802_15_4_NONASK_PHY
54+
USB_LINUX_MMAPPED
55+
FC_2
56+
FC_2_WITH_FRAME_DELIMS
57+
IPNET
58+
CAN_SOCKETCAN
59+
IPV4
60+
IPV6
61+
IEEE802_15_4_NOFCS
62+
DBUS
63+
DVB_CI
64+
MUX27010
65+
STANAG_5066_D_PDU
66+
NFLOG
67+
NETANALYZER
68+
NETANALYZER_TRANSPARENT
69+
IPOIB
70+
MPEG_2_TS
71+
NG40
72+
NFC_LLCP
73+
INFINIBAND
74+
SCTP
75+
USBPCAP
76+
RTAC_SERIAL
77+
BLUETOOTH_LE_LL
78+
NETLINK
79+
BLUETOOTH_LINUX_MONITOR
80+
BLUETOOTH_BREDR_BB
81+
BLUETOOTH_LE_LL_WITH_PHDR
82+
PROFIBUS_DL
83+
PKTAP
84+
EPON
85+
IPMI_HPM_2
86+
ZWAVE_R1_R2
87+
ZWAVE_R3
88+
WATTSTOPPER_DLM
89+
ISO_14443
90+
RDS
91+
USB_DARWIN
92+
SDLC

pcap.c

Lines changed: 268 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
4949

5050
#if LUA_VERSION_NUM > 501
5151
#define luaL_reg luaL_Reg
52-
#endif
52+
#endif
5353

5454
static double tv2secs(struct timeval* tv)
5555
{
@@ -184,19 +184,285 @@ static void pcap_dlt_set(lua_State* L, const char* name, int number)
184184
lua_settable(L, -3);
185185
}
186186

187-
/* TODO - add all the DLT values... */
188187
static void pcap_make_dlt(lua_State* L)
189188
{
190189
lua_newtable(L);
190+
#ifdef DLT_NULL
191+
pcap_dlt_set(L, "NULL", DLT_NULL);
192+
#endif
191193
#ifdef DLT_EN10MB
192194
pcap_dlt_set(L, "EN10MB", DLT_EN10MB);
193195
#endif
196+
#ifdef DLT_AX25
197+
pcap_dlt_set(L, "AX25", DLT_AX25);
198+
#endif
199+
#ifdef DLT_IEEE802
200+
pcap_dlt_set(L, "IEEE802", DLT_IEEE802);
201+
#endif
202+
#ifdef DLT_ARCNET
203+
pcap_dlt_set(L, "ARCNET", DLT_ARCNET);
204+
#endif
205+
#ifdef DLT_SLIP
206+
pcap_dlt_set(L, "SLIP", DLT_SLIP);
207+
#endif
208+
#ifdef DLT_PPP
209+
pcap_dlt_set(L, "PPP", DLT_PPP);
210+
#endif
211+
#ifdef DLT_FDDI
212+
pcap_dlt_set(L, "FDDI", DLT_FDDI);
213+
#endif
214+
#ifdef DLT_PPP_SERIAL
215+
pcap_dlt_set(L, "PPP_SERIAL", DLT_PPP_SERIAL);
216+
#endif
217+
#ifdef DLT_PPP_ETHER
218+
pcap_dlt_set(L, "PPP_ETHER", DLT_PPP_ETHER);
219+
#endif
220+
#ifdef DLT_ATM_RFC1483
221+
pcap_dlt_set(L, "ATM_RFC1483", DLT_ATM_RFC1483);
222+
#endif
194223
#ifdef DLT_RAW
195224
pcap_dlt_set(L, "RAW", DLT_RAW);
196225
#endif
226+
#ifdef DLT_C_HDLC
227+
pcap_dlt_set(L, "C_HDLC", DLT_C_HDLC);
228+
#endif
229+
#ifdef DLT_IEEE802_11
230+
pcap_dlt_set(L, "IEEE802_11", DLT_IEEE802_11);
231+
#endif
232+
#ifdef DLT_FRELAY
233+
pcap_dlt_set(L, "FRELAY", DLT_FRELAY);
234+
#endif
235+
#ifdef DLT_LOOP
236+
pcap_dlt_set(L, "LOOP", DLT_LOOP);
237+
#endif
197238
#ifdef DLT_LINUX_SLL
198239
pcap_dlt_set(L, "LINUX_SLL", DLT_LINUX_SLL);
199240
#endif
241+
#ifdef DLT_LTALK
242+
pcap_dlt_set(L, "LTALK", DLT_LTALK);
243+
#endif
244+
#ifdef DLT_PFLOG
245+
pcap_dlt_set(L, "PFLOG", DLT_PFLOG);
246+
#endif
247+
#ifdef DLT_PRISM_HEADER
248+
pcap_dlt_set(L, "PRISM_HEADER", DLT_PRISM_HEADER);
249+
#endif
250+
#ifdef DLT_IP_OVER_FC
251+
pcap_dlt_set(L, "IP_OVER_FC", DLT_IP_OVER_FC);
252+
#endif
253+
#ifdef DLT_SUNATM
254+
pcap_dlt_set(L, "SUNATM", DLT_SUNATM);
255+
#endif
256+
#ifdef DLT_IEEE802_11_RADIO
257+
pcap_dlt_set(L, "IEEE802_11_RADIO", DLT_IEEE802_11_RADIO);
258+
#endif
259+
#ifdef DLT_ARCNET_LINUX
260+
pcap_dlt_set(L, "ARCNET_LINUX", DLT_ARCNET_LINUX);
261+
#endif
262+
#ifdef DLT_APPLE_IP_OVER_IEEE1394
263+
pcap_dlt_set(L, "APPLE_IP_OVER_IEEE1394", DLT_APPLE_IP_OVER_IEEE1394);
264+
#endif
265+
#ifdef DLT_MTP2_WITH_PHDR
266+
pcap_dlt_set(L, "MTP2_WITH_PHDR", DLT_MTP2_WITH_PHDR);
267+
#endif
268+
#ifdef DLT_MTP2
269+
pcap_dlt_set(L, "MTP2", DLT_MTP2);
270+
#endif
271+
#ifdef DLT_MTP3
272+
pcap_dlt_set(L, "MTP3", DLT_MTP3);
273+
#endif
274+
#ifdef DLT_SCCP
275+
pcap_dlt_set(L, "SCCP", DLT_SCCP);
276+
#endif
277+
#ifdef DLT_DOCSIS
278+
pcap_dlt_set(L, "DOCSIS", DLT_DOCSIS);
279+
#endif
280+
#ifdef DLT_LINUX_IRDA
281+
pcap_dlt_set(L, "LINUX_IRDA", DLT_LINUX_IRDA);
282+
#endif
283+
#ifdef DLT_USER0-DLT_USER15
284+
pcap_dlt_set(L, "USER0-DLT_USER15", DLT_USER0-DLT_USER15);
285+
#endif
286+
#ifdef DLT_IEEE802_11_RADIO_AVS
287+
pcap_dlt_set(L, "IEEE802_11_RADIO_AVS", DLT_IEEE802_11_RADIO_AVS);
288+
#endif
289+
#ifdef DLT_BACNET_MS_TP
290+
pcap_dlt_set(L, "BACNET_MS_TP", DLT_BACNET_MS_TP);
291+
#endif
292+
#ifdef DLT_PPP_PPPD
293+
pcap_dlt_set(L, "PPP_PPPD", DLT_PPP_PPPD);
294+
#endif
295+
#ifdef DLT_GPRS_LLC
296+
pcap_dlt_set(L, "GPRS_LLC", DLT_GPRS_LLC);
297+
#endif
298+
#ifdef DLT_GPF_T
299+
pcap_dlt_set(L, "GPF_T", DLT_GPF_T);
300+
#endif
301+
#ifdef DLT_GPF_F
302+
pcap_dlt_set(L, "GPF_F", DLT_GPF_F);
303+
#endif
304+
#ifdef DLT_LINUX_LAPD
305+
pcap_dlt_set(L, "LINUX_LAPD", DLT_LINUX_LAPD);
306+
#endif
307+
#ifdef DLT_BLUETOOTH_HCI_H4
308+
pcap_dlt_set(L, "BLUETOOTH_HCI_H4", DLT_BLUETOOTH_HCI_H4);
309+
#endif
310+
#ifdef DLT_USB_LINUX
311+
pcap_dlt_set(L, "USB_LINUX", DLT_USB_LINUX);
312+
#endif
313+
#ifdef DLT_PPI
314+
pcap_dlt_set(L, "PPI", DLT_PPI);
315+
#endif
316+
#ifdef DLT_IEEE802_15_4
317+
pcap_dlt_set(L, "IEEE802_15_4", DLT_IEEE802_15_4);
318+
#endif
319+
#ifdef DLT_SITA
320+
pcap_dlt_set(L, "SITA", DLT_SITA);
321+
#endif
322+
#ifdef DLT_ERF
323+
pcap_dlt_set(L, "ERF", DLT_ERF);
324+
#endif
325+
#ifdef DLT_BLUETOOTH_HCI_H4_WITH_PHDR
326+
pcap_dlt_set(L, "BLUETOOTH_HCI_H4_WITH_PHDR", DLT_BLUETOOTH_HCI_H4_WITH_PHDR);
327+
#endif
328+
#ifdef DLT_AX25_KISS
329+
pcap_dlt_set(L, "AX25_KISS", DLT_AX25_KISS);
330+
#endif
331+
#ifdef DLT_LAPD
332+
pcap_dlt_set(L, "LAPD", DLT_LAPD);
333+
#endif
334+
#ifdef DLT_PPP_WITH_DIR
335+
pcap_dlt_set(L, "PPP_WITH_DIR", DLT_PPP_WITH_DIR);
336+
#endif
337+
#ifdef DLT_C_HDLC_WITH_DIR
338+
pcap_dlt_set(L, "C_HDLC_WITH_DIR", DLT_C_HDLC_WITH_DIR);
339+
#endif
340+
#ifdef DLT_FRELAY_WITH_DIR
341+
pcap_dlt_set(L, "FRELAY_WITH_DIR", DLT_FRELAY_WITH_DIR);
342+
#endif
343+
#ifdef DLT_IPMB_LINUX
344+
pcap_dlt_set(L, "IPMB_LINUX", DLT_IPMB_LINUX);
345+
#endif
346+
#ifdef DLT_IEEE802_15_4_NONASK_PHY
347+
pcap_dlt_set(L, "IEEE802_15_4_NONASK_PHY", DLT_IEEE802_15_4_NONASK_PHY);
348+
#endif
349+
#ifdef DLT_USB_LINUX_MMAPPED
350+
pcap_dlt_set(L, "USB_LINUX_MMAPPED", DLT_USB_LINUX_MMAPPED);
351+
#endif
352+
#ifdef DLT_FC_2
353+
pcap_dlt_set(L, "FC_2", DLT_FC_2);
354+
#endif
355+
#ifdef DLT_FC_2_WITH_FRAME_DELIMS
356+
pcap_dlt_set(L, "FC_2_WITH_FRAME_DELIMS", DLT_FC_2_WITH_FRAME_DELIMS);
357+
#endif
358+
#ifdef DLT_IPNET
359+
pcap_dlt_set(L, "IPNET", DLT_IPNET);
360+
#endif
361+
#ifdef DLT_CAN_SOCKETCAN
362+
pcap_dlt_set(L, "CAN_SOCKETCAN", DLT_CAN_SOCKETCAN);
363+
#endif
364+
#ifdef DLT_IPV4
365+
pcap_dlt_set(L, "IPV4", DLT_IPV4);
366+
#endif
367+
#ifdef DLT_IPV6
368+
pcap_dlt_set(L, "IPV6", DLT_IPV6);
369+
#endif
370+
#ifdef DLT_IEEE802_15_4_NOFCS
371+
pcap_dlt_set(L, "IEEE802_15_4_NOFCS", DLT_IEEE802_15_4_NOFCS);
372+
#endif
373+
#ifdef DLT_DBUS
374+
pcap_dlt_set(L, "DBUS", DLT_DBUS);
375+
#endif
376+
#ifdef DLT_DVB_CI
377+
pcap_dlt_set(L, "DVB_CI", DLT_DVB_CI);
378+
#endif
379+
#ifdef DLT_MUX27010
380+
pcap_dlt_set(L, "MUX27010", DLT_MUX27010);
381+
#endif
382+
#ifdef DLT_STANAG_5066_D_PDU
383+
pcap_dlt_set(L, "STANAG_5066_D_PDU", DLT_STANAG_5066_D_PDU);
384+
#endif
385+
#ifdef DLT_NFLOG
386+
pcap_dlt_set(L, "NFLOG", DLT_NFLOG);
387+
#endif
388+
#ifdef DLT_NETANALYZER
389+
pcap_dlt_set(L, "NETANALYZER", DLT_NETANALYZER);
390+
#endif
391+
#ifdef DLT_NETANALYZER_TRANSPARENT
392+
pcap_dlt_set(L, "NETANALYZER_TRANSPARENT", DLT_NETANALYZER_TRANSPARENT);
393+
#endif
394+
#ifdef DLT_IPOIB
395+
pcap_dlt_set(L, "IPOIB", DLT_IPOIB);
396+
#endif
397+
#ifdef DLT_MPEG_2_TS
398+
pcap_dlt_set(L, "MPEG_2_TS", DLT_MPEG_2_TS);
399+
#endif
400+
#ifdef DLT_NG40
401+
pcap_dlt_set(L, "NG40", DLT_NG40);
402+
#endif
403+
#ifdef DLT_NFC_LLCP
404+
pcap_dlt_set(L, "NFC_LLCP", DLT_NFC_LLCP);
405+
#endif
406+
#ifdef DLT_INFINIBAND
407+
pcap_dlt_set(L, "INFINIBAND", DLT_INFINIBAND);
408+
#endif
409+
#ifdef DLT_SCTP
410+
pcap_dlt_set(L, "SCTP", DLT_SCTP);
411+
#endif
412+
#ifdef DLT_USBPCAP
413+
pcap_dlt_set(L, "USBPCAP", DLT_USBPCAP);
414+
#endif
415+
#ifdef DLT_RTAC_SERIAL
416+
pcap_dlt_set(L, "RTAC_SERIAL", DLT_RTAC_SERIAL);
417+
#endif
418+
#ifdef DLT_BLUETOOTH_LE_LL
419+
pcap_dlt_set(L, "BLUETOOTH_LE_LL", DLT_BLUETOOTH_LE_LL);
420+
#endif
421+
#ifdef DLT_NETLINK
422+
pcap_dlt_set(L, "NETLINK", DLT_NETLINK);
423+
#endif
424+
#ifdef DLT_BLUETOOTH_LINUX_MONITOR
425+
pcap_dlt_set(L, "BLUETOOTH_LINUX_MONITOR", DLT_BLUETOOTH_LINUX_MONITOR);
426+
#endif
427+
#ifdef DLT_BLUETOOTH_BREDR_BB
428+
pcap_dlt_set(L, "BLUETOOTH_BREDR_BB", DLT_BLUETOOTH_BREDR_BB);
429+
#endif
430+
#ifdef DLT_BLUETOOTH_LE_LL_WITH_PHDR
431+
pcap_dlt_set(L, "BLUETOOTH_LE_LL_WITH_PHDR", DLT_BLUETOOTH_LE_LL_WITH_PHDR);
432+
#endif
433+
#ifdef DLT_PROFIBUS_DL
434+
pcap_dlt_set(L, "PROFIBUS_DL", DLT_PROFIBUS_DL);
435+
#endif
436+
#ifdef DLT_PKTAP
437+
pcap_dlt_set(L, "PKTAP", DLT_PKTAP);
438+
#endif
439+
#ifdef DLT_EPON
440+
pcap_dlt_set(L, "EPON", DLT_EPON);
441+
#endif
442+
#ifdef DLT_IPMI_HPM_2
443+
pcap_dlt_set(L, "IPMI_HPM_2", DLT_IPMI_HPM_2);
444+
#endif
445+
#ifdef DLT_ZWAVE_R1_R2
446+
pcap_dlt_set(L, "ZWAVE_R1_R2", DLT_ZWAVE_R1_R2);
447+
#endif
448+
#ifdef DLT_ZWAVE_R3
449+
pcap_dlt_set(L, "ZWAVE_R3", DLT_ZWAVE_R3);
450+
#endif
451+
#ifdef DLT_WATTSTOPPER_DLM
452+
pcap_dlt_set(L, "WATTSTOPPER_DLM", DLT_WATTSTOPPER_DLM);
453+
#endif
454+
#ifdef DLT_ISO_14443
455+
pcap_dlt_set(L, "ISO_14443", DLT_ISO_14443);
456+
#endif
457+
#ifdef DLT_RDS
458+
pcap_dlt_set(L, "RDS", DLT_RDS);
459+
#endif
460+
#ifdef DLT_USB_DARWIN
461+
pcap_dlt_set(L, "USB_DARWIN", DLT_USB_DARWIN);
462+
#endif
463+
#ifdef DLT_SDLC
464+
pcap_dlt_set(L, "SDLC", DLT_SDLC);
465+
#endif
200466
#ifdef DLT_USER0
201467
pcap_dlt_set(L, "USER0", DLT_USER0);
202468
#endif

0 commit comments

Comments
 (0)