libcoap 4.3.2rc2

coap_subscribe_internal.h
Go to the documentation of this file.
1/*
2 * coap_subscribe_internal.h -- Structures, Enums & Functions that are not
3 * exposed to application programming
4 *
5 * Copyright (C) 2010-2023 Olaf Bergmann <bergmann@tzi.org>
6 *
7 * SPDX-License-Identifier: BSD-2-Clause
8 *
9 * This file is part of the CoAP library libcoap. Please see README for terms
10 * of use.
11 */
12
18#ifndef COAP_SUBSCRIBE_INTERNAL_H_
19#define COAP_SUBSCRIBE_INTERNAL_H_
20
21#include "coap_internal.h"
22
23#if COAP_SERVER_SUPPORT
24
37#ifndef COAP_OBS_MAX_NON
38#define COAP_OBS_MAX_NON 5
39#endif /* COAP_OBS_MAX_NON */
40#if COAP_OBS_MAX_NON > 255
41#error COAP_OBS_MAX_NON is too large
42#endif /* COAP_OBS_MAX_NON > 255 */
43
49#ifndef COAP_OBS_MAX_FAIL
50#define COAP_OBS_MAX_FAIL 1
51#endif /* COAP_OBS_MAX_FAIL */
52#if COAP_OBS_MAX_FAIL > 255
53#error COAP_OBS_MAX_FAIL is too large
54#endif /* COAP_OBS_MAX_FAIL > 255 */
55
57 struct coap_subscription_t {
58 struct coap_subscription_t *next;
59 struct coap_session_t *session;
61 uint8_t non_cnt;
62 uint8_t fail_cnt;
63 uint8_t dirty;
66 coap_cache_key_t *cache_key;
67 coap_pdu_t *pdu;
68};
69
70 void coap_subscription_init(coap_subscription_t *);
71
79 void coap_handle_failed_notify(coap_context_t *context,
80 coap_session_t *session,
81 const coap_bin_const_t *token);
82
89 void coap_check_notify(coap_context_t *context);
90
105 coap_subscription_t *coap_add_observer(coap_resource_t *resource,
106 coap_session_t *session,
107 const coap_bin_const_t *token,
108 const coap_pdu_t *pdu);
109
119 coap_subscription_t *coap_find_observer(coap_resource_t *resource,
120 coap_session_t *session,
121 const coap_bin_const_t *token);
122
131 void coap_touch_observer(coap_context_t *context,
132 coap_session_t *session,
133 const coap_bin_const_t *token);
134
146 int coap_delete_observer(coap_resource_t *resource,
147 coap_session_t *session,
148 const coap_bin_const_t *token);
149
156 void coap_delete_observers(coap_context_t *context, coap_session_t *session);
157
163 void coap_persist_cleanup(coap_context_t *context);
164
167#endif /* COAP_SERVER_SUPPORT */
168#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