diff options
author | Guy Harris <guy@alum.mit.edu> | 1999-08-24 03:19:34 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 1999-08-24 03:19:34 +0000 |
commit | 678b5fd6ffcb9b6fad1cd9769e393fe580cf28fa (patch) | |
tree | 04bfdca69dd647e2f67813f7bcd4642cfe5ea826 /packet-fddi.c | |
parent | 9fc0d3aefe081a52867b60cea82bb124dbb50cf5 (diff) |
Add a new Wiretap encapsulation type WTAP_ENCAP_FDDI_BITSWAPPED, meaning
"FDDI with the MAC addresses bit-swapped"; whether the MAC addresses are
bit-swapped is a property of the machine on which the capture was taken,
not of the machine on which the capture is being read - right now, none
of the capture file formats we read indicate whether FDDI MAC addresses
are bit-swapped, but this does let us treat non-"libpcap" captures as
being bit-swapped or not bit-swapped independent of the machine on which
they're being read (and of the machine on which they were captured, but
I have the impression they're bit-swapped on most platforms), and allows
us to, if, as, and when we implement packet capture in Wiretap, mark
packets in a capture file written in Wiretap-native format based on the
machine on which they are captured (assuming the rule "Ultrix, Alpha,
and BSD/OS are the only platforms that don't bit-swap", or some other
compile-time rule, gets the right answer, or that some platform has
drivers that can tell us whether the addresses are bit-swapped).
(NOTE: if, for any of the capture file formats used only on one
platform, FDDI MAC addresses aren't bit-swapped, the code to read that
capture file format should be fixed to flag them as not bit-swapped.)
Use the encapsulation type to decide whether to bit-swap addresses in
"dissect_fddi()".
svn path=/trunk/; revision=557
Diffstat (limited to 'packet-fddi.c')
-rw-r--r-- | packet-fddi.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/packet-fddi.c b/packet-fddi.c index 91cef08dd9..73ab41344d 100644 --- a/packet-fddi.c +++ b/packet-fddi.c @@ -3,7 +3,7 @@ * * Laurent Deniel <deniel@worldnet.fr> * - * $Id: packet-fddi.c,v 1.17 1999/08/23 22:13:35 gram Exp $ + * $Id: packet-fddi.c,v 1.18 1999/08/24 03:19:22 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@zing.org> @@ -77,11 +77,6 @@ static int hf_fddi_src = -1; #define FDDI_P_DHOST 1 #define FDDI_P_SHOST 7 -/* On some systems, the FDDI MAC addresses are bit-swapped. */ -#if !defined(ultrix) && !defined(__alpha) && !defined(__bsdi) -#define BIT_SWAPPED_MAC_ADDRS -#endif - /* "swaptab[i]" is the value of "i" with the bits reversed. */ static u_char swaptab[256] = { 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, @@ -118,19 +113,6 @@ static u_char swaptab[256] = { 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; -static void get_mac_addr(u_char *swapped_addr, const u_char *addr) -{ - int i; - - for (i = 0; i < 6; i++) { -#ifdef BIT_SWAPPED_MAC_ADDRS - swapped_addr[i] = swaptab[addr[i]]; -#else - swapped_addr[i] = addr[i]; -#endif - } -} - static void swap_mac_addr(u_char *swapped_addr, const u_char *orig_addr) { @@ -184,7 +166,8 @@ capture_fddi(const u_char *pd, guint32 cap_len, packet_counts *ld) { } /* capture_fddi */ -void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree) +void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree, + gboolean bitswapped) { int offset = 0, fc; proto_tree *fh_tree; @@ -199,8 +182,13 @@ void dissect_fddi(const u_char *pd, frame_data *fd, proto_tree *tree) /* Extract the source and destination addresses, possibly bit-swapping them. */ - get_mac_addr(dst, (u_char *)&pd[FDDI_P_DHOST]); - get_mac_addr(src, (u_char *)&pd[FDDI_P_SHOST]); + if (bitswapped) { + swap_mac_addr(dst, (u_char *)&pd[FDDI_P_DHOST]); + swap_mac_addr(src, (u_char *)&pd[FDDI_P_SHOST]); + } else { + memcpy(dst, (u_char *)&pd[FDDI_P_DHOST], sizeof dst); + memcpy(src, (u_char *)&pd[FDDI_P_SHOST], sizeof src); + } fc = (int) pd[FDDI_P_FC]; |