changed IP_IS_V6_VAL() to take an instance, not a pointer (to get the _val() functions the same)

This commit is contained in:
goldsimon 2015-04-23 07:26:29 +02:00
parent 009755ba01
commit 00a46f104a
5 changed files with 13 additions and 13 deletions

View File

@ -322,14 +322,14 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
} }
memset(ai, 0, total_size); memset(ai, 0, total_size);
sa = (struct sockaddr_storage *)(void*)((u8_t*)ai + sizeof(struct addrinfo)); sa = (struct sockaddr_storage *)(void*)((u8_t*)ai + sizeof(struct addrinfo));
if (IP_IS_V6(addr)) { if (IP_IS_V6_VAL(addr)) {
#if LWIP_IPV6 #if LWIP_IPV6
struct sockaddr_in6 *sa6 = (struct sockaddr_in6*)sa; struct sockaddr_in6 *sa6 = (struct sockaddr_in6*)sa;
/* set up sockaddr */ /* set up sockaddr */
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr)); inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
sa->sin_family = AF_INET6; sa6->sin6_family = AF_INET6;
sa->sin_len = sizeof(struct sockaddr_in6); sa6->sin6_len = sizeof(struct sockaddr_in6);
sa->sin_port = htons((u16_t)port_nr); sa6->sin6_port = htons((u16_t)port_nr);
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
} else { } else {
#if LWIP_IPV4 #if LWIP_IPV4

View File

@ -244,7 +244,7 @@ snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific
ip_route_get_local_ip(PCB_ISIPV6(trap_msg.pcb), &trap_msg.pcb->local_ip, ip_route_get_local_ip(PCB_ISIPV6(trap_msg.pcb), &trap_msg.pcb->local_ip,
&td->dip, dst_if, dst_ip, &dst_ip_storage); &td->dip, dst_if, dst_ip, &dst_ip_storage);
if ((dst_if != NULL) && (dst_ip != NULL)) { if ((dst_if != NULL) && (dst_ip != NULL)) {
trap_msg.sip_raw_len = (IP_IS_V6_VAL(dst_ip) ? 16 : 4); trap_msg.sip_raw_len = (IP_IS_V6_VAL(*dst_ip) ? 16 : 4);
memcpy(trap_msg.sip_raw, dst_ip, trap_msg.sip_raw_len); memcpy(trap_msg.sip_raw, dst_ip, trap_msg.sip_raw_len);
trap_msg.gen_trap = generic_trap; trap_msg.gen_trap = generic_trap;
trap_msg.spc_trap = specific_trap; trap_msg.spc_trap = specific_trap;

View File

@ -63,7 +63,7 @@
"The Dynamic and/or Private Ports are those from 49152 through 65535" */ "The Dynamic and/or Private Ports are those from 49152 through 65535" */
#define TCP_LOCAL_PORT_RANGE_START 0xc000 #define TCP_LOCAL_PORT_RANGE_START 0xc000
#define TCP_LOCAL_PORT_RANGE_END 0xffff #define TCP_LOCAL_PORT_RANGE_END 0xffff
#define TCP_ENSURE_LOCAL_PORT_RANGE(port) (((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START) #define TCP_ENSURE_LOCAL_PORT_RANGE(port) ((u16_t)(((port) & ~TCP_LOCAL_PORT_RANGE_START) + TCP_LOCAL_PORT_RANGE_START))
#endif #endif
#if LWIP_TCP_KEEPALIVE #if LWIP_TCP_KEEPALIVE
@ -1845,7 +1845,7 @@ tcp_netif_ipv4_addr_changed_pcblist(const ip4_addr_t* old_addr, struct tcp_pcb*
pcb = pcb_list; pcb = pcb_list;
while (pcb != NULL) { while (pcb != NULL) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (!IP_IS_V6_VAL(&pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), old_addr) if (!IP_IS_V6_VAL(pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), old_addr)
#if LWIP_AUTOIP #if LWIP_AUTOIP
/* connections to link-local addresses must persist (RFC3927 ch. 1.9) */ /* connections to link-local addresses must persist (RFC3927 ch. 1.9) */
&& !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip)) && !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip))
@ -1879,7 +1879,7 @@ void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) { for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) {
next = lpcb->next; next = lpcb->next;
/* Is this an IPv4 pcb? */ /* Is this an IPv4 pcb? */
if (!IP_IS_V6_VAL(&lpcb->local_ip)) { if (!IP_IS_V6_VAL(lpcb->local_ip)) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if ((!(ip4_addr_isany(ip_2_ip4(&lpcb->local_ip)))) && if ((!(ip4_addr_isany(ip_2_ip4(&lpcb->local_ip)))) &&
(ip4_addr_cmp(ip_2_ip4(&lpcb->local_ip), old_addr))) { (ip4_addr_cmp(ip_2_ip4(&lpcb->local_ip), old_addr))) {

View File

@ -61,12 +61,12 @@ typedef struct _ip_addr {
#define IPADDR4_INIT(u32val) { { { u32val, 0ul, 0ul, 0ul } }, IPADDR_TYPE_V4 } #define IPADDR4_INIT(u32val) { { { u32val, 0ul, 0ul, 0ul } }, IPADDR_TYPE_V4 }
#define IPADDR6_INIT(a, b, c, d) { { { a, b, c, d } }, IPADDR_TYPE_V6 } #define IPADDR6_INIT(a, b, c, d) { { { a, b, c, d } }, IPADDR_TYPE_V6 }
#define IP_IS_V6_VAL(ipaddr) ((ipaddr)->type == IPADDR_TYPE_V6) #define IP_IS_V6_VAL(ipaddr) ((ipaddr).type == IPADDR_TYPE_V6)
#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(ipaddr)) #define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(*(ipaddr)))
#define IP_SET_TYPE_L(ipaddr, iptype) do { (ipaddr)->type = (iptype); }while(0) #define IP_SET_TYPE_L(ipaddr, iptype) do { (ipaddr)->type = (iptype); }while(0)
#define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_L(ipaddr, iptype); }}while(0) #define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_L(ipaddr, iptype); }}while(0)
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (PCB_ISIPV6(pcb) == IP_IS_V6_VAL(ipaddr)) #define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (PCB_ISIPV6(pcb) == IP_IS_V6(ipaddr))
/* Convert ipv4/ipv6 address to generic ip address. /* Convert ipv4/ipv6 address to generic ip address.
Since source types do not contain the type field, a target storage need to be supplied. */ Since source types do not contain the type field, a target storage need to be supplied. */
@ -88,7 +88,7 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
#define IP_ADDR6(ipaddr,idx,a,b,c,d) do { IP6_ADDR(ip_2_ip6(ipaddr),idx,a,b,c,d); \ #define IP_ADDR6(ipaddr,idx,a,b,c,d) do { IP6_ADDR(ip_2_ip6(ipaddr),idx,a,b,c,d); \
IP_SET_TYPE_L(ipaddr, IPADDR_TYPE_V6); } while(0) IP_SET_TYPE_L(ipaddr, IPADDR_TYPE_V6); } while(0)
#define ip_addr_copy(dest, src) do{if(IP_IS_V6_VAL(&(src))){ \ #define ip_addr_copy(dest, src) do{if(IP_IS_V6_VAL(src)){ \
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V6); }else{ \ ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V6); }else{ \
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V4); }}while(0) ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V4); }}while(0)
#define ip_addr_copy_from_ip6(dest, src) do{ \ #define ip_addr_copy_from_ip6(dest, src) do{ \

View File

@ -84,7 +84,7 @@ struct nd6_neighbor_cache_entry {
struct nd6_destination_cache_entry { struct nd6_destination_cache_entry {
ip6_addr_t destination_addr; ip6_addr_t destination_addr;
ip6_addr_t next_hop_addr; ip6_addr_t next_hop_addr;
u32_t pmtu; u16_t pmtu;
u32_t age; u32_t age;
}; };