1COAP_CONTEXT(3)                 libcoap Manual                 COAP_CONTEXT(3)
2
3
4

NAME

6       coap_context, coap_new_context, coap_free_context,
7       coap_context_set_max_idle_sessions, coap_context_get_max_idle_sessions,
8       coap_context_set_max_handshake_sessions,
9       coap_context_get_max_handshake_sessions,
10       coap_context_set_session_timeout, coap_context_get_session_timeout -
11       Work with CoAP contexts
12

SYNOPSIS

14       #include <coap3/coap.h>
15
16       coap_context_t *coap_new_context(const coap_address_t *listen_addr);
17
18       void coap_free_context(coap_context_t *context);
19
20       void coap_context_set_max_idle_sessions(coap_context_t *context,
21       unsigned int max_idle_sessions);
22
23       unsigned int coap_context_get_max_idle_sessions( const coap_context_t
24       *context);
25
26       void coap_context_set_max_handshake_sessions(coap_context_t *context,
27       unsigned int max_handshake_sessions);
28
29       unsigned int coap_context_get_max_handshake_sessions( const
30       coap_context_t *context);
31
32       void coap_context_set_session_timeout(coap_context_t *context, unsigned
33       int session_timeout);
34
35       unsigned int coap_context_get_session_timeout( const coap_context_t
36       *context);
37
38       void coap_context_set_csm_timeout(coap_context_t *context, unsigned int
39       csm_timeout);
40
41       unsigned int coap_context_get_csm_timeout(const coap_context_t
42       *context);
43
44       For specific (D)TLS library support, link with -lcoap-3-notls,
45       -lcoap-3-gnutls, -lcoap-3-openssl, -lcoap-3-mbedtls or
46       -lcoap-3-tinydtls. Otherwise, link with -lcoap-3 to get the default
47       (D)TLS library support.
48

DESCRIPTION

50       This man page focuses on the CoAP Context and how to update or get
51       information from the opaque coap_context_t structure.
52
53       The CoAP stack’s global state is stored in a coap_context_t Context
54       object. Resources, Endpoints and Sessions are associated with this
55       context object. There can be more than one coap_context_t object per
56       application, it is up to the application to manage each one
57       accordingly.
58
59       The coap_new_context() function creates a new Context that is then used
60       to keep all the CoAP Resources, Endpoints and Sessions information. The
61       optional listen_addr parameter, if set for a CoAP server, creates an
62       Endpoint that is added to the context that is listening for
63       un-encrypted traffic on the IP address and port number defined by
64       listen_addr.
65
66       The coap_free_context() function must be used to release the CoAP stack
67       context. It clears all entries from the receive queue and send queue
68       and deletes the Resources that have been registered with context, and
69       frees the attached Sessions and Endpoints.
70
71       The coap_context_set_max_idle_sessions() function sets the maximum
72       number of idle server sessions to max_idle_sessions for context. If
73       this number is exceeded, the least recently used server session is
74       completely removed. 0 (the initial default) means that the number of
75       idle sessions is not monitored.
76
77       The coap_context_get_max_idle_sessions() function returns the maximum
78       number of idle server sessions for context.
79
80       The coap_context_set_max_handshake_sessions() function sets the maximum
81       number of outstanding server sessions in (D)TLS handshake to
82       max_handshake_sessions for context. If this number is exceeded, the
83       least recently used server session in handshake is completely removed.
84       0 (the default) means that the number of handshakes is not monitored.
85
86       The coap_context_get_max_handshake_sessions() function returns the
87       maximum number of outstanding server sessions in (D)TLS handshake for
88       context.
89
90       The coap_context_set_session_timeout() function sets the number of
91       seconds of inactivity to session_timeout for context before an idle
92       server session is removed. 0 (the default) means wait for the default
93       of 300 seconds.
94
95       The coap_context_get_session_timeout() function returns the seconds to
96       wait before timing out an idle server session for context.
97
98       The coap_context_set_csm_timeout() function sets the number of seconds
99       to wait for a (TCP) CSM negotiation response from the peer to
100       csm_timeout for context. 0 (the default) means wait forever.
101
102       The coap_context_get_csm_timeout() function returns the seconds to wait
103       for a (TCP) CSM negotiation response from the peer for context,
104

RETURN VALUES

106       coap_new_context() function returns a newly created context or NULL if
107       there is a creation failure.
108
109       coap_context_get_max_idle_sessions() returns the maximum number of idle
110       server sessions.
111
112       coap_context_get_max_handshake_sessions() returns the maximum number of
113       outstanding server sessions in (D)TLS handshake.
114
115       coap_context_get_session_timeout() returns the seconds to wait before
116       timing out an idle server session.
117
118       coap_context_get_csm_timeout() returns the seconds to wait for a (TCP)
119       CSM negotiation response from the peer.
120

SEE ALSO

122       coap_session(3)
123

FURTHER INFORMATION

125       See "RFC7252: The Constrained Application Protocol (CoAP)" for further
126       information.
127

BUGS

129       Please report bugs on the mailing list for libcoap:
130       libcoap-developers@lists.sourceforge.net or raise an issue on GitHub at
131       https://github.com/obgm/libcoap/issues
132

AUTHORS

134       The libcoap project <libcoap-developers@lists.sourceforge.net>
135
136
137
138coap_context 4.3.0                01/20/2022                   COAP_CONTEXT(3)
Impressum