Loading...
Searching...
No Matches
coap_subscribe_internal.h
Go to the documentation of this file.
/*
* coap_subscribe_internal.h -- Structures, Enums & Functions that are not
* exposed to application programming
*
* Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
#ifndef COAP_SUBSCRIBE_INTERNAL_H_
#define COAP_SUBSCRIBE_INTERNAL_H_
#include "coap_internal.h"
#if COAP_SERVER_SUPPORT
#ifndef COAP_OBS_MAX_NON
#define COAP_OBS_MAX_NON 5
#endif /* COAP_OBS_MAX_NON */
#if COAP_OBS_MAX_NON > 255
#error COAP_OBS_MAX_NON is too large
#endif /* COAP_OBS_MAX_NON > 255 */
#ifndef COAP_OBS_MAX_FAIL
#define COAP_OBS_MAX_FAIL 1
#endif /* COAP_OBS_MAX_FAIL */
#if COAP_OBS_MAX_FAIL > 255
#error COAP_OBS_MAX_FAIL is too large
#endif /* COAP_OBS_MAX_FAIL > 255 */
struct coap_subscription_t {
struct coap_subscription_t *next;
struct coap_session_t *session;
uint8_t non_cnt;
uint8_t fail_cnt;
uint8_t dirty;
coap_cache_key_t *cache_key;
coap_pdu_t *pdu;
};
void coap_subscription_init(coap_subscription_t *);
void coap_handle_failed_notify(coap_context_t *context,
coap_session_t *session,
const coap_bin_const_t *token);
void coap_check_notify(coap_context_t *context);
coap_subscription_t *coap_add_observer(coap_resource_t *resource,
coap_session_t *session,
const coap_bin_const_t *token,
const coap_pdu_t *pdu);
coap_subscription_t *coap_find_observer(coap_resource_t *resource,
coap_session_t *session,
const coap_bin_const_t *token);
void coap_touch_observer(coap_context_t *context,
coap_session_t *session,
const coap_bin_const_t *token);
int coap_delete_observer(coap_resource_t *resource,
coap_session_t *session,
const coap_bin_const_t *token);
void coap_delete_observers(coap_context_t *context, coap_session_t *session);
void coap_persist_cleanup(coap_context_t *context);
#endif /* COAP_SERVER_SUPPORT */
#endif /* COAP_SUBSCRIBE_INTERNAL_H_ */
coap_internal.h
Pulls together all the internal only header files.
coap_persist_cleanup
void coap_persist_cleanup(coap_context_t *context)
Close down persist tracking, releasing any memory used.
coap_delete_observer
int coap_delete_observer(coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token)
Removes any subscription for observer from resource and releases the allocated storage.
coap_find_observer
coap_subscription_t * coap_find_observer(coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token)
Returns a subscription object for given peer.
coap_delete_observers
void coap_delete_observers(coap_context_t *context, coap_session_t *session)
Removes any subscription for session and releases the allocated storage.
coap_check_notify
void coap_check_notify(coap_context_t *context)
Checks all known resources to see if they are dirty and then notifies subscribed observers.
coap_handle_failed_notify
void coap_handle_failed_notify(coap_context_t *context, coap_session_t *session, const coap_bin_const_t *token)
Handles a failed observe notify.
coap_subscription_init
void coap_subscription_init(coap_subscription_t *)
coap_add_observer
coap_subscription_t * coap_add_observer(coap_resource_t *resource, coap_session_t *session, const coap_bin_const_t *token, const coap_pdu_t *pdu)
Adds the specified peer as observer for resource.
coap_touch_observer
void coap_touch_observer(coap_context_t *context, coap_session_t *session, const coap_bin_const_t *token)
Flags that data is ready to be sent to observers.
coap_bin_const_t
CoAP binary data definition with const data.
Definition coap_str.h:64
coap_cache_key_t
Definition coap_cache_internal.h:37
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition coap_net_internal.h:49
coap_pdu_t
structure for CoAP PDUs
Definition coap_pdu_internal.h:119
coap_resource_t
Abstraction of resource that can be attached to coap_context_t.
Definition coap_resource_internal.h:53
coap_session_t
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...
Definition coap_session_internal.h:68
coap_session_t::context
coap_context_t * context
session's context
Definition coap_session_internal.h:86
coap_subscription_t
Number of notifications that may be sent non-confirmable before a confirmable message is sent to dete...
Definition coap_subscribe_internal.h:57
coap_subscription_t::dirty
uint8_t dirty
set if the notification temporarily could not be sent (in that case, the resource's partially dirty f...
Definition coap_subscribe_internal.h:63
coap_subscription_t::non_cnt
uint8_t non_cnt
up to 255 non-confirmable notifies allowed
Definition coap_subscribe_internal.h:61
coap_subscription_t::cache_key
coap_cache_key_t * cache_key
Definition coap_subscribe_internal.h:66
coap_subscription_t::session
struct coap_session_t * session
subscriber session
Definition coap_subscribe_internal.h:59
coap_subscription_t::fail_cnt
uint8_t fail_cnt
up to 255 confirmable notifies can fail
Definition coap_subscribe_internal.h:62
coap_subscription_t::next
struct coap_subscription_t * next
next element in linked list
Definition coap_subscribe_internal.h:58
coap_subscription_t::pdu
coap_pdu_t * pdu
cache_key to identify requester
Definition coap_subscribe_internal.h:67