|
| 1 | +/* |
| 2 | + * Copyright (C) 2024 ML!PA Consulting GmbH |
| 3 | + * |
| 4 | + * This file is subject to the terms and conditions of the GNU Lesser General |
| 5 | + * Public License v2.1. See the file LICENSE in the top level directory for |
| 6 | + * more details. |
| 7 | + */ |
| 8 | + |
| 9 | +/** |
| 10 | + * @defgroup net_gcoap_forward_proxy_thread GCoAP Forward Proxy Thread |
| 11 | + * @ingroup net_gcoap |
| 12 | + * @brief Forward proxy thread implementation for GCoAP |
| 13 | + * |
| 14 | + * @{ |
| 15 | + * |
| 16 | + * @file |
| 17 | + * @brief Definitions for the GCoAP forward proxy internal communication |
| 18 | + * |
| 19 | + * @author Mariem Charrada <[email protected]> |
| 20 | + */ |
| 21 | + |
| 22 | +#ifndef FORWARD_PROXY_INTERNAL_H |
| 23 | +#define FORWARD_PROXY_INTERNAL_H |
| 24 | + |
| 25 | +#include <stdint.h> |
| 26 | +#include "net/coap.h" |
| 27 | +#include "net/gcoap.h" |
| 28 | +#include "net/sock/udp.h" |
| 29 | +#include "ztimer.h" |
| 30 | +#include "event.h" |
| 31 | + |
| 32 | +#ifdef __cplusplus |
| 33 | +extern "C" { |
| 34 | +#endif |
| 35 | + |
| 36 | +/** |
| 37 | + * @brief client ep structure |
| 38 | + */ |
| 39 | +typedef struct { |
| 40 | + coap_pkt_t pdu; /**< forward CoAP PDU */ |
| 41 | + sock_udp_ep_t server_ep; /**< forward Server endpoint */ |
| 42 | + sock_udp_ep_t ep; /**< client endpoint */ |
| 43 | + uint16_t mid; /**< message ID */ |
| 44 | + uint8_t flags; /**< client flags */ |
| 45 | +#if IS_USED(MODULE_NANOCOAP_CACHE) |
| 46 | + uint8_t req_etag[COAP_ETAG_LENGTH_MAX]; /**< request ETag */ |
| 47 | +#endif |
| 48 | + ztimer_t empty_ack_timer; /**< empty ACK timer */ |
| 49 | + event_t event; /**< client event */ |
| 50 | +} client_ep_t; |
| 51 | + |
| 52 | +/** |
| 53 | + * @brief Stack size for the forward proxy thread |
| 54 | + * |
| 55 | + */ |
| 56 | +#ifndef GCOAP_PROXY_STACK_SIZE |
| 57 | +#define GCOAP_PROXY_STACK_SIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE \ |
| 58 | + + sizeof(coap_pkt_t) + GCOAP_DTLS_EXTRA_STACKSIZE) |
| 59 | +#endif |
| 60 | + |
| 61 | +/** |
| 62 | + * @brief Definition of forward proxy thread msgs. |
| 63 | + */ |
| 64 | +enum { |
| 65 | + GCOAP_FORWARD_PROXY_MSG_SEND, |
| 66 | +}; |
| 67 | + |
| 68 | +/** |
| 69 | + * @brief Initialize the forward proxy thread |
| 70 | + */ |
| 71 | +void gcoap_forward_proxy_thread_init(void); |
| 72 | + |
| 73 | +/** |
| 74 | + * @brief Forward the CoAP request to the server |
| 75 | + * The client endpoint is passed as an argument |
| 76 | + * and freed if the send failed. |
| 77 | + * |
| 78 | + * @param[in] cep client endpoint |
| 79 | + * @return @ref gcoap_req_send |
| 80 | + */ |
| 81 | +int gcoap_forward_proxy_req_send(client_ep_t *cep); |
| 82 | + |
| 83 | +#ifdef __cplusplus |
| 84 | +} |
| 85 | +#endif |
| 86 | + |
| 87 | +#endif /* FORWARD_PROXY_INTERNAL_H */ |
| 88 | +/** |
| 89 | + * @} |
| 90 | + */ |
0 commit comments