15 #ifndef COAP_ADDRESS_H_ 16 #define COAP_ADDRESS_H_ 21 #include <sys/types.h> 24 #if defined(WITH_LWIP) 26 #include <lwip/ip_addr.h> 33 #define _coap_address_equals_impl(A, B) \ 34 ((A)->port == (B)->port \ 35 && (!!ip_addr_cmp(&(A)->addr,&(B)->addr))) 37 #define _coap_address_isany_impl(A) ip_addr_isany(&(A)->addr) 39 #define _coap_is_mcast_impl(Address) ip_addr_ismulticast(&(Address)->addr) 41 #elif defined(WITH_CONTIKI) 50 #define _coap_address_equals_impl(A,B) \ 51 ((A)->port == (B)->port \ 52 && uip_ipaddr_cmp(&((A)->addr),&((B)->addr))) 55 #define _coap_address_isany_impl(A) 0 57 #define _coap_is_mcast_impl(Address) uip_is_addr_mcast(&((Address)->addr)) 66 struct sockaddr_in
sin;
81 switch (a->
addr.
sa.sa_family) {
83 return a->
addr.
sin.sin_addr.s_addr == INADDR_ANY;
85 return memcmp(&in6addr_any,
87 sizeof(in6addr_any)) == 0;
109 #if defined(WITH_LWIP) || defined(WITH_CONTIKI) 114 if ( src->
addr.
sa.sa_family == AF_INET6 ) {
119 }
else if ( src->
addr.
sa.sa_family == AF_INET ) {
127 #if defined(WITH_LWIP) || defined(WITH_CONTIKI) 135 assert(a); assert(b);
136 return _coap_address_equals_impl(a, b);
151 #if !defined(WITH_LWIP) && !defined(WITH_CONTIKI) 165 return a && _coap_is_mcast_impl(a);
int coap_address_equals(const coap_address_t *a, const coap_address_t *b)
Compares given address objects a and b.
multi-purpose address abstraction
struct coap_address_t coap_address_t
multi-purpose address abstraction
void coap_address_init(coap_address_t *addr)
Resets the given coap_address_t object addr to its default values.
COAP_STATIC_INLINE int _coap_address_isany_impl(const coap_address_t *a)
#define COAP_STATIC_INLINE
COAP_STATIC_INLINE int coap_address_isany(const coap_address_t *a)
Checks if given address object a denotes the wildcard address.
COAP_STATIC_INLINE void coap_address_copy(coap_address_t *dst, const coap_address_t *src)
union coap_address_t::@0 addr
socklen_t size
size of addr
int coap_is_mcast(const coap_address_t *a)
Checks if given address a denotes a multicast address.