--- embedaddon/dhcp/common/packet.c 2012/02/21 22:30:18 1.1 +++ embedaddon/dhcp/common/packet.c 2012/10/09 09:06:54 1.1.1.1 @@ -3,7 +3,8 @@ Packet assembly code, originally contributed by Archie Cobbs. */ /* - * Copyright (c) 2004,2005,2007,2009 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC") * Copyright (c) 1996-2003 by Internet Software Consortium * * Permission to use, copy, modify, and distribute this software for any @@ -105,18 +106,25 @@ void assemble_hw_header (interface, buf, bufix, to) unsigned *bufix; struct hardware *to; { -#if defined (HAVE_TR_SUPPORT) - if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802) - assemble_tr_header (interface, buf, bufix, to); - else + switch (interface->hw_address.hbuf[0]) { +#if defined(HAVE_TR_SUPPORT) + case HTYPE_IEEE802: + assemble_tr_header(interface, buf, bufix, to); + break; #endif #if defined (DEC_FDDI) - if (interface -> hw_address.hbuf [0] == HTYPE_FDDI) - assemble_fddi_header (interface, buf, bufix, to); - else + case HTYPE_FDDI: + assemble_fddi_header(interface, buf, bufix, to); + break; #endif - assemble_ethernet_header (interface, buf, bufix, to); - + case HTYPE_INFINIBAND: + log_error("Attempt to assemble hw header for infiniband"); + break; + case HTYPE_ETHER: + default: + assemble_ethernet_header(interface, buf, bufix, to); + break; + } } /* UDP header and IP header assembled together for convenience. */ @@ -184,7 +192,9 @@ void assemble_udp_ip_header (interface, buf, bufix, #ifdef PACKET_DECODING /* Decode a hardware header... */ -/* XXX currently only supports ethernet; doesn't check for other types. */ +/* Support for ethernet, TR and FDDI + * Doesn't support infiniband yet as the supported oses shouldn't get here + */ ssize_t decode_hw_header (interface, buf, bufix, from) struct interface_info *interface; @@ -192,17 +202,22 @@ ssize_t decode_hw_header (interface, buf, bufix, from) unsigned bufix; struct hardware *from; { + switch(interface->hw_address.hbuf[0]) { #if defined (HAVE_TR_SUPPORT) - if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802) - return decode_tr_header (interface, buf, bufix, from); - else + case HTYPE_IEEE802: + return (decode_tr_header(interface, buf, bufix, from)); #endif #if defined (DEC_FDDI) - if (interface -> hw_address.hbuf [0] == HTYPE_FDDI) - return decode_fddi_header (interface, buf, bufix, from); - else + case HTYPE_FDDI: + return (decode_fddi_header(interface, buf, bufix, from)); #endif - return decode_ethernet_header (interface, buf, bufix, from); + case HTYPE_INFINIBAND: + log_error("Attempt to decode hw header for infiniband"); + return (0); + case HTYPE_ETHER: + default: + return (decode_ethernet_header(interface, buf, bufix, from)); + } } /* UDP header and IP header decoded together for convenience. */