1/*
2 * Copyright (c) 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
--- 104 unchanged lines hidden (view full) ---
113 * LINKTYPE_* values, either).
114 */
115#define LINKTYPE_NULL DLT_NULL
116#define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
117#define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */
118#define LINKTYPE_AX25 DLT_AX25
119#define LINKTYPE_PRONET DLT_PRONET
120#define LINKTYPE_CHAOS DLT_CHAOS
121#define LINKTYPE_IEEE802_5 DLT_IEEE802 /* DLT_IEEE802 is used for 802.5 Token Ring */
122#define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
123#define LINKTYPE_SLIP DLT_SLIP
124#define LINKTYPE_PPP DLT_PPP
125#define LINKTYPE_FDDI DLT_FDDI
126
127/*
128 * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
129 * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
--- 58 unchanged lines hidden (view full) ---
188
189/*
190 * Reserved for use with OpenBSD ipfilter.
191 */
192#define LINKTYPE_IPFILTER 116
193
194#define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */
195#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
196#define LINKTYPE_IEEE802_11_PRISM 119 /* 802.11 plus Prism II monitor mode radio metadata header */
197#define LINKTYPE_IEEE802_11_AIRONET 120 /* 802.11 plus FreeBSD Aironet driver radio metadata header */
198
199/*
200 * Reserved for Siemens HiPath HDLC.
201 */
202#define LINKTYPE_HHDLC 121
203
204#define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */
205#define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
206
207/*
208 * Reserved as per request from Kent Dahlgren <kent@praesum.com>
209 * for private use.
210 */
211#define LINKTYPE_RIO 124 /* RapidIO */
212#define LINKTYPE_PCI_EXP 125 /* PCI Express */
213#define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */
214
215#define LINKTYPE_IEEE802_11_RADIOTAP 127 /* 802.11 plus radiotap radio metadata header */
216
217/*
218 * Reserved for the TZSP encapsulation, as per request from
219 * Chris Waters <chris.waters@networkchemistry.com>
220 * TZSP is a generic encapsulation for any other link type,
221 * which includes a means to include meta-information
222 * with the packet, e.g. signal strength and channel
223 * for 802.11 packets.
--- 78 unchanged lines hidden (view full) ---
302#define LINKTYPE_USER15 162
303
304/*
305 * For future use with 802.11 captures - defined by AbsoluteValue
306 * Systems to store a number of bits of link-layer information
307 * including radio information:
308 *
309 * http://www.shaftnet.org/~pizza/software/capturefrm.txt
310 */
311#define LINKTYPE_IEEE802_11_AVS 163 /* 802.11 plus AVS radio metadata header */
312
313/*
314 * Juniper-private data link type, as per request from
315 * Hannes Gredler <hannes@juniper.net>. The corresponding
316 * DLT_s are used for passing on chassis-internal
317 * metainformation such as QOS profiles, etc..
318 */
319#define LINKTYPE_JUNIPER_MONITOR 164
320
321/*
322 * BACnet MS/TP frames.
323 */
324#define LINKTYPE_BACNET_MS_TP 165
325
326/*
327 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
328 *
329 * This is used in some OSes to allow a kernel socket filter to distinguish
330 * between incoming and outgoing packets, on a socket intended to
--- 511 unchanged lines hidden (view full) ---
842
843/*
844 * IP-over-Infiniband, as specified by RFC 4391.
845 *
846 * Requested by Petr Sumbera <petr.sumbera@oracle.com>.
847 */
848#define LINKTYPE_IPOIB 242
849
850/*
851 * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
852 *
853 * Requested by Guy Martin <gmsoft@tuxicoman.be>.
854 */
855#define LINKTYPE_MPEG_2_TS 243
856
857/*
858 * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
859 * used by their ng40 protocol tester.
860 *
861 * Requested by Jens Grimmer <jens.grimmer@ng4t.com>.
862 */
863#define LINKTYPE_NG40 244
864
865/*
866 * Pseudo-header giving adapter number and flags, followed by an NFC
867 * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
868 * as specified by NFC Forum Logical Link Control Protocol Technical
869 * Specification LLCP 1.1.
870 *
871 * Requested by Mike Wakerly <mikey@google.com>.
872 */
873#define LINKTYPE_NFC_LLCP 245
874
875/*
876 * pfsync output; DLT_PFSYNC is 18, which collides with DLT_CIP in
877 * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and Mac OS X, and
878 * is 121, which collides with DLT_HHDLC, in FreeBSD. We pick a
879 * shiny new link-layer header type value that doesn't collide with
880 * anything, in the hopes that future pfsync savefiles, if any,
881 * won't require special hacks to distinguish from other savefiles.
882 *
883 */
884#define LINKTYPE_PFSYNC 246
885
886#define LINKTYPE_MATCHING_MAX 246 /* highest value in the "matching" range */
887
888static struct linktype_map {
889 int dlt;
890 int linktype;
891} map[] = {
892 /*
893 * These DLT_* codes have LINKTYPE_* codes with values identical
894 * to the values of the corresponding DLT_* code.
895 */
896 { DLT_NULL, LINKTYPE_NULL },
897 { DLT_EN10MB, LINKTYPE_ETHERNET },
898 { DLT_EN3MB, LINKTYPE_EXP_ETHERNET },
899 { DLT_AX25, LINKTYPE_AX25 },
900 { DLT_PRONET, LINKTYPE_PRONET },
901 { DLT_CHAOS, LINKTYPE_CHAOS },
902 { DLT_IEEE802, LINKTYPE_IEEE802_5 },
903 { DLT_ARCNET, LINKTYPE_ARCNET_BSD },
904 { DLT_SLIP, LINKTYPE_SLIP },
905 { DLT_PPP, LINKTYPE_PPP },
906 { DLT_FDDI, LINKTYPE_FDDI },
907 { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
908
909 /*
910 * These DLT_* codes have different values on different
911 * platforms; we map them to LINKTYPE_* codes that
912 * have values that should never be equal to any DLT_*
913 * code.
914 */
915#ifdef DLT_FR
916 /* BSD/OS Frame Relay */
917 { DLT_FR, LINKTYPE_FRELAY },
918#endif
919
920 { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 },
921 { DLT_RAW, LINKTYPE_RAW },
922 { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
923 { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
924
925 /* BSD/OS Cisco HDLC */
926 { DLT_C_HDLC, LINKTYPE_C_HDLC },
927
--- 23 unchanged lines hidden (view full) ---
951};
952
953int
954dlt_to_linktype(int dlt)
955{
956 int i;
957
958 /*
959 * Map DLT_PFSYNC, whatever it might be, to LINKTYPE_PFSYNC.
960 */
961 if (dlt == DLT_PFSYNC)
962 return (LINKTYPE_PFSYNC);
963
964 /*
965 * Map the values in the matching range.
966 */
967 if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
968 return (dlt);
969
970 /*
971 * Map the values outside that range.
972 */
--- 11 unchanged lines hidden (view full) ---
984}
985
986int
987linktype_to_dlt(int linktype)
988{
989 int i;
990
991 /*
992 * Map LINKTYPE_PFSYNC to DLT_PFSYNC, whatever it might be.
993 * LINKTYPE_PFSYNC is in the matching range, to make sure
994 * it's as safe from reuse as we can arrange, so we do
995 * this test first.
996 */
997 if (linktype == LINKTYPE_PFSYNC)
998 return (DLT_PFSYNC);
999
1000 /*
1001 * Map the values in the matching range.
1002 */
1003 if (linktype >= LINKTYPE_MATCHING_MIN &&
1004 linktype <= LINKTYPE_MATCHING_MAX)
1005 return (linktype);
1006
1007 /*
1008 * Map the values outside that range.
--- 150 unchanged lines hidden ---
2 * Copyright (c) 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
--- 104 unchanged lines hidden (view full) ---
113 * LINKTYPE_* values, either).
114 */
115#define LINKTYPE_NULL DLT_NULL
116#define LINKTYPE_ETHERNET DLT_EN10MB /* also for 100Mb and up */
117#define LINKTYPE_EXP_ETHERNET DLT_EN3MB /* 3Mb experimental Ethernet */
118#define LINKTYPE_AX25 DLT_AX25
119#define LINKTYPE_PRONET DLT_PRONET
120#define LINKTYPE_CHAOS DLT_CHAOS
121#define LINKTYPE_IEEE802_5 DLT_IEEE802 /* DLT_IEEE802 is used for 802.5 Token Ring */
122#define LINKTYPE_ARCNET_BSD DLT_ARCNET /* BSD-style headers */
123#define LINKTYPE_SLIP DLT_SLIP
124#define LINKTYPE_PPP DLT_PPP
125#define LINKTYPE_FDDI DLT_FDDI
126
127/*
128 * LINKTYPE_PPP is for use when there might, or might not, be an RFC 1662
129 * PPP in HDLC-like framing header (with 0xff 0x03 before the PPP protocol
--- 58 unchanged lines hidden (view full) ---
188
189/*
190 * Reserved for use with OpenBSD ipfilter.
191 */
192#define LINKTYPE_IPFILTER 116
193
194#define LINKTYPE_PFLOG 117 /* OpenBSD DLT_PFLOG */
195#define LINKTYPE_CISCO_IOS 118 /* For Cisco-internal use */
196#define LINKTYPE_IEEE802_11_PRISM 119 /* 802.11 plus Prism II monitor mode radio metadata header */
197#define LINKTYPE_IEEE802_11_AIRONET 120 /* 802.11 plus FreeBSD Aironet driver radio metadata header */
198
199/*
200 * Reserved for Siemens HiPath HDLC.
201 */
202#define LINKTYPE_HHDLC 121
203
204#define LINKTYPE_IP_OVER_FC 122 /* RFC 2625 IP-over-Fibre Channel */
205#define LINKTYPE_SUNATM 123 /* Solaris+SunATM */
206
207/*
208 * Reserved as per request from Kent Dahlgren <kent@praesum.com>
209 * for private use.
210 */
211#define LINKTYPE_RIO 124 /* RapidIO */
212#define LINKTYPE_PCI_EXP 125 /* PCI Express */
213#define LINKTYPE_AURORA 126 /* Xilinx Aurora link layer */
214
215#define LINKTYPE_IEEE802_11_RADIOTAP 127 /* 802.11 plus radiotap radio metadata header */
216
217/*
218 * Reserved for the TZSP encapsulation, as per request from
219 * Chris Waters <chris.waters@networkchemistry.com>
220 * TZSP is a generic encapsulation for any other link type,
221 * which includes a means to include meta-information
222 * with the packet, e.g. signal strength and channel
223 * for 802.11 packets.
--- 78 unchanged lines hidden (view full) ---
302#define LINKTYPE_USER15 162
303
304/*
305 * For future use with 802.11 captures - defined by AbsoluteValue
306 * Systems to store a number of bits of link-layer information
307 * including radio information:
308 *
309 * http://www.shaftnet.org/~pizza/software/capturefrm.txt
310 */
311#define LINKTYPE_IEEE802_11_AVS 163 /* 802.11 plus AVS radio metadata header */
312
313/*
314 * Juniper-private data link type, as per request from
315 * Hannes Gredler <hannes@juniper.net>. The corresponding
316 * DLT_s are used for passing on chassis-internal
317 * metainformation such as QOS profiles, etc..
318 */
319#define LINKTYPE_JUNIPER_MONITOR 164
320
321/*
322 * BACnet MS/TP frames.
323 */
324#define LINKTYPE_BACNET_MS_TP 165
325
326/*
327 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>.
328 *
329 * This is used in some OSes to allow a kernel socket filter to distinguish
330 * between incoming and outgoing packets, on a socket intended to
--- 511 unchanged lines hidden (view full) ---
842
843/*
844 * IP-over-Infiniband, as specified by RFC 4391.
845 *
846 * Requested by Petr Sumbera <petr.sumbera@oracle.com>.
847 */
848#define LINKTYPE_IPOIB 242
849
850/*
851 * MPEG-2 transport stream (ISO 13818-1/ITU-T H.222.0).
852 *
853 * Requested by Guy Martin <gmsoft@tuxicoman.be>.
854 */
855#define LINKTYPE_MPEG_2_TS 243
856
857/*
858 * ng4T GmbH's UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as
859 * used by their ng40 protocol tester.
860 *
861 * Requested by Jens Grimmer <jens.grimmer@ng4t.com>.
862 */
863#define LINKTYPE_NG40 244
864
865/*
866 * Pseudo-header giving adapter number and flags, followed by an NFC
867 * (Near-Field Communications) Logical Link Control Protocol (LLCP) PDU,
868 * as specified by NFC Forum Logical Link Control Protocol Technical
869 * Specification LLCP 1.1.
870 *
871 * Requested by Mike Wakerly <mikey@google.com>.
872 */
873#define LINKTYPE_NFC_LLCP 245
874
875/*
876 * pfsync output; DLT_PFSYNC is 18, which collides with DLT_CIP in
877 * SuSE 6.3, on OpenBSD, NetBSD, DragonFly BSD, and Mac OS X, and
878 * is 121, which collides with DLT_HHDLC, in FreeBSD. We pick a
879 * shiny new link-layer header type value that doesn't collide with
880 * anything, in the hopes that future pfsync savefiles, if any,
881 * won't require special hacks to distinguish from other savefiles.
882 *
883 */
884#define LINKTYPE_PFSYNC 246
885
886#define LINKTYPE_MATCHING_MAX 246 /* highest value in the "matching" range */
887
888static struct linktype_map {
889 int dlt;
890 int linktype;
891} map[] = {
892 /*
893 * These DLT_* codes have LINKTYPE_* codes with values identical
894 * to the values of the corresponding DLT_* code.
895 */
896 { DLT_NULL, LINKTYPE_NULL },
897 { DLT_EN10MB, LINKTYPE_ETHERNET },
898 { DLT_EN3MB, LINKTYPE_EXP_ETHERNET },
899 { DLT_AX25, LINKTYPE_AX25 },
900 { DLT_PRONET, LINKTYPE_PRONET },
901 { DLT_CHAOS, LINKTYPE_CHAOS },
902 { DLT_IEEE802, LINKTYPE_IEEE802_5 },
903 { DLT_ARCNET, LINKTYPE_ARCNET_BSD },
904 { DLT_SLIP, LINKTYPE_SLIP },
905 { DLT_PPP, LINKTYPE_PPP },
906 { DLT_FDDI, LINKTYPE_FDDI },
907 { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL },
908
909 /*
910 * These DLT_* codes have different values on different
911 * platforms; we map them to LINKTYPE_* codes that
912 * have values that should never be equal to any DLT_*
913 * code.
914 */
915#ifdef DLT_FR
916 /* BSD/OS Frame Relay */
917 { DLT_FR, LINKTYPE_FRELAY },
918#endif
919
920 { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 },
921 { DLT_RAW, LINKTYPE_RAW },
922 { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS },
923 { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS },
924
925 /* BSD/OS Cisco HDLC */
926 { DLT_C_HDLC, LINKTYPE_C_HDLC },
927
--- 23 unchanged lines hidden (view full) ---
951};
952
953int
954dlt_to_linktype(int dlt)
955{
956 int i;
957
958 /*
959 * Map DLT_PFSYNC, whatever it might be, to LINKTYPE_PFSYNC.
960 */
961 if (dlt == DLT_PFSYNC)
962 return (LINKTYPE_PFSYNC);
963
964 /*
965 * Map the values in the matching range.
966 */
967 if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX)
968 return (dlt);
969
970 /*
971 * Map the values outside that range.
972 */
--- 11 unchanged lines hidden (view full) ---
984}
985
986int
987linktype_to_dlt(int linktype)
988{
989 int i;
990
991 /*
992 * Map LINKTYPE_PFSYNC to DLT_PFSYNC, whatever it might be.
993 * LINKTYPE_PFSYNC is in the matching range, to make sure
994 * it's as safe from reuse as we can arrange, so we do
995 * this test first.
996 */
997 if (linktype == LINKTYPE_PFSYNC)
998 return (DLT_PFSYNC);
999
1000 /*
1001 * Map the values in the matching range.
1002 */
1003 if (linktype >= LINKTYPE_MATCHING_MIN &&
1004 linktype <= LINKTYPE_MATCHING_MAX)
1005 return (linktype);
1006
1007 /*
1008 * Map the values outside that range.
--- 150 unchanged lines hidden ---