Skip to content

Commit

Permalink
Add OC_API annotations to oc_network_monitor.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Sep 27, 2024
1 parent ad35db6 commit e8bf175
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 64 deletions.
5 changes: 4 additions & 1 deletion api/cloud/oc_cloud.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
#include "oc_api.h"
#include "oc_collection.h"
#include "oc_core_res.h"
#include "oc_network_monitor.h"
#include "port/oc_assert.h"
#include "util/oc_endpoint_address_internal.h"
#include "util/oc_mmem_internal.h"
#include "util/oc_secure_string_internal.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */

#ifdef OC_SECURITY
#include "security/oc_tls_internal.h"
#endif /* OC_SECURITY */
Expand Down
1 change: 0 additions & 1 deletion api/oc_session_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "api/oc_session_events_internal.h"
#include "oc_api.h"
#include "oc_buffer.h"
#include "oc_network_monitor.h"
#include "oc_session_events.h"
#include "oc_signal_event_loop.h"
#include "port/oc_connectivity_internal.h"
Expand Down
7 changes: 7 additions & 0 deletions api/plgd/device-provisioning-client/plgd_dps.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
#include "api/oc_tcp_internal.h"
#include "oc_certs.h"
#include "oc_core_res.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */

#include <assert.h>
#include <inttypes.h>
Expand Down Expand Up @@ -226,13 +229,17 @@ plgd_dps_session_callbacks_deinit(plgd_dps_context_t *ctx)
void
plgd_dps_interface_callbacks_init(void)
{
#ifdef OC_NETWORK_MONITOR
oc_add_network_interface_event_callback(dps_interface_event_handler);
#endif /* OC_NETWORK_MONITOR */
}

void
plgd_dps_interface_callbacks_deinit(void)
{
#ifdef OC_NETWORK_MONITOR
oc_remove_network_interface_event_callback(dps_interface_event_handler);
#endif /* OC_NETWORK_MONITOR */
}

#endif /* OC_SESSION_EVENTS */
Expand Down
1 change: 0 additions & 1 deletion api/plgd/device-provisioning-client/plgd_dps_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "plgd_dps_internal.h"

#include "oc_cred.h"
#include "oc_network_monitor.h"
#include "security/oc_cred_util_internal.h"
#include "util/oc_list.h"

Expand Down
1 change: 0 additions & 1 deletion api/plgd/unittest/plgdtimetest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "messaging/coap/transactions_internal.h"
#include "oc_acl.h"
#include "oc_core_res.h"
#include "oc_network_monitor.h"
#include "oc_ri.h"
#include "port/oc_log_internal.h"
#include "port/oc_network_event_handler_internal.h"
Expand Down
58 changes: 2 additions & 56 deletions include/oc_network_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

#include "oc_export.h"
#include "oc_network_events.h"
#include "oc_session_events.h"
#include "util/oc_compiler.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -37,6 +35,7 @@ extern "C" {
* @return 0 on success
* @return -1 on error
*/
OC_API
int oc_add_network_interface_event_callback(interface_event_handler_t cb);

/**
Expand All @@ -46,61 +45,8 @@ int oc_add_network_interface_event_callback(interface_event_handler_t cb);
* @return 0 on success
* @return -1 on error
*/
int oc_remove_network_interface_event_callback(interface_event_handler_t cb);

/**
* @brief Add the callback to receive session event notifications.
*
* @param cb The callback to be added. Must not be NULL.
* @return 0 on success
* @return -1 on error
*
* @deprecated replaced by oc_add_session_event_callback_v1 in v2.2.5.4
*/
OC_API
int oc_add_session_event_callback(session_event_handler_t cb)
OC_DEPRECATED("replaced by oc_add_session_event_callback_v1 in v2.2.5.4");

/**
* @brief Add the callback to receive session event notifications.
*
* @param cb The callback to be added (cannot be NULL).
* @param user_data user data passed to the callback when invoked
* @return 0 on success
* @return -1 on error
*/
OC_API
int oc_add_session_event_callback_v1(session_event_handler_v1_t cb,
void *user_data);

/**
* @brief Remove the callback to receive session event notifications.
* @param cb The callback to be removed. Must not be NULL.
* @return 0 on success
* @return -1 on error
*
* @deprecated replaced by oc_remove_session_event_callback_v1 in v2.2.5.4
*/
OC_API
int oc_remove_session_event_callback(session_event_handler_t cb)
OC_DEPRECATED("replaced by oc_remove_session_event_callback_v1 in v2.2.5.4");

/**
* @brief Remove the callback with to receive session event notifications.
*
* @param cb The callback to be removed.
* @param user_data user data provided to the callback by
oc_add_session_event_callback_v1
* @param ignore_user_data ignore user_data and match only the function pointer
* @return 0 on success
* @return OC_ERR_SESSION_EVENT_HANDLER_NOT_FOUND when no match was found
* @return -1 other errors
*
* @see oc_add_session_event_callback_v1
*/
OC_API
int oc_remove_session_event_callback_v1(session_event_handler_v1_t cb,
void *user_data, bool ignore_user_data);
int oc_remove_network_interface_event_callback(interface_event_handler_t cb);

#ifdef __cplusplus
}
Expand Down
55 changes: 55 additions & 0 deletions include/oc_session_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "oc_export.h"
#include "oc_endpoint.h"
#include "util/oc_compiler.h"

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -76,6 +77,60 @@ typedef void (*session_event_handler_v1_t)(const oc_endpoint_t *endpoint,
OC_API
void oc_session_events_set_event_delay(int secs);

/**
* @brief Add the callback to receive session event notifications.
*
* @param cb The callback to be added. Must not be NULL.
* @return 0 on success
* @return -1 on error
*
* @deprecated replaced by oc_add_session_event_callback_v1 in v2.2.5.4
*/
OC_API
int oc_add_session_event_callback(session_event_handler_t cb)
OC_DEPRECATED("replaced by oc_add_session_event_callback_v1 in v2.2.5.4");

/**
* @brief Add the callback to receive session event notifications.
*
* @param cb The callback to be added (cannot be NULL).
* @param user_data user data passed to the callback when invoked
* @return 0 on success
* @return -1 on error
*/
OC_API
int oc_add_session_event_callback_v1(session_event_handler_v1_t cb,
void *user_data);

/**
* @brief Remove the callback to receive session event notifications.
* @param cb The callback to be removed. Must not be NULL.
* @return 0 on success
* @return -1 on error
*
* @deprecated replaced by oc_remove_session_event_callback_v1 in v2.2.5.4
*/
OC_API
int oc_remove_session_event_callback(session_event_handler_t cb)
OC_DEPRECATED("replaced by oc_remove_session_event_callback_v1 in v2.2.5.4");

/**
* @brief Remove the callback with to receive session event notifications.
*
* @param cb The callback to be removed.
* @param user_data user data provided to the callback by
oc_add_session_event_callback_v1
* @param ignore_user_data ignore user_data and match only the function pointer
* @return 0 on success
* @return OC_ERR_SESSION_EVENT_HANDLER_NOT_FOUND when no match was found
* @return -1 other errors
*
* @see oc_add_session_event_callback_v1
*/
OC_API
int oc_remove_session_event_callback_v1(session_event_handler_v1_t cb,
void *user_data, bool ignore_user_data);

#ifdef __cplusplus
}
#endif
Expand Down
5 changes: 4 additions & 1 deletion port/android/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "oc_buffer.h"
#include "oc_core_res.h"
#include "oc_endpoint.h"
#include "oc_network_monitor.h"
#include "port/common/posix/oc_socket_internal.h"
#include "port/oc_assert.h"
#include "port/oc_connectivity.h"
Expand All @@ -41,6 +40,10 @@
#include "port/oc_random.h"
#include "util/oc_macros_internal.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */

#ifdef OC_SESSION_EVENTS
#include "api/oc_session_events_internal.h"
#endif /* OC_SESSION_EVENTS */
Expand Down
3 changes: 3 additions & 0 deletions port/esp32/adapter/src/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
#include "oc_buffer.h"
#include "oc_core_res.h"
#include "oc_endpoint.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */

#ifdef OC_SESSION_EVENTS
#include "api/oc_session_events_internal.h"
Expand Down
5 changes: 4 additions & 1 deletion port/linux/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "oc_buffer.h"
#include "oc_core_res.h"
#include "oc_endpoint.h"
#include "oc_network_monitor.h"
#include "port/common/posix/oc_socket_internal.h"
#include "port/oc_assert.h"
#include "port/oc_clock.h"
Expand All @@ -41,6 +40,10 @@
#include "util/oc_features.h"
#include "util/oc_macros_internal.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */

#ifdef OC_SESSION_EVENTS
#include "api/oc_session_events_internal.h"
#endif /* OC_SESSION_EVENTS */
Expand Down
2 changes: 1 addition & 1 deletion port/unittest/connectivitytest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ TEST(TestConnectivity_wakeup, WakeupInvalidDevice)
}
#endif /* OC_DYNAMIC_ALLOCATION */

#ifdef OC_NETWORK_MONITOR
static void
interface_event_handler(oc_interface_event_t event)
{
Expand All @@ -183,7 +184,6 @@ TEST_F(TestConnectivity, oc_remove_network_interface_event_callback_fail)
-1, oc_remove_network_interface_event_callback(interface_event_handler));
}

#ifdef OC_NETWORK_MONITOR
TEST_F(TestConnectivity, handle_network_interface_event_callback)
{
oc_add_network_interface_event_callback(interface_event_handler);
Expand Down
4 changes: 3 additions & 1 deletion port/windows/ipadapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "oc_buffer.h"
#include "oc_core_res.h"
#include "oc_endpoint.h"
#include "oc_network_monitor.h"
#include "port/common/posix/oc_socket_internal.h"
#include "port/oc_assert.h"
#include "port/oc_connectivity.h"
Expand All @@ -36,6 +35,9 @@
#include "util/oc_list.h"
#include "util/oc_memb.h"

#ifdef OC_NETWORK_MONITOR
#include "oc_network_monitor.h"
#endif /* OC_NETWORK_MONITOR */
#ifdef OC_TCP
#include "tcpadapter.h"
#endif /* OC_TCP */
Expand Down
1 change: 1 addition & 0 deletions swig/swig_interfaces/oc_session_events.i
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ void jni_session_events_set_event_delay(int secs)
}
%}
#define OC_API
#define OC_DEPRECATED(...)
%include "oc_session_events.h"

0 comments on commit e8bf175

Please sign in to comment.