Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes from Iotivity for draft-ietf-core-coap-tcp-tls and cross-platform support #47

Open
wants to merge 49 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1b3818d
Patches from IoTivity
dthaler Jul 27, 2016
c1bda6e
Patches from IoTivity
dthaler Jul 27, 2016
673a575
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 27, 2016
c11591d
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 27, 2016
0e35a2f
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 28, 2016
40a6d09
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 28, 2016
c044245
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 28, 2016
62c0186
More work on merging IoTivity patches
dthaler Jul 28, 2016
fd5c9ec
More work on merging IoTivity patches
dthaler Jul 28, 2016
72c7ce6
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jul 29, 2016
42aedb2
Fix merge bug
dthaler Sep 22, 2016
65e7398
Windows-specific fix
dthaler Sep 22, 2016
e43531b
Port tests to windows
dthaler Sep 22, 2016
749514f
Fix for x86 Windows
dthaler Oct 11, 2016
9feaa9e
Fix release build error
dthaler Oct 14, 2016
9373a4c
Linux compilation fix
dthaler Jan 20, 2017
0012bae
Merge remote-tracking branch 'upstream/develop' into develop
dthaler Jan 20, 2017
fa987b4
Fixes from merging
dthaler Jan 20, 2017
d03c8a0
Addressed feedback from tijuca, don't use negative logic in ifdefs
dthaler Jan 20, 2017
ccc0f01
Fix typo
dthaler Jan 20, 2017
ee5123d
Merge pull request #1 from dthaler/develop
PawelWMS Jan 27, 2017
092d7e2
Fixing C4018 warnings for x86 builds.
PawelWMS Jan 27, 2017
a455214
Merge pull request #2 from PawelWMS/develop
dthaler Jan 27, 2017
bc69a9f
Fix travis issues
dthaler Jan 27, 2017
4d3805f
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jan 27, 2017
2238ebb
Fix more travis issues
dthaler Jan 27, 2017
c38dc95
Fix more travis issues
dthaler Jan 27, 2017
7d34f47
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jan 27, 2017
8c39fe4
Fix more travis issues
dthaler Jan 27, 2017
62c6792
Fix more travis issues
dthaler Jan 27, 2017
39fabf2
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jan 27, 2017
d0ed3e8
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Jan 27, 2017
60a0af0
Merge branch 'develop' of https://github.com/dthaler/libcoap into dev…
dthaler Feb 9, 2017
40a2641
Fix pdu length truncation
danmihai1 Mar 8, 2017
a8b1149
Merge pull request #4 from danmihai1/develop
dthaler Mar 8, 2017
f21c7fb
Merge remote-tracking branch 'upstream/develop' into develop
dthaler Mar 21, 2017
358bd58
Merge remote-tracking branch 'upstream/develop' into develop
dthaler Apr 3, 2017
d54f001
Fixing libcoap W4 warnings.
PawelWMS Mar 7, 2017
9f1d956
Bracket fixes.
PawelWMS Apr 4, 2017
577804c
Merge pull request #5 from PawelWMS/origin_W4_fix
dthaler Apr 5, 2017
2f6ff0c
Added CoAP over WebSocket support.
SenthilKumarGS Apr 28, 2017
f4d20bc
Merge pull request #6 from SenthilKumarGS/develop
dthaler May 30, 2017
5f2d238
Update pdu.c
Koushik4082 May 17, 2018
5dc2fdc
Update pdu.c
Koushik4082 May 17, 2018
7164418
Merge pull request #1 from Koushik4082/Koushik4082-patch-1
Koushik4082 May 17, 2018
bd60461
Update pdu.h
Koushik4082 May 17, 2018
fa8b2b9
Merge pull request #7 from Koushik4082/develop
dthaler Jun 4, 2018
b497109
Fix for where WITH_TCP is defined, WITH_WS is not.
mwichmann Sep 13, 2018
5a16b17
Merge pull request #8 from mwichmann/ws-fix
dthaler Sep 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion coap_config.h.contiki
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

#define HAVE_STRNLEN 1
#define HAVE_SNPRINTF 1
#define HAVE_STRINGS_H 1

/* there is no file-oriented output */
#define COAP_DEBUG_FD NULL
Expand Down Expand Up @@ -120,7 +121,7 @@ typedef void FILE;
# endif /* UIP_CONF_BYTE_ORDER */
#endif /* BYTE_ORDER */

/* Define assert() as emtpy directive unless HAVE_ASSERT_H is given. */
/* Define assert() as empty directive unless HAVE_ASSERT_H is given. */
#ifndef HAVE_ASSERT_H
# define assert(x)
#endif
Expand Down
61 changes: 61 additions & 0 deletions coap_config.h.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef _COAP_CONFIG_H_
#define _COAP_CONFIG_H_

#if defined(_WIN32)

/* Define to 1 if you have <ws2tcpip.h> header file. */
#define HAVE_WS2TCPIP_H 1

/* Define to 1 if you have <winsock2.h> header file. */
#define HAVE_WINSOCK2_H 1

/* Define to 1 if you have <assert.h> header file. */
#define HAVE_ASSERT_H 1

/* Define to 1 if you have <limits.h> header file. */
#define HAVE_LIMITS_H 1

/* Define to 1 if you have <stdio.h> header file. */
#define HAVE_STDIO_H 1

/* Define to 1 if you have <time.h> header file. */
#define HAVE_TIME_H 1

/* Define to 1 if you have malloc(). */
#define HAVE_MALLOC 1

/* Define to 1 if you have vprintf(). */
#define HAVE_VPRINTF 1

/* Define to 1 if you have strnlen(). */
#define HAVE_STRNLEN 1

/* Define to 1 if you have snprintf(). */
#if defined(_MSC_VER) && (_MSC_VER >= 1900)
#define HAVE_SNPRINTF 1
#endif

#define ssize_t SSIZE_T
#define in_port_t uint16_t

#endif

/* Define to the full name of this package. */
#define PACKAGE_NAME "libcoap"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "libcoap 4.1.1"

#ifndef COAP_STATIC_INLINE
# if defined(__cplusplus)
# define COAP_STATIC_INLINE inline
# else
# ifdef _MSC_VER
# define COAP_STATIC_INLINE static __inline
# else
# define COAP_STATIC_INLINE static inline
# endif
# endif
#endif

#endif /* _COAP_CONFIG_H_ */
6 changes: 3 additions & 3 deletions examples/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ coap_tick_t obs_wait = 0; /* timeout for current subscription */
#define UNUSED_PARAM
#endif /* GCC */

static inline void
COAP_STATIC_INLINE void
set_timeout(coap_tick_t *timer, const unsigned int seconds) {
coap_ticks(timer);
*timer += seconds * COAP_TICKS_PER_SECOND;
Expand Down Expand Up @@ -305,7 +305,7 @@ resolve_address(const str *server, struct sockaddr *dst) {
((Pdu)->hdr->code == COAP_RESPONSE_CODE(201) || \
(Pdu)->hdr->code == COAP_RESPONSE_CODE(204)))

static inline int
COAP_STATIC_INLINE int
check_token(coap_pdu_t *received) {
return received->hdr->token_length == the_token.length &&
memcmp(received->hdr->token, the_token.s, the_token.length) == 0;
Expand Down Expand Up @@ -808,7 +808,7 @@ cmdline_proxy(char *arg) {
return 1;
}

static inline void
COAP_STATIC_INLINE void
cmdline_token(char *arg) {
strncpy((char *)the_token.s, arg, min(sizeof(_token_data), strlen(arg)));
the_token.length = strlen(arg);
Expand Down
4 changes: 2 additions & 2 deletions examples/coap-rd.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ rd_t *resources = NULL;
#define UNUSED_PARAM
#endif /* GCC */

static inline rd_t *
COAP_STATIC_INLINE rd_t *
rd_new(void) {
rd_t *rd;
rd = (rd_t *)coap_malloc(sizeof(rd_t));
Expand All @@ -75,7 +75,7 @@ rd_new(void) {
return rd;
}

static inline void
COAP_STATIC_INLINE void
rd_delete(rd_t *rd) {
if (rd) {
coap_free(rd->data.s);
Expand Down
6 changes: 3 additions & 3 deletions examples/etsi_iot_01.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ coap_new_payload(size_t size) {
return p;
}

static inline coap_payload_t *
COAP_STATIC_INLINE coap_payload_t *
coap_find_payload(const coap_key_t key) {
coap_payload_t *p;
HASH_FIND(hh, test_resources, key, sizeof(coap_key_t), p);
return p;
}

static inline void
COAP_STATIC_INLINE void
coap_add_payload(const coap_key_t key, coap_payload_t *payload,
coap_dynamic_uri_t *uri) {
assert(payload);
Expand All @@ -109,7 +109,7 @@ coap_add_payload(const coap_key_t key, coap_payload_t *payload,
}
}

static inline void
COAP_STATIC_INLINE void
coap_delete_payload(coap_payload_t *payload) {
if (payload) {
coap_dynamic_uri_t *uri;
Expand Down
26 changes: 16 additions & 10 deletions include/coap/address.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
#ifndef _COAP_ADDRESS_H_
#define _COAP_ADDRESS_H_

#ifdef HAVE_ASSERT_H
#include <assert.h>
#else
#ifndef assert
# define assert(x)
#endif
#endif
#include <stdint.h>
#include <string.h>

Expand Down Expand Up @@ -52,7 +58,7 @@ typedef struct coap_address_t {
#define _coap_is_mcast_impl(Address) uip_is_addr_mcast(&((Address)->addr))
#endif /* WITH_CONTIKI */

#ifdef WITH_POSIX
#if !defined(WITH_LWIP) && !defined(WITH_CONTIKI)
/** multi-purpose address abstraction */
typedef struct coap_address_t {
socklen_t size; /**< size of addr */
Expand All @@ -71,7 +77,7 @@ typedef struct coap_address_t {
*/
int coap_address_equals(const coap_address_t *a, const coap_address_t *b);

static inline int
COAP_STATIC_INLINE int
_coap_address_isany_impl(const coap_address_t *a) {
/* need to compare only relevant parts of sockaddr_in6 */
switch (a->addr.sa.sa_family) {
Expand All @@ -88,7 +94,7 @@ _coap_address_isany_impl(const coap_address_t *a) {
return 0;
}

static inline int
COAP_STATIC_INLINE int
_coap_is_mcast_impl(const coap_address_t *a) {
if (!a)
return 0;
Expand All @@ -103,7 +109,7 @@ _coap_is_mcast_impl(const coap_address_t *a) {
}
return 0;
}
#endif /* WITH_POSIX */
#endif /* !WITH_LWIP && !WITH_CONTIKI */

/**
* Resets the given coap_address_t object @p addr to its default values. In
Expand All @@ -112,23 +118,23 @@ _coap_is_mcast_impl(const coap_address_t *a) {
*
* @param addr The coap_address_t object to initialize.
*/
static inline void
COAP_STATIC_INLINE void
coap_address_init(coap_address_t *addr) {
assert(addr);
memset(addr, 0, sizeof(coap_address_t));
#ifdef WITH_POSIX
#if defined(WITH_LWIP) || defined(WITH_CONTIKI)
/* lwip and Contiki have constant address sizes and doesn't need the .size part */
addr->size = sizeof(addr->addr);
#endif
}

#ifndef WITH_POSIX
#if defined(WITH_LWIP) || defined(WITH_CONTIKI)
/**
* Compares given address objects @p a and @p b. This function returns @c 1 if
* addresses are equal, @c 0 otherwise. The parameters @p a and @p b must not be
* @c NULL;
*/
static inline int
COAP_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);
Expand All @@ -140,7 +146,7 @@ coap_address_equals(const coap_address_t *a, const coap_address_t *b) {
* function returns @c 1 if this is the case, @c 0 otherwise. The parameters @p
* a must not be @c NULL;
*/
static inline int
COAP_STATIC_INLINE int
coap_address_isany(const coap_address_t *a) {
assert(a);
return _coap_address_isany_impl(a);
Expand All @@ -150,7 +156,7 @@ coap_address_isany(const coap_address_t *a) {
* Checks if given address @p a denotes a multicast address. This function
* returns @c 1 if @p a is multicast, @c 0 otherwise.
*/
static inline int
COAP_STATIC_INLINE int
coap_is_mcast(const coap_address_t *a) {
return a && _coap_is_mcast_impl(a);
}
Expand Down
2 changes: 1 addition & 1 deletion include/coap/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ coap_async_state_t *coap_find_async(coap_context_t *context, coap_tid_t id);
*
* @param s The state object to update.
*/
static inline void
COAP_STATIC_INLINE void
coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); }

/** @} */
Expand Down
6 changes: 3 additions & 3 deletions include/coap/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise.
*/
inline static int
COAP_STATIC_INLINE int
bits_setb(uint8_t *vec, size_t size, uint8_t bit) {
if (size <= (bit >> 3))
return -1;
Expand All @@ -48,7 +48,7 @@ bits_setb(uint8_t *vec, size_t size, uint8_t bit) {
*
* @return @c -1 if @p bit does not fit into @p vec, @c 1 otherwise.
*/
inline static int
COAP_STATIC_INLINE int
bits_clrb(uint8_t *vec, size_t size, uint8_t bit) {
if (size <= (bit >> 3))
return -1;
Expand All @@ -67,7 +67,7 @@ bits_clrb(uint8_t *vec, size_t size, uint8_t bit) {
*
* @return @c 1 if the bit is set, @c 0 otherwise.
*/
inline static int
COAP_STATIC_INLINE int
bits_getb(const uint8_t *vec, size_t size, uint8_t bit) {
if (size <= (bit >> 3))
return -1;
Expand Down
4 changes: 2 additions & 2 deletions include/coap/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ unsigned int coap_opt_block_num(const coap_opt_t *block_opt);
* Checks if more than @p num blocks are required to deliver @p data_len
* bytes of data for a block size of 1 << (@p szx + 4).
*/
static inline int
COAP_STATIC_INLINE int
coap_more_blocks(size_t data_len, unsigned int num, unsigned short szx) {
return ((num+1) << (szx + 4)) < data_len;
}

/** Sets the More-bit in @p block_opt */
static inline void
COAP_STATIC_INLINE void
coap_opt_block_set_m(coap_opt_t *block_opt, int m) {
if (m)
*(COAP_OPT_VALUE(block_opt) + (COAP_OPT_LENGTH(block_opt) - 1)) |= 0x08;
Expand Down
1 change: 1 addition & 0 deletions include/coap/coap.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern "C" {
#include "bits.h"
#include "block.h"
#include "coap_io.h"
#include "coap_list.h"
#include "coap_time.h"
#include "debug.h"
#include "encode.h"
Expand Down
6 changes: 2 additions & 4 deletions include/coap/coap_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ struct coap_context_t;
* tuple (handle, addr) must uniquely identify this endpoint.
*/
typedef struct coap_endpoint_t {
#if defined(WITH_POSIX) || defined(WITH_CONTIKI)
#ifndef WITH_LWIP
union {
int fd; /**< on POSIX systems */
void *conn; /**< opaque connection (e.g. uip_conn in Contiki) */
} handle; /**< opaque handle to identify this endpoint */
#endif /* WITH_POSIX or WITH_CONTIKI */

#ifdef WITH_LWIP
#else
struct udp_pcb *pcb;
/**< @FIXME --chrysn
* this was added in a hurry, not sure it confirms to the overall model */
Expand Down
48 changes: 48 additions & 0 deletions include/coap/coap_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */

/* coap_list.h -- CoAP list structures
*
* Copyright (C) 2010,2011,2015 Olaf Bergmann <[email protected]>
*
* This file is part of the CoAP library libcoap. Please see README for terms of
* use.
*/

#ifndef _COAP_LIST_H_
#define _COAP_LIST_H_

#include "utlist.h"

struct coap_linkedlistnode {
struct coap_linkedlistnode *next;
void *data;

/**
* Callback function that is called from coap_delete to release
* additional memory allocated by data Set to NULL if you do not
* need this. Note that data is free'd automatically. */
void (*delete_func)(void *);
};

typedef struct coap_linkedlistnode coap_list_t;

/**
* Adds node to given queue, ordered by specified order function. Returns 1
* when insert was successful, 0 otherwise.
*/
int coap_insert(coap_list_t **queue, coap_list_t *node, int (*order)(void *, void *));

/* destroys specified node */
int coap_delete(coap_list_t *node);

/* removes all items from given queue and frees the allocated storage */
void coap_delete_list(coap_list_t *queue);

/**
* Creates a new list node and adds the given data object. The memory allocated
* by data will be released by coap_delete() with the new node. Returns the
* new list node.
*/
coap_list_t *coap_new_listnode(void *data, void (*delete_func)(void *));

#endif /* _COAP_LIST_H_ */
Loading