• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * coap_subscribe_internal.h -- Structures, Enums & Functions that are not
3  * exposed to application programming
4  *
5  * Copyright (C) 2010-2019 Olaf Bergmann <bergmann@tzi.org>
6  *
7  * This file is part of the CoAP library libcoap. Please see README for terms
8  * of use.
9  */
10 
11 /**
12  * @file coap_subscribe_internal.h
13  * @brief COAP subscribe internal information
14  */
15 
16 #ifndef COAP_SUBSCRIBE_INTERNAL_H_
17 #define COAP_SUBSCRIBE_INTERNAL_H_
18 
19 /**
20  * @defgroup subscribe_internal Subscribe (Internal)
21  * Structures, Enums and Functions that are not exposed to applications
22  * @{
23  */
24 
25 #ifndef COAP_OBS_MAX_NON
26 /**
27  * Number of notifications that may be sent non-confirmable before a confirmable
28  * message is sent to detect if observers are alive. The maximum allowed value
29  * here is @c 15.
30  */
31 #define COAP_OBS_MAX_NON   5
32 #endif /* COAP_OBS_MAX_NON */
33 
34 #ifndef COAP_OBS_MAX_FAIL
35 /**
36  * Number of confirmable notifications that may fail (i.e. time out without
37  * being ACKed) before an observer is removed. The maximum value for
38  * COAP_OBS_MAX_FAIL is @c 3.
39  */
40 #define COAP_OBS_MAX_FAIL  3
41 #endif /* COAP_OBS_MAX_FAIL */
42 
43 /** Subscriber information */
44 struct coap_subscription_t {
45   struct coap_subscription_t *next; /**< next element in linked list */
46   struct coap_session_t *session;   /**< subscriber session */
47 
48   unsigned int non_cnt:4;  /**< up to 15 non-confirmable notifies allowed */
49   unsigned int fail_cnt:2; /**< up to 3 confirmable notifies can fail */
50   unsigned int dirty:1;    /**< set if the notification temporarily could not be
51                             *   sent (in that case, the resource's partially
52                             *   dirty flag is set too) */
53   unsigned int has_block2:1; /**< GET request had Block2 definition */
54   uint16_t tid;             /**< transaction id, if any, in regular host byte order */
55   coap_block_t block2;     /**< GET request Block2 definition */
56   size_t token_length;     /**< actual length of token */
57   unsigned char token[8];  /**< token used for subscription */
58   struct coap_string_t *query; /**< query string used for subscription, if any */
59 };
60 
61 void coap_subscription_init(coap_subscription_t *);
62 
63 /** @} */
64 
65 #endif /* COAP_SUBSCRIBE_INTERNAL_H_ */
66