Get rid of the definitions of LITTLE_ENDIAN and BIG_ENDIAN in

"epan/pint.h" - they caused GCC to whine about them being redefined when
I compiled on FreeBSD 3.4.

Get rid of the stuff in "packet-ipv6.h" that defines various bit vectors
differently depending on the byte order of the machine; instead, define
them so that they work with items in host byte order.  This lets us use
a number of them rather than using hardwired hex values.

Put "frag.ip6f_offlg" in host byte order before using it; this means
that IP6F_MORE_FRAG can still be used even though it now works only on
items in host byte order.

svn path=/trunk/; revision=2610
This commit is contained in:
Guy Harris 2000-11-11 10:23:43 +00:00
parent 6647ded001
commit 00e5867b10
4 changed files with 21 additions and 63 deletions

View File

@ -2,7 +2,7 @@
* Definitions for extracting and translating integers safely and portably
* via pointers.
*
* $Id: pint.h,v 1.2 2000/09/28 03:16:16 gram Exp $
* $Id: pint.h,v 1.3 2000/11/11 10:23:43 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -112,15 +112,4 @@
#define htolel(l) (l)
#endif
/* Byte ordering */
#ifndef BYTE_ORDER
# define LITTLE_ENDIAN 4321
# define BIG_ENDIAN 1234
# ifdef WORDS_BIGENDIAN
# define BYTE_ORDER BIG_ENDIAN
# else
# define BYTE_ORDER LITTLE_ENDIAN
# endif
#endif
#endif /* PINT_H */

View File

@ -1,7 +1,7 @@
/* packet-icmpv6.c
* Routines for ICMPv6 packet disassembly
*
* $Id: packet-icmpv6.c,v 1.29 2000/11/09 21:57:35 guy Exp $
* $Id: packet-icmpv6.c,v 1.30 2000/11/11 10:23:41 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -339,14 +339,14 @@ dissect_nodeinfo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0001, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_SUPTYPE_FLAG_COMPRESS, sizeof(flags) * 8,
"Compressed reply supported",
"No compressed reply support"));
} else {
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0001, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_SUPTYPE_FLAG_COMPRESS, sizeof(flags) * 8,
"Compressed", "Not compressed"));
}
break;
@ -355,7 +355,7 @@ dissect_nodeinfo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0001, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_FQDN_FLAG_VALIDTTL, sizeof(flags) * 8,
"Valid TTL field", "Meaningless TTL field"));
}
break;
@ -363,25 +363,25 @@ dissect_nodeinfo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0020, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_GLOBAL, sizeof(flags) * 8,
"Global address",
"Not global address"));
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0010, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_SITELOCAL, sizeof(flags) * 8,
"Site-local address",
"Not site-local address"));
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0008, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_LINKLOCAL, sizeof(flags) * 8,
"Link-local address",
"Not link-local address"));
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0004, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_COMPAT, sizeof(flags) * 8,
"IPv4 compatible/mapped address",
"Not IPv4 compatible/mapped address"));
/* fall through */
@ -389,13 +389,13 @@ dissect_nodeinfo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0002, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_ALL, sizeof(flags) * 8,
"All unicast address",
"Unicast addresses on the queried interface"));
proto_tree_add_text(field_tree, NullTVB,
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
sizeof(ni->ni_flags), "%s",
decode_boolean_bitfield(flags, 0x0001, sizeof(flags) * 8,
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_TRUNCATE, sizeof(flags) * 8,
"Truncated", "Not truncated"));
break;
}
@ -1048,13 +1048,13 @@ dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x80000000, 32, "Router", "Not router"));
ND_NA_FLAG_ROUTER, 32, "Router", "Not router"));
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x40000000, 32, "Solicited", "Not adverted"));
ND_NA_FLAG_SOLICITED, 32, "Solicited", "Not adverted"));
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
decode_boolean_bitfield(na_flags,
0x20000000, 32, "Override", "Not override"));
ND_NA_FLAG_OVERRIDE, 32, "Override", "Not override"));
targetoff = offset + offsetof(struct nd_neighbor_advert, nd_na_target);
na_target_p = (struct e_in6_addr*) &pd[targetoff];

View File

@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
* $Id: packet-ipv6.c,v 1.43 2000/08/13 14:08:06 deniel Exp $
* $Id: packet-ipv6.c,v 1.44 2000/11/11 10:23:41 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -147,7 +147,8 @@ dissect_frag6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
memcpy(&frag, (void *) &pd[offset], sizeof(frag));
len = sizeof(frag);
*fragstart = ntohs(frag.ip6f_offlg) & 0xfff8;
frag.ip6f_offlg = ntohs(frag.ip6f_offlg);
*fragstart = frag.ip6f_offlg & IP6F_OFF_MASK;
if (check_col(fd, COL_INFO)) {
col_add_fstr(fd, COL_INFO,
"IPv6 fragment (nxt=%s (0x%02x) off=%u id=0x%x)",
@ -174,7 +175,7 @@ dissect_frag6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
proto_tree_add_text(rthdr_tree, NullTVB,
offset + offsetof(struct ip6_frag, ip6f_offlg), 2,
"Offset: %u",
ntohs(frag.ip6f_offlg) & 0xfff8);
frag.ip6f_offlg & IP6F_OFF_MASK);
proto_tree_add_text(rthdr_tree, NullTVB,
offset + offsetof(struct ip6_frag, ip6f_offlg), 2,
@ -327,9 +328,9 @@ dissect_ipv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) {
*/
proto_tree_add_uint_format(ipv6_tree, hf_ipv6_flow, NullTVB,
offset + offsetof(struct ip6_hdr, ip6_flow), 4,
(unsigned long)(ntohl(ipv6.ip6_flow & IPV6_FLOWLABEL_MASK)),
(unsigned long)(ntohl(ipv6.ip6_flow) & IPV6_FLOWLABEL_MASK),
"Flowlabel: 0x%05lx",
(unsigned long)(ntohl(ipv6.ip6_flow & IPV6_FLOWLABEL_MASK)));
(unsigned long)(ntohl(ipv6.ip6_flow) & IPV6_FLOWLABEL_MASK));
proto_tree_add_uint(ipv6_tree, hf_ipv6_plen, NullTVB,
offset + offsetof(struct ip6_hdr, ip6_plen), 2,

View File

@ -1,7 +1,7 @@
/* packet-ipv6.h
* Definitions for IPv6 packet disassembly
*
* $Id: packet-ipv6.h,v 1.15 2000/11/09 16:39:59 itojun Exp $
* $Id: packet-ipv6.h,v 1.16 2000/11/11 10:23:41 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@ -94,13 +94,8 @@ struct ip6_hdr {
#define IP6H_SRC 8
#define IP6H_DST 24
#ifdef WORDS_BIGENDIAN
#define IPV6_FLOWINFO_MASK 0x0fffffff /* flow info (28 bits) */
#define IPV6_FLOWLABEL_MASK 0x000fffff /* flow label (20 bits) */
#else
#define IPV6_FLOWINFO_MASK 0xffffff0f /* flow info (28 bits) */
#define IPV6_FLOWLABEL_MASK 0xffff0f00 /* flow label (20 bits) */
#endif
/*
* Extension Headers
@ -174,15 +169,9 @@ struct ip6_frag {
guint32 ip6f_ident; /* identification */
};
#if BYTE_ORDER == BIG_ENDIAN
#define IP6F_OFF_MASK 0xfff8 /* mask out offset from _offlg */
#define IP6F_RESERVED_MASK 0x0006 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0001 /* more-fragments flag */
#else /* BYTE_ORDER == LITTLE_ENDIAN */
#define IP6F_OFF_MASK 0xf8ff /* mask out offset from _offlg */
#define IP6F_RESERVED_MASK 0x0600 /* reserved bits in ip6f_offlg */
#define IP6F_MORE_FRAG 0x0100 /* more-fragments flag */
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
/*
* Definition for ICMPv6.
@ -340,15 +329,9 @@ struct nd_neighbor_advert { /* neighbor advertisement */
#define nd_na_code nd_na_hdr.icmp6_code
#define nd_na_cksum nd_na_hdr.icmp6_cksum
#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
#if BYTE_ORDER == BIG_ENDIAN
#define ND_NA_FLAG_ROUTER 0x80000000
#define ND_NA_FLAG_SOLICITED 0x40000000
#define ND_NA_FLAG_OVERRIDE 0x20000000
#elif BYTE_ORDER == LITTLE_ENDIAN
#define ND_NA_FLAG_ROUTER 0x80
#define ND_NA_FLAG_SOLICITED 0x40
#define ND_NA_FLAG_OVERRIDE 0x20
#endif
struct nd_redirect { /* redirect */
struct icmp6_hdr nd_rd_hdr;
@ -425,15 +408,9 @@ struct icmp6_nodeinfo {
#define NI_QTYPE_NODEADDR 3 /* Node Addresses */
#define NI_QTYPE_IPV4ADDR 4 /* IPv4 Addresses */
#if BYTE_ORDER == BIG_ENDIAN
#define NI_SUPTYPE_FLAG_COMPRESS 0x1
#define NI_FQDN_FLAG_VALIDTTL 0x1
#elif BYTE_ORDER == LITTLE_ENDIAN
#define NI_SUPTYPE_FLAG_COMPRESS 0x0100
#define NI_FQDN_FLAG_VALIDTTL 0x0100
#endif
#if BYTE_ORDER == BIG_ENDIAN
#define NI_NODEADDR_FLAG_TRUNCATE 0x1
#define NI_NODEADDR_FLAG_ALL 0x2
#define NI_NODEADDR_FLAG_COMPAT 0x4
@ -441,15 +418,6 @@ struct icmp6_nodeinfo {
#define NI_NODEADDR_FLAG_SITELOCAL 0x10
#define NI_NODEADDR_FLAG_GLOBAL 0x20
#define NI_NODEADDR_FLAG_ANYCAST 0x40 /* just experimental. not in spec */
#elif BYTE_ORDER == LITTLE_ENDIAN
#define NI_NODEADDR_FLAG_TRUNCATE 0x0100
#define NI_NODEADDR_FLAG_ALL 0x0200
#define NI_NODEADDR_FLAG_COMPAT 0x0400
#define NI_NODEADDR_FLAG_LINKLOCAL 0x0800
#define NI_NODEADDR_FLAG_SITELOCAL 0x1000
#define NI_NODEADDR_FLAG_GLOBAL 0x2000
#define NI_NODEADDR_FLAG_ANYCAST 0x4000 /* just experimental. not in spec */
#endif
struct ni_reply_fqdn {
guint32 ni_fqdn_ttl; /* TTL */