[En-Nut-Discussion] DHCP option one byte offset (Big Endian)?

Harald Kipp harald.kipp at egnite.de
Tue Jul 29 10:03:22 CEST 2003


Tyou,

Can you or anyone else provide more details, please?

I'm busy with some DHCP updates to make it more conforming
to RFC 2131. I'll try to keep it as portable as possible.

For normal structures there's always something like pragma
pack(1). But for DHCP options it is different. If cp is a
pointer into options, would all of the following work with
the H8?

   u_long ip; /* Network byte order! */
   memcpy(&ip, cp, 4);
or
   ip = *((u_long *)cp);
or
   ip = *cp << 24 + *(cp + 1) << 16 + *(cp + 2) << 8 + *(cp + 3);

I'd prefer the second one.

Harald




More information about the En-Nut-Discussion mailing list