Don't base interpretation of LINKTYPE_ values on DLT_ value definitions.

Instead, explicitly check for particular build platforms.  This means
that the interpretation of the link-layer type values with different
meanings on different platforms won't be dependent on the particular
version of libpcap with which Wireshark happens to be built, and also
means that we don't have to fix pcap-common.c to include pcap.h or
net/bpf.h.

Fix some comments while we're at it.

Bug: 10956
Change-Id: If331d9b92081fb0bdf416620fb2ad8dce57dea6b
Reviewed-on: https://code.wireshark.org/review/7140
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2015-02-15 14:03:12 -08:00
parent ad6d259e1e
commit 1917023fc1
1 changed files with 16 additions and 27 deletions

View File

@ -463,25 +463,11 @@ static const struct {
/*
* 11 is DLT_ATM_RFC1483 on most platforms; the only libpcaps I've
* seen that define anything other than DLT_ATM_RFC1483 as 11 are
* the BSD/OS one, which defines DLT_FR as 11, and libpcap 0.5,
* which define it as 100, mapping the kernel's value to 100, in
* an attempt to hide the different values used on different
* the BSD/OS one, which defines DLT_FR as 11. We handle it as
* Frame Relay on BSD/OS and LLC-encapsulated ATM on all other
* platforms.
*
* If this is a platform where DLT_FR is defined as 11, we
* don't handle 11 at all; otherwise, we handle it as
* DLT_ATM_RFC1483 (this means we'd misinterpret Frame Relay
* captures from BSD/OS if running on platforms other than BSD/OS,
* but
*
* 1) we don't yet support DLT_FR
*
* and
*
* 2) nothing short of a heuristic would let us interpret
* them correctly).
*/
#if defined(DLT_FR) && (DLT_FR == 11)
#if defined(__bsdi__) /* BSD/OS */
{ 11, WTAP_ENCAP_FRELAY },
#else
{ 11, WTAP_ENCAP_ATM_RFC1483 },
@ -499,9 +485,9 @@ static const struct {
* as WTAP_ENCAP_NULL, otherwise, unless DLT_C_HDLC is defined
* as 12, interpret it as WTAP_ENCAP_RAW_IP.
*/
#if defined(DLT_LOOP) && (DLT_LOOP == 12)
#if defined(__OpenBSD__)
{ 12, WTAP_ENCAP_NULL },
#elif defined(DLT_C_HDLC) && (DLT_C_HDLC == 12)
#elif defined(__bsdi__) /* BSD/OS */
/*
* Put entry for Cisco HDLC here.
* XXX - is this just WTAP_ENCAP_CHDLC, i.e. does the frame
@ -532,7 +518,7 @@ static const struct {
* treate 13 as WTAP_ENCAP_ATM_RFC1483, but, on all other
* systems, we can read OpenBSD DLT_ENC captures.
*/
#if defined(DLT_ATM_RFC1483) && (DLT_ATM_RFC1483 == 13)
#if defined(__bsdi__) /* BSD/OS */
{ 13, WTAP_ENCAP_ATM_RFC1483 },
#else
{ 13, WTAP_ENCAP_ENC },
@ -581,21 +567,24 @@ static const struct {
* DLT_I4L_IP with the ISDN4Linux patches for libpcap
* (and on SuSE 6.3).
*/
#if defined(DLT_CIP) && (DLT_CIP == 16)
{ 16, WTAP_ENCAP_LINUX_ATM_CLIP },
#endif
#if defined(DLT_HDLC) && (DLT_HDLC == 16)
#if defined(__NetBSD__)
{ 16, WTAP_ENCAP_CHDLC },
#elif !defined(__bsdi__)
/*
* If you care about the two different Linux interpretations
* of 16, fix it yourself.
*/
{ 16, WTAP_ENCAP_LINUX_ATM_CLIP },
#endif
/*
* 17 is DLT_LANE8023 in SuSE 6.3 libpcap; we don't currently
* handle it.
* It is also used as the PF (Packet Filter) logging format beginning
* with OpenBSD 3.0; we use 17 for PF logs unless DLT_LANE8023 is
* defined with the value 17.
* with OpenBSD 3.0; we use 17 for PF logs on OpenBSD and don't
* use it otherwise.
*/
#if !defined(DLT_LANE8023) || (DLT_LANE8023 != 17)
#if defined(__OpenBSD__)
{ 17, WTAP_ENCAP_OLD_PFLOG },
#endif