From fae64b471713bea2244e2f6c0015a1ba571827bf Mon Sep 17 00:00:00 2001 From: Daniel Adam Date: Sat, 28 Sep 2024 12:19:22 +0200 Subject: [PATCH] Update public API --- api/oc_message_buffer.c | 2 +- api/unittest/buffersettingstest.cpp | 3 +- port/oc_connectivity.h | 47 +-------------------- port/oc_connectivity_internal.h | 27 ++++++++++++ port/oc_dns.h | 64 +++++++++++++++++++++++++++++ security/oc_oscore_engine.c | 1 + 6 files changed, 96 insertions(+), 48 deletions(-) create mode 100644 port/oc_dns.h diff --git a/api/oc_message_buffer.c b/api/oc_message_buffer.c index b7001c017..7ed556c03 100644 --- a/api/oc_message_buffer.c +++ b/api/oc_message_buffer.c @@ -22,7 +22,7 @@ #include "messaging/coap/engine_internal.h" #include "oc_signal_event_loop.h" #include "oc_buffer.h" -#include "port/oc_connectivity.h" +#include "port/oc_connectivity_internal.h" #include "util/oc_features.h" #include "util/oc_process.h" diff --git a/api/unittest/buffersettingstest.cpp b/api/unittest/buffersettingstest.cpp index c96014bcc..bda39240d 100644 --- a/api/unittest/buffersettingstest.cpp +++ b/api/unittest/buffersettingstest.cpp @@ -50,11 +50,10 @@ TEST(BufferSettings, SetMaxAppDataSize) TEST(BufferSettings, SetMinAppDataSize) { size_t min_app_size = static_cast(oc_get_min_app_data_size()); - oc_set_min_app_data_size(42); EXPECT_EQ(42, oc_get_min_app_data_size()); - oc_set_min_app_data_size(max_app_size); + oc_set_min_app_data_size(min_app_size); } #endif /* !OC_APP_DATA_BUFFER_SIZE && OC_REP_ENCODING_REALLOC */ diff --git a/port/oc_connectivity.h b/port/oc_connectivity.h index fb89df95a..9f8a98a3c 100644 --- a/port/oc_connectivity.h +++ b/port/oc_connectivity.h @@ -29,6 +29,7 @@ #include "oc_export.h" #include "oc_network_events.h" #include "oc_session_events.h" +#include "port/oc_dns.h" #include "util/oc_atomic.h" #include "util/oc_features.h" #include "util/oc_memb.h" @@ -141,57 +142,13 @@ typedef struct oc_message_s #endif /* OC_HAS_FEATURE_MESSAGE_DYNAMIC_BUFFER */ } oc_message_t; -/** - * @brief send buffer - * - * @param message message to send - * @return int >=0 number of sent bytes - * @return int -1 on error - */ -int oc_send_buffer(oc_message_t *message); - -/** - * @brief send discovery request - * - * @param message the message - */ -void oc_send_discovery_request(oc_message_t *message); - -/** - * @brief end TCP session for the specific endpoint. - * - * @param endpoint the endpoint to close the session for - * - * @deprecated replaced by oc_close_session in v2.2.5.14 - */ -void oc_connectivity_end_session(const oc_endpoint_t *endpoint) - OC_DEPRECATED("replaced by oc_close_session in v2.2.5.14"); - -#ifdef OC_DNS_LOOKUP -/** - * @brief dns look up - * - * @param domain the url - * @param addr the address - * @param flags the transport flags - * @return int 0 = success - */ -int oc_dns_lookup(const char *domain, oc_string_t *addr, transport_flags flags); -#ifdef OC_DNS_CACHE -/** - * @brief clear the DNS cache - * - */ -void oc_dns_clear_cache(void); -#endif /* OC_DNS_CACHE */ -#endif /* OC_DNS_LOOKUP */ - /** * @brief retrieve list of endpoints for the device * * @param device the device index * @return oc_endpoint_t* list of endpoints */ +OC_API oc_endpoint_t *oc_connectivity_get_endpoints(size_t device); #ifdef OC_TCP diff --git a/port/oc_connectivity_internal.h b/port/oc_connectivity_internal.h index cd5ac30d7..a9b867880 100644 --- a/port/oc_connectivity_internal.h +++ b/port/oc_connectivity_internal.h @@ -27,6 +27,7 @@ #include "port/oc_connectivity.h" #include "util/oc_compiler.h" #include "util/oc_features.h" + #include #include #include @@ -53,6 +54,15 @@ int oc_connectivity_init(size_t device, oc_connectivity_ports_t ports); */ void oc_connectivity_shutdown(size_t device); +/** + * @brief send buffer + * + * @param message message to send + * @return int >=0 number of sent bytes + * @return int -1 on error + */ +int oc_send_buffer(oc_message_t *message); + /** * @brief Send message to endpoint. * @@ -65,6 +75,13 @@ void oc_connectivity_shutdown(size_t device); */ int oc_send_buffer2(oc_message_t *message, bool queue); +/** + * @brief send discovery request + * + * @param message the message + */ +void oc_send_discovery_request(oc_message_t *message); + #ifdef OC_DYNAMIC_ALLOCATION /** * @brief send a wakeup signal to the device to start consuming network events @@ -96,6 +113,16 @@ void handle_session_event_callback(const oc_endpoint_t *endpoint, #ifdef OC_TCP +/** + * @brief end TCP session for the specific endpoint. + * + * @param endpoint the endpoint to close the session for + * + * @deprecated replaced by oc_close_session in v2.2.5.14 + */ +void oc_connectivity_end_session(const oc_endpoint_t *endpoint) + OC_DEPRECATED("replaced by oc_close_session in v2.2.5.14"); + /** * @brief End TCP session for the specific endpoint. * diff --git a/port/oc_dns.h b/port/oc_dns.h new file mode 100644 index 000000000..2735241e9 --- /dev/null +++ b/port/oc_dns.h @@ -0,0 +1,64 @@ +/**************************************************************************** + * + * Copyright (c) 2016, 2018, 2020 Intel Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"), + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +/** + * @file + */ + +#ifndef OC_PORT_DNS_H +#define OC_PORT_DNS_H + +#include "oc_endpoint.h" +#include "oc_export.h" +#include "oc_helpers.h" +#include "util/oc_features.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef OC_DNS_LOOKUP + +/** + * @brief dns look up + * + * @param domain the url + * @param addr the address + * @param flags the transport flags + * @return int 0 = success + */ +OC_API +int oc_dns_lookup(const char *domain, oc_string_t *addr, transport_flags flags); + +#ifdef OC_DNS_CACHE + +/** + * @brief clear the DNS cache + */ +OC_API +void oc_dns_clear_cache(void); + +#endif /* OC_DNS_CACHE */ + +#endif /* OC_DNS_LOOKUP */ + +#ifdef __cplusplus +} +#endif + +#endif /* OC_PORT_DNS_H */ diff --git a/security/oc_oscore_engine.c b/security/oc_oscore_engine.c index f24a873d4..644bff825 100644 --- a/security/oc_oscore_engine.c +++ b/security/oc_oscore_engine.c @@ -33,6 +33,7 @@ #include "oc_pstat_internal.h" #include "oc_store.h" #include "oc_tls_internal.h" +#include "port/oc_connectivity_internal.h" #include "util/oc_process.h" #include "mbedtls/ccm.h"