-
Notifications
You must be signed in to change notification settings - Fork 424
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
base: develop
Are you sure you want to change the base?
Changes from 31 commits
1b3818d
c1bda6e
673a575
c11591d
0e35a2f
40a6d09
c044245
62c0186
fd5c9ec
72c7ce6
42aedb2
65e7398
e43531b
749514f
9feaa9e
9373a4c
0012bae
fa987b4
d03c8a0
ccc0f01
ee5123d
092d7e2
a455214
bc69a9f
4d3805f
2238ebb
c38dc95
7d34f47
8c39fe4
62c6792
39fabf2
d0ed3e8
60a0af0
40a2641
a8b1149
f21c7fb
358bd58
d54f001
9f1d956
577804c
2f6ff0c
f4d20bc
5f2d238
5dc2fdc
7164418
bd60461
fa8b2b9
b497109
5a16b17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#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 version of this package. */ | ||
#define PACKAGE_VERSION "4.1.1" | ||
|
||
/* 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_ */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ AM_CFLAGS = -isystem$(top_builddir)/include/coap -I$(top_srcdir)/include/coap $( | |
# etsi_iot_01 and tiny are missing | ||
bin_PROGRAMS = coap-client coap-server coap-rd | ||
|
||
coap_client_SOURCES = client.c coap_list.c | ||
coap_client_SOURCES = client.c coap_append.c | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Renaming this file would not be necessary when keeping coap_list.{h,c} in the examples folder.) |
||
coap_client_LDADD = $(top_builddir)/.libs/libcoap-$(LIBCOAP_API_VERSION).la | ||
|
||
coap_server_SOURCES = coap-server.c | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,37 @@ | |
|
||
#include <string.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#ifdef HAVE_UNISTD_H | ||
# include <unistd.h> | ||
#else | ||
# include "getopt.h" | ||
#endif | ||
#include <stdio.h> | ||
#include <ctype.h> | ||
#include <sys/select.h> | ||
#ifdef HAVE_SYS_SELECT_H | ||
# include <sys/select.h> | ||
#endif | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
#include <netdb.h> | ||
#ifdef HAVE_SYS_SOCKET_H | ||
# include <sys/socket.h> | ||
#endif | ||
#ifdef HAVE_NETINET_IN_H | ||
# include <netinet/in.h> | ||
#endif | ||
#ifdef HAVE_ARPA_INET_H | ||
# include <arpa/inet.h> | ||
#endif | ||
#ifdef HAVE_NETDB_H | ||
# include <netdb.h> | ||
#endif | ||
#ifndef HAVE_STRCASECMP | ||
/* The POSIX strcasecmp() is not supported, so use the ISO C++ conformant _stricmp instead. */ | ||
# define strcasecmp _stricmp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder where _stricmp() might be defined. In my (draft version) of ISO 14882:2011, there is no such thing. Please enlighten me. |
||
#endif | ||
|
||
#include "coap.h" | ||
#include "coap_append.h" | ||
#include "coap_list.h" | ||
|
||
int flags = 0; | ||
|
@@ -61,15 +80,17 @@ coap_tick_t max_wait; /* global timeout (changed by set_timeou | |
unsigned int obs_seconds = 30; /* default observe time */ | ||
coap_tick_t obs_wait = 0; /* timeout for current subscription */ | ||
|
||
#ifndef min | ||
#define min(a,b) ((a) < (b) ? (a) : (b)) | ||
#endif | ||
|
||
#ifdef __GNUC__ | ||
#define UNUSED_PARAM __attribute__ ((unused)) | ||
#else /* not a GCC */ | ||
#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; | ||
|
@@ -305,7 +326,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; | ||
|
@@ -694,7 +715,7 @@ cmdline_uri(char *arg, int create_uri_opts) { | |
if (proxy.length) { /* create Proxy-Uri from argument */ | ||
size_t len = strlen(arg); | ||
while (len > 270) { | ||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above for notes on these changes. |
||
new_option_node(COAP_OPTION_PROXY_URI, | ||
270, | ||
(unsigned char *)arg)); | ||
|
@@ -703,7 +724,7 @@ cmdline_uri(char *arg, int create_uri_opts) { | |
arg += 270; | ||
} | ||
|
||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(COAP_OPTION_PROXY_URI, | ||
len, | ||
(unsigned char *)arg)); | ||
|
@@ -714,7 +735,7 @@ cmdline_uri(char *arg, int create_uri_opts) { | |
} | ||
|
||
if (uri.port != COAP_DEFAULT_PORT && create_uri_opts) { | ||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(COAP_OPTION_URI_PORT, | ||
coap_encode_var_bytes(portbuf, uri.port), | ||
portbuf)); | ||
|
@@ -725,7 +746,7 @@ cmdline_uri(char *arg, int create_uri_opts) { | |
res = coap_split_path(uri.path.s, uri.path.length, buf, &buflen); | ||
|
||
while (res--) { | ||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(COAP_OPTION_URI_PATH, | ||
COAP_OPT_LENGTH(buf), | ||
COAP_OPT_VALUE(buf))); | ||
|
@@ -740,7 +761,7 @@ cmdline_uri(char *arg, int create_uri_opts) { | |
res = coap_split_query(uri.query.s, uri.query.length, buf, &buflen); | ||
|
||
while (res--) { | ||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(COAP_OPTION_URI_QUERY, | ||
COAP_OPT_LENGTH(buf), | ||
COAP_OPT_VALUE(buf))); | ||
|
@@ -792,14 +813,14 @@ set_blocksize(void) { | |
opt_length = coap_encode_var_bytes(buf, | ||
(block.num << 4 | block.m << 3 | block.szx)); | ||
|
||
coap_insert(&optlist, new_option_node(opt, opt_length, buf)); | ||
coap_append(&optlist, new_option_node(opt, opt_length, buf)); | ||
} | ||
} | ||
|
||
static void | ||
cmdline_subscribe(char *arg) { | ||
obs_seconds = atoi(arg); | ||
coap_insert(&optlist, new_option_node(COAP_OPTION_SUBSCRIPTION, 0, NULL)); | ||
coap_append(&optlist, new_option_node(COAP_OPTION_SUBSCRIPTION, 0, NULL)); | ||
} | ||
|
||
static int | ||
|
@@ -835,7 +856,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); | ||
|
@@ -852,7 +873,7 @@ cmdline_option(char *arg) { | |
if (*arg == ',') | ||
++arg; | ||
|
||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(num, strlen(arg), (unsigned char *)arg)); | ||
} | ||
|
||
|
@@ -1212,7 +1233,7 @@ main(int argc, char **argv) { | |
&& create_uri_opts) { | ||
/* add Uri-Host */ | ||
|
||
coap_insert(&optlist, | ||
coap_append(&optlist, | ||
new_option_node(COAP_OPTION_URI_HOST, | ||
uri.host.length, | ||
uri.host.s)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why you have moved coap_list back into the library. The code has been used only in examples/client.c for some time now and thus should live there (until it is removed entirely).