Add comment about purpose of struct ip_addr2.

Improve white space formatting, add parens in IP4_ADDR().
This commit is contained in:
curtmcd 2006-05-26 18:52:27 +00:00
parent 7026bbcdd4
commit 076a884651

View File

@ -46,6 +46,10 @@ PACK_STRUCT_END
# include "arch/epstruct.h" # include "arch/epstruct.h"
#endif #endif
/*
* struct ipaddr2 is used in the definition of the ARP packet format in
* order to support compilers that don't have structure packing.
*/
#ifdef PACK_STRUCT_USE_INCLUDES #ifdef PACK_STRUCT_USE_INCLUDES
# include "arch/bpstruct.h" # include "arch/bpstruct.h"
#endif #endif
@ -74,8 +78,8 @@ extern const struct ip_addr ip_addr_broadcast;
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any) #define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast) #define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */ #define INADDR_NONE ((u32_t)0xffffffff) /* 255.255.255.255 */
#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */ #define INADDR_LOOPBACK ((u32_t)0x7f000001) /* 127.0.0.1 */
/* Definitions of the bits in an Internet address integer. /* Definitions of the bits in an Internet address integer.
@ -110,9 +114,11 @@ extern const struct ip_addr ip_addr_broadcast;
#define IN_LOOPBACKNET 127 /* official! */ #define IN_LOOPBACKNET 127 /* official! */
#define IP4_ADDR(ipaddr, a,b,c,d) \
#define IP4_ADDR(ipaddr, a,b,c,d) (ipaddr)->addr = htonl(((u32_t)(a & 0xff) << 24) | ((u32_t)(b & 0xff) << 16) | \ (ipaddr)->addr = htonl(((u32_t)((a) & 0xff) << 24) | \
((u32_t)(c & 0xff) << 8) | (u32_t)(d & 0xff)) ((u32_t)((b) & 0xff) << 16) | \
((u32_t)((c) & 0xff) << 8) | \
(u32_t)((d) & 0xff))
#define ip_addr_set(dest, src) (dest)->addr = \ #define ip_addr_set(dest, src) (dest)->addr = \
((src) == NULL? 0:\ ((src) == NULL? 0:\
@ -137,23 +143,18 @@ u8_t ip_addr_isbroadcast(struct ip_addr *, struct netif *);
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000)) #define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
#define ip_addr_debug_print(debug, ipaddr) \
LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \
ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff : 0, \
ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff : 0, \
ipaddr ? (u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff : 0, \
ipaddr ? (u16_t)ntohl((ipaddr)->addr) & 0xff : 0))
#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%"U16_F".%"U16_F".%"U16_F".%"U16_F, \ /* These are cast to u16_t, with the intent that they are often arguments
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \ * to printf using the U16_F format from cc.h. */
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \
ipaddr?(u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \
ipaddr?(u16_t)ntohl((ipaddr)->addr) & 0xff:0U))
/* cast to unsigned int, as it is used as argument to printf functions
* which expect integer arguments. CSi: use cc.h formatters (conversion chars)! */
#define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff) #define ip4_addr1(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
#define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff) #define ip4_addr2(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
#define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff) #define ip4_addr3(ipaddr) ((u16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
#define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff) #define ip4_addr4(ipaddr) ((u16_t)(ntohl((ipaddr)->addr)) & 0xff)
#endif /* __LWIP_IP_ADDR_H__ */ #endif /* __LWIP_IP_ADDR_H__ */