Negotiation Channel Protocol - Connection Management Functions

Negotiation Channel Protocol Messaging Functions.

Defines

TRF_API_MAJOR
TRF_API_MINOR
TRF_API_PATCH
trfNCSendDelimited
trfNCRecvDelimited
trfNCFullRecv
trfNCFullSend

Functions

int trfNCPollMsg(TRFSock sock)

Poll for incoming messages on the socket.

Parameters:

sock – Socket descriptor.

Returns:

Whether there is an incoming message. Negative error code on failure.

int trfNCRecvMsg(TRFSock sock, uint8_t *buf, uint32_t size, int timeout, TrfMsg__MessageWrapper **handle)

Receive a delimited message in TRF Protocol Buffers format.

Parameters:
  • sock – Socket descriptor to receive from.

  • buf – Buffer to receive data into

  • size – Buffer max size

  • timeout – Receive timeout

  • handle – Handle to received message (raw data stored inside buf)

Returns:

0 on success, negative error code on failure

int trfNCSendMsg(TRFSock sock, uint8_t *buf, uint32_t size, int timeout, TrfMsg__MessageWrapper *handle)

Sends a delimited message in TRF Protocol Buffers format.

Parameters:
  • fd – File descriptor to send to.

  • buf – Scratch buffer for writing data to be sent

  • size – Buffer max size

  • timeout – Send timeout in milliseconds

  • handle – Message data handle, to be packed into buf and sent

Returns:

0 on success, negative error code on failure.

int trfNCRecv(TRFSock sock, ssize_t length, uint8_t *buf, int timeout)

Reliably recieves messages on the socket.

            Blocks until a message has been received in its entirety, or
            a timeout or error occurs.

Parameters:
  • sock – Socket to read from.

  • size – TNumber of bytes to receive.

  • buf – Pointer to buffer where message will be stored

  • timeout – Timeout in milliseconds

Returns:

0 on success, negative error code on failure

int trfNCSend(TRFSock sock, ssize_t length, uint8_t *buf, int timeout)

Reliably sends messages on the socket.

            Blocks until a message has been sent in its entirety, or a 
            timeout or error occurs.

Parameters:
  • sock – Socket to send to.

  • size – Number of bytes to send.

  • buf – Buffer containing the message to be sent

  • timeout – Timeout in milliseconds

Returns:

0 on success, negative error code on failure

int trf__AddrMsgToInterface(TrfMsg__MessageWrapper *msg, PTRFInterface *out)

Add Protobuf message to PTRFInterface.

Parameters:
  • msg – Protobuf message wrapper

  • out – PTRFInterface to message to be decoded into

Returns:

0 on success, negative error code on failure