Skip to content

Commit

Permalink
Update public API
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Sep 28, 2024
1 parent 97a24ff commit fae64b4
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 48 deletions.
2 changes: 1 addition & 1 deletion api/oc_message_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 1 addition & 2 deletions api/unittest/buffersettingstest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ TEST(BufferSettings, SetMaxAppDataSize)
TEST(BufferSettings, SetMinAppDataSize)
{
size_t min_app_size = static_cast<size_t>(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 */
Expand Down
47 changes: 2 additions & 45 deletions port/oc_connectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions port/oc_connectivity_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "port/oc_connectivity.h"
#include "util/oc_compiler.h"
#include "util/oc_features.h"

#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
Expand All @@ -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.
*
Expand All @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down
64 changes: 64 additions & 0 deletions port/oc_dns.h
Original file line number Diff line number Diff line change
@@ -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 */
1 change: 1 addition & 0 deletions security/oc_oscore_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit fae64b4

Please sign in to comment.