mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-30 02:07:09 +03:00
add coap_session_get_endpoint, coap_endpoint_get_app_data and coap_endpoint_set_app_data
This commit is contained in:
1 parent
ce2057b7a9
commit
0ec5f799f2
7 files changed
+143
-1
No files matched your search
@@ -203,6 +203,15 @@ coap_session_type_t coap_session_get_type(const coap_session_t *session);
|
||||
*/
|
||||
coap_session_state_t coap_session_get_state(const coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Get the endpoint of a session
|
||||
*
|
||||
* @param session The CoAP session.
|
||||
*
|
||||
* @return The session's endpoint, or @c NULL on error.
|
||||
*/
|
||||
coap_endpoint_t *coap_session_get_endpoint(const coap_session_t *session);
|
||||
|
||||
/**
|
||||
* Get the session if index
|
||||
*
|
||||
@@ -455,6 +464,36 @@ void coap_endpoint_set_default_mtu(coap_endpoint_t *endpoint, unsigned mtu);
|
||||
*/
|
||||
COAP_API void coap_free_endpoint(coap_endpoint_t *endpoint);
|
||||
|
||||
/**
|
||||
* Returns any application-specific data that has been stored with @p
|
||||
* endpoint using the function coap_endpoint_set_app_data(). This function
|
||||
* will return @c NULL if no data has been stored.
|
||||
*
|
||||
* @param endpoint The CoAP endpoint.
|
||||
*
|
||||
* @return Pointer to the stored data or @c NULL.
|
||||
*/
|
||||
void *coap_endpoint_get_app_data(const coap_endpoint_t *endpoint);
|
||||
|
||||
/**
|
||||
* Stores @p data with the given endpoint, returning the previously stored
|
||||
* value or NULL. The data @p callback can be defined if the data is to be
|
||||
* released when the endpoint is deleted.
|
||||
*
|
||||
* Note: It is the responsibility of the caller to free off (if appropriate) any
|
||||
* returned data.
|
||||
*
|
||||
* @param endpoint The CoAP endpoint.
|
||||
* @param data The pointer to the data to store or NULL to just clear out the
|
||||
* previous data.
|
||||
* @param callback The optional release call-back for data on endpoint
|
||||
* removal or NULL.
|
||||
*
|
||||
* @return The previous data (if any) stored in the endpoint.
|
||||
*/
|
||||
COAP_API void *coap_endpoint_set_app_data(coap_endpoint_t *endpoint, void *data,
|
||||
coap_app_data_free_callback_t callback);
|
||||
|
||||
/**
|
||||
* Get the session associated with the specified @p remote_addr and @p index.
|
||||
*
|
||||
|
||||
@@ -255,6 +255,9 @@ struct coap_endpoint_t {
|
||||
any */
|
||||
coap_address_t bind_addr; /**< local interface address */
|
||||
coap_session_t *sessions; /**< hash table or list of active sessions */
|
||||
|
||||
void *app_data; /**< application-specific data */
|
||||
coap_app_data_free_callback_t app_cb; /**< call-back to release app_data */
|
||||
};
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
@@ -651,6 +654,27 @@ void coap_session_server_keepalive_failed(coap_session_t *session);
|
||||
void *coap_session_set_app_data2_lkd(coap_session_t *session, void *data,
|
||||
coap_app_data_free_callback_t callback);
|
||||
|
||||
/**
|
||||
* Stores @p data with the given endpoint, returning the previously stored
|
||||
* value or NULL. The data @p callback can be defined if the data is to be
|
||||
* released when the endpoint is deleted.
|
||||
*
|
||||
* Note: This function must be called in the locked state.
|
||||
*
|
||||
* Note: It is the responsibility of the caller to free off (if appropriate) any
|
||||
* returned data.
|
||||
*
|
||||
* @param endpoint The CoAP endpoint.
|
||||
* @param data The pointer to the data to store or NULL to just clear out the
|
||||
* previous data.
|
||||
* @param callback The optional release call-back for data on endpoint
|
||||
* removal or NULL.
|
||||
*
|
||||
* @return The previous data (if any) stored in the endpoint.
|
||||
*/
|
||||
void *coap_endpoint_set_app_data_lkd(coap_endpoint_t *endpoint, void *data,
|
||||
coap_app_data_free_callback_t callback);
|
||||
|
||||
void coap_session_free(coap_session_t *session);
|
||||
void coap_session_mfree(coap_session_t *session);
|
||||
|
||||
|
||||
Reference in new issue
Block a user