RTRlib
Loading...
Searching...
No Matches
Transport sockets

The RTR transport sockets implement the communication channel (e.g., SSH, TCP, TCP-AO) between an RTR server and client. More...

Modules

 SSH transport socket
 An implementation of the SSH protocol for the RTR transport.
 
 TCP transport socket
 An implementation of the TCP protocol for the RTR transport.
 

Data Structures

struct  tr_socket
 A transport socket datastructure. More...
 

Macros

#define RTRLIB_TRANSPORT_CONNECT_TIMEOUT_DEFAULT   30
 Default connect timeout.
 

Typedefs

typedef void(* tr_close_fp) (void *socket)
 A function pointer to a technology specific close function.
 
typedef int(* tr_open_fp) (void *socket)
 A function pointer to a technology specific open function.
 
typedef void(* tr_free_fp) (struct tr_socket *tr_sock)
 A function pointer to a technology specific free function.
 
typedef int(* tr_recv_fp) (const void *socket, void *pdu, const size_t len, const time_t timeout)
 A function pointer to a technology specific recv function.
 
typedef int(* tr_send_fp) (const void *socket, const void *pdu, const size_t len, const time_t timeout)
 A function pointer to a technology specific send function.
 
typedef const char *(* tr_ident_fp) (void *socket)
 A function pointer to a technology specific info function.
 

Enumerations

enum  tr_rtvals {
  TR_SUCCESS = 0 , TR_ERROR = -1 , TR_WOULDBLOCK = -2 , TR_INTR = -3 ,
  TR_CLOSED = -4
}
 The return values for tr_ functions. More...
 

Functions

int tr_open (struct tr_socket *socket)
 Establish the connection.
 
void tr_close (struct tr_socket *socket)
 Close the socket connection.
 
void tr_free (struct tr_socket *socket)
 Deallocates all memory that the passed socket uses.
 
int tr_recv (const struct tr_socket *socket, void *buf, const size_t len, const time_t timeout)
 Receives <= len Bytes data from the socket.
 
int tr_send (const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout)
 Send <= len Bytes data over the socket.
 
int tr_send_all (const struct tr_socket *socket, const void *pdu, const size_t len, const time_t timeout)
 Repeatedly calls tr_send(..) till len Bytes were sent, the timeout expired or an error occurred.
 
int tr_recv_all (const struct tr_socket *socket, const void *buf, const size_t len, const time_t timeout)
 Repeatedly calls tr_recv(..) till len Bytes were received, the timeout expired or an error occurred.
 
const char * tr_ident (struct tr_socket *socket)
 Returns an identifier for the socket endpoint, eg host:port.
 

Detailed Description

The RTR transport sockets implement the communication channel (e.g., SSH, TCP, TCP-AO) between an RTR server and client.

Before using the transport socket, a tr_socket must be initialized based on a protocol-dependent init function (e.g., tr_tcp_init()).
The tr_* functions call the corresponding function pointers, which are passed in the tr_socket struct, and forward the remaining arguments.

Macro Definition Documentation

◆ RTRLIB_TRANSPORT_CONNECT_TIMEOUT_DEFAULT

#define RTRLIB_TRANSPORT_CONNECT_TIMEOUT_DEFAULT   30

#include <rtrlib/transport/transport.h>

Default connect timeout.

Typedef Documentation

◆ tr_close_fp

typedef void(* tr_close_fp) (void *socket)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific close function.

See also
tr_close

◆ tr_free_fp

typedef void(* tr_free_fp) (struct tr_socket *tr_sock)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific free function.

All memory associated with the tr_socket will be freed.

See also
tr_free

◆ tr_ident_fp

typedef const char *(* tr_ident_fp) (void *socket)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific info function.

See also
tr_send

◆ tr_open_fp

typedef int(* tr_open_fp) (void *socket)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific open function.

See also
tr_open

◆ tr_recv_fp

typedef int(* tr_recv_fp) (const void *socket, void *pdu, const size_t len, const time_t timeout)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific recv function.

See also
tr_recv

◆ tr_send_fp

typedef int(* tr_send_fp) (const void *socket, const void *pdu, const size_t len, const time_t timeout)

#include <rtrlib/transport/transport.h>

A function pointer to a technology specific send function.

See also
tr_send

Enumeration Type Documentation

◆ tr_rtvals

enum tr_rtvals

#include <rtrlib/transport/transport.h>

The return values for tr_ functions.

Enumerator
TR_SUCCESS 

Operation was successful.

TR_ERROR 

Error occurred.

TR_WOULDBLOCK 

No data is available on the socket.

TR_INTR 

Call was interrupted from a signal.

TR_CLOSED 

Connection closed.

Function Documentation

◆ tr_close()

void tr_close ( struct tr_socket socket)

#include <rtrlib/transport/transport_private.h>

Close the socket connection.

Parameters
[in]socketSocket that will be closed.

◆ tr_free()

void tr_free ( struct tr_socket socket)

#include <rtrlib/transport/transport_private.h>

Deallocates all memory that the passed socket uses.

Socket have to be closed before.

Parameters
[in]socketwhich will be freed.

◆ tr_ident()

const char * tr_ident ( struct tr_socket socket)

#include <rtrlib/transport/transport_private.h>

Returns an identifier for the socket endpoint, eg host:port.

Parameters
[in]socketreturn Pointer to a \0 terminated String return NULL on error

◆ tr_open()

int tr_open ( struct tr_socket socket)

#include <rtrlib/transport/transport_private.h>

Establish the connection.

Parameters
[in]socketSocket that will be used.
Returns
TR_SUCCESS On success.
TR_ERROR On error.

◆ tr_recv()

int tr_recv ( const struct tr_socket socket,
void *  buf,
const size_t  len,
const time_t  timeout 
)

#include <rtrlib/transport/transport_private.h>

Receives <= len Bytes data from the socket.

Parameters
[in]socketSocket that will be used.
[out]bufReceived data, must be an allocated memory area of >=pdu_len bytes.
[in]lenSize of pdu in Bytes.
[in]timeoutMax. seconds the function will block till len data was received.
Returns
>0 Number of Bytes read.
TR_ERROR On error.
TR_WOULDBLOCK If no data was available at the socket before the timeout expired.

◆ tr_recv_all()

int tr_recv_all ( const struct tr_socket socket,
const void *  buf,
const size_t  len,
const time_t  timeout 
)

#include <rtrlib/transport/transport_private.h>

Repeatedly calls tr_recv(..) till len Bytes were received, the timeout expired or an error occurred.

Parameters
[in]socketSocket that will be used.
[out]bufReceived data, must be an allocated memory area of >=len bytes.
[in]lenSize of pdu in Bytes.
[in]timeoutMax. seconds the functions should try to receive len data till it returns.
Returns
>0 Number of Bytes received.
TR_ERROR On error.
TR_WOULDBLOCK If send would block.

◆ tr_send()

int tr_send ( const struct tr_socket socket,
const void *  pdu,
const size_t  len,
const time_t  timeout 
)

#include <rtrlib/transport/transport_private.h>

Send <= len Bytes data over the socket.

Parameters
[in]socketSocket that will be used.
[out]pduData that will be be sent.
[in]lenSize of pdu in Bytes.
[in]timeoutMax. seconds the function should try to send the data till it returns.
Returns
>0 Number of Bytes sent.
TR_ERROR On error.

◆ tr_send_all()

int tr_send_all ( const struct tr_socket socket,
const void *  pdu,
const size_t  len,
const time_t  timeout 
)

#include <rtrlib/transport/transport_private.h>

Repeatedly calls tr_send(..) till len Bytes were sent, the timeout expired or an error occurred.

Parameters
[in]socketSocket that will be used.
[out]pduData that will be be sent.
[in]lenSize of pdu in Bytes.
[in]timeoutMax. seconds the functions should try to send pdu till it returns.
Returns
>0 Number of Bytes sent.
TR_ERROR On Error.
TR_WOULDBLOCK If send would block.