diff --git a/MigrationGuide.md b/MigrationGuide.md index 2a2aada90..353215088 100644 --- a/MigrationGuide.md +++ b/MigrationGuide.md @@ -143,9 +143,9 @@ void eventCallback( MQTTDeserializedInfo_t * pDeserializedInfo ); // Network send. -int32_t networkSend( NetworkContext_t * pContext, const void * pBuffer, size_t bytes ); +int32_t networkSend( void * pContext, const void * pBuffer, size_t bytes ); // Network receive. -int32_t networkRecv( NetworkContext_t * pContext, void * pBuffer, size_t bytes ); +int32_t networkRecv( void * pContext, void * pBuffer, size_t bytes ); MQTTContext_t mqttContext; TransportInterface_t transport; @@ -183,9 +183,9 @@ void eventCallback( MQTTDeserializedInfo_t * pDeserializedInfo ); // Network send. -int32_t networkSend( NetworkContext_t * pContext, const void * pBuffer, size_t bytes ); +int32_t networkSend( void * pContext, const void * pBuffer, size_t bytes ); // Network receive. -int32_t networkRecv( NetworkContext_t * pContext, void * pBuffer, size_t bytes ); +int32_t networkRecv( void * pContext, void * pBuffer, size_t bytes ); MQTTContext_t mqttContext; TransportInterface_t transport; diff --git a/docs/doxygen/porting.dox b/docs/doxygen/porting.dox index 2f26a4f46..9d76cc933 100644 --- a/docs/doxygen/porting.dox +++ b/docs/doxygen/porting.dox @@ -35,24 +35,17 @@ A port must implement functions corresponding to the following functions pointer - [Transport Receive](@ref TransportRecv_t): A function to receive bytes from a network. @code int32_t (* TransportRecv_t )( - NetworkContext_t * pNetworkContext, void * pBuffer, size_t bytesToRecv + void * pNetworkContext, void * pBuffer, size_t bytesToRecv ); @endcode - [Transport Send](@ref TransportSend_t): A function to send bytes over a network. @code int32_t (* TransportSend_t )( - NetworkContext_t * pNetworkContext, const void * pBuffer, size_t bytesToSend + void * pNetworkContext, const void * pBuffer, size_t bytesToSend ); @endcode -The above two functions take in a pointer to a @ref NetworkContext_t, the typename of a -`struct NetworkContext`. The NetworkContext struct must also be defined by the port, and -ought to contain any information necessary to send and receive data with the @ref TransportSend_t -and @ref TransportRecv_t implementations, respectively: -@code -struct NetworkContext { - // Fields necessary for the transport implementations, e.g. a TCP socket descriptor. -}; +The above two functions take in a void pointer to an implementation-defined context. @endcode @section mqtt_porting_time Time Function diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 9a66ec1b3..a0dece2ce 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -773,13 +773,13 @@ static int32_t sendMessageVector( MQTTContext_t * pContext, { if( pContext->transportInterface.writev != NULL ) { - sendResult = pContext->transportInterface.writev( pContext->transportInterface.pNetworkContext, + sendResult = pContext->transportInterface.writev( pContext->pNetworkContext, pIoVectIterator, vectorsToBeSent ); } else { - sendResult = pContext->transportInterface.send( pContext->transportInterface.pNetworkContext, + sendResult = pContext->transportInterface.send( pContext->pNetworkContext, pIoVectIterator->iov_base, pIoVectIterator->iov_len ); } @@ -858,7 +858,7 @@ static int32_t sendBuffer( MQTTContext_t * pContext, while( ( bytesSentOrError < ( int32_t ) bytesToSend ) && ( bytesSentOrError >= 0 ) ) { - sendResult = pContext->transportInterface.send( pContext->transportInterface.pNetworkContext, + sendResult = pContext->transportInterface.send( pContext->pNetworkContext, pIndex, bytesToSend - ( size_t ) bytesSentOrError ); @@ -968,7 +968,7 @@ static int32_t recvExact( const MQTTContext_t * pContext, while( ( bytesRemaining > 0U ) && ( receiveError == false ) ) { - bytesRecvd = recvFunc( pContext->transportInterface.pNetworkContext, + bytesRecvd = recvFunc( pContext->pNetworkContext, pIndex, bytesRemaining ); @@ -1655,7 +1655,7 @@ static MQTTStatus_t receiveSingleIteration( MQTTContext_t * pContext, assert( pContext->networkBuffer.pBuffer != NULL ); /* Read as many bytes as possible into the network buffer. */ - recvBytes = pContext->transportInterface.recv( pContext->transportInterface.pNetworkContext, + recvBytes = pContext->transportInterface.recv( pContext->pNetworkContext, &( pContext->networkBuffer.pBuffer[ pContext->index ] ), pContext->networkBuffer.size - pContext->index ); @@ -2274,7 +2274,7 @@ static MQTTStatus_t receiveConnack( const MQTTContext_t * pContext, * returned after a transport receive timeout, an error, or a successful * receive of packet type and length. */ status = MQTT_GetIncomingPacketTypeAndLength( pContext->transportInterface.recv, - pContext->transportInterface.pNetworkContext, + pContext->pNetworkContext, pIncomingPacket ); /* The loop times out based on 2 conditions. @@ -2467,6 +2467,7 @@ static MQTTStatus_t validatePublishParams( const MQTTContext_t * pContext, MQTTStatus_t MQTT_Init( MQTTContext_t * pContext, const TransportInterface_t * pTransportInterface, + void * pNetworkContext, MQTTGetCurrentTimeFunc_t getTimeFunction, MQTTEventCallback_t userCallback, const MQTTFixedBuffer_t * pNetworkBuffer ) @@ -2475,14 +2476,16 @@ MQTTStatus_t MQTT_Init( MQTTContext_t * pContext, /* Validate arguments. */ if( ( pContext == NULL ) || ( pTransportInterface == NULL ) || - ( pNetworkBuffer == NULL ) ) + ( pNetworkBuffer == NULL ) || ( pNetworkContext == NULL ) ) { LogError( ( "Argument cannot be NULL: pContext=%p, " "pTransportInterface=%p, " - "pNetworkBuffer=%p", + "pNetworkBuffer=%p, " + "pNetworkContext=%p", ( void * ) pContext, ( void * ) pTransportInterface, - ( void * ) pNetworkBuffer ) ); + ( void * ) pNetworkBuffer, + ( void * ) pNetworkContext ) ); status = MQTTBadParameter; } else if( getTimeFunction == NULL ) @@ -2511,6 +2514,7 @@ MQTTStatus_t MQTT_Init( MQTTContext_t * pContext, pContext->connectStatus = MQTTNotConnected; pContext->transportInterface = *pTransportInterface; + pContext->pNetworkContext = pNetworkContext; pContext->getTime = getTimeFunction; pContext->appCallback = userCallback; pContext->networkBuffer = *pNetworkBuffer; diff --git a/source/core_mqtt_serializer.c b/source/core_mqtt_serializer.c index 537925996..5f427b4e5 100644 --- a/source/core_mqtt_serializer.c +++ b/source/core_mqtt_serializer.c @@ -301,7 +301,7 @@ static uint8_t * encodeString( uint8_t * pDestination, * @return The Remaining Length of the incoming packet. */ static size_t getRemainingLength( TransportRecv_t recvFunc, - NetworkContext_t * pNetworkContext ); + void * pNetworkContext ); /** * @brief Retrieves, decodes and stores the Remaining Length from the network @@ -799,7 +799,7 @@ static void serializePublishCommon( const MQTTPublishInfo_t * pPublishInfo, } static size_t getRemainingLength( TransportRecv_t recvFunc, - NetworkContext_t * pNetworkContext ) + void * pNetworkContext ) { size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0; uint8_t encodedByte = 0; @@ -2561,7 +2561,7 @@ MQTTStatus_t MQTT_DeserializeAck( const MQTTPacketInfo_t * pIncomingPacket, /*-----------------------------------------------------------*/ MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength( TransportRecv_t readFunc, - NetworkContext_t * pNetworkContext, + void * pNetworkContext, MQTTPacketInfo_t * pIncomingPacket ) { MQTTStatus_t status = MQTTSuccess; diff --git a/source/include/core_mqtt.h b/source/include/core_mqtt.h index 1493f3794..277d76755 100644 --- a/source/include/core_mqtt.h +++ b/source/include/core_mqtt.h @@ -185,6 +185,11 @@ typedef struct MQTTContext */ TransportInterface_t transportInterface; + /** + * @brief The transport interface context for this MQTT connection. + */ + void * pNetworkContext; + /** * @brief The buffer used in sending and receiving packets from the network. */ @@ -289,9 +294,9 @@ typedef struct MQTTDeserializedInfo * MQTTDeserializedInfo_t * pDeserializedInfo * ); * // Network send. - * int32_t networkSend( NetworkContext_t * pContext, const void * pBuffer, size_t bytes ); + * int32_t networkSend( void * pContext, const void * pBuffer, size_t bytes ); * // Network receive. - * int32_t networkRecv( NetworkContext_t * pContext, void * pBuffer, size_t bytes ); + * int32_t networkRecv( void * pContext, void * pBuffer, size_t bytes ); * * MQTTContext_t mqttContext; * TransportInterface_t transport; @@ -360,9 +365,9 @@ MQTTStatus_t MQTT_Init( MQTTContext_t * pContext, * MQTTDeserializedInfo_t * pDeserializedInfo * ); * // Network send. - * int32_t networkSend( NetworkContext_t * pContext, const void * pBuffer, size_t bytes ); + * int32_t networkSend( void * pContext, const void * pBuffer, size_t bytes ); * // Network receive. - * int32_t networkRecv( NetworkContext_t * pContext, void * pBuffer, size_t bytes ); + * int32_t networkRecv( void * pContext, void * pBuffer, size_t bytes ); * * MQTTContext_t mqttContext; * TransportInterface_t transport; diff --git a/source/include/core_mqtt_serializer.h b/source/include/core_mqtt_serializer.h index da2e7e4ed..8e8bd59bf 100644 --- a/source/include/core_mqtt_serializer.h +++ b/source/include/core_mqtt_serializer.h @@ -1046,7 +1046,7 @@ MQTTStatus_t MQTT_SerializePingreq( const MQTTFixedBuffer_t * pFixedBuffer ); * * // TransportRecv_t function for reading from the network. * int32_t socket_recv( - * NetworkContext_t * pNetworkContext, + * void * pNetworkContext, * void * pBuffer, * size_t bytesToRecv * ); @@ -1162,7 +1162,7 @@ MQTTStatus_t MQTT_DeserializeAck( const MQTTPacketInfo_t * pIncomingPacket, * * // TransportRecv_t function for reading from the network. * int32_t socket_recv( - * NetworkContext_t * pNetworkContext, + * void * pNetworkContext, * void * pBuffer, * size_t bytesToRecv * ); @@ -1201,7 +1201,7 @@ MQTTStatus_t MQTT_DeserializeAck( const MQTTPacketInfo_t * pIncomingPacket, */ /* @[declare_mqtt_getincomingpackettypeandlength] */ MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength( TransportRecv_t readFunc, - NetworkContext_t * pNetworkContext, + void * pNetworkContext, MQTTPacketInfo_t * pIncomingPacket ); /* @[declare_mqtt_getincomingpackettypeandlength] */ diff --git a/source/interface/transport_interface.h b/source/interface/transport_interface.h index 634885e7a..66b1f97cf 100644 --- a/source/interface/transport_interface.h +++ b/source/interface/transport_interface.h @@ -58,34 +58,14 @@ * - [Transport Receive](@ref TransportRecv_t) * - [Transport Send](@ref TransportSend_t) * - * Each of the functions above take in an opaque context @ref NetworkContext_t. + * Each of the functions above take in an opaque context. * The functions above and the context are also grouped together in the - * @ref TransportInterface_t structure:

* @snippet this define_transportinterface *
* * @transportsectionimplementation * * The following steps give guidance on implementing the transport interface: - * - * -# Implementing @ref NetworkContext_t

- * @snippet this define_networkcontext - *
- * @ref NetworkContext_t is the incomplete type struct NetworkContext. - * The implemented struct NetworkContext must contain all of the information - * that is needed to receive and send data with the @ref TransportRecv_t - * and the @ref TransportSend_t implementations.
- * In the case of TLS over TCP, struct NetworkContext is typically implemented - * with the TCP socket context and a TLS context.

- * Example code: - * @code{c} - * struct NetworkContext - * { - * struct MyTCPSocketContext tcpSocketContext; - * struct MyTLSContext tlsContext; - * }; - * @endcode - *
* -# Implementing @ref TransportRecv_t

* @snippet this define_transportrecv *
@@ -99,19 +79,20 @@ *

* Example code: * @code{c} - * int32_t myNetworkRecvImplementation( NetworkContext_t * pNetworkContext, + * int32_t myNetworkRecvImplementation( void * pNetworkContext, * void * pBuffer, * size_t bytesToRecv ) * { * int32_t bytesReceived = 0; * bool callTlsRecvFunc = true; + * NetworkContext_t * pContext = ( NetworkContext_t * ) pNetworkContext; * * // For a single byte read request, check if data is available on the network. * if( bytesToRecv == 1 ) * { * // If no data is available on the network, do not call TLSRecv * // to avoid blocking for socket timeout. - * if( TLSRecvCount( pNetworkContext->tlsContext ) == 0 ) + * if( TLSRecvCount( pContext->tlsContext ) == 0 ) * { * callTlsRecvFunc = false; * } @@ -119,7 +100,7 @@ * * if( callTlsRecvFunc == true ) * { - * bytesReceived = TLSRecv( pNetworkContext->tlsContext, + * bytesReceived = TLSRecv( pContext->tlsContext, * pBuffer, * bytesToRecv, * MY_SOCKET_TIMEOUT ); @@ -152,12 +133,13 @@ *

* Example code: * @code{c} - * int32_t myNetworkSendImplementation( NetworkContext_t * pNetworkContext, + * int32_t myNetworkSendImplementation( void * pNetworkContext, * const void * pBuffer, * size_t bytesToSend ) * { * int32_t bytesSent = 0; - * bytesSent = TLSSend( pNetworkContext->tlsContext, + * NetworkContext_t * pContext = ( NetworkContext_t * ) pNetworkContext; + * bytesSent = TLSSend( pContext->tlsContext, * pBuffer, * bytesToSend, * MY_SOCKET_TIMEOUT ); @@ -179,18 +161,6 @@ * @endcode */ -/** - * @transportstruct - * @typedef NetworkContext_t - * @brief The NetworkContext is an incomplete type. An implementation of this - * interface must define struct NetworkContext for the system requirements. - * This context is passed into the network interface functions. - */ -/* @[define_networkcontext] */ -struct NetworkContext; -typedef struct NetworkContext NetworkContext_t; -/* @[define_networkcontext] */ - /** * @transportcallback * @brief Transport interface for receiving data on the network. @@ -218,7 +188,7 @@ typedef struct NetworkContext NetworkContext_t; * has occurred. */ /* @[define_transportrecv] */ -typedef int32_t ( * TransportRecv_t )( NetworkContext_t * pNetworkContext, +typedef int32_t ( * TransportRecv_t )( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ); /* @[define_transportrecv] */ @@ -240,7 +210,7 @@ typedef int32_t ( * TransportRecv_t )( NetworkContext_t * pNetworkContext, * has occurred. */ /* @[define_transportsend] */ -typedef int32_t ( * TransportSend_t )( NetworkContext_t * pNetworkContext, +typedef int32_t ( * TransportSend_t )( void * pNetworkContext, const void * pBuffer, size_t bytesToSend ); /* @[define_transportsend] */ @@ -288,7 +258,7 @@ typedef struct TransportOutVector * has occurred. */ /* @[define_transportwritev] */ -typedef int32_t ( * TransportWritev_t )( NetworkContext_t * pNetworkContext, +typedef int32_t ( * TransportWritev_t )( void * pNetworkContext, TransportOutVector_t * pIoVec, size_t ioVecCount ); /* @[define_transportwritev] */ @@ -303,7 +273,6 @@ typedef struct TransportInterface TransportRecv_t recv; /**< Transport receive function pointer. */ TransportSend_t send; /**< Transport send function pointer. */ TransportWritev_t writev; /**< Transport writev function pointer. */ - NetworkContext_t * pNetworkContext; /**< Implementation-defined network context. */ } TransportInterface_t; /* @[define_transportinterface] */ diff --git a/test/cbmc/include/network_interface_stubs.h b/test/cbmc/include/network_interface_stubs.h index 80178e7b3..572d796e8 100644 --- a/test/cbmc/include/network_interface_stubs.h +++ b/test/cbmc/include/network_interface_stubs.h @@ -41,7 +41,7 @@ * * @return Any value from INT32_MIN to INT32_MAX. */ -int32_t NetworkInterfaceReceiveStub( NetworkContext_t * pNetworkContext, +int32_t NetworkInterfaceReceiveStub( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ); @@ -54,7 +54,7 @@ int32_t NetworkInterfaceReceiveStub( NetworkContext_t * pNetworkContext, * * @return Any value from INT32_MIN to INT32_MAX. */ -int32_t NetworkInterfaceSendStub( NetworkContext_t * pNetworkContext, +int32_t NetworkInterfaceSendStub( void * pNetworkContext, const void * pBuffer, size_t bytesToSend ); diff --git a/test/cbmc/stubs/network_interface_stubs.c b/test/cbmc/stubs/network_interface_stubs.c index 72b689047..7269e0946 100644 --- a/test/cbmc/stubs/network_interface_stubs.c +++ b/test/cbmc/stubs/network_interface_stubs.c @@ -44,7 +44,7 @@ #define MAX_NETWORK_RECV_TRIES 4 #endif -int32_t NetworkInterfaceReceiveStub( NetworkContext_t * pNetworkContext, +int32_t NetworkInterfaceReceiveStub( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { @@ -75,7 +75,7 @@ int32_t NetworkInterfaceReceiveStub( NetworkContext_t * pNetworkContext, return bytesOrError; } -int32_t NetworkInterfaceSendStub( NetworkContext_t * pNetworkContext, +int32_t NetworkInterfaceSendStub( void * pNetworkContext, const void * pBuffer, size_t bytesToSend ) { diff --git a/test/unit-test/core_mqtt_serializer_utest.c b/test/unit-test/core_mqtt_serializer_utest.c index 648917ca1..77eacc361 100644 --- a/test/unit-test/core_mqtt_serializer_utest.c +++ b/test/unit-test/core_mqtt_serializer_utest.c @@ -179,7 +179,7 @@ int suiteTearDown( int numFailures ) /** * @brief Mock successful transport receive by reading data from a buffer. */ -static int32_t mockReceive( NetworkContext_t * pNetworkContext, +static int32_t mockReceive( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { @@ -205,7 +205,7 @@ static int32_t mockReceive( NetworkContext_t * pNetworkContext, /** * @brief Mock transport receive with no data available. */ -static int32_t mockReceiveNoData( NetworkContext_t * pNetworkContext, +static int32_t mockReceiveNoData( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { @@ -220,7 +220,7 @@ static int32_t mockReceiveNoData( NetworkContext_t * pNetworkContext, /** * @brief Mock transport receive failure. */ -static int32_t mockReceiveFailure( NetworkContext_t * pNetworkContext, +static int32_t mockReceiveFailure( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { @@ -235,7 +235,7 @@ static int32_t mockReceiveFailure( NetworkContext_t * pNetworkContext, /** * @brief Mock transport receive that succeeds once, then fails. */ -static int32_t mockReceiveSucceedThenFail( NetworkContext_t * pNetworkContext, +static int32_t mockReceiveSucceedThenFail( void * pNetworkContext, void * pBuffer, size_t bytesToRecv ) { diff --git a/test/unit-test/core_mqtt_state_utest.c b/test/unit-test/core_mqtt_state_utest.c index b230af22a..4b0e75e67 100644 --- a/test/unit-test/core_mqtt_state_utest.c +++ b/test/unit-test/core_mqtt_state_utest.c @@ -57,7 +57,7 @@ int suiteTearDown( int numFailures ) /* ========================================================================== */ -static int32_t transportRecvSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportRecvSuccess( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) { @@ -66,7 +66,7 @@ static int32_t transportRecvSuccess( NetworkContext_t * pNetworkContext, return bytesToRead; } -static int32_t transportSendSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportSendSuccess( void * pNetworkContext, const void * pBuffer, size_t bytesToWrite ) { diff --git a/test/unit-test/core_mqtt_utest.c b/test/unit-test/core_mqtt_utest.c index dc8b0441b..cd8ac1b34 100644 --- a/test/unit-test/core_mqtt_utest.c +++ b/test/unit-test/core_mqtt_utest.c @@ -259,7 +259,7 @@ int suiteTearDown( int numFailures ) * @brief Mock successful transport send, and write data into buffer for * verification. */ -static int32_t mockSend( NetworkContext_t * pNetworkContext, +static int32_t mockSend( void * pNetworkContext, const void * pMessage, size_t bytesToSend ) { @@ -339,7 +339,7 @@ static uint32_t getTimeDummy( void ) * @return Number of bytes sent; negative value on error; * 0 for timeout or 0 bytes sent. */ -static int32_t transportWritevSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportWritevSuccess( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -434,7 +434,7 @@ static void verifyEncodedTopicStringUnsubscribe( TransportOutVector_t * pIoVecto * @return Number of bytes sent; negative value on error; * 0 for timeout or 0 bytes sent. */ -static int32_t transportWritevSubscribeSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportWritevSubscribeSuccess( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -523,7 +523,7 @@ static int32_t transportWritevSubscribeSuccess( NetworkContext_t * pNetworkConte * @return Number of bytes sent; negative value on error; * 0 for timeout or 0 bytes sent. */ -static int32_t transportWritevUnsubscribeSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportWritevUnsubscribeSuccess( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -601,7 +601,7 @@ static int32_t transportWritevUnsubscribeSuccess( NetworkContext_t * pNetworkCon * @return Number of bytes sent; negative value on error; * 0 for timeout or 0 bytes sent. */ -static int32_t transportWritevFail( NetworkContext_t * pNetworkContext, +static int32_t transportWritevFail( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -618,7 +618,7 @@ static int32_t transportWritevFail( NetworkContext_t * pNetworkContext, return bytesToWrite + 3; } -static int32_t transportWritevError( NetworkContext_t * pNetworkContext, +static int32_t transportWritevError( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -640,7 +640,7 @@ static int32_t transportWritevError( NetworkContext_t * pNetworkContext, * @return Number of bytes sent; negative value on error; * 0 for timeout or 0 bytes sent. */ -static int32_t transportSendSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportSendSuccess( void * pNetworkContext, const void * pBuffer, size_t bytesToWrite ) { @@ -652,7 +652,7 @@ static int32_t transportSendSuccess( NetworkContext_t * pNetworkContext, /** * @brief Mocked failed transport send. */ -static int32_t transportSendFailure( NetworkContext_t * pNetworkContext, +static int32_t transportSendFailure( void * pNetworkContext, const void * pBuffer, size_t bytesToWrite ) { @@ -665,7 +665,7 @@ static int32_t transportSendFailure( NetworkContext_t * pNetworkContext, /** * @brief Mocked transport send that always returns 0 bytes sent. */ -static int32_t transportSendNoBytes( NetworkContext_t * pNetworkContext, +static int32_t transportSendNoBytes( void * pNetworkContext, const void * pBuffer, size_t bytesToWrite ) { @@ -678,7 +678,7 @@ static int32_t transportSendNoBytes( NetworkContext_t * pNetworkContext, /** * @brief Mocked transport send that succeeds then fails. */ -static int32_t transportSendSucceedThenFail( NetworkContext_t * pNetworkContext, +static int32_t transportSendSucceedThenFail( void * pNetworkContext, const void * pMessage, size_t bytesToSend ) { @@ -700,7 +700,7 @@ static int32_t transportSendSucceedThenFail( NetworkContext_t * pNetworkContext, /** * @brief Mocked transport send that only sends half of the bytes. */ -static int32_t transportWritevPartialByte( NetworkContext_t * pNetworkContext, +static int32_t transportWritevPartialByte( void * pNetworkContext, TransportOutVector_t * pIoVectorIterator, size_t vectorsToBeSent ) { @@ -732,7 +732,7 @@ static int32_t transportWritevPartialByte( NetworkContext_t * pNetworkContext, * * @return Number of bytes received; negative value on error. */ -static int32_t transportRecvSuccess( NetworkContext_t * pNetworkContext, +static int32_t transportRecvSuccess( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) { @@ -741,7 +741,7 @@ static int32_t transportRecvSuccess( NetworkContext_t * pNetworkContext, return bytesToRead; } -static int32_t transportRecvOneSuccessOneFail( NetworkContext_t * pNetworkContext, +static int32_t transportRecvOneSuccessOneFail( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) { @@ -762,7 +762,7 @@ static int32_t transportRecvOneSuccessOneFail( NetworkContext_t * pNetworkContex /** * @brief Mocked failed transport read. */ -static int32_t transportRecvFailure( NetworkContext_t * pNetworkContext, +static int32_t transportRecvFailure( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) { @@ -775,7 +775,7 @@ static int32_t transportRecvFailure( NetworkContext_t * pNetworkContext, /** * @brief Mocked transport reading one byte at a time. */ -static int32_t transportRecvOneByte( NetworkContext_t * pNetworkContext, +static int32_t transportRecvOneByte( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) { @@ -789,7 +789,7 @@ static int32_t transportRecvOneByte( NetworkContext_t * pNetworkContext, * @brief Mocked transport returning zero bytes to simulate reception * of no data over network. */ -static int32_t transportRecvNoData( NetworkContext_t * pNetworkContext, +static int32_t transportRecvNoData( void * pNetworkContext, void * pBuffer, size_t bytesToRead ) {