Loading...
Searching...
No Matches
messaging.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024-2026 Carl Seifert
3 * SPDX-FileCopyrightText: 2024-2026 TU Dresden
4 * SPDX-License-Identifier: LGPL-2.1-only
5 */
6
7#pragma once
8
9#include <stdint.h>
10
11#include "net/unicoap.h"
12
17
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* MARK: - Private Messaging API */
33
60
83typedef enum {
84
100
131
132 /* MARK: unicoap_driver_extension_point */
133} __attribute__((__packed__)) unicoap_messaging_flags_t;
134
141#define UNICOAP_MESSAGING_FLAGS_DEFAULT (0)
142
152
211
235 bool truncated);
236
249
277
293int unicoap_messaging_process_rfc7252(const uint8_t* pdu, size_t size,
295
296/* MARK: unicoap_driver_extension_point */
297
314 unicoap_packet_t* packet,
316 void* exchange);
317
320 unicoap_packet_t* packet,
322 void* exchange);
323
332void unicoap_generate_token(uint8_t* token);
333
340static inline unicoap_messaging_flags_t
342{
343 /* We documented other flags are RFU, hence downcasting to the messaging
344 flags bitfield width is fine here */
345 return (unicoap_messaging_flags_t)resource_flags;
346}
347
355 unicoap_request_flags_t request_flags)
356{
357 /* We documented other flags are RFU, hence downcasting to the messaging
358 flags bitfield width is fine here */
359 return (unicoap_messaging_flags_t)request_flags;
360}
361
362
363/* MARK: - Private Exchange-Layer Server API */
380
390 const unicoap_resource_t* resource);
392
393/* MARK: - Private exchange-layer client API */
408
419 unicoap_request_flags_t request_flags);
420
433 unicoap_endpoint_t* endpoint,
434 unicoap_callback_t callback,
438
439#ifdef __cplusplus
440}
441#endif
442
unicoap_request_flags_t
Flags for enabling advanced features in client exchanges.
Definition client.h:47
int unicoap_client_send_request_body(unicoap_message_t *request, unicoap_endpoint_t *endpoint, unicoap_callback_t callback, unicoap_request_parameters_t *parameters, unicoap_request_flags_t flags)
Sends entire request body, may be split into parts and then sent.
int unicoap_server_send_response_body(unicoap_packet_t *packet, const unicoap_resource_t *resource)
Sends entire response body, may be split into parts and then sent.
unicoap_messaging_rfc7252_event_type_t
RFC 7252 event used to notify messaging layer of a change.
Definition messaging.h:253
static unicoap_messaging_flags_t _messaging_flags_resource(unicoap_resource_flags_t resource_flags)
Retrieves the part of a resource flags bitfield relevant for the messaging driver.
Definition messaging.h:341
int unicoap_client_send_request_part(unicoap_packet_t *packet, unicoap_client_memo_t *memo, unicoap_request_flags_t request_flags)
Sends part of request body, such as single request in a block-wise transfer.
int unicoap_messaging_send_rfc7252(unicoap_packet_t *packet, unicoap_messaging_flags_t flags, void *exchange)
Sends CoAP over UDP or DTLS packet, see unicoap_messaging_send.
unicoap_messaging_flags_t
Messaging layer result after initial treatment of an inbound message.
Definition messaging.h:83
int unicoap_exchange_process(unicoap_packet_t *packet, unicoap_exchange_arg_t arg)
Processes message.
int unicoap_server_process_request(unicoap_packet_t *packet, const unicoap_resource_t *resource)
Informs the unicoap server a new packet has been preprocessed and can be handled.
unicoap_preprocessing_result_t unicoap_exchange_preprocess(unicoap_packet_t *packet, unicoap_messaging_flags_t *flags, unicoap_exchange_arg_t *arg, bool truncated)
Performs initial processing of a CoAP packet after it has been parsed.
static unicoap_messaging_flags_t _messaging_flags_client(unicoap_request_flags_t request_flags)
Retrieves the part of a request flags bitfield relevant for the messaging driver.
Definition messaging.h:354
void unicoap_generate_token(uint8_t *token)
Generates new token.
int unicoap_messaging_send(unicoap_packet_t *packet, unicoap_messaging_flags_t flags, void *exchange)
Forwards packet to messaging layer and the corresponding driver for further message processing,...
unicoap_preprocessing_result_t
Result of unicoap_exchange_preprocess.
Definition messaging.h:156
int unicoap_messaging_process_rfc7252(const uint8_t *pdu, size_t size, unicoap_messaging_rfc7252_event_type_t event, unicoap_packet_t *packet)
Internal RFC 7252 messaging inbound processor.
int unicoap_client_process_response(unicoap_packet_t *packet, unicoap_client_memo_t *memo)
Informs the unicoap client a new packet has been preprocessed and can be handled.
@ UNICOAP_MESSAGING_RFC7252_EVENT_RX
'Received' event
Definition messaging.h:259
@ UNICOAP_MESSAGING_RFC7252_EVENT_SESSION_ESTABLISHED
'Session established' event
Definition messaging.h:275
@ UNICOAP_MESSAGING_RFC7252_EVENT_TRUNCATED
'Truncated' event
Definition messaging.h:267
@ UNICOAP_MESSAGING_FLAG_TRACK
Instructs the messaging layer to keep track of potential transmissions related to this packet.
Definition messaging.h:130
@ UNICOAP_MESSAGING_FLAG_RELIABLE
Messaging flag indicating the stack wants this message to be transmitted reliably.
Definition messaging.h:99
@ UNICOAP_PREPROCESSING_SUCCESS_RESPONSE
The given message can be processed.
Definition messaging.h:201
@ UNICOAP_PREPROCESSING_ERROR_NOTIFICATION_UNEXPECTED
Unexpected notification, no known client exchange (observation)
Definition messaging.h:184
@ UNICOAP_PREPROCESSING_ERROR_UNSUPPORTED
The given message cannot be processed due to being unsupported.
Definition messaging.h:170
@ UNICOAP_PREPROCESSING_ERROR_REQUEST
The given message cannot be handled, disregarded.
Definition messaging.h:194
@ UNICOAP_PREPROCESSING_ERROR_TRUNCATED
The given message is truncated and can thus not be handled.
Definition messaging.h:189
@ UNICOAP_PREPROCESSING_SUCCESS_REQUEST
The given message can be processed.
Definition messaging.h:208
@ UNICOAP_PREPROCESSING_ERROR_INVALID_CODE_CLASS
The given message's code class is not valid.
Definition messaging.h:165
@ UNICOAP_PREPROCESSING_ERROR_RESPONSE_UNEXPECTED
The given message is unexpected and cannot be processed.
Definition messaging.h:177
unicoap_resource_flags_t
Flags for enabling advanced features in server exchanges.
Definition server.h:310
struct unicoap_resource unicoap_resource_t
CoAP resource.
Definition server.h:202
event structure
Definition event.h:142
Client exchange.
Definition state.h:415
A CoAP endpoint.
Definition transport.h:204
Generic CoAP message.
Definition message.h:72
A type acting as an envelope for a message and data connected, like endpoints.
Definition packet.h:45
Additional parameters to customize request behavior.
Definition client.h:70
Main header for unicoap
Argument passed to exchange-layer processing function.
Definition messaging.h:146
unicoap_client_memo_t * client
Client memo.
Definition messaging.h:150
const unicoap_resource_t * resource
Resource.
Definition messaging.h:148