pcap-common.c (235426) | pcap-common.c (241231) |
---|---|
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 | 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_TOKEN_RING DLT_IEEE802 /* DLT_IEEE802 is used for Token Ring */ | 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 */ | 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_PRISM_HEADER 119 /* 802.11+Prism II monitor mode */ 197#define LINKTYPE_AIRONET_HEADER 120 /* FreeBSD Aironet driver stuff */ | 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 | 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_RADIO 127 /* 802.11 plus BSD radio header */ | 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 | 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 * but could and arguably should also be used by non-AVS Linux 312 * 802.11 drivers; that may happen in the future. | |
313 */ | 310 */ |
314#define LINKTYPE_IEEE802_11_RADIO_AVS 163 /* 802.11 plus AVS radio header */ | 311#define LINKTYPE_IEEE802_11_AVS 163 /* 802.11 plus AVS radio metadata header */ |
315 316/* 317 * Juniper-private data link type, as per request from 318 * Hannes Gredler <hannes@juniper.net>. The corresponding 319 * DLT_s are used for passing on chassis-internal 320 * metainformation such as QOS profiles, etc.. 321 */ 322#define LINKTYPE_JUNIPER_MONITOR 164 323 324/* | 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/* |
325 * Reserved for BACnet MS/TP. | 322 * BACnet MS/TP frames. |
326 */ 327#define LINKTYPE_BACNET_MS_TP 165 328 329/* 330 * Another PPP variant as per request from Karsten Keil <kkeil@suse.de>. 331 * 332 * This is used in some OSes to allow a kernel socket filter to distinguish 333 * between incoming and outgoing packets, on a socket intended to --- 511 unchanged lines hidden (view full) --- 845 846/* 847 * IP-over-Infiniband, as specified by RFC 4391. 848 * 849 * Requested by Petr Sumbera <petr.sumbera@oracle.com>. 850 */ 851#define LINKTYPE_IPOIB 242 852 | 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 |
853#define LINKTYPE_MATCHING_MAX 242 /* highest value in the "matching" range */ | 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 |
854 | 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 |
|
855static struct linktype_map { 856 int dlt; 857 int linktype; 858} map[] = { 859 /* 860 * These DLT_* codes have LINKTYPE_* codes with values identical 861 * to the values of the corresponding DLT_* code. 862 */ 863 { DLT_NULL, LINKTYPE_NULL }, 864 { DLT_EN10MB, LINKTYPE_ETHERNET }, 865 { DLT_EN3MB, LINKTYPE_EXP_ETHERNET }, 866 { DLT_AX25, LINKTYPE_AX25 }, 867 { DLT_PRONET, LINKTYPE_PRONET }, 868 { DLT_CHAOS, LINKTYPE_CHAOS }, | 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 }, |
869 { DLT_IEEE802, LINKTYPE_TOKEN_RING }, | 902 { DLT_IEEE802, LINKTYPE_IEEE802_5 }, |
870 { DLT_ARCNET, LINKTYPE_ARCNET_BSD }, 871 { DLT_SLIP, LINKTYPE_SLIP }, 872 { DLT_PPP, LINKTYPE_PPP }, 873 { DLT_FDDI, LINKTYPE_FDDI }, | 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 }, |
|
874 875 /* 876 * These DLT_* codes have different values on different 877 * platforms; we map them to LINKTYPE_* codes that 878 * have values that should never be equal to any DLT_* 879 * code. 880 */ 881#ifdef DLT_FR 882 /* BSD/OS Frame Relay */ 883 { DLT_FR, LINKTYPE_FRELAY }, 884#endif 885 | 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 |
886 { DLT_SYMANTEC_FIREWALL, LINKTYPE_SYMANTEC_FIREWALL }, | |
887 { DLT_ATM_RFC1483, LINKTYPE_ATM_RFC1483 }, 888 { DLT_RAW, LINKTYPE_RAW }, 889 { DLT_SLIP_BSDOS, LINKTYPE_SLIP_BSDOS }, 890 { DLT_PPP_BSDOS, LINKTYPE_PPP_BSDOS }, 891 892 /* BSD/OS Cisco HDLC */ 893 { DLT_C_HDLC, LINKTYPE_C_HDLC }, 894 --- 23 unchanged lines hidden (view full) --- 918}; 919 920int 921dlt_to_linktype(int dlt) 922{ 923 int i; 924 925 /* | 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 /* |
|
926 * Map the values in the matching range. 927 */ 928 if (dlt >= DLT_MATCHING_MIN && dlt <= DLT_MATCHING_MAX) 929 return (dlt); 930 931 /* 932 * Map the values outside that range. 933 */ --- 11 unchanged lines hidden (view full) --- 945} 946 947int 948linktype_to_dlt(int linktype) 949{ 950 int i; 951 952 /* | 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 /* |
|
953 * Map the values in the matching range. 954 */ 955 if (linktype >= LINKTYPE_MATCHING_MIN && 956 linktype <= LINKTYPE_MATCHING_MAX) 957 return (linktype); 958 959 /* 960 * Map the values outside that range. --- 150 unchanged lines hidden --- | 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 --- |