diff options
author | guy <guy> | 2000-10-12 03:53:57 +0000 |
---|---|---|
committer | guy <guy> | 2000-10-12 03:53:57 +0000 |
commit | 2c961ff2248fe951e57e1453bbe2a3e388912a37 (patch) | |
tree | 7396548168bb33608336f4c570f206005f0189f3 /pcap-linux.c | |
parent | f7179f8b0d0e788eb0386b8f79f5e6092adca9a9 (diff) |
Get rid of the PCAP_ENCAP_ values - if an application uses them, that
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.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r-- | pcap-linux.c | 47 |
1 files changed, 14 insertions, 33 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 0559626a..76e5700c 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -26,7 +26,7 @@ */ #ifndef lint static const char rcsid[] = - "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.30 2000-09-20 15:10:29 torsten Exp $ (LBL)"; + "@(#) $Header: /tcpdump/master/libpcap/pcap-linux.c,v 1.31 2000-10-12 03:53:59 guy Exp $ (LBL)"; #endif /* @@ -459,11 +459,9 @@ pcap_setfilter(pcap_t *handle, struct bpf_program *filter) /* * Linux uses the ARP hardware type to identify the type of an - * interface. pcap uses the PCAP_ENCAP_xxx constants for this. This + * interface. pcap uses the DLT_xxx constants for this. This * function maps the ARPHRD_xxx constant to an appropriate - * PCAP_ENCAP__xxx constant. - * FIXME: This function is inappropriately named after the namechange - * DLT -> PCAP_ENCAP. + * DLT_xxx constant. * * Returns -1 if unable to map the type. */ @@ -472,42 +470,25 @@ static int map_arphrd_to_dlt(int arptype) switch (arptype) { case ARPHRD_ETHER: case ARPHRD_METRICOM: - case ARPHRD_LOOPBACK: - return PCAP_ENCAP_ETHERNET; - - case ARPHRD_EETHER: - return PCAP_ENCAP_EXP_ETHERNET; - - case ARPHRD_AX25: - return PCAP_ENCAP_AX25; - - case ARPHRD_PRONET: - return PCAP_ENCAP_PRONET; - - case ARPHRD_CHAOS: - return PCAP_ENCAP_CHAOS; - - case ARPHRD_IEEE802: - return PCAP_ENCAP_TOKEN_RING; - - case ARPHRD_ARCNET: - return PCAP_ENCAP_ARCNET; - - case ARPHRD_FDDI: - return PCAP_ENCAP_FDDI; + case ARPHRD_LOOPBACK: return DLT_EN10MB; + case ARPHRD_EETHER: return DLT_EN3MB; + case ARPHRD_AX25: return DLT_AX25; + case ARPHRD_PRONET: return DLT_PRONET; + case ARPHRD_CHAOS: return DLT_CHAOS; + case ARPHRD_IEEE802: return DLT_IEEE802; + case ARPHRD_ARCNET: return DLT_ARCNET; + case ARPHRD_FDDI: return DLT_FDDI; #ifndef ARPHRD_ATM /* FIXME: How to #include this? */ #define ARPHRD_ATM 19 #endif - case ARPHRD_ATM: - return PCAP_ENCAP_ATM_CLIP; + case ARPHRD_ATM: return DLT_ATM_CLIP; case ARPHRD_PPP: case ARPHRD_CSLIP: case ARPHRD_SLIP6: case ARPHRD_CSLIP6: - case ARPHRD_SLIP: - return PCAP_ENCAP_RAW; + case ARPHRD_SLIP: return DLT_RAW; } return -1; @@ -580,7 +561,7 @@ live_open_new(pcap_t *handle, char *device, int promisc, fprintf(stderr, "Warning: Falling back to cooked socket\n"); - handle->linktype = PCAP_ENCAP_RAW; + handle->linktype = DLT_RAW; } |