Skip to content

Commit

Permalink
coap: Update to latest libcoap code (4.3.2rc1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdeep1 committed Jul 22, 2023
1 parent 10a1fdd commit 34ca972
Show file tree
Hide file tree
Showing 15 changed files with 130 additions and 2,592 deletions.
31 changes: 14 additions & 17 deletions coap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
if(NOT CONFIG_LWIP_IPV6 AND NOT CMAKE_BUILD_EARLY_EXPANSION)
message(STATUS "IPV6 support is disabled so the coap component will not be built")
# note: the component is still included in the build so it can become visible again in config
# without needing to re-run CMake. However no source or header files are built.
idf_component_register()
return()
endif()

set(include_dirs port/include port/include libcoap/include)

set(srcs
"port/src/block.c"
"libcoap/src/coap_address.c"
"libcoap/src/coap_asn1.c"
"libcoap/src/coap_async.c"
"libcoap/src/coap_block.c"
"libcoap/src/coap_cache.c"
"libcoap/src/coap_debug.c"
"libcoap/src/coap_dtls.c"
"libcoap/src/coap_encode.c"
"libcoap/src/coap_event.c"
"libcoap/src/coap_hashkey.c"
"libcoap/src/coap_io.c"
"libcoap/src/coap_layers.c"
"libcoap/src/coap_mbedtls.c"
"libcoap/src/coap_mem.c"
"libcoap/src/coap_net.c"
"libcoap/src/coap_netif.c"
"libcoap/src/coap_notls.c"
"libcoap/src/coap_option.c"
"libcoap/src/coap_oscore.c"
"libcoap/src/coap_pdu.c"
"libcoap/src/coap_prng.c"
"libcoap/src/coap_resource.c"
"libcoap/src/coap_session.c"
"libcoap/src/coap_str.c"
"libcoap/src/coap_subscribe.c"
"libcoap/src/coap_tcp.c"
"libcoap/src/coap_time.c"
"libcoap/src/encode.c"
"libcoap/src/mem.c"
"libcoap/src/net.c"
"libcoap/src/pdu.c"
"libcoap/src/resource.c"
"libcoap/src/str.c"
"libcoap/src/uri.c"
"libcoap/src/coap_mbedtls.c")
"libcoap/src/coap_uri.c"
"libcoap/src/coap_ws.c")

idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
Expand Down
38 changes: 31 additions & 7 deletions coap/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ menu "CoAP Configuration"

endchoice #COAP_MBEDTLS_ENCRYPTION_MODE

config COAP_MBEDTLS_DEBUG
config COAP_DEBUGGING
bool "Enable CoAP debugging"
default n
help
Expand All @@ -33,9 +33,9 @@ menu "CoAP Configuration"
configuration, but logging level mbedTLS must be set for CoAP
to log it.

choice COAP_MBEDTLS_DEBUG_LEVEL
choice COAP_DEBUGGING_LEVEL
bool "Set CoAP debugging level"
depends on COAP_MBEDTLS_DEBUG
depends on COAP_DEBUGGING
default COAP_LOG_WARNING
help
Set CoAP debugging level
Expand All @@ -56,13 +56,13 @@ menu "CoAP Configuration"
bool "Info"
config COAP_LOG_DEBUG
bool "Debug"
config COAP_LOG_MBEDTLS
bool "mbedTLS"
config COAP_LOG_OSCORE
bool "OSCORE"
endchoice

config COAP_LOG_DEFAULT_LEVEL
int
default 0 if !COAP_MBEDTLS_DEBUG
default 0 if !COAP_DEBUGGING
default 0 if COAP_LOG_EMERG
default 1 if COAP_LOG_ALERT
default 2 if COAP_LOG_CRIT
Expand All @@ -71,7 +71,7 @@ menu "CoAP Configuration"
default 5 if COAP_LOG_NOTICE
default 6 if COAP_LOG_INFO
default 7 if COAP_LOG_DEBUG
default 9 if COAP_LOG_MBEDTLS
default 8 if COAP_LOG_OSCORE

config COAP_TCP_SUPPORT
bool "Enable TCP within CoAP"
Expand All @@ -82,6 +82,30 @@ menu "CoAP Configuration"

If this option is disabled, redundent CoAP TCP code is removed.

config COAP_OSCORE_SUPPORT
bool "Enable OSCORE support within CoAP"
default n
help
Enable OSCORE functionality for CoAP.

If this option is disabled, redundent CoAP OSCORE code is removed.

config COAP_OBSERVE_PERSIST
bool "Enable Server Observe Persist support within CoAP"
default n
help
Enable Server Observe Persist support for CoAP.

If this option is disabled, redundent CoAP Observe Persist code is removed.

config COAP_WEBSOCKETS
bool "Enable WebSockets support within CoAP"
default n
help
Enable WebSockets support for CoAP.

If this option is disabled, redundent CoAP WebSocket code is removed.

config COAP_CLIENT_SUPPORT
bool "Enable Client functionality within CoAP"
default n
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ published under EPL+EDL: http://www.eclipse.org/californium/

## libcoap Documentation
This can be found at [libcoap Documentation](https://libcoap.net/documentation.html).
The current API is 4.3.0.
The current API is 4.3.2.

## libcoap Specific Issues
These can be raised at [libcoap Issues](https://github.com/obgm/libcoap/issues).
Expand Down
7 changes: 5 additions & 2 deletions coap/examples/coap_client/main/coap_client_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
If you'd rather not, just change the below entry to a value
that is between 0 and 7 with
the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7
Caution: Logging is enabled in libcoap only up to level as defined
by 'idf.py menuconfig' to reduce code size.
*/
#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL

Expand Down Expand Up @@ -143,7 +146,7 @@ verify_cn_callback(const char *cn,
void *arg
)
{
coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n",
coap_log_info("CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
return 1;
}
Expand Down Expand Up @@ -387,7 +390,7 @@ static void coap_example_client(void *p)
coap_register_response_handler(ctx, message_handler);

if (coap_split_uri((const uint8_t *)server_uri, strlen(server_uri), &uri) == -1) {
ESP_LOGE(TAG, "CoAP server uri error");
ESP_LOGE(TAG, "CoAP server uri %s error", server_uri);
goto clean_up;
}
if (!coap_build_optlist(&uri)) {
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_client/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ version: "1.0.0"
description: CoAP Client Example
dependencies:
espressif/coap:
version: "^4.3.0"
version: "^4.3.2"
override_path: '../../../'
2 changes: 1 addition & 1 deletion coap/examples/coap_server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ until a CoAP client does a PUT with different data.

## libcoap Documentation
This can be found at [libcoap Documentation](https://libcoap.net/documentation.html).
The current API is 4.3.0.
The current API is 4.3.2.

## libcoap Specific Issues
These can be raised at [libcoap Issues](https://github.com/obgm/libcoap/issues).
Expand Down
7 changes: 6 additions & 1 deletion coap/examples/coap_server/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,29 @@ menu "Example CoAP Server Configuration"

config EXAMPLE_COAP_MCAST_IPV4_V6
bool "IPV4 & IPV6"
depends on LWIP_IPV4 && LWIP_IPV6
select EXAMPLE_COAP_MCAST_IPV4
select EXAMPLE_COAP_MCAST_IPV6

config EXAMPLE_COAP_MCAST_IPV4_ONLY
bool "IPV4"
depends on LWIP_IPV4
select EXAMPLE_COAP_MCAST_IPV4

config EXAMPLE_COAP_MCAST_IPV6_ONLY
bool "IPV6"
depends on LWIP_IPV6
select EXAMPLE_COAP_MCAST_IPV6

endchoice

config EXAMPLE_COAP_MCAST_IPV4
bool
depends on LWIP_IPV4

config EXAMPLE_COAP_MCAST_IPV6
bool
select EXAMPLE_CONNECT_IPV6 if IDF_TARGET_ESP32
depends on LWIP_IPV6

config EXAMPLE_COAP_MULTICAST_IPV4_ADDR
string "CoAP Multicast IPV4 Address (receive)"
Expand Down
5 changes: 4 additions & 1 deletion coap/examples/coap_server/main/coap_server_example_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
If you'd rather not, just change the below entry to a value
that is between 0 and 7 with
the config you want - ie #define EXAMPLE_COAP_LOG_DEFAULT_LEVEL 7
Caution: Logging is enabled in libcoap only up to level as defined
by 'idf.py menuconfig' to reduce code size.
*/
#define EXAMPLE_COAP_LOG_DEFAULT_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL

Expand Down Expand Up @@ -159,7 +162,7 @@ verify_cn_callback(const char *cn,
void *arg
)
{
coap_log(LOG_INFO, "CN '%s' presented by server (%s)\n",
coap_log_info("CN '%s' presented by server (%s)\n",
cn, depth ? "CA" : "Certificate");
return 1;
}
Expand Down
2 changes: 1 addition & 1 deletion coap/examples/coap_server/main/idf_component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ version: "1.0.0"
description: CoAP Server Example
dependencies:
espressif/coap:
version: "^4.3.0"
version: "^4.3.2"
override_path: '../../../'
2 changes: 1 addition & 1 deletion coap/idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "4.3.1~3"
version: "4.3.2~0"
description: Constrained Application Protocol (CoAP) C Library
url: https://github.com/espressif/idf-extra-components/tree/master/coap
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion coap/libcoap
Submodule libcoap updated 252 files
29 changes: 21 additions & 8 deletions coap/port/include/coap3/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,41 @@
extern "C" {
#endif

#ifdef CONFIG_LWIP_IPV4
#define COAP_IPV4_SUPPORT 1
#else /* ! CONFIG_LWIP_IPV4 */
struct sockaddr_in {
u8_t sin_len;
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
};
#endif /* ! CONFIG_LWIP_IPV4 */

#include "coap3/libcoap.h"

#include "coap3/coap_forward_decls.h"
#include "coap3/block.h"
#include "coap3/coap_address.h"
#include "coap3/coap_async.h"
#include "coap3/coap_block.h"
#include "coap3/coap_cache.h"
#include "coap3/coap_debug.h"
#include "coap3/coap_dtls.h"
#include "coap3/coap_encode.h"
#include "coap3/coap_event.h"
#include "coap3/coap_io.h"
#include "coap3/coap_mem.h"
#include "coap3/coap_net.h"
#include "coap3/coap_option.h"
#include "coap3/coap_oscore.h"
#include "coap3/coap_pdu.h"
#include "coap3/coap_prng.h"
#include "coap3/coap_str.h"
#include "coap3/coap_resource.h"
#include "coap3/coap_subscribe.h"
#include "coap3/coap_time.h"
#include "coap3/encode.h"
#include "coap3/mem.h"
#include "coap3/net.h"
#include "coap3/pdu.h"
#include "coap3/resource.h"
#include "coap3/str.h"
#include "coap3/uri.h"
#include "coap3/coap_uri.h"
#include "coap3/coap_ws.h"

#ifdef __cplusplus
}
Expand Down
38 changes: 38 additions & 0 deletions coap/port/include/coap_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,48 @@
#define COAP_SERVER_SUPPORT 1
#endif /* CONFIG_COAP_SERVER_SUPPORT */

#ifdef CONFIG_LWIP_IPV4
#define COAP_IPV4_SUPPORT 1
#endif /* CONFIG_LWIP_IPV4 */

#ifdef CONFIG_LWIP_IPV6
#define COAP_IPV6_SUPPORT 1
#endif /* CONFIG_LWIP_IPV6 */

#ifdef CONFIG_COAP_TCP_SUPPORT
#define COAP_DISABLE_TCP 0
#else /* ! CONFIG_COAP_TCP_SUPPORT */
#define COAP_DISABLE_TCP 1
#endif /* ! CONFIG_COAP_TCP_SUPPORT */

#ifdef CONFIG_COAP_OSCORE_SUPPORT
#define COAP_OSCORE_SUPPORT 1
#else /* ! CONFIG_COAP_OSCORE_SUPPORT */
#define COAP_OSCORE_SUPPORT 0
#endif /* ! CONFIG_COAP_OSCORE_SUPPORT */

#ifdef CONFIG_COAP_WEBSOCKETS
#define COAP_WS_SUPPORT 1
#else /* ! CONFIG_COAP_WEBSOCKETS */
#define COAP_WS_SUPPORT 0
#endif /* ! CONFIG_COAP_WEBSOCKETS */

#ifdef CONFIG_COAP_OBSERVE_PERSIST
#define COAP_WITH_OBSERVE_PERSIST 1
#else /* ! CONFIG_COAP_OBSERVE_PERSIST */
#define COAP_WITH_OBSERVE_PERSIST 0
#endif /* ! CONFIG_COAP_OBSERVE_PERSIST */

#ifdef CONFIG_COAP_Q_BLOCK
#define COAP_Q_BLOCK_SUPPORT 1
#else /* ! CONFIG_COAP_Q_BLOCK */
#define COAP_Q_BLOCK_SUPPORT 0
#endif /* ! CONFIG_COAP_Q_BLOCK */

#ifdef CONFIG_COAP_DEBUGGING
#define COAP_MAX_LOGGING_LEVEL CONFIG_COAP_LOG_DEFAULT_LEVEL
#else /* ! CONFIG_COAP_DEBUGGING */
#define COAP_MAX_LOGGING_LEVEL 0
#endif /* ! CONFIG_COAP_DEBUGGING */

#endif /* _CONFIG_H_ */
7 changes: 5 additions & 2 deletions coap/port/include/coap_config_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#ifdef WITH_POSIX

#include <sys/socket.h>
#include <sys/un.h>
#include <net/if.h>

#define HAVE_SYS_SOCKET_H
Expand All @@ -32,6 +33,7 @@
#define HAVE_STRUCT_CMSGHDR
#define HAVE_PTHREAD_H
#define HAVE_PTHREAD_MUTEX_LOCK
#define HAVE_GETRANDOM

#define ipi_spec_dst ipi_addr
struct in6_pktinfo {
Expand All @@ -47,11 +49,12 @@ struct in6_pktinfo {
#define IPV6_PKTINFO IPV6_CHECKSUM

#define PACKAGE_NAME "libcoap-posix"
#define PACKAGE_VERSION "4.3.1"
#define PACKAGE_VERSION "4.3.2"

#ifdef CONFIG_MBEDTLS_TLS_ENABLED
#define HAVE_MBEDTLS
#define COAP_WITH_LIBMBEDTLS
#endif /* CONFIG_MBEDTLS_TLS_ENABLED */

#define COAP_CONSTRAINED_STACK 1
#define ESPIDF_VERSION

Expand Down
Loading

0 comments on commit 34ca972

Please sign in to comment.