Skip to content

Commit 9dcfd65

Browse files
Update transport_interface.h (FreeRTOS#146)
* Update transport_interface.h * Update lexicon.txt * Update lexicon.txt
1 parent 8fa66e6 commit 9dcfd65

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

lexicon.txt

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ init
116116
initializerequestheaders
117117
int
118118
iot
119+
ioveccount
120+
ip
119121
isfield
120122
isheaderresponse
121123
isheadresponse
@@ -185,6 +187,7 @@ pheaders
185187
phost
186188
phttpparser
187189
phttpparsingcontext
190+
piovec
188191
plaintext
189192
plastheaderfield
190193
plastheadervalue
@@ -248,6 +251,7 @@ strchr
248251
strerror
249252
strncpy
250253
struct
254+
structs
251255
sublicense
252256
tcp
253257
tcpsocketcontext
@@ -278,4 +282,5 @@ url
278282
valuefound
279283
valuelen
280284
valueloc
285+
writev
281286
xxxx

source/interface/transport_interface.h

+51-2
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,64 @@ typedef int32_t ( * TransportSend_t )( NetworkContext_t * pNetworkContext,
243243
size_t bytesToSend );
244244
/* @[define_transportsend] */
245245

246+
/**
247+
* @brief Transport vector structure for sending multiple messages.
248+
*/
249+
typedef struct TransportOutVector
250+
{
251+
/**
252+
* @brief Base address of data.
253+
*/
254+
const void * iov_base;
255+
256+
/**
257+
* @brief Length of data in buffer.
258+
*/
259+
size_t iov_len;
260+
} TransportOutVector_t;
261+
262+
/**
263+
* @transportcallback
264+
* @brief Transport interface function for "vectored" / scatter-gather based
265+
* writes. This function is expected to iterate over the list of vectors pIoVec
266+
* having ioVecCount entries containing portions of one MQTT message at a maximum.
267+
* If the proper functionality is available, then the data in the list should be
268+
* copied to the underlying TCP buffer before flushing the buffer. Implementing it
269+
* in this fashion will lead to sending of fewer TCP packets for all the values
270+
* in the list.
271+
*
272+
* @note If the proper write functionality is not present for a given device/IP-stack,
273+
* then there is no strict requirement to implement write. Only the send and recv
274+
* interfaces must be defined for the application to work properly.
275+
*
276+
* @param[in] pNetworkContext Implementation-defined network context.
277+
* @param[in] pIoVec An array of TransportIoVector_t structs.
278+
* @param[in] ioVecCount Number of TransportIoVector_t in pIoVec.
279+
*
280+
* @return The number of bytes written or a negative value to indicate error.
281+
*
282+
* @note If no data is written to the buffer due to the buffer being full this MUST
283+
* return zero as the return value.
284+
* A zero return value SHOULD represent that the write operation can be retried
285+
* by calling the API function. Zero MUST NOT be returned if a network disconnection
286+
* has occurred.
287+
*/
288+
/* @[define_transportwritev] */
289+
typedef int32_t ( * TransportWritev_t )( NetworkContext_t * pNetworkContext,
290+
TransportOutVector_t * pIoVec,
291+
size_t ioVecCount );
292+
/* @[define_transportwritev] */
293+
246294
/**
247295
* @transportstruct
248296
* @brief The transport layer interface.
249297
*/
250298
/* @[define_transportinterface] */
251299
typedef struct TransportInterface
252300
{
253-
TransportRecv_t recv; /**< Transport receive interface. */
254-
TransportSend_t send; /**< Transport send interface. */
301+
TransportRecv_t recv; /**< Transport receive function pointer. */
302+
TransportSend_t send; /**< Transport send function pointer. */
303+
TransportWritev_t writev; /**< Transport writev function pointer. */
255304
NetworkContext_t * pNetworkContext; /**< Implementation-defined network context. */
256305
} TransportInterface_t;
257306
/* @[define_transportinterface] */

0 commit comments

Comments
 (0)