]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
struct etharp_hdr: split _hwlen_protolen into two u8_t's to prevent using htons on...
authorgoldsimon <goldsimon>
Sun, 16 May 2010 16:26:12 +0000 (16:26 +0000)
committergoldsimon <goldsimon>
Sun, 16 May 2010 16:26:12 +0000 (16:26 +0000)
src/include/netif/etharp.h
src/netif/etharp.c

index 51d7b6ad6088f514f4383c906914af7ecf66dcc1..a4803ec4dbbd9341b05f049cbf056f1058a6408e 100644 (file)
@@ -115,7 +115,8 @@ PACK_STRUCT_BEGIN
 struct etharp_hdr {
   PACK_STRUCT_FIELD(u16_t hwtype);
   PACK_STRUCT_FIELD(u16_t proto);
-  PACK_STRUCT_FIELD(u16_t _hwlen_protolen);
+  PACK_STRUCT_FIELD(u8_t  hwlen);
+  PACK_STRUCT_FIELD(u8_t  protolen);
   PACK_STRUCT_FIELD(u16_t opcode);
   PACK_STRUCT_FIELD(struct eth_addr shwaddr);
   PACK_STRUCT_FIELD(struct ip_addr2 sipaddr);
index da10abb03cdd614c32cf94ab9b29f40a1010b427..f690ecd90417ef4335b519045d7c99b526669a30 100644 (file)
@@ -83,12 +83,6 @@ const struct eth_addr ethzero = {{0,0,0,0,0,0}};
 
 #define HWTYPE_ETHERNET 1
 
-#define ARPH_HWLEN(hdr) (ntohs((hdr)->_hwlen_protolen) >> 8)
-#define ARPH_PROTOLEN(hdr) (ntohs((hdr)->_hwlen_protolen) & 0xff)
-
-#define ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8))
-#define ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8))
-
 enum etharp_state {
   ETHARP_STATE_EMPTY = 0,
   ETHARP_STATE_PENDING,
@@ -701,12 +695,13 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
 
   /* RFC 826 "Packet Reception": */
   if ((hdr->hwtype != PP_HTONS(HWTYPE_ETHERNET)) ||
-      (hdr->_hwlen_protolen != PP_HTONS((ETHARP_HWADDR_LEN << 8) | sizeof(ip_addr_t))) ||
+      (hdr->hwlen != ETHARP_HWADDR_LEN) ||
+      (hdr->protolen != sizeof(ip_addr_t)) ||
       (hdr->proto != PP_HTONS(ETHTYPE_IP)) ||
       (ethhdr->type != PP_HTONS(ETHTYPE_ARP)))  {
     LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING,
       ("etharp_arp_input: packet dropped, wrong hw type, hwlen, proto, protolen or ethernet type (%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F"/%"U16_F")\n",
-      hdr->hwtype, ARPH_HWLEN(hdr), hdr->proto, ARPH_PROTOLEN(hdr), ethhdr->type));
+      hdr->hwtype, hdr->hwlen, hdr->proto, hdr->protolen, ethhdr->type));
     ETHARP_STATS_INC(etharp.proterr);
     ETHARP_STATS_INC(etharp.drop);
     pbuf_free(p);
@@ -1153,8 +1148,9 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr,
 
   hdr->hwtype = PP_HTONS(HWTYPE_ETHERNET);
   hdr->proto = PP_HTONS(ETHTYPE_IP);
-  /* set hwlen and protolen together */
-  hdr->_hwlen_protolen = PP_HTONS((ETHARP_HWADDR_LEN << 8) | sizeof(ip_addr_t));
+  /* set hwlen and protolen */
+  hdr->hwlen = ETHARP_HWADDR_LEN;
+  hdr->protolen = sizeof(ip_addr_t);
 
   ethhdr->type = PP_HTONS(ETHTYPE_ARP);
   /* send ARP query */