Ethereal-dev: Re: [ethereal-dev] Checked in support for MPLS

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Fri, 10 Mar 2000 00:44:27 -0800
> I just checked in support for MultiProtocol Label Switching
> (MPLS). The following stuff has been added:
> 
> 	- MPLS extensions to RSVP

The code in that was fetching some fields by casting pointers into the
packet to "ulong *" and dereferencing the resulting pointer - this is
bad for three reasons:

	"ulong" is not a system-declared data type on all platforms
	(it's not on FreeBSD 3.4, at least, for example);

	casting an arbitrary pointer into a frame to point to something
	longer than 1 byte, and dereferencing it, is dangerous, as
	there's no guarantee that said pointer is properly aligned on
	machines that require alignment (such as SPARC, Alpha, and MIPS,
	and possibly at least some other RISC processors);

	the data in an RSVP packet is presumably big-endian in any case,
	so you should use "pntohl()" to access it, rather than just
	blithely dereferencing it;

so I changed the code in question to use "pntohl()" to extract fields
from an RSVP packet rather than casting pointers to "ulong *" and
dereferencing them.

I shall add a note about this to the "README.developer" file (which
already has a comment noting that C++-style comments should not be used,
for example, as some C compilers reject them).