18#if defined(HAVE_STRNLEN) && defined(__GNUC__) && !defined(_GNU_SOURCE)
27#ifdef HAVE_ARPA_INET_H
39# define fprintf(fd, ...) LWIP_PLATFORM_DIAG((__VA_ARGS__))
44# define fprintf(fd, ...) { (void)fd; printf(__VA_ARGS__); }
46# define vfprintf(fd, ...) { (void)fd; printf(__VA_ARGS__); }
48# ifndef LOG_CONF_LEVEL_COAP
49# define LOG_CONF_LEVEL_COAP 2
53 (LOG_CONF_LEVEL_COAP == 1 ?
55 (LOG_CONF_LEVEL_COAP == 2 ?
57 (LOG_CONF_LEVEL_COAP == 3 ?
65#include "flash_utils.h"
78 return PACKAGE_STRING;
83#ifdef LIBCOAP_PACKAGE_BUILD
84 return LIBCOAP_PACKAGE_BUILD;
86 return PACKAGE_STRING;
116 "EMRG",
"ALRT",
"CRIT",
"ERR ",
"WARN",
"NOTE",
"INFO",
"DEBG",
"OSC ",
118 "Emrg",
"Alrt",
"Crit",
"Err ",
"Warn",
"Note",
"Info",
"Debg"
125 snprintf(bad,
sizeof(bad),
"%4d", level);
146 tmp = localtime(&now);
147 lensofar = strftime(s, len,
"%b %d %H:%M:%S", tmp);
148 if (len > lensofar + 4) {
149 lensofar += snprintf(&s[lensofar], len-lensofar,
".%03u",
160 return snprintf(s, len,
"%u.%03u",
171#if !defined(HAVE_STRNLEN) && !defined(__MINGW32__)
183 while (*s++ && n < maxlen)
191 unsigned char *result,
size_t buflen,
int encode_always) {
192 const uint8_t hex[] =
"0123456789ABCDEF";
194 assert(data || len == 0);
201 if (!encode_always && isprint(*data)) {
202 if (cnt+1 < buflen) {
209 if (cnt+4 < buflen) {
212 *result++ = hex[(*data & 0xf0) >> 4];
213 *result++ = hex[*data & 0x0f];
228#define min(a,b) ((a) < (b) ? (a) : (b))
231#ifndef INET6_ADDRSTRLEN
232#define INET6_ADDRSTRLEN 46
240#if (defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )) && !defined(RIOT_VERSION)
247 switch (addr->
addr.
sa.sa_family) {
250 snprintf((
char *)buf, len,
"%s:%d",
257 snprintf((
char *)buf, len,
"[%s]:%d",
262#if COAP_AF_UNIX_SUPPORT
269 memcpy(buf,
"(unknown address type)",
min(22+1, len));
273 return strlen((
char *)buf);
277# if defined(RIOT_VERSION)
284 switch (addr->riot.family) {
287 snprintf((
char *)buf, len,
"%s:%d",
294 snprintf((
char *)buf, len,
"[%s]:%d",
301 memcpy(buf,
"(unknown address type)",
min(22+1, len));
305 return strlen((
char *)buf);
312 snprintf((
char *)buf, len,
"[%s]:%d",
315 return strlen((
char *)buf);
317 unsigned char *p = buf;
318# if NETSTACK_CONF_WITH_IPV6
323 if (len < 40 + 2 + 6)
331# warning "IPv4 network addresses will not be included in debug output"
347 return strlen((
char *)buf);
355 snprintf((
char *)buf, len,
"[%s]:%d",
358 return strlen((
char *)buf);
360 unsigned char *p = buf;
366 switch (IP_GET_TYPE(addr->
addr)) {
368 if (len < IP4ADDR_STRLEN_MAX + 6)
371 p += strlen((
char *)buf);
375 case IPADDR_TYPE_ANY:
376 if (len < 40 + 2 + 6)
380 p += strlen((
char *)buf);
387 *p++ =
'0' + (addr->port / 10000) % 10;
388 *p++ =
'0' + (addr->port / 1000) % 10;
389 *p++ =
'0' + (addr->port / 100) % 10;
390 *p++ =
'0' + (addr->port / 10) % 10;
391 *p++ =
'0' + addr->port % 10;
394 return strlen((
char *)buf);
403# warning "inet_ntop() not available, network addresses will not be included in debug output"
416#if (defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )) && !defined(RIOT_VERSION)
417 const void *addrptr = NULL;
423 switch (addr->
addr.
sa.sa_family) {
426 if (len < INET_ADDRSTRLEN)
428 addrptr = &addr->
addr.
sin.sin_addr;
435 addrptr = &addr->
addr.
sin6.sin6_addr;
438#if COAP_AF_UNIX_SUPPORT
445 memcpy(buf,
"(unknown address type)",
min(22+1, len));
451 if (inet_ntop(addr->
addr.
sa.sa_family, addrptr, (
char *)buf, len) == 0) {
460# if defined(RIOT_VERSION)
465 switch (addr->riot.family) {
468 if (ipv4_addr_to_str(buf, (ipv4_addr_t *)&addr->riot.
addr.ipv4, (
size_t)len) == NULL) {
475 if (ipv6_addr_to_str(buf, (ipv6_addr_t *)&addr->riot.
addr.ipv6, (
size_t)len) == NULL) {
493# if NETSTACK_CONF_WITH_IPV6
494 const char hex[] =
"0123456789ABCDEF";
502 for (i=0; i < 16; i += 2) {
506 *p++ = hex[(addr->
addr.u8[i] & 0xf0) >> 4];
507 *p++ = hex[(addr->
addr.u8[i] & 0x0f)];
508 *p++ = hex[(addr->
addr.u8[i+1] & 0xf0) >> 4];
509 *p++ = hex[(addr->
addr.u8[i+1] & 0x0f)];
513# warning "IPv4 network addresses will not be included in debug output"
527 switch (IP_GET_TYPE(&addr->
addr)) {
530 if (len < IP4ADDR_STRLEN_MAX)
532 memcpy(buf, ip4addr_ntoa(ip_2_ip4(&addr->
addr)), IP4ADDR_STRLEN_MAX);
537 case IPADDR_TYPE_ANY:
541 memcpy(buf, ip6addr_ntoa(&addr->
addr.u_addr.ip6), 40);
543 memcpy(buf, ip6addr_ntoa(&addr->
addr), 40);
556# warning "inet_ntop() not available, network addresses will not be included in debug output"
566 static const char *types[] = {
"CON",
"NON",
"ACK",
"RST",
"???" };
568 return types[
min(t,
sizeof(types)/
sizeof(
char *) - 1)];
574 static const char *methods[] = {
"0.00",
"GET",
"POST",
"PUT",
"DELETE",
575 "FETCH",
"PATCH",
"iPATCH"
577 static const char *signals[] = {
"7.00",
"CSM",
"Ping",
"Pong",
"Release",
582 if (c <
sizeof(methods)/
sizeof(
const char *)) {
584 }
else if (c >= 224 && c - 224 < (
int)(
sizeof(signals)/
sizeof(
const char *))) {
585 return signals[c-224];
587 snprintf(buf,
sizeof(buf),
"%u.%02u", (c >> 5) & 0x7, c & 0x1f);
595 struct option_desc_t {
600 static struct option_desc_t options[] = {
629 static struct option_desc_t options_csm[] = {
635 static struct option_desc_t options_pingpong[] = {
639 static struct option_desc_t options_release[] = {
644 static struct option_desc_t options_abort[] = {
652 for (i = 0; i <
sizeof(options_csm)/
sizeof(
struct option_desc_t); i++) {
653 if (option_type == options_csm[i].type) {
654 return options_csm[i].name;
658 for (i = 0; i <
sizeof(options_pingpong)/
sizeof(
struct option_desc_t); i++) {
659 if (option_type == options_pingpong[i].type) {
660 return options_pingpong[i].name;
664 for (i = 0; i <
sizeof(options_release)/
sizeof(
struct option_desc_t); i++) {
665 if (option_type == options_release[i].type) {
666 return options_release[i].name;
670 for (i = 0; i <
sizeof(options_abort)/
sizeof(
struct option_desc_t); i++) {
671 if (option_type == options_abort[i].type) {
672 return options_abort[i].name;
677 for (i = 0; i <
sizeof(options)/
sizeof(
struct option_desc_t); i++) {
678 if (option_type == options[i].type) {
679 return options[i].name;
684 snprintf(buf,
sizeof(buf),
"%u", option_type);
690 unsigned char *result,
unsigned int buflen) {
696 static struct desc_t formats[] = {
727 { 75,
"application/dcaf+cbor" }
733 for (i = 0; i <
sizeof(formats)/
sizeof(
struct desc_t); i++) {
734 if (format_type == formats[i].type) {
735 return snprintf((
char *)result, buflen,
"%s", formats[i].name);
740 return snprintf((
char *)result, buflen,
"%d", format_type);
750 return !(content_format == -1 ||
757#define COAP_DO_SHOW_OUTPUT_LINE \
759 if (use_fprintf_for_show_pdu) { \
760 fprintf(COAP_DEBUG_FD, "%s", outbuf); \
763 coap_log(level, "%s", outbuf); \
779#if COAP_DEBUG_BUF_SIZE < 5
780#error "COAP_DEBUG_BUF_SIZE must be at least 5, should be >= 32 to be useful"
785#if COAP_CONSTRAINED_STACK
788 static unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
789 static char outbuf[COAP_DEBUG_BUF_SIZE];
792 unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
793 char outbuf[COAP_DEBUG_BUF_SIZE];
796 int encode = 0, have_options = 0;
800 int content_format = -1;
804 const uint8_t *opt_val;
805 size_t outbuflen = 0;
806 int is_oscore_payload = 0;
813 snprintf(outbuf,
sizeof(outbuf),
"v:%d t:%s c:%s i:%04x {",
820 snprintf(outbuf,
sizeof(outbuf),
"v:WebSocket c:%s {",
825 snprintf(outbuf,
sizeof(outbuf),
"v:Reliable c:%s {",
830 outbuflen = strlen(outbuf);
831 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
834 outbuflen = strlen(outbuf);
835 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"}");
840 outbuflen = strlen(outbuf);
841 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" [");
847 outbuflen = strlen(outbuf);
848 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
",");
852 switch (opt_iter.
number) {
855 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
867 switch (opt_iter.
number) {
871 buf,
sizeof(buf), 0);
874 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
883 switch (opt_iter.
number) {
885 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
894 switch (opt_iter.
number) {
911 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT(%zu)",
916 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT",
920 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/%u",
936 if (opt_val[0] & 0x20) {
938 snprintf((
char *)buf,
sizeof(buf),
"grp");
940 if (opt_val[0] & 0x07) {
942 cnt = opt_val[0] & 0x07;
943 if (cnt > opt_len - ofs)
945 buf_len = strlen((
char *)buf);
946 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%spIV=0x",
948 for (i = 0; (uint32_t)i < cnt; i++) {
949 buf_len = strlen((
char *)buf);
950 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
951 "%02x", opt_val[ofs + i]);
955 if (opt_val[0] & 0x10) {
960 if (cnt > opt_len - ofs - 1)
963 buf_len = strlen((
char *)buf);
964 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skc=0x",
966 for (i = 0; (uint32_t)i < cnt; i++) {
967 buf_len = strlen((
char *)buf);
968 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
969 "%02x", opt_val[ofs + i]);
973 if (opt_val[0] & 0x08) {
978 buf_len = strlen((
char *)buf);
979 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skid=0x",
981 for (i = 0; (uint32_t)i < cnt; i++) {
982 buf_len = strlen((
char *)buf);
983 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
984 "%02x", opt_val[ofs + i]);
989 buf_len = strlen((
char *)buf);
990 is_oscore_payload = 1;
1001 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
1014 snprintf((
char *)buf,
sizeof(buf),
"0x");
1015 for (i = 0; (uint32_t)i < opt_len; i++) {
1016 buf_len = strlen((
char *)buf);
1017 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
1018 "%02x", opt_val[i]);
1020 buf_len = strlen((
char *)buf);
1037 buf,
sizeof(buf), encode);
1040 outbuflen = strlen(outbuf);
1041 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1046 outbuflen = strlen(outbuf);
1047 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" ]");
1052 outbuflen = strlen(outbuf);
1053 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" :: ");
1054 outbuflen = strlen(outbuf);
1055 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1056 "data length %zu (data suppressed)\n", data_len);
1061 outbuflen = strlen(outbuf);
1062 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" :: ");
1064 if (
is_binary(content_format) || !isprint(data[0]) || is_oscore_payload) {
1065 size_t keep_data_len = data_len;
1066 const uint8_t *keep_data = data;
1068 outbuflen = strlen(outbuf);
1069 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1070 "binary data length %zu\n", data_len);
1076 snprintf(outbuf,
sizeof(outbuf),
"<<");
1077 while (data_len--) {
1078 outbuflen = strlen(outbuf);
1079 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1082 outbuflen = strlen(outbuf);
1083 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
1084 data_len = keep_data_len;
1086 outbuflen = strlen(outbuf);
1087 if (outbuflen ==
sizeof(outbuf)-1)
1089 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1096 snprintf(outbuf,
sizeof(outbuf),
"<<");
1097 while (data_len--) {
1098 outbuflen = strlen(outbuf);
1099 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1100 "%c ", isprint(*data) ? *data :
'.');
1103 outbuflen = strlen(outbuf);
1104 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
1108 outbuflen = strlen(outbuf);
1109 max_length =
sizeof(outbuf)-outbuflen;
1110 if (max_length > 1) {
1111 outbuf[outbuflen++] =
'\'';
1112 outbuf[outbuflen] =
'\000';
1115 if (max_length > 1) {
1117 (
unsigned char *)&outbuf[outbuflen],
1121 if (outbuflen <
sizeof(outbuf)-4-1) {
1122 outbuf[outbuflen++] =
'\'';
1123 outbuf[outbuflen] =
'\000';
1128 outbuflen = strlen(outbuf);
1129 if (outbuflen ==
sizeof(outbuf)-1)
1131 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1150 switch (tls_version->
type) {
1152 snprintf(buffer, bufsize,
"TLS Library: None");
1155 snprintf(buffer, bufsize,
"TLS Library: TinyDTLS - runtime %lu.%lu.%lu, "
1156 "libcoap built for %lu.%lu.%lu",
1157 (
unsigned long)(tls_version->
version >> 16),
1158 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1159 (
unsigned long)(tls_version->
version & 0xff),
1165 switch (tls_version->
version &0xf) {
1167 strcpy(beta,
"-dev");
1173 strcpy(beta,
"-beta");
1174 beta[5] = (tls_version->
version &0xf) +
'0';
1178 sub[0] = ((tls_version->
version >> 4) & 0xff) ?
1179 ((tls_version->
version >> 4) & 0xff) +
'a' -1 :
'\000';
1183 strcpy(b_beta,
"-dev");
1189 strcpy(b_beta,
"-beta");
1195 ((tls_version->
built_version >> 4) & 0xff) +
'a' -1 :
'\000';
1197 snprintf(buffer, bufsize,
"TLS Library: OpenSSL - runtime "
1198 "%lu.%lu.%lu%s%s, libcoap built for %lu.%lu.%lu%s%s",
1199 (
unsigned long)(tls_version->
version >> 28),
1200 (
unsigned long)((tls_version->
version >> 20) & 0xff),
1201 (
unsigned long)((tls_version->
version >> 12) & 0xff), sub, beta,
1208 snprintf(buffer, bufsize,
"TLS Library: GnuTLS - runtime %lu.%lu.%lu, "
1209 "libcoap built for %lu.%lu.%lu",
1210 (
unsigned long)(tls_version->
version >> 16),
1211 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1212 (
unsigned long)(tls_version->
version & 0xff),
1218 snprintf(buffer, bufsize,
"TLS Library: Mbed TLS - runtime %lu.%lu.%lu, "
1219 "libcoap built for %lu.%lu.%lu",
1220 (
unsigned long)(tls_version->
version >> 24),
1221 (
unsigned long)((tls_version->
version >> 16) & 0xff),
1222 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1228 snprintf(buffer, bufsize,
"TLS Library: wolfSSL - runtime %lu.%lu.%lu, "
1229 "libcoap built for %lu.%lu.%lu",
1230 (
unsigned long)(tls_version->
version >> 24),
1231 (
unsigned long)((tls_version->
version >> 12) & 0xfff),
1232 (
unsigned long)((tls_version->
version >> 0) & 0xfff),
1234 (
unsigned long)((tls_version->
built_version >> 12) & 0xfff),
1235 (
unsigned long)((tls_version->
built_version >> 0) & 0xfff));
1238 snprintf(buffer, bufsize,
"Library type %d unknown", tls_version->
type);
1256 if (have_dtls == 0 && have_tls == 0) {
1257 snprintf(buffer, bufsize,
"(No DTLS or TLS support)");
1260 snprintf(buffer, bufsize,
1261 "(%sDTLS and %sTLS support; %sPSK, %sPKI, %sPKCS11, %sRPK and %sCID support)\n(%sOSCORE)\n(%sWebSockets)",
1262 have_dtls ?
"" :
"No ",
1263 have_tls ?
"" :
"no ",
1264 have_psk ?
"" :
"no ",
1265 have_pki ?
"" :
"no ",
1266 have_pkcs11 ?
"" :
"no ",
1267 have_rpk ?
"" :
"no ",
1268 have_cid ?
"" :
"no ",
1269 have_oscore ?
"Have " :
"No ",
1270 have_ws ?
"Have " :
"No ");
1285#if COAP_CONSTRAINED_STACK
1287 static char message[COAP_DEBUG_BUF_SIZE];
1289 char message[COAP_DEBUG_BUF_SIZE];
1292 va_start(ap, format);
1295 flash_vsnprintf(message,
sizeof(message), format, ap);
1297 vsnprintf(message,
sizeof(message), format, ap);
1313 fprintf(log_fd,
"%.*s ", (
int)len, timebuf);
1317 va_start(ap, format);
1319 flash_vfprintf(log_fd, format, ap);
1321 vfprintf(log_fd, format, ap);
1338 const char *p = loss_level;
1340 int n = (int)strtol(p, &end, 10), i = 0;
1341 if (end == p || n < 0)
1355 n = (int)strtol(p, &end, 10);
1356 if (end == p || n <= 0)
1365 n = (int)strtol(p, &end, 10);
1366 if (end == p || n <= 0)
uint16_t coap_address_get_port(const coap_address_t *addr)
Returns the port from addr in host byte order.
static uint16_t packet_loss_level
static struct packet_num_interval packet_loss_intervals[10]
static int send_packet_count
int coap_debug_set_packet_loss(const char *loss_level)
Set the packet loss level for testing.
static coap_log_handler_t log_handler
COAP_STATIC_INLINE int is_binary(int content_format)
Returns 1 if the given content_format is either unknown or known to carry binary data.
static int enable_data_for_show_pdu
static const char * msg_code_string(uint16_t c)
Returns a textual description of the method or response code.
#define COAP_DO_SHOW_OUTPUT_LINE
static size_t print_readable(const uint8_t *data, size_t len, unsigned char *result, size_t buflen, int encode_always)
static const char * msg_option_string(uint8_t code, uint16_t option_type)
Returns a textual description of the option name.
static size_t strnlen(const char *s, size_t maxlen)
A length-safe strlen() fake.
static const char * loglevels[]
COAP_STATIC_INLINE size_t print_timestamp(char *s, size_t len, coap_tick_t t)
static const char * msg_type_string(uint16_t t)
Returns a textual description of the message type t.
static int use_fprintf_for_show_pdu
static int num_packet_loss_intervals
int coap_debug_send_packet(void)
Check to see whether a packet should be sent or not.
void coap_debug_reset(void)
Reset all the defined logging parameters.
static unsigned int print_content_format(unsigned int format_type, unsigned char *result, unsigned int buflen)
Library specific build wrapper for coap_internal.h.
uint8_t coap_opt_t
Use byte-oriented access methods here because sliding a complex struct coap_opt_t over the data buffe...
#define COAP_OPT_BLOCK_SZX(opt)
Returns the value of the SZX-field of a Block option opt.
#define COAP_OPT_BLOCK_MORE(opt)
Returns the value of the More-bit of a Block option opt.
unsigned int coap_opt_block_num(const coap_opt_t *block_opt)
Returns the value of field num in the given block option block_opt.
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
coap_time_t coap_ticks_to_rt(coap_tick_t t)
Helper function that converts coap ticks to wallclock time.
uint64_t coap_ticks_to_rt_us(coap_tick_t t)
Helper function that converts coap ticks to POSIX wallclock time in us.
int coap_prng_lkd(void *buf, size_t len)
Fills buf with len random bytes using the default pseudo random number generator.
void coap_ticks(coap_tick_t *)
Returns the current value of an internal tick counter.
coap_tls_version_t * coap_get_tls_library_version(void)
Determine the type and version of the underlying (D)TLS library.
@ COAP_TLS_LIBRARY_WOLFSSL
Using wolfSSL library.
@ COAP_TLS_LIBRARY_GNUTLS
Using GnuTLS library.
@ COAP_TLS_LIBRARY_TINYDTLS
Using TinyDTLS library.
@ COAP_TLS_LIBRARY_NOTLS
No DTLS library.
@ COAP_TLS_LIBRARY_OPENSSL
Using OpenSSL library.
@ COAP_TLS_LIBRARY_MBEDTLS
Using Mbed TLS library.
unsigned int coap_decode_var_bytes(const uint8_t *buf, size_t len)
Decodes multiple-length byte sequences.
void coap_set_log_handler(coap_log_handler_t handler)
Add a custom log callback handler.
const char * coap_log_level_desc(coap_log_t level)
Get the current logging description.
#define coap_log_debug(...)
coap_log_t coap_get_log_level(void)
Get the current logging level.
char * coap_string_tls_version(char *buffer, size_t bufsize)
Build a string containing the current (D)TLS library linked with and built for version.
#define coap_log_alert(...)
void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu)
Display the contents of the specified pdu.
void coap_enable_pdu_data_output(int enable_data)
Defines whether the data is to be output or not for the coap_show_pdu() function.
char * coap_string_tls_support(char *buffer, size_t bufsize)
Build a string containing the current (D)TLS library support.
#define COAP_MAX_LOGGING_LEVEL
#define COAP_ERR_FD
Used for output for COAP_LOG_CRIT to COAP_LOG_EMERG.
const char * coap_package_version(void)
Get the library package version.
void coap_set_log_level(coap_log_t level)
Sets the log level to the specified value.
void coap_log_impl(coap_log_t level, const char *format,...)
Writes the given text to COAP_ERR_FD (for level <= COAP_LOG_CRIT) or COAP_DEBUG_FD (for level >= COAP...
size_t coap_print_addr(const coap_address_t *addr, unsigned char *buf, size_t len)
Print the address into the defined buffer.
#define COAP_DEBUG_FD
Used for output for COAP_LOG_OSCORE to COAP_LOG_ERR.
const char * coap_package_build(void)
Get the library package build.
const char * coap_print_ip_addr(const coap_address_t *addr, char *buf, size_t len)
Print the IP address into the defined buffer.
void coap_show_tls_version(coap_log_t level)
Display the current (D)TLS library linked with and built for version.
void coap_set_show_pdu_output(int use_fprintf)
Defines the output mode for the coap_show_pdu() function.
#define coap_log_err(...)
const char * coap_package_name(void)
Get the library package name.
void(* coap_log_handler_t)(coap_log_t level, const char *message)
Logging callback handler definition.
#define coap_log(level,...)
Logging function.
coap_opt_t * coap_option_next(coap_opt_iterator_t *oi)
Updates the iterator oi to point to the next option.
uint32_t coap_opt_length(const coap_opt_t *opt)
Returns the length of the given option.
coap_opt_iterator_t * coap_option_iterator_init(const coap_pdu_t *pdu, coap_opt_iterator_t *oi, const coap_opt_filter_t *filter)
Initializes the given option iterator oi to point to the beginning of the pdu's option list.
#define COAP_OPT_ALL
Pre-defined filter that includes all options.
const uint8_t * coap_opt_value(const coap_opt_t *opt)
Returns a pointer to the value of the given option.
#define COAP_DEFAULT_VERSION
#define COAP_OPTION_HOP_LIMIT
#define COAP_OPTION_NORESPONSE
#define COAP_OPTION_URI_HOST
#define COAP_OPTION_IF_MATCH
#define COAP_MEDIATYPE_APPLICATION_COSE_MAC
#define COAP_MEDIATYPE_APPLICATION_SENSML_EXI
#define COAP_MEDIATYPE_APPLICATION_CWT
#define COAP_OPTION_BLOCK2
#define COAP_MEDIATYPE_APPLICATION_MB_CBOR_SEQ
#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT
#define COAP_MEDIATYPE_APPLICATION_RDF_XML
#define COAP_OPTION_CONTENT_FORMAT
#define COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS
#define COAP_OPTION_SIZE2
#define COAP_MEDIATYPE_APPLICATION_SENSML_XML
#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN
#define COAP_OPTION_BLOCK1
#define COAP_OPTION_Q_BLOCK1
#define COAP_OPTION_PROXY_SCHEME
#define COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET
#define COAP_MEDIATYPE_APPLICATION_OSCORE
#define COAP_MEDIATYPE_APPLICATION_SENML_CBOR
#define COAP_OPTION_URI_QUERY
#define COAP_MEDIATYPE_APPLICATION_COSE_KEY
#define COAP_MEDIATYPE_APPLICATION_COSE_SIGN1
#define COAP_OPTION_IF_NONE_MATCH
#define COAP_MEDIATYPE_APPLICATION_OCTET_STREAM
#define COAP_OPTION_LOCATION_PATH
#define COAP_OPTION_URI_PATH
#define COAP_SIGNALING_OPTION_EXTENDED_TOKEN_LENGTH
#define COAP_MEDIATYPE_APPLICATION_SENML_EXI
#define COAP_OPTION_OSCORE
#define COAP_MEDIATYPE_APPLICATION_CBOR
#define COAP_OPTION_SIZE1
#define COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0
#define COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER
#define COAP_MEDIATYPE_TEXT_PLAIN
#define COAP_MEDIATYPE_APPLICATION_JSON
#define COAP_OPTION_LOCATION_QUERY
#define COAP_MEDIATYPE_APPLICATION_COSE_MAC0
#define COAP_MEDIATYPE_APPLICATION_ACE_CBOR
#define COAP_OPTION_Q_BLOCK2
#define COAP_MEDIATYPE_APPLICATION_SENML_JSON
#define COAP_MEDIATYPE_APPLICATION_EXI
#define COAP_SIGNALING_OPTION_CUSTODY
int coap_get_data(const coap_pdu_t *pdu, size_t *len, const uint8_t **data)
Retrieves the length and data pointer of specified PDU.
#define COAP_MEDIATYPE_APPLICATION_COAP_GROUP_JSON
#define COAP_OPTION_URI_PORT
#define COAP_MEDIATYPE_APPLICATION_SENML_XML
#define COAP_OPTION_ACCEPT
#define COAP_MEDIATYPE_APPLICATION_DOTS_CBOR
#define COAP_OPTION_MAXAGE
#define COAP_MEDIATYPE_APPLICATION_SENSML_JSON
#define COAP_OPTION_PROXY_URI
#define COAP_OPTION_OBSERVE
#define COAP_SIGNALING_OPTION_HOLD_OFF
#define COAP_MEDIATYPE_APPLICATION_LINK_FORMAT
#define COAP_SIGNALING_OPTION_BAD_CSM_OPTION
#define COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE
#define COAP_MEDIATYPE_APPLICATION_XML
#define COAP_MEDIATYPE_APPLICATION_SENSML_CBOR
@ COAP_SIGNALING_CODE_ABORT
@ COAP_SIGNALING_CODE_CSM
@ COAP_SIGNALING_CODE_PING
@ COAP_SIGNALING_CODE_PONG
@ COAP_SIGNALING_CODE_RELEASE
#define COAP_PROTO_NOT_RELIABLE(p)
int coap_dtls_cid_is_supported(void)
Check whether (D)TLS CID is available.
int coap_dtls_psk_is_supported(void)
Check whether (D)TLS PSK is available.
int coap_tls_is_supported(void)
Check whether TLS is available.
int coap_ws_is_supported(void)
Check whether WebSockets is available.
int coap_oscore_is_supported(void)
Check whether OSCORE is available.
int coap_dtls_is_supported(void)
Check whether DTLS is available.
int coap_dtls_pki_is_supported(void)
Check whether (D)TLS PKI is available.
int coap_dtls_rpk_is_supported(void)
Check whether (D)TLS RPK is available.
int coap_dtls_pkcs11_is_supported(void)
Check whether (D)TLS PKCS11 is available.
#define COAP_STATIC_INLINE
Multi-purpose address abstraction.
struct coap_sockaddr_un cun
union coap_address_t::@0 addr
size_t length
length of binary data
const uint8_t * s
read-only binary data
Iterator to run through PDU options.
coap_option_num_t number
decoded option number
coap_pdu_code_t code
request method (value 1–31) or response code (value 64-255)
coap_bin_const_t actual_token
Actual token in pdu.
coap_mid_t mid
message id, if any, in regular host byte order
coap_session_t * session
Session responsible for PDU or NULL.
coap_pdu_type_t type
message type
coap_proto_t proto
protocol used
char sun_path[COAP_UNIX_PATH_MAX]
The structure used for returning the underlying (D)TLS library information.
uint64_t built_version
(D)TLS Built against Library Version
coap_tls_library_t type
Library type.
uint64_t version
(D)TLS runtime Library Version