lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] alignment error of 4 bytes alignment


From: 乔崇
Subject: [lwip-users] alignment error of 4 bytes alignment
Date: Wed, 12 Nov 2003 16:52:50 +0800

Dear Sir:
        I have solve the problem by modifications as bellow.
/////////////////////// in low_level_receive////////////////////////////
        p = pbuf_alloc(PBUF_LINK, packetLength-4, PBUF_POOL);
        if(p != NULL) {
          p->payload = (void*)((int)p->payload -2);
/////////////////////// etharp.c  line 245///////////////////////////////
 if (ipaddr->addr == 0)
change to
  if (MYL(&ipaddr->addr) == 0)
////////////////////// ip_addr.h rewriten /////////////////////////////
#define MYC(p) ((unsigned char *)p)
#define MYs(p) ((unsigned short)((MYC(p)[1]<<8)|MYC(p)[0]))
#define MYS(p) ((unsigned short *)p)
#define MYL(p) ((unsigned int)((MYS(p)[1]<<16)|MYS(p)[0]))

inline void
ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
{
if(src)
{
MYS(dest)[0]=MYS(src)[0];
MYS(dest)[1]=MYS(src)[1];
}
else
{
MYS(dest)[0]=0;
MYS(dest)[1]=0;
}
}

inline int
ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
                struct ip_addr *mask)
{
return ((MYL(addr1)&MYL(mask))==(MYL(addr2)&MYL(mask)));
}

inline int
ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2)
{
  return (MYL(addr1)==MYL(addr2));
}

inline int
ip_addr_isany(struct ip_addr *addr)
{
return ((addr==0) || (MYL(addr)==0));
}

inline int ip_addr_isbroadcast(struct ip_addr *addr,struct ip_addr *mask)
{
return (((MYL(addr) & ~MYL(mask)) == \
           (0xffffffff & ~MYL(mask))) || \
                                         (MYL(addr) == 0xffffffff) || \
                                         (MYL(addr) == 0x00000000));
}
u16_t htons(u16_t n);
u16_t ntohs(u16_t n);
u32_t htonl(u32_t n);
u32_t ntohl(u32_t n);

inline int ip_addr_ismulticast(struct ip_addr *addr)
{
return ((MYL(addr) & ntohl(0xf0000000)) == ntohl(0xe0000000));
}

/*-----------------------------------------------*/


#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%u.%u.%u.%u", \
        ipaddr?(unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 24) & 0xff:0, \
        ipaddr?(unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 16) & 0xff:0, \
        ipaddr?(unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 8) & 0xff:0, \
        ipaddr?(unsigned int)ntohl(MYL(&(ipaddr)->addr)) & 0xff:0U))

/* cast to unsigned int, as it is used as argument to printf functions
 * which expect integer arguments */
#define ip4_addr1(ipaddr) ((unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 24) & 
0xff)
#define ip4_addr2(ipaddr) ((unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 16) & 
0xff)
#define ip4_addr3(ipaddr) ((unsigned int)(ntohl(MYL(&(ipaddr)->addr)) >> 8) & 
0xff)
#define ip4_addr4(ipaddr) ((unsigned int)(ntohl(MYL(&(ipaddr)->addr))) & 0xff)

               qiaochong
address@hidden
          2003-11-12







reply via email to

[Prev in Thread] Current Thread [Next in Thread]