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
101 /* MARK: unicoap_driver_extension_point */
102} __attribute__((__packed__)) unicoap_messaging_flags_t;
103
110#define UNICOAP_MESSAGING_FLAGS_DEFAULT (0)
111
120
179
203 bool truncated);
204
217
229
246int unicoap_messaging_process_rfc7252(const uint8_t* pdu, size_t size, bool truncated,
247 unicoap_packet_t* packet);
248
249/* MARK: unicoap_driver_extension_point */
250
265
268
277void unicoap_generate_token(uint8_t* token);
278
285static inline unicoap_messaging_flags_t
287{
288 /* We documented other flags are RFU, hence downcasting to the messaging
289 flags bitfield width is fine here */
290 return (unicoap_messaging_flags_t)resource_flags;
291}
292
293
294/* MARK: - Private Exchange-Layer Server API */
311
321 const unicoap_resource_t* resource);
323
324#ifdef __cplusplus
325}
326#endif
327
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.
int unicoap_messaging_send(unicoap_packet_t *packet, unicoap_messaging_flags_t flags)
Forwards packet to messaging layer and the corresponding driver for further message processing,...
int unicoap_exchange_release_endpoint_state(const unicoap_endpoint_t *endpoint)
Releases all buffers and state allocated in connection with the given endpoint.
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:286
int unicoap_messaging_send_rfc7252(unicoap_packet_t *packet, unicoap_messaging_flags_t flags)
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.
int unicoap_messaging_process_rfc7252(const uint8_t *pdu, size_t size, bool truncated, unicoap_packet_t *packet)
Internal RFC 7252 messaging inbound processor.
void unicoap_generate_token(uint8_t *token)
Generates new token.
unicoap_preprocessing_result_t
Result of unicoap_exchange_preprocess.
Definition messaging.h:124
@ 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:169
@ UNICOAP_PREPROCESSING_ERROR_NOTIFICATION_UNEXPECTED
Unexpected notification, no known client exchange (observation)
Definition messaging.h:152
@ UNICOAP_PREPROCESSING_ERROR_UNSUPPORTED
The given message cannot be processed due to being unsupported.
Definition messaging.h:138
@ UNICOAP_PREPROCESSING_ERROR_REQUEST
The given message cannot be handled, disregarded.
Definition messaging.h:162
@ UNICOAP_PREPROCESSING_ERROR_TRUNCATED
The given message is truncated and can thus not be handled.
Definition messaging.h:157
@ UNICOAP_PREPROCESSING_SUCCESS_REQUEST
The given message can be processed.
Definition messaging.h:176
@ UNICOAP_PREPROCESSING_ERROR_INVALID_CODE_CLASS
The given message's code class is not valid.
Definition messaging.h:133
@ UNICOAP_PREPROCESSING_ERROR_RESPONSE_UNEXPECTED
The given message is unexpected and cannot be processed.
Definition messaging.h:145
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
A CoAP endpoint.
Definition transport.h:182
A type acting as an envelope for a message and data connected, like endpoints.
Definition packet.h:45
Main header for unicoap
Argument passed to exchange-layer processing function.
Definition messaging.h:115
const unicoap_resource_t * resource
Resource.
Definition messaging.h:117