diff --git a/address.h b/address.h index 9564fcd1..403240e0 100644 --- a/address.h +++ b/address.h @@ -39,12 +39,10 @@ #ifdef WITH_LWIP #include -typedef struct __coap_address_t { +typedef struct coap_address_t { uint16_t port; ip_addr_t addr; -} __coap_address_t; - -#define coap_address_t __coap_address_t +} coap_address_t; /* FIXME oversimplification: just assuming it's an ipv4 address instead of * looking up the appropraite lwip function */ @@ -59,13 +57,11 @@ typedef struct __coap_address_t { #ifdef WITH_CONTIKI #include "uip.h" -typedef struct __coap_address_t { +typedef struct coap_address_t { unsigned char size; uip_ipaddr_t addr; unsigned short port; -} __coap_address_t; - -#define coap_address_t __coap_address_t +} coap_address_t; #define _coap_address_equals_impl(A,B) \ ((A)->size == (B)->size \ @@ -74,10 +70,10 @@ typedef struct __coap_address_t { #define _coap_is_mcast_impl(Address) uip_is_addr_mcast(&((Address)->addr)) #endif /* WITH_CONTIKI */ +#ifdef WITH_POSIX /** multi-purpose address abstraction */ -#ifndef coap_address_t -typedef struct __coap_address_t { +typedef struct coap_address_t { socklen_t size; /**< size of addr */ union { struct sockaddr sa; @@ -85,9 +81,7 @@ typedef struct __coap_address_t { struct sockaddr_in sin; struct sockaddr_in6 sin6; } addr; -} __coap_address_t; - -#define coap_address_t __coap_address_t +} coap_address_t; static inline int _coap_address_equals_impl(const coap_address_t *a, @@ -127,7 +121,7 @@ case AF_INET6: } return 0; } -#endif /* coap_address_t */ +#endif /* WITH_POSIX */ /** * Resets the given coap_address_t object @p addr to its default diff --git a/config.h.lwip b/config.h.lwip index baac7574..073a9e54 100644 --- a/config.h.lwip +++ b/config.h.lwip @@ -17,7 +17,4 @@ /* FIXME just a quick hack */ #define COAP_TICKS_PER_SECOND 10 -/* easy solution for the time being; could also use lwip's pbufs */ -#define HAVE_MALLOC 1 - #endif /* _CONFIG_H_ */ diff --git a/configure.in b/configure.in index ef0e9f54..44a1ad4e 100644 --- a/configure.in +++ b/configure.in @@ -70,6 +70,10 @@ AC_ARG_WITH(shared, [BUILD_SO="BUILD_SO=1"], []) +# disambiguate between autoconf generated setups and contiki / lwip setups +# which use explicit config.h.* files +CPPFLAGS="${CPPFLAGS} -DWITH_POSIX" + # Checks for header files. AC_CHECK_HEADERS([assert.h arpa/inet.h limits.h netdb.h netinet/in.h stdlib.h string.h strings.h sys/socket.h sys/time.h time.h unistd.h sys/unistd.h]) diff --git a/debug.c b/debug.c index dcf771f3..64c1bc3f 100644 --- a/debug.c +++ b/debug.c @@ -137,7 +137,7 @@ print_readable( const unsigned char *data, unsigned int len, #endif size_t -coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t len) { +coap_print_addr(const struct coap_address_t *addr, unsigned char *buf, size_t len) { #ifdef HAVE_ARPA_INET_H const void *addrptr = NULL; in_port_t port; diff --git a/debug.h b/debug.h index e17b0402..98ae8db6 100644 --- a/debug.h +++ b/debug.h @@ -52,8 +52,8 @@ void coap_log_impl(coap_log_t level, const char *format, ...); #include "pdu.h" void coap_show_pdu(const coap_pdu_t *); -struct __coap_address_t; -size_t coap_print_addr(const struct __coap_address_t *, unsigned char *, size_t); +struct coap_address_t; +size_t coap_print_addr(const struct coap_address_t *, unsigned char *, size_t); #else