14 #ifndef _COAP_ADDRESS_H_
15 #define _COAP_ADDRESS_H_
23 #warning "assertions are disabled"
31 #ifdef HAVE_NETINET_IN_H
32 #include <netinet/in.h>
35 #ifdef HAVE_NETINET_IN_H
36 #include <sys/socket.h>
40 #include <lwip/ip_addr.h>
42 typedef struct coap_address_t {
50 #define _coap_address_equals_impl(A, B) ((A)->addr.addr == (B)->addr.addr && A->port == B->port)
54 #define _coap_is_mcast_impl(Address) 0
60 typedef struct coap_address_t {
66 #define _coap_address_equals_impl(A,B) \
67 ((A)->size == (B)->size \
68 && (A)->port == (B)->port \
69 && uip_ipaddr_cmp(&((A)->addr),&((B)->addr)))
71 #define _coap_is_mcast_impl(Address) uip_is_addr_mcast(&((Address)->addr))
76 typedef struct coap_address_t {
80 struct sockaddr_storage st;
81 struct sockaddr_in sin;
82 struct sockaddr_in6 sin6;
87 _coap_address_equals_impl(
const coap_address_t *a,
88 const coap_address_t *b) {
89 if (a->size != b->size || a->addr.sa.sa_family != b->addr.sa.sa_family)
93 switch (a->addr.sa.sa_family) {
96 a->addr.sin.sin_port == b->addr.sin.sin_port &&
97 memcmp(&a->addr.sin.sin_addr, &b->addr.sin.sin_addr,
98 sizeof(
struct in_addr)) == 0;
100 return a->addr.sin6.sin6_port == b->addr.sin6.sin6_port &&
101 memcmp(&a->addr.sin6.sin6_addr, &b->addr.sin6.sin6_addr,
102 sizeof(
struct in6_addr)) == 0;
110 _coap_is_mcast_impl(
const coap_address_t *a) {
114 switch (a->addr.sa.sa_family) {
116 return IN_MULTICAST(a->addr.sin.sin_addr.s_addr);
118 return IN6_IS_ADDR_MULTICAST(&a->addr.sin6.sin6_addr);
136 memset(addr, 0,
sizeof(coap_address_t));
139 addr->size =
sizeof(addr->addr);
150 assert(a); assert(b);
151 return _coap_address_equals_impl(a, b);
160 return a && _coap_is_mcast_impl(a);
static int coap_is_mcast(const coap_address_t *a)
Checks if given address a denotes a multicast address.
static void coap_address_init(coap_address_t *addr)
Resets the given coap_address_t object addr to its default values.
static int coap_address_equals(const coap_address_t *a, const coap_address_t *b)
Compares given address objects a and b.