From f300bf4d48682920cab1bd43bfdc790b33520896 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Fri, 13 Jan 2012 18:43:25 +0100 Subject: [PATCH] compare coap addresses (currently only uip) --- address.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/address.h b/address.h index d83060f9..7bc7afa8 100644 --- a/address.h +++ b/address.h @@ -41,6 +41,12 @@ typedef struct __coap_address_t { } __coap_address_t; #define coap_address_t __coap_address_t + +#define _coap_address_equals_impl(A,B) \ + ((A)->size == (B)->size \ + && (A)->port == (B)->port \ + && uip_ipaddr_cmp((A),(B))) + #endif /* WITH_CONTIKI */ /** multi-purpose address abstraction */ @@ -56,6 +62,8 @@ typedef struct __coap_address_t { } __coap_address_t; #define coap_address_t __coap_address_t + +/* FIXME: implement _coap_address_equals_impl(a, b);*/ #endif /* coap_address_t */ /** @@ -72,4 +80,10 @@ coap_address_init(coap_address_t *addr) { addr->size = sizeof(addr->addr); } +static inline int +coap_address_equals(const coap_address_t *a, const coap_address_t *b) { + assert(a); assert(b); + return _coap_address_equals_impl(a, b); +} + #endif /* _COAP_ADDRESS_H_ */