Commit Graph

14 Commits

Author SHA1 Message Date
Guy Harris
eeabdc9b78 Prevent GCC from doing some alignment-unsafe optimizations on SPARC.
At least some versions of GCC will, on SPARC, generate code for

	if (bp->bp_htype == 1 && bp->bp_hlen == 6 && bp->bp_op == BOOTPREQUEST) {

where bp is a pointer to a struct bootp, that loads the first 4-byte
word in that structure, masks out the field in that structure that's not
being compared, and compares against a word with the appropriate values
in the other fields.  That won't work, because there's no guarantee that
bp points to a value aligned on a 4-byte boundary.

Declaring "struct bootp" to be packed appears to keep at least GCC 4.2.4
from performing that optimization; we define an "UNALIGNED" tag to apply
to structures to prevent that optimization, and apply that tag to the
structures in bootp.h.  (We'll apply it to other structures as we
discover the need for it.)
2010-08-14 17:31:04 -07:00
hannes
ba4d1ee8bf cosmetic change: stick to the 80 columns per line rule 2008-04-22 09:46:03 +00:00
guy
c708411839 From Francois-Xavier Le Bail: decode DCHP option 249 (Microsoft's
Classless Static Route option) the same way as option 121 (RFC 3442's
Classless Static Route option).
2007-08-21 21:59:11 +00:00
guy
aa976c54cf From Francois-Xavier Le Bail: suport for the DHCP Classless Static Route
option (RFC 3442).

Just modify the "len" variable as we parse an option - no need for a
separate variable representing the amount of data left (I suspect that's
why the wrong variable appears to have been used in the "trailing data
length" message; I'd expect that message to indicate how much *extra*
data there was in the option, not how much *total* data there was in the
option).

Add checks for too-short options in some cases where they were missing.
In the check for the Client FQDN option, skip past what data there is in
the option if it's too short, so it doesn't show up as extra data in the
option.

For the Agent Circuit option, for each suboption:

	check to make sure the suboption length doesn't go past what's
	left in the option;

	don't reject options with an option type or length of 0 (neither
	are forbidden by RFC 3046, and, in fact, RFC 3046 says "a
	sub-option length may be zero");

	use fn_printn() to print the Agent Circuit ID suboption, rather
	than doing the equivalent ourselves with a safeputchar() loop.
2007-07-24 17:28:56 +00:00
guy
90c8108085 From Kevin Steves: in the client FQDN option:
0) fix off by one (4 vs. 3)
	1) print flag bits
	2) print rcode fields if either is non-zero
2007-01-29 20:55:01 +00:00
guy
d87f746286 Move the definitions of "bootp_flag_values[]" and "bootp_op_values[]"
out of "bootp.h" into "print-bootp.c", so we don't get unused copies of
them in files other than "print-bootp.c" that include "bootp.h", and so
we don't get warnings from GCC 3.3 about those unused copies.
2003-07-01 19:16:06 +00:00
hannes
b466dcdfe6 per bill fenners suggestion:
lets print a little more useful information in non-verbose mode like
  - Request/Reply indication
  - hardware adress
2003-04-28 07:43:03 +00:00
guy
fcc82f451d The "__attribute__((packed))" tag on structures causes some files not to
compile with Sun C, as "interface.h" isn't being included before the
structures are being declared.

Furthermore, in the files that Sun C *can* compile, it doesn't cause Sun
C to generate code that's safe with unaligned accesses, as
"__attribute__" is defined as a do-nothing macro with compilers that
don't support it.

Therefore, we get rid of that tag on the structures to which it was
added, and instead use "EXTRACT_16BIT()" and "EXTRACT_32BIT()" to fetch
16-bit and 32-bit big-endian quantities from packets.  We also fix some
other references to multi-byte quantities to get rid of code that tries
to do unaligned loads on platforms that don't support them.

We also throw in a hack that makes those macros use
"__attribute__((packed))" on structures containing only one 16-bit or
32-bit integer to get the compiler to generate unaligned-safe code
rather than doing it by hand.  (GCC on SPARC produces the same code that
doing it by hand does; I don't know if GCC on any other big-endian
strict-alignment processor generates better code for that case.  On
little-endian processors, as "ntohs()" and "ntohl()" might be functions,
that might actually produce worse code.)

Fix some places to use "%u" rather than "%d" to print unsigned
quantities.
2002-12-11 07:13:49 +00:00
itojun
10afb02ac8 put __attribute__((packed)) to packet headers. s/u_short/u_int16_t/ and so
forth while i'm here
2002-11-09 17:19:16 +00:00
fenner
aee1aa6195 Add NDS tags 62 and 63 from RFC 2242. 2001-01-09 07:39:13 +00:00
fenner
e89bfcd207 Update for new RFC's and IANA assignments. Many special-format options
are printed as binary strings.  Any of these that are in common use
 can get their own printers.
2000-12-03 23:42:23 +00:00
itojun
fb75d3cd5a always use u_intXX_t for protocol format declaration. char/short/int may not
come with exact size.  while at it, correct signedness of ip/udp header field.
nuke most of the use of bitfield.
TODO: bitfield in namser.h
2000-10-03 02:54:54 +00:00
mcr
ce751501ab now prints DHCP options 1999-10-17 23:35:46 +00:00
mcr
f555c163f9 Initial revision 1999-10-07 23:47:09 +00:00