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 ?
73 return PACKAGE_STRING;
78#ifdef LIBCOAP_PACKAGE_BUILD
79 return LIBCOAP_PACKAGE_BUILD;
81 return PACKAGE_STRING;
106 "EMRG",
"ALRT",
"CRIT",
"ERR ",
"WARN",
"NOTE",
"INFO",
"DEBG",
"OSC ",
108 "Emrg",
"Alrt",
"Crit",
"Err ",
"Warn",
"Note",
"Info",
"Debg"
114 printf(
"[%s: COAP ] ",
loglevels[level]);
125 tmp = localtime(&now);
126 lensofar = strftime(s, len,
"%b %d %H:%M:%S", tmp);
127 if (len > lensofar + 4) {
128 lensofar += snprintf(&s[lensofar], len-lensofar,
".%03u",
139 return snprintf(s, len,
"%u.%03u",
150#if !defined(HAVE_STRNLEN) && !defined(__MINGW32__)
162 while (*s++ && n < maxlen)
170 unsigned char *result,
size_t buflen,
int encode_always) {
171 const uint8_t hex[] =
"0123456789ABCDEF";
173 assert(data || len == 0);
180 if (!encode_always && isprint(*data)) {
181 if (cnt+1 < buflen) {
188 if (cnt+4 < buflen) {
191 *result++ = hex[(*data & 0xf0) >> 4];
192 *result++ = hex[*data & 0x0f];
207#define min(a,b) ((a) < (b) ? (a) : (b))
210#ifndef INET6_ADDRSTRLEN
211#define INET6_ADDRSTRLEN 46
219#if defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )
226 switch (addr->
addr.
sa.sa_family) {
229 snprintf((
char *)buf, len,
"%s:%d",
236 snprintf((
char *)buf, len,
"[%s]:%d",
241#if COAP_AF_UNIX_SUPPORT
248 memcpy(buf,
"(unknown address type)",
min(22+1, len));
252 return strlen((
char *)buf);
261 snprintf((
char *)buf, len,
"[%s]:%d",
264 return strlen((
char *)buf);
266 unsigned char *p = buf;
267# if NETSTACK_CONF_WITH_IPV6
272 if (len < 40 + 2 + 6)
280# warning "IPv4 network addresses will not be included in debug output"
296 return strlen((
char *)buf);
304 snprintf((
char *)buf, len,
"[%s]:%d",
307 return strlen((
char *)buf);
309 unsigned char *p = buf;
315 switch (IP_GET_TYPE(addr->
addr)) {
317 if (len < IP4ADDR_STRLEN_MAX + 6)
320 p += strlen((
char *)buf);
324 case IPADDR_TYPE_ANY:
325 if (len < 40 + 2 + 6)
329 p += strlen((
char *)buf);
336 *p++ =
'0' + (addr->port / 10000) % 10;
337 *p++ =
'0' + (addr->port / 1000) % 10;
338 *p++ =
'0' + (addr->port / 100) % 10;
339 *p++ =
'0' + (addr->port / 10) % 10;
340 *p++ =
'0' + addr->port % 10;
343 return strlen((
char *)buf);
352# warning "inet_ntop() not available, network addresses will not be included in debug output"
365#if defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )
366 const void *addrptr = NULL;
372 switch (addr->
addr.
sa.sa_family) {
375 if (len < INET_ADDRSTRLEN)
377 addrptr = &addr->
addr.
sin.sin_addr;
384 addrptr = &addr->
addr.
sin6.sin6_addr;
387#if COAP_AF_UNIX_SUPPORT
394 memcpy(buf,
"(unknown address type)",
min(22+1, len));
400 if (inet_ntop(addr->
addr.
sa.sa_family, addrptr, (
char *)buf, len) == 0) {
412# if NETSTACK_CONF_WITH_IPV6
413 const char hex[] =
"0123456789ABCDEF";
421 for (i=0; i < 16; i += 2) {
425 *p++ = hex[(addr->
addr.u8[i] & 0xf0) >> 4];
426 *p++ = hex[(addr->
addr.u8[i] & 0x0f)];
427 *p++ = hex[(addr->
addr.u8[i+1] & 0xf0) >> 4];
428 *p++ = hex[(addr->
addr.u8[i+1] & 0x0f)];
432# warning "IPv4 network addresses will not be included in debug output"
446 switch (IP_GET_TYPE(&addr->
addr)) {
449 if (len < IP4ADDR_STRLEN_MAX)
451 memcpy(buf, ip4addr_ntoa(ip_2_ip4(&addr->
addr)), IP4ADDR_STRLEN_MAX);
456 case IPADDR_TYPE_ANY:
460 memcpy(buf, ip6addr_ntoa(&addr->
addr.u_addr.ip6), 40);
462 memcpy(buf, ip6addr_ntoa(&addr->
addr), 40);
475# warning "inet_ntop() not available, network addresses will not be included in debug output"
485 static const char *types[] = {
"CON",
"NON",
"ACK",
"RST",
"???" };
487 return types[
min(t,
sizeof(types)/
sizeof(
char *) - 1)];
493 static const char *methods[] = {
"0.00",
"GET",
"POST",
"PUT",
"DELETE",
494 "FETCH",
"PATCH",
"iPATCH"
496 static const char *signals[] = {
"7.00",
"CSM",
"Ping",
"Pong",
"Release",
501 if (c <
sizeof(methods)/
sizeof(
const char *)) {
503 }
else if (c >= 224 && c - 224 < (
int)(
sizeof(signals)/
sizeof(
const char *))) {
504 return signals[c-224];
506 snprintf(buf,
sizeof(buf),
"%u.%02u", (c >> 5) & 0x7, c & 0x1f);
514 struct option_desc_t {
519 static struct option_desc_t options[] = {
548 static struct option_desc_t options_csm[] = {
554 static struct option_desc_t options_pingpong[] = {
558 static struct option_desc_t options_release[] = {
563 static struct option_desc_t options_abort[] = {
571 for (i = 0; i <
sizeof(options_csm)/
sizeof(
struct option_desc_t); i++) {
572 if (option_type == options_csm[i].type) {
573 return options_csm[i].name;
577 for (i = 0; i <
sizeof(options_pingpong)/
sizeof(
struct option_desc_t); i++) {
578 if (option_type == options_pingpong[i].type) {
579 return options_pingpong[i].name;
583 for (i = 0; i <
sizeof(options_release)/
sizeof(
struct option_desc_t); i++) {
584 if (option_type == options_release[i].type) {
585 return options_release[i].name;
589 for (i = 0; i <
sizeof(options_abort)/
sizeof(
struct option_desc_t); i++) {
590 if (option_type == options_abort[i].type) {
591 return options_abort[i].name;
596 for (i = 0; i <
sizeof(options)/
sizeof(
struct option_desc_t); i++) {
597 if (option_type == options[i].type) {
598 return options[i].name;
603 snprintf(buf,
sizeof(buf),
"%u", option_type);
609 unsigned char *result,
unsigned int buflen) {
615 static struct desc_t formats[] = {
646 { 75,
"application/dcaf+cbor" }
652 for (i = 0; i <
sizeof(formats)/
sizeof(
struct desc_t); i++) {
653 if (format_type == formats[i].type) {
654 return snprintf((
char *)result, buflen,
"%s", formats[i].name);
659 return snprintf((
char *)result, buflen,
"%d", format_type);
669 return !(content_format == -1 ||
676#define COAP_DO_SHOW_OUTPUT_LINE \
678 if (use_fprintf_for_show_pdu) { \
679 fprintf(COAP_DEBUG_FD, "%s", outbuf); \
682 coap_log(level, "%s", outbuf); \
698#if COAP_DEBUG_BUF_SIZE < 5
699#error "COAP_DEBUG_BUF_SIZE must be at least 5, should be >= 32 to be useful"
704#if COAP_CONSTRAINED_STACK
707 static unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
708 static char outbuf[COAP_DEBUG_BUF_SIZE];
711 unsigned char buf[
min(COAP_DEBUG_BUF_SIZE, 1035)];
712 char outbuf[COAP_DEBUG_BUF_SIZE];
715 int encode = 0, have_options = 0;
719 int content_format = -1;
723 const uint8_t *opt_val;
724 size_t outbuflen = 0;
725 int is_oscore_payload = 0;
731#if COAP_CONSTRAINED_STACK
732 coap_mutex_lock(&m_show_pdu);
736 snprintf(outbuf,
sizeof(outbuf),
"v:%d t:%s c:%s i:%04x {",
743 snprintf(outbuf,
sizeof(outbuf),
"v:WebSocket c:%s {",
748 snprintf(outbuf,
sizeof(outbuf),
"v:Reliable c:%s {",
753 outbuflen = strlen(outbuf);
754 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
757 outbuflen = strlen(outbuf);
758 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"}");
763 outbuflen = strlen(outbuf);
764 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" [");
770 outbuflen = strlen(outbuf);
771 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
",");
775 switch (opt_iter.
number) {
778 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
790 switch (opt_iter.
number) {
794 buf,
sizeof(buf), 0);
797 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
806 switch (opt_iter.
number) {
808 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
817 switch (opt_iter.
number) {
834 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT(%zu)",
839 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/BERT",
843 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u/%c/%u",
859 if (opt_val[0] & 0x20) {
861 snprintf((
char *)buf,
sizeof(buf),
"grp");
863 if (opt_val[0] & 0x07) {
865 cnt = opt_val[0] & 0x07;
866 if (cnt > opt_len - ofs)
868 buf_len = strlen((
char *)buf);
869 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%spIV=0x",
871 for (i = 0; (uint32_t)i < cnt; i++) {
872 buf_len = strlen((
char *)buf);
873 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
874 "%02x", opt_val[ofs + i]);
878 if (opt_val[0] & 0x10) {
883 if (cnt > opt_len - ofs - 1)
886 buf_len = strlen((
char *)buf);
887 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skc=0x",
889 for (i = 0; (uint32_t)i < cnt; i++) {
890 buf_len = strlen((
char *)buf);
891 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
892 "%02x", opt_val[ofs + i]);
896 if (opt_val[0] & 0x08) {
901 buf_len = strlen((
char *)buf);
902 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
"%skid=0x",
904 for (i = 0; (uint32_t)i < cnt; i++) {
905 buf_len = strlen((
char *)buf);
906 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
907 "%02x", opt_val[ofs + i]);
912 buf_len = strlen((
char *)buf);
913 is_oscore_payload = 1;
924 buf_len = snprintf((
char *)buf,
sizeof(buf),
"%u",
937 snprintf((
char *)buf,
sizeof(buf),
"0x");
938 for (i = 0; (uint32_t)i < opt_len; i++) {
939 buf_len = strlen((
char *)buf);
940 snprintf((
char *)&buf[buf_len],
sizeof(buf)-buf_len,
943 buf_len = strlen((
char *)buf);
960 buf,
sizeof(buf), encode);
963 outbuflen = strlen(outbuf);
964 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
969 outbuflen = strlen(outbuf);
970 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" ]");
974 outbuflen = strlen(outbuf);
975 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
" :: ");
977 if (
is_binary(content_format) || !isprint(data[0]) || is_oscore_payload) {
978 size_t keep_data_len = data_len;
979 const uint8_t *keep_data = data;
981 outbuflen = strlen(outbuf);
982 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
983 "binary data length %zu\n", data_len);
989 snprintf(outbuf,
sizeof(outbuf),
"<<");
991 outbuflen = strlen(outbuf);
992 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
995 outbuflen = strlen(outbuf);
996 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
997 data_len = keep_data_len;
999 outbuflen = strlen(outbuf);
1000 if (outbuflen ==
sizeof(outbuf)-1)
1002 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1009 snprintf(outbuf,
sizeof(outbuf),
"<<");
1010 while (data_len--) {
1011 outbuflen = strlen(outbuf);
1012 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
1013 "%c ", isprint(*data) ? *data :
'.');
1016 outbuflen = strlen(outbuf);
1017 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
">>");
1021 outbuflen = strlen(outbuf);
1022 max_length =
sizeof(outbuf)-outbuflen;
1023 if (max_length > 1) {
1024 outbuf[outbuflen++] =
'\'';
1025 outbuf[outbuflen] =
'\000';
1028 if (max_length > 1) {
1030 (
unsigned char *)&outbuf[outbuflen],
1034 if (outbuflen <
sizeof(outbuf)-4-1) {
1035 outbuf[outbuflen++] =
'\'';
1036 outbuf[outbuflen] =
'\000';
1041 outbuflen = strlen(outbuf);
1042 if (outbuflen ==
sizeof(outbuf)-1)
1044 snprintf(&outbuf[outbuflen],
sizeof(outbuf)-outbuflen,
"\n");
1047#if COAP_CONSTRAINED_STACK
1048 coap_mutex_unlock(&m_show_pdu);
1067 switch (tls_version->
type) {
1069 snprintf(buffer, bufsize,
"TLS Library: None");
1072 snprintf(buffer, bufsize,
"TLS Library: TinyDTLS - runtime %lu.%lu.%lu, "
1073 "libcoap built for %lu.%lu.%lu",
1074 (
unsigned long)(tls_version->
version >> 16),
1075 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1076 (
unsigned long)(tls_version->
version & 0xff),
1082 switch (tls_version->
version &0xf) {
1084 strcpy(beta,
"-dev");
1090 strcpy(beta,
"-beta");
1091 beta[5] = (tls_version->
version &0xf) +
'0';
1095 sub[0] = ((tls_version->
version >> 4) & 0xff) ?
1096 ((tls_version->
version >> 4) & 0xff) +
'a' -1 :
'\000';
1100 strcpy(b_beta,
"-dev");
1106 strcpy(b_beta,
"-beta");
1112 ((tls_version->
built_version >> 4) & 0xff) +
'a' -1 :
'\000';
1114 snprintf(buffer, bufsize,
"TLS Library: OpenSSL - runtime "
1115 "%lu.%lu.%lu%s%s, libcoap built for %lu.%lu.%lu%s%s",
1116 (
unsigned long)(tls_version->
version >> 28),
1117 (
unsigned long)((tls_version->
version >> 20) & 0xff),
1118 (
unsigned long)((tls_version->
version >> 12) & 0xff), sub, beta,
1125 snprintf(buffer, bufsize,
"TLS Library: GnuTLS - runtime %lu.%lu.%lu, "
1126 "libcoap built for %lu.%lu.%lu",
1127 (
unsigned long)(tls_version->
version >> 16),
1128 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1129 (
unsigned long)(tls_version->
version & 0xff),
1135 snprintf(buffer, bufsize,
"TLS Library: Mbed TLS - runtime %lu.%lu.%lu, "
1136 "libcoap built for %lu.%lu.%lu",
1137 (
unsigned long)(tls_version->
version >> 24),
1138 (
unsigned long)((tls_version->
version >> 16) & 0xff),
1139 (
unsigned long)((tls_version->
version >> 8) & 0xff),
1145 snprintf(buffer, bufsize,
"Library type %d unknown", tls_version->
type);
1162 if (have_dtls == 0 && have_tls == 0) {
1163 snprintf(buffer, bufsize,
"(No DTLS or TLS support)");
1166 snprintf(buffer, bufsize,
1167 "(%sDTLS and %sTLS support; %sPSK, %sPKI, %sPKCS11, and %sRPK support)\n(%sOSCORE)\n(%sWebSockets)",
1168 have_dtls ?
"" :
"No ",
1169 have_tls ?
"" :
"no ",
1170 have_psk ?
"" :
"no ",
1171 have_pki ?
"" :
"no ",
1172 have_pkcs11 ?
"" :
"no ",
1173 have_rpk ?
"" :
"no ",
1174 have_oscore ?
"Have " :
"No ",
1175 have_ws ?
"Have " :
"No ");
1190#if COAP_CONSTRAINED_STACK
1192 static char message[COAP_DEBUG_BUF_SIZE];
1194 char message[COAP_DEBUG_BUF_SIZE];
1197 va_start(ap, format);
1198#if COAP_CONSTRAINED_STACK
1199 coap_mutex_lock(&m_log_impl);
1202 vsnprintf(message,
sizeof(message), format, ap);
1205#if COAP_CONSTRAINED_STACK
1206 coap_mutex_unlock(&m_log_impl);
1220 fprintf(log_fd,
"%.*s ", (
int)len, timebuf);
1223 fprintf(log_fd,
"%4d ", level);
1225 fprintf(log_fd,
"%s ",
loglevels[level]);
1228 va_start(ap, format);
1229 vfprintf(log_fd, format, ap);
1245 const char *p = loss_level;
1247 int n = (int)strtol(p, &end, 10), i = 0;
1248 if (end == p || n < 0)
1262 n = (int)strtol(p, &end, 10);
1263 if (end == p || n <= 0)
1272 n = (int)strtol(p, &end, 10);
1273 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 int 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)
Pulls together all the internal only header files.
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(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.
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_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.
@ 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.
#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.
int coap_oscore_is_supported(void)
Check whether OSCORE is available.
#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_ws_is_supported(void)
Check whether WebSockets 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