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"
77 return PACKAGE_STRING;
82#ifdef LIBCOAP_PACKAGE_BUILD
83 return LIBCOAP_PACKAGE_BUILD;
85 return PACKAGE_STRING;
110 "EMRG",
"ALRT",
"CRIT",
"ERR ",
"WARN",
"NOTE",
"INFO",
"DEBG",
"OSC ",
112 "Emrg",
"Alrt",
"Crit",
"Err ",
"Warn",
"Note",
"Info",
"Debg"
119 snprintf(bad,
sizeof(bad),
"%4d", level);
140 tmp = localtime(&now);
141 lensofar = strftime(s, len,
"%b %d %H:%M:%S", tmp);
142 if (len > lensofar + 4) {
143 lensofar += snprintf(&s[lensofar], len-lensofar,
".%03u",
154 return snprintf(s, len,
"%u.%03u",
165#if !defined(HAVE_STRNLEN) && !defined(__MINGW32__)
177 while (*s++ && n < maxlen)
185 unsigned char *result,
size_t buflen,
int encode_always) {
186 const uint8_t hex[] =
"0123456789ABCDEF";
188 assert(data || len == 0);
195 if (!encode_always && isprint(*data)) {
196 if (cnt+1 < buflen) {
203 if (cnt+4 < buflen) {
206 *result++ = hex[(*data & 0xf0) >> 4];
207 *result++ = hex[*data & 0x0f];
222#define min(a,b) ((a) < (b) ? (a) : (b))
225#ifndef INET6_ADDRSTRLEN
226#define INET6_ADDRSTRLEN 46
234#if (defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )) && !defined(RIOT_VERSION)
241 switch (addr->
addr.
sa.sa_family) {
244 snprintf((
char *)buf, len,
"%s:%d",
251 snprintf((
char *)buf, len,
"[%s]:%d",
256#if COAP_AF_UNIX_SUPPORT
263 memcpy(buf,
"(unknown address type)",
min(22+1, len));
267 return strlen((
char *)buf);
271# if defined(RIOT_VERSION)
278 switch (addr->riot.family) {
281 snprintf((
char *)buf, len,
"%s:%d",
288 snprintf((
char *)buf, len,
"[%s]:%d",
295 memcpy(buf,
"(unknown address type)",
min(22+1, len));
299 return strlen((
char *)buf);
306 snprintf((
char *)buf, len,
"[%s]:%d",
309 return strlen((
char *)buf);
311 unsigned char *p = buf;
312# if NETSTACK_CONF_WITH_IPV6
317 if (len < 40 + 2 + 6)
325# warning "IPv4 network addresses will not be included in debug output"
341 return strlen((
char *)buf);
349 snprintf((
char *)buf, len,
"[%s]:%d",
352 return strlen((
char *)buf);
354 unsigned char *p = buf;
360 switch (IP_GET_TYPE(addr->
addr)) {
362 if (len < IP4ADDR_STRLEN_MAX + 6)
365 p += strlen((
char *)buf);
369 case IPADDR_TYPE_ANY:
370 if (len < 40 + 2 + 6)
374 p += strlen((
char *)buf);
381 *p++ =
'0' + (addr->port / 10000) % 10;
382 *p++ =
'0' + (addr->port / 1000) % 10;
383 *p++ =
'0' + (addr->port / 100) % 10;
384 *p++ =
'0' + (addr->port / 10) % 10;
385 *p++ =
'0' + addr->port % 10;
388 return strlen((
char *)buf);
397# warning "inet_ntop() not available, network addresses will not be included in debug output"
410#if (defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )) && !defined(RIOT_VERSION)
411 const void *addrptr = NULL;
417 switch (addr->
addr.
sa.sa_family) {
420 if (len < INET_ADDRSTRLEN)
422 addrptr = &addr->
addr.
sin.sin_addr;
429 addrptr = &addr->
addr.
sin6.sin6_addr;
432#if COAP_AF_UNIX_SUPPORT
439 memcpy(buf,
"(unknown address type)",
min(22+1, len));
445 if (inet_ntop(addr->
addr.
sa.sa_family, addrptr, (
char *)buf, len) == 0) {
454# if defined(RIOT_VERSION)
459 switch (addr->riot.family) {
462 if (ipv4_addr_to_str(buf, (ipv4_addr_t *)&addr->riot.
addr.ipv4, (
size_t)len) == NULL) {
469 if (ipv6_addr_to_str(buf, (ipv6_addr_t *)&addr->riot.
addr.ipv6, (
size_t)len) == NULL) {
487# if NETSTACK_CONF_WITH_IPV6
488 const char hex[] =
"0123456789ABCDEF";
496 for (i=0; i < 16; i += 2) {
500 *p++ = hex[(addr->
addr.u8[i] & 0xf0) >> 4];
501 *p++ = hex[(addr->
addr.u8[i] & 0x0f)];
502 *p++ = hex[(addr->
addr.u8[i+1] & 0xf0) >> 4];
503 *p++ = hex[(addr->
addr.u8[i+1] & 0x0f)];
507# warning "IPv4 network addresses will not be included in debug output"
521 switch (IP_GET_TYPE(&addr->
addr)) {
524 if (len < IP4ADDR_STRLEN_MAX)
526 memcpy(buf, ip4addr_ntoa(ip_2_ip4(&addr->
addr)), IP4ADDR_STRLEN_MAX);
531 case IPADDR_TYPE_ANY:
535 memcpy(buf, ip6addr_ntoa(&addr->
addr.u_addr.ip6), 40);
537 memcpy(buf, ip6addr_ntoa(&addr->
addr), 40);
550# warning "inet_ntop() not available, network addresses will not be included in debug output"
560 static const char *types[] = {
"CON",
"NON",
"ACK",
"RST",
"???" };
562 return types[
min(t,
sizeof(types)/
sizeof(
char *) - 1)];
568 static const char *methods[] = {
"0.00",
"GET",
"POST",
"PUT",
"DELETE",
569 "FETCH",
"PATCH",
"iPATCH"
571 static const char *signals[] = {
"7.00",
"CSM",
"Ping",
"Pong",
"Release",
576 if (c <
sizeof(methods)/
sizeof(
const char *)) {
578 }
else if (c >= 224 && c - 224 < (
int)(
sizeof(signals)/
sizeof(
const char *))) {
579 return signals[c-224];
581 snprintf(buf,
sizeof(buf),
"%u.%02u", (c >> 5) & 0x7, c & 0x1f);
589 struct option_desc_t {
594 static struct option_desc_t options[] = {
623 static struct option_desc_t options_csm[] = {
629 static struct option_desc_t options_pingpong[] = {
633 static struct option_desc_t options_release[] = {
638 static struct option_desc_t options_abort[] = {
646 for (i = 0; i <
sizeof(options_csm)/
sizeof(
struct option_desc_t); i++) {
647 if (option_type == options_csm[i].type) {
648 return options_csm[i].name;
652 for (i = 0; i <
sizeof(options_pingpong)/
sizeof(
struct option_desc_t); i++) {
653 if (option_type == options_pingpong[i].type) {
654 return options_pingpong[i].name;
658 for (i = 0; i <
sizeof(options_release)/
sizeof(
struct option_desc_t); i++) {
659 if (option_type == options_release[i].type) {
660 return options_release[i].name;
664 for (i = 0; i <
sizeof(options_abort)/
sizeof(
struct option_desc_t); i++) {
665 if (option_type == options_abort[i].type) {
666 return options_abort[i].name;
671 for (i = 0; i <
sizeof(options)/
sizeof(
struct option_desc_t); i++) {
672 if (option_type == options[i].type) {
673 return options[i].name;
678 snprintf(buf,
sizeof(buf),
"%u", option_type);
684 unsigned char *result,
unsigned int buflen) {
690 static struct desc_t formats[] = {
721 { 75,
"application/dcaf+cbor" }
727 for (i = 0; i <
sizeof(formats)/
sizeof(
struct desc_t); i++) {
728 if (format_type == formats[i].type) {
729 return snprintf((
char *)result, buflen,
"%s", formats[i].name);
734 return snprintf((
char *)result, buflen,
"%d", format_type);
744 return !(content_format == -1 ||
751#define COAP_DO_SHOW_OUTPUT_LINE \
753 if (use_fprintf_for_show_pdu) { \
754 fprintf(COAP_DEBUG_FD, "%s", outbuf); \
757 coap_log(level, "%s", outbuf); \
773#if COAP_DEBUG_BUF_SIZE < 5
774#error "COAP_DEBUG_BUF_SIZE must be at least 5, should be >= 32 to be useful"
779#if COAP_CONSTRAINED_STACK
782 static unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
783 static char outbuf[COAP_DEBUG_BUF_SIZE];
786 unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
787 char outbuf[COAP_DEBUG_BUF_SIZE];
790 int encode = 0, have_options = 0;
794 int content_format = -1;
798 const uint8_t *opt_val;
799 size_t outbuflen = 0;
800 int is_oscore_payload = 0;
807 snprintf(outbuf,
sizeof(outbuf),
"v:%d t:%s c:%s i:%04x {",
814 snprintf(outbuf,
sizeof(outbuf),
"v:WebSocket c:%s {",
819 snprintf(outbuf,
sizeof(outbuf),
"v:Reliable c:%s {",
824 outbuflen = strlen(outbuf);
825 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
828 outbuflen = strlen(outbuf);
829 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"}");
834 outbuflen = strlen(outbuf);
835 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" [");
841 outbuflen = strlen(outbuf);
842 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
",");
846 switch (opt_iter.
number) {
849 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
861 switch (opt_iter.
number) {
865 buf,
sizeof(buf), 0);
868 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
877 switch (opt_iter.
number) {
879 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
888 switch (opt_iter.
number) {
905 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT(%zu)",
910 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT",
914 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/%u",
930 if (opt_val[0] & 0x20) {
932 snprintf((
char *)buf,
sizeof(buf),
"grp");
934 if (opt_val[0] & 0x07) {
936 cnt = opt_val[0] & 0x07;
937 if (cnt > opt_len - ofs)
939 buf_len = strlen((
char *)buf);
940 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%spIV=0x",
942 for (i = 0; (uint32_t)i < cnt; i++) {
943 buf_len = strlen((
char *)buf);
944 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
945 "%02x", opt_val[ofs + i]);
949 if (opt_val[0] & 0x10) {
954 if (cnt > opt_len - ofs - 1)
957 buf_len = strlen((
char *)buf);
958 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skc=0x",
960 for (i = 0; (uint32_t)i < cnt; i++) {
961 buf_len = strlen((
char *)buf);
962 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
963 "%02x", opt_val[ofs + i]);
967 if (opt_val[0] & 0x08) {
972 buf_len = strlen((
char *)buf);
973 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skid=0x",
975 for (i = 0; (uint32_t)i < cnt; i++) {
976 buf_len = strlen((
char *)buf);
977 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
978 "%02x", opt_val[ofs + i]);
983 buf_len = strlen((
char *)buf);
984 is_oscore_payload = 1;
995 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
1008 snprintf((
char *)buf,
sizeof(buf),
"0x");
1009 for (i = 0; (uint32_t)i < opt_len; i++) {
1010 buf_len = strlen((
char *)buf);
1011 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
1012 "%02x", opt_val[i]);
1014 buf_len = strlen((
char *)buf);
1031 buf,
sizeof(buf), encode);
1034 outbuflen = strlen(outbuf);
1035 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1040 outbuflen = strlen(outbuf);
1041 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" ]");
1045 outbuflen = strlen(outbuf);
1046 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" :: ");
1048 if (
is_binary(content_format) || !isprint(data[0]) || is_oscore_payload) {
1049 size_t keep_data_len = data_len;
1050 const uint8_t *keep_data = data;
1052 outbuflen = strlen(outbuf);
1053 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1054 "binary data length %zu\n", data_len);
1060 snprintf(outbuf,
sizeof(outbuf),
"<<");
1061 while (data_len--) {
1062 outbuflen = strlen(outbuf);
1063 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1066 outbuflen = strlen(outbuf);
1067 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
1068 data_len = keep_data_len;
1070 outbuflen = strlen(outbuf);
1071 if (outbuflen ==
sizeof(outbuf)-1)
1073 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1080 snprintf(outbuf,
sizeof(outbuf),
"<<");
1081 while (data_len--) {
1082 outbuflen = strlen(outbuf);
1083 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1084 "%c ", isprint(*data) ? *data :
'.');
1087 outbuflen = strlen(outbuf);
1088 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
1092 outbuflen = strlen(outbuf);
1093 max_length =
sizeof(outbuf)-outbuflen;
1094 if (max_length > 1) {
1095 outbuf[outbuflen++] =
'\'';
1096 outbuf[outbuflen] =
'\000';
1099 if (max_length > 1) {
1101 (
unsigned char *)&outbuf[outbuflen],
1105 if (outbuflen <
sizeof(outbuf)-4-1) {
1106 outbuf[outbuflen++] =
'\'';
1107 outbuf[outbuflen] =
'\000';
1112 outbuflen = strlen(outbuf);
1113 if (outbuflen ==
sizeof(outbuf)-1)
1115 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1134 switch (tls_version->
type) {
1136 snprintf(buffer, bufsize,
"TLS Library: None");
1139 snprintf(buffer, bufsize,
"TLS Library: TinyDTLS - runtime %lu.%lu.%lu, "
1140 "libcoap built for %lu.%lu.%lu",
1141 (
unsigned long)(tls_version->
version >> 16),
1142 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1143 (
unsigned long)(tls_version->
version & 0xff),
1149 switch (tls_version->
version &0xf) {
1151 strcpy(beta,
"-dev");
1157 strcpy(beta,
"-beta");
1158 beta[5] = (tls_version->
version &0xf) +
'0';
1162 sub[0] = ((tls_version->
version >> 4) & 0xff) ?
1163 ((tls_version->
version >> 4) & 0xff) +
'a' -1 :
'\000';
1167 strcpy(b_beta,
"-dev");
1173 strcpy(b_beta,
"-beta");
1179 ((tls_version->
built_version >> 4) & 0xff) +
'a' -1 :
'\000';
1181 snprintf(buffer, bufsize,
"TLS Library: OpenSSL - runtime "
1182 "%lu.%lu.%lu%s%s, libcoap built for %lu.%lu.%lu%s%s",
1183 (
unsigned long)(tls_version->
version >> 28),
1184 (
unsigned long)((tls_version->
version >> 20) & 0xff),
1185 (
unsigned long)((tls_version->
version >> 12) & 0xff), sub, beta,
1192 snprintf(buffer, bufsize,
"TLS Library: GnuTLS - runtime %lu.%lu.%lu, "
1193 "libcoap built for %lu.%lu.%lu",
1194 (
unsigned long)(tls_version->
version >> 16),
1195 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1196 (
unsigned long)(tls_version->
version & 0xff),
1202 snprintf(buffer, bufsize,
"TLS Library: Mbed TLS - runtime %lu.%lu.%lu, "
1203 "libcoap built for %lu.%lu.%lu",
1204 (
unsigned long)(tls_version->
version >> 24),
1205 (
unsigned long)((tls_version->
version >> 16) & 0xff),
1206 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1212 snprintf(buffer, bufsize,
"TLS Library: wolfSSL - runtime %lu.%lu.%lu, "
1213 "libcoap built for %lu.%lu.%lu",
1214 (
unsigned long)(tls_version->
version >> 24),
1215 (
unsigned long)((tls_version->
version >> 12) & 0xfff),
1216 (
unsigned long)((tls_version->
version >> 0) & 0xfff),
1218 (
unsigned long)((tls_version->
built_version >> 12) & 0xfff),
1219 (
unsigned long)((tls_version->
built_version >> 0) & 0xfff));
1222 snprintf(buffer, bufsize,
"Library type %d unknown", tls_version->
type);
1240 if (have_dtls == 0 && have_tls == 0) {
1241 snprintf(buffer, bufsize,
"(No DTLS or TLS support)");
1244 snprintf(buffer, bufsize,
1245 "(%sDTLS and %sTLS support; %sPSK, %sPKI, %sPKCS11, %sRPK and %sCID support)\n(%sOSCORE)\n(%sWebSockets)",
1246 have_dtls ?
"" :
"No ",
1247 have_tls ?
"" :
"no ",
1248 have_psk ?
"" :
"no ",
1249 have_pki ?
"" :
"no ",
1250 have_pkcs11 ?
"" :
"no ",
1251 have_rpk ?
"" :
"no ",
1252 have_cid ?
"" :
"no ",
1253 have_oscore ?
"Have " :
"No ",
1254 have_ws ?
"Have " :
"No ");
1269#if COAP_CONSTRAINED_STACK
1271 static char message[COAP_DEBUG_BUF_SIZE];
1273 char message[COAP_DEBUG_BUF_SIZE];
1276 va_start(ap, format);
1279 flash_vsnprintf(message,
sizeof(message), format, ap);
1281 vsnprintf(message,
sizeof(message), format, ap);
1297 fprintf(log_fd,
"%.*s ", (
int)len, timebuf);
1301 va_start(ap, format);
1303 flash_vfprintf(log_fd, format, ap);
1305 vfprintf(log_fd, format, ap);
1322 const char *p = loss_level;
1324 int n = (int)strtol(p, &end, 10), i = 0;
1325 if (end == p || n < 0)
1339 n = (int)strtol(p, &end, 10);
1340 if (end == p || n <= 0)
1349 n = (int)strtol(p, &end, 10);
1350 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 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.
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