coreMQTT v2.1.0
MQTT 3.1.1 Client Library
transport_interface.h
Go to the documentation of this file.
1/*
2 * coreMQTT v2.1.0
3 * Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: MIT
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy of
8 * this software and associated documentation files (the "Software"), to deal in
9 * the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11 * the Software, and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in all
15 * copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
30#ifndef TRANSPORT_INTERFACE_H_
31#define TRANSPORT_INTERFACE_H_
32
33#include <stdint.h>
34#include <stddef.h>
35
36/* *INDENT-OFF* */
37#ifdef __cplusplus
38 extern "C" {
39#endif
40/* *INDENT-ON* */
41
189/* @[define_networkcontext] */
190struct NetworkContext;
191typedef struct NetworkContext NetworkContext_t;
192/* @[define_networkcontext] */
193
220/* @[define_transportrecv] */
221typedef int32_t ( * TransportRecv_t )( NetworkContext_t * pNetworkContext,
222 void * pBuffer,
223 size_t bytesToRecv );
224/* @[define_transportrecv] */
225
242/* @[define_transportsend] */
243typedef int32_t ( * TransportSend_t )( NetworkContext_t * pNetworkContext,
244 const void * pBuffer,
245 size_t bytesToSend );
246/* @[define_transportsend] */
247
251typedef struct TransportOutVector
252{
256 const void * iov_base;
257
261 size_t iov_len;
263
290/* @[define_transportwritev] */
291typedef int32_t ( * TransportWritev_t )( NetworkContext_t * pNetworkContext,
292 TransportOutVector_t * pIoVec,
293 size_t ioVecCount );
294/* @[define_transportwritev] */
295
300/* @[define_transportinterface] */
301typedef struct TransportInterface
302{
308/* @[define_transportinterface] */
309
310/* *INDENT-OFF* */
311#ifdef __cplusplus
312 }
313#endif
314/* *INDENT-ON* */
315
316#endif /* ifndef TRANSPORT_INTERFACE_H_ */
int32_t(* TransportRecv_t)(NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv)
Transport interface for receiving data on the network.
Definition: transport_interface.h:221
int32_t(* TransportSend_t)(NetworkContext_t *pNetworkContext, const void *pBuffer, size_t bytesToSend)
Transport interface for sending data over the network.
Definition: transport_interface.h:243
int32_t(* TransportWritev_t)(NetworkContext_t *pNetworkContext, TransportOutVector_t *pIoVec, size_t ioVecCount)
Transport interface function for "vectored" / scatter-gather based writes. This function is expected ...
Definition: transport_interface.h:291
struct NetworkContext NetworkContext_t
The NetworkContext is an incomplete type. An implementation of this interface must define struct Netw...
Definition: transport_interface.h:191
The transport layer interface.
Definition: transport_interface.h:302
TransportSend_t send
Definition: transport_interface.h:304
TransportRecv_t recv
Definition: transport_interface.h:303
TransportWritev_t writev
Definition: transport_interface.h:305
NetworkContext_t * pNetworkContext
Definition: transport_interface.h:306
Transport vector structure for sending multiple messages.
Definition: transport_interface.h:252
const void * iov_base
Base address of data.
Definition: transport_interface.h:256
size_t iov_len
Length of data in buffer.
Definition: transport_interface.h:261