libcoap 4.3.1
coap_net_internal.h
Go to the documentation of this file.
1/*
2 * coap_net_internal.h -- CoAP context internal information
3 * exposed to application programming
4 *
5 * Copyright (C) 2010-2022 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_NET_INTERNAL_H_
19#define COAP_NET_INTERNAL_H_
20
21#include "coap_internal.h"
22
36 unsigned char retransmit_cnt;
38 uint8_t is_mcast;
39 unsigned int timeout;
43};
44
50#if COAP_SERVER_SUPPORT
60#endif /* COAP_SERVER_SUPPORT */
61
62#ifndef WITHOUT_ASYNC
66#endif /* WITHOUT_ASYNC */
67
73#if COAP_SERVER_SUPPORT
75#endif /* COAP_SERVER_SUPPORT */
76#if COAP_CLIENT_SUPPORT
78#endif /* COAP_CLIENT_SUPPORT */
79
80#ifdef WITH_CONTIKI
81 struct uip_udp_conn *conn;
82 struct etimer retransmit_timer;
84 struct etimer notify_timer;
85#endif /* WITH_CONTIKI */
86
87#ifdef WITH_LWIP
88 uint8_t timer_configured;
91#endif /* WITH_LWIP */
92
93#if COAP_CLIENT_SUPPORT
95#endif /* COAP_CLIENT_SUPPORT */
99
105
106 ssize_t (*network_send)(coap_socket_t *sock, const coap_session_t *session,
107 const uint8_t *data, size_t datalen);
108
109 ssize_t (*network_read)(coap_socket_t *sock, coap_packet_t *packet);
110
112
113#if COAP_SERVER_SUPPORT
116#endif /* COAP_SERVER_SUPPORT */
117
118 unsigned int session_timeout;
121 unsigned int max_idle_sessions;
127 unsigned int ping_timeout;
130 unsigned int csm_timeout;
133 uint64_t etag;
135#if COAP_SERVER_SUPPORT
141#endif /* COAP_SERVER_SUPPORT */
142 void *app;
143#ifdef COAP_EPOLL_SUPPORT
144 int epfd;
145 int eptimerfd;
146 coap_tick_t next_timeout;
147#endif /* COAP_EPOLL_SUPPORT */
148#if COAP_SERVER_SUPPORT
152#endif /* COAP_SERVER_SUPPORT */
153 uint8_t block_mode;
154};
155
164int coap_insert_node(coap_queue_t **queue, coap_queue_t *node);
165
174
182void coap_delete_all(coap_queue_t *queue);
183
190
196unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now);
197
202
207
218
232int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len);
233
251 coap_session_t *session,
252 coap_mid_t id,
253 coap_queue_t **node);
254
257 coap_queue_t *node);
258
269 coap_session_t *session,
270 const uint8_t *token,
271 size_t token_length);
272
280void
282 coap_session_t *session,
283 coap_nack_reason_t reason);
284
288void coap_dispatch(coap_context_t *context, coap_session_t *session,
289 coap_pdu_t *pdu);
290
323 coap_pdu_t *pdu,
324 coap_opt_filter_t *unknown);
325
338 coap_session_t *session,
339 coap_pdu_t *request);
340
354unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r);
355
372
382
385#endif /* COAP_NET_INTERNAL_H_ */
386
Pulls together all the internal only header files.
coap_nack_reason_t
Definition: coap_io.h:69
uint64_t coap_tick_t
This data type represents internal timer ticks with COAP_TICKS_PER_SECOND resolution.
Definition: coap_time.h:127
void(* coap_resource_release_userdata_handler_t)(void *user_data)
Definition of release resource user_data callback function.
Definition: resource.h:320
unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now)
Set sendqueue_basetime in the given context object ctx to now.
Definition: net.c:162
void coap_delete_all(coap_queue_t *queue)
Removes all items from given queue and frees the allocated storage.
Definition: net.c:256
int coap_remove_from_queue(coap_queue_t **queue, coap_session_t *session, coap_mid_t id, coap_queue_t **node)
This function removes the element with given id from the list given list.
Definition: net.c:2077
int coap_delete_node(coap_queue_t *node)
Destroys specified node.
Definition: net.c:236
coap_queue_t * coap_peek_next(coap_context_t *context)
Returns the next pdu to send without removing from sendqeue.
Definition: net.c:279
coap_pdu_t * coap_wellknown_response(coap_context_t *context, coap_session_t *session, coap_pdu_t *request)
Creates a new response for given request with the contents of .well-known/core.
int coap_client_delay_first(coap_session_t *session)
Delay the sending of the first client request until some other negotiation has completed.
Definition: net.c:1045
coap_queue_t * coap_pop_next(coap_context_t *context)
Returns the next pdu to send and removes it from the sendqeue.
Definition: net.c:287
void coap_dispatch(coap_context_t *context, coap_session_t *session, coap_pdu_t *pdu)
Dispatches the PDUs from the receive queue in given context.
Definition: net.c:3160
coap_mid_t coap_send_internal(coap_session_t *session, coap_pdu_t *pdu)
Sends a CoAP message to given peer.
Definition: net.c:1242
int coap_insert_node(coap_queue_t **queue, coap_queue_t *node)
Adds node to given queue, ordered by variable t in node.
Definition: net.c:199
unsigned int coap_calc_timeout(coap_session_t *session, unsigned char r)
Calculates the initial timeout based on the session CoAP transmission parameters 'ack_timeout',...
Definition: net.c:956
coap_mid_t coap_retransmit(coap_context_t *context, coap_queue_t *node)
Handles retransmissions of confirmable messages.
Definition: net.c:1447
void coap_cancel_all_messages(coap_context_t *context, coap_session_t *session, const uint8_t *token, size_t token_length)
Cancels all outstanding messages for session session that have the specified token.
Definition: net.c:2158
int coap_option_check_critical(coap_session_t *session, coap_pdu_t *pdu, coap_opt_filter_t *unknown)
Verifies that pdu contains no unknown critical options.
Definition: net.c:688
coap_mid_t coap_wait_ack(coap_context_t *context, coap_session_t *session, coap_queue_t *node)
Definition: net.c:982
coap_queue_t * coap_new_node(void)
Creates a new node suitable for adding to the CoAP sendqueue.
Definition: net.c:265
void coap_cancel_session_messages(coap_context_t *context, coap_session_t *session, coap_nack_reason_t reason)
Cancels all outstanding messages for session session.
Definition: net.c:2121
int coap_handle_dgram(coap_context_t *ctx, coap_session_t *session, uint8_t *data, size_t data_len)
Parses and interprets a CoAP datagram with context ctx.
Definition: net.c:2040
void(* coap_pong_handler_t)(coap_session_t *session, const coap_pdu_t *received, const coap_mid_t mid)
Received Pong handler that is used as callback in coap_context_t.
Definition: net.h:97
coap_response_t(* coap_response_handler_t)(coap_session_t *session, const coap_pdu_t *sent, const coap_pdu_t *received, const coap_mid_t mid)
Response handler that is used as callback in coap_context_t.
Definition: net.h:61
void(* coap_ping_handler_t)(coap_session_t *session, const coap_pdu_t *received, const coap_mid_t mid)
Received Ping handler that is used as callback in coap_context_t.
Definition: net.h:86
void(* coap_nack_handler_t)(coap_session_t *session, const coap_pdu_t *sent, const coap_nack_reason_t reason, const coap_mid_t mid)
Negative Acknowedge handler that is used as callback in coap_context_t.
Definition: net.h:74
int(* coap_event_handler_t)(coap_session_t *session, const coap_event_t event)
Type for event handler functions that can be registered with a CoAP context using the unction coap_se...
Definition: coap_event.h:105
int coap_mid_t
coap_mid_t is used to store the CoAP Message ID of a CoAP PDU.
Definition: pdu.h:243
The CoAP stack's global state is stored in a coap_context_t object.
coap_tick_t sendqueue_basetime
The time stamp in the first element of the sendqeue is relative to sendqueue_basetime.
coap_pong_handler_t pong_handler
uint64_t etag
Next ETag to use.
unsigned int csm_timeout
Timeout for waiting for a CSM from the remote side.
void * app
application-specific data
coap_async_t * async_state
list of asynchronous message ids
coap_session_t * sessions
client sessions
coap_nack_handler_t nack_handler
unsigned int ping_timeout
Minimum inactivity time before sending a ping message.
coap_resource_t * resources
hash table or list of known resources
ssize_t(* network_send)(coap_socket_t *sock, const coap_session_t *session, const uint8_t *data, size_t datalen)
uint16_t * cache_ignore_options
CoAP options to ignore when creating a cache-key.
coap_opt_filter_t known_options
coap_resource_release_userdata_handler_t release_userdata
function to release user_data when resource is deleted
coap_ping_handler_t ping_handler
uint32_t csm_max_message_size
Value for CSM Max-Message-Size.
size_t cache_ignore_count
The number of CoAP options to ignore when creating a cache-key.
unsigned int max_handshake_sessions
Maximum number of simultaneous negotating sessions per endpoint.
coap_queue_t * sendqueue
coap_response_handler_t response_handler
coap_cache_entry_t * cache
CoAP cache-entry cache.
uint8_t mcast_per_resource
Mcast controlled on a per resource basis.
uint8_t observe_pending
Observe response pending.
coap_endpoint_t * endpoint
the endpoints used for listening
coap_event_handler_t handle_event
Callback function that is used to signal events to the application.
unsigned int session_timeout
Number of seconds of inactivity after which an unused session will be closed.
ssize_t(* network_read)(coap_socket_t *sock, coap_packet_t *packet)
coap_resource_t * proxy_uri_resource
can be used for handling proxy URI resources
coap_dtls_spsk_t spsk_setup_data
Contains the initial PSK server setup data.
uint8_t block_mode
Zero or more COAP_BLOCK_ or'd options.
coap_resource_t * unknown_resource
can be used for handling unknown resources
unsigned int max_idle_sessions
Maximum number of simultaneous unused sessions per endpoint.
The structure used for defining the Server PSK setup data to be used.
Definition: coap_dtls.h:437
Abstraction of virtual endpoint that can be attached to coap_context_t.
structure for CoAP PDUs
Queue entry.
coap_session_t * session
the CoAP session
coap_pdu_t * pdu
the CoAP PDU to send
unsigned int timeout
the randomized timeout value
uint8_t is_mcast
Set if this is a queued mcast response.
struct coap_queue_t * next
coap_mid_t id
CoAP message id.
coap_tick_t t
when to send PDU for the next time
unsigned char retransmit_cnt
retransmission counter, will be removed when zero
Abstraction of resource that can be attached to coap_context_t.
Abstraction of virtual session that can be attached to coap_context_t (client) or coap_endpoint_t (se...