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-2021 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_
#ifndef COAP_OBS_MAX_NON
#define COAP_OBS_MAX_NON 5
#endif /* COAP_OBS_MAX_NON */
#ifndef COAP_OBS_MAX_FAIL
#define COAP_OBS_MAX_FAIL 3
#endif /* COAP_OBS_MAX_FAIL */
struct coap_subscription_t {
struct coap_subscription_t *next;
struct coap_session_t *session;
unsigned int non_cnt:4;
unsigned int fail_cnt:2;
unsigned int dirty:1;
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_binary_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_binary_t *token,
const coap_pdu_t *pdu);
coap_subscription_t *coap_find_observer(coap_resource_t *resource,
coap_session_t *session,
const coap_binary_t *token);
void coap_touch_observer(coap_context_t *context,
coap_session_t *session,
const coap_binary_t *token);
int coap_delete_observer(coap_resource_t *resource,
coap_session_t *session,
const coap_binary_t *token);
void coap_delete_observers(coap_context_t *context, coap_session_t *session);
#endif /* COAP_SUBSCRIBE_INTERNAL_H_ */
coap_delete_observer
int coap_delete_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token)
Removes any subscription for observer from resource and releases the allocated storage.
Definition: resource.c:816
coap_add_observer
coap_subscription_t * coap_add_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token, const coap_pdu_t *pdu)
Adds the specified peer as observer for resource.
Definition: resource.c:721
coap_find_observer
coap_subscription_t * coap_find_observer(coap_resource_t *resource, coap_session_t *session, const coap_binary_t *token)
Returns a subscription object for given peer.
Definition: resource.c:686
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.
Definition: resource.c:842
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.
Definition: resource.c:1062
coap_handle_failed_notify
void coap_handle_failed_notify(coap_context_t *context, coap_session_t *session, const coap_binary_t *token)
Handles a failed observe notify.
Definition: resource.c:1125
coap_subscription_init
void coap_subscription_init(coap_subscription_t *)
Definition: subscribe.c:15
coap_touch_observer
void coap_touch_observer(coap_context_t *context, coap_session_t *session, const coap_binary_t *token)
Flags that data is ready to be sent to observers.
Definition: resource.c:803
coap_binary_t
CoAP binary data definition.
Definition: str.h:50
coap_cache_key_t
Definition: coap_cache_internal.h:34
coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
Definition: coap_net_internal.h:45
coap_pdu_t
structure for CoAP PDUs token, if any, follows the fixed size header, then options until payload mark...
Definition: coap_pdu_internal.h:94
coap_resource_t
Abstraction of resource that can be attached to coap_context_t.
Definition: coap_resource_internal.h:42
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:48
coap_session_t::context
coap_context_t * context
session's context
Definition: coap_session_internal.h:63
coap_subscription_t
Subscriber information.
Definition: coap_subscribe_internal.h:47
coap_subscription_t::fail_cnt
unsigned int fail_cnt
up to 3 confirmable notifies can fail
Definition: coap_subscribe_internal.h:52
coap_subscription_t::non_cnt
unsigned int non_cnt
up to 15 non-confirmable notifies allowed
Definition: coap_subscribe_internal.h:51
coap_subscription_t::cache_key
coap_cache_key_t * cache_key
Definition: coap_subscribe_internal.h:56
coap_subscription_t::session
struct coap_session_t * session
subscriber session
Definition: coap_subscribe_internal.h:49
coap_subscription_t::dirty
unsigned int dirty
set if the notification temporarily could not be sent (in that case, the resource's partially dirty f...
Definition: coap_subscribe_internal.h:53
coap_subscription_t::next
struct coap_subscription_t * next
next element in linked list
Definition: coap_subscribe_internal.h:48
coap_subscription_t::pdu
coap_pdu_t * pdu
cache_key to identify requester
Definition: coap_subscribe_internal.h:57