Skip to content

Commit

Permalink
Get rid of the PCAP_ENCAP_ values - if an application uses them, that
Browse files Browse the repository at this point in the history
application won't build with any other version of libpcap, which means
that a lot of applications won't use them.  In addition,
"pcap_linktype()" needs to return DLT_ values, so that platforms that
build libpcap as a shared library won't break binary compatibility if
they update to this version of libpcap.

Instead, we map from DLT_ values to LINKTYPE_ values when writing
savefiles, and map from LINKTYPE_ values to DLT_ values when reading
savefiles, so that savefiles don't have platform-dependent DLT_ values
in the header as the link type, they have platform-independent LINKTYPE_
values.

This means we don't need to make DLT_ATM_RFC1483, DLT_RAW, etc. have
platform-independent values starting at 100 - only the values in the
savefile header need to be like that.
  • Loading branch information
yuguy committed Oct 12, 2000
1 parent f7179f8 commit 2c961ff
Show file tree
Hide file tree
Showing 12 changed files with 348 additions and 355 deletions.
72 changes: 46 additions & 26 deletions bpf/net/bpf.h
Expand Up @@ -37,7 +37,7 @@
*
* @(#)bpf.h 7.1 (Berkeley) 5/7/91
*
* @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.39 2000-09-17 04:04:39 guy Exp $ (LBL)
* @(#) $Header: /tcpdump/master/libpcap/bpf/net/Attic/bpf.h,v 1.40 2000-10-12 03:54:02 guy Exp $ (LBL)
*/

#ifndef BPF_MAJOR_VERSION
Expand Down Expand Up @@ -160,6 +160,9 @@ struct bpf_hdr {

/*
* Data-link level type codes.
*/

/*
* These are the types that are the same on all platforms; on other
* platforms, a <net/bpf.h> should be supplied that defines the additional
* DLT_* codes appropriately for that platform (the BSDs, for example,
Expand All @@ -178,40 +181,57 @@ struct bpf_hdr {
#define DLT_SLIP 8 /* Serial Line IP */
#define DLT_PPP 9 /* Point-to-point Protocol */
#define DLT_FDDI 10 /* FDDI */
#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */

/*
* These are the values that were traditionally defined in <net/bpf.h>,
* but that are not the same on all platforms; if they are not already
* defined (e.g., defined above because this is a BSD that defines them
* for use in its kernel), we define them to have the appropriate
* PCAP_ENCAP_* value from <pcap.h>, so that programs using those DLT_
* codes will continue to compile and will be able to read capture files
* from the current version of libpcap.
* These are values from the traditional libpcap "bpf.h".
* Ports of this to particular platforms should replace these definitions
* with the ones appropriate to that platform, if the values are
* different on that platform.
*/
#ifndef DLT_ATM_RFC1483
#define DLT_ATM_RFC1483 100 /* LLC/SNAP encapsulated atm */
#endif
#ifndef DLT_RAW
#define DLT_RAW 101 /* raw IP */
#endif
#define DLT_ATM_RFC1483 11 /* LLC/SNAP encapsulated atm */
#define DLT_RAW 12 /* raw IP */

/*
* These are values from BSD/OS's "bpf.h".
* These are not the same as the values from the traditional libpcap
* "bpf.h"; however, these values shouldn't be generated by any
* OS other than BSD/OS, so the correct values to use here are the
* BSD/OS values.
*
* Platforms that have already assigned these values to other
* DLT_ codes, however, should give these codes the values
* from that platform, so that programs that use these codes will
* continue to compile - even though they won't correctly read
* files of these types.
*/
#define DLT_SLIP_BSDOS 15 /* BSD/OS Serial Line IP */
#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */

#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */

/*
* NOTE: these two values were defined by LBL libpcap, but with values
* that didn't seem to correspond to the values that were used in BSD/OS;
* neither of them are, as far as I know, used in any kernel, so they
* should not be defined above. We therefore don't bother checking to
* see if they're already defined.
* This value is defined by NetBSD; other platforms should refrain from
* using it for other purposes, so that NetBSD savefiles with a link
* type of 50 can be read as this type on all platforms.
*/
#define DLT_SLIP_BSDOS 102 /* BSD/OS Serial Line IP */
#define DLT_PPP_BSDOS 103 /* BSD/OS Point-to-point Protocol */
#define DLT_PPP_SERIAL 50 /* PPP over serial with HDLC encapsulation */

/*
* This value was defined by libpcap 0.5; we now use it as a DLT_* value
* solely for backwards compatibility - new programs should use
* PCAP_ENCAP_C_HDLC instead.
* This value was defined by libpcap 0.5; platforms that have defined
* it with a different value should define it here with that value -
* a link type of 104 in a save file will be mapped to DLT_C_HDLC,
* whatever value that happens to be, so programs will correctly
* handle files with that link type regardless of the value of
* DLT_C_HDLC.
*
* The name DLT_C_HDLC was used by BSD/OS; we use that name for source
* compatibility with programs written for BSD/OS.
*
* libpcap 0.5 defined it as DLT_CHDLC; we define DLT_CHDLC as well,
* for source compatibility with programs written for libpcap 0.5.
*/
#define DLT_CHDLC 104 /* Cisco HDLC */
#define DLT_C_HDLC 104 /* Cisco HDLC */
#define DLT_CHDLC DLT_C_HDLC

/*
* The instruction encondings.
Expand Down

0 comments on commit 2c961ff

Please sign in to comment.