RTE OSAdapter POSIX 0.1.0 build 41b3eb3
POSIX/Linux OAL OSAdapter for Platform_RTE
Loading...
Searching...
No Matches
rte_posix_osadapter_socket.c File Reference

POSIX implementation of the raw OS socket layer (rte_os_socket_ops_t). More...

#include "rte/posix_osadapter/rte_posix_osadapter.h"
#include "rte_posix_osadapter_poll.h"
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <poll.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
Include dependency graph for rte_posix_osadapter_socket.c:

Go to the source code of this file.

Macros

#define _POSIX_C_SOURCE   200809L

Functions

static rte_status_t posix_socket_set_nonblocking (rte_os_socket_handle_t handle, bool nonblocking)
static rte_status_t posix_socket_open (rte_os_socket_type_t type, rte_os_socket_handle_t *out_handle)
static rte_status_t posix_socket_bind (rte_os_socket_handle_t handle, const char *host, uint16_t port)
static rte_status_t posix_socket_connect (rte_os_socket_handle_t handle, const char *host, uint16_t port)
static rte_status_t posix_socket_send (rte_os_socket_handle_t handle, const void *buf, size_t len, size_t *out_sent)
static rte_status_t posix_socket_sendto (rte_os_socket_handle_t handle, const void *buf, size_t len, const char *host, uint16_t port, size_t *out_sent)
static rte_status_t posix_socket_recv (rte_os_socket_handle_t handle, void *buf, size_t len, size_t *out_recv)
static rte_status_t posix_socket_recvfrom (rte_os_socket_handle_t handle, void *buf, size_t len, char *out_host, size_t host_len, uint16_t *out_port, size_t *out_recv)
static rte_status_t posix_socket_poll (rte_os_socket_handle_t handle, uint32_t events, rte_duration_ms_t timeout_ms, uint32_t *out_revents)
static rte_status_t posix_socket_close (rte_os_socket_handle_t handle)
const rte_os_socket_ops_t * rte_posix_osadapter_socket_ops (void)
 The POSIX raw OS socket operations vtable (UDP and TCP).

Variables

static const rte_os_socket_ops_t s_posix_socket_ops

Detailed Description

POSIX implementation of the raw OS socket layer (rte_os_socket_ops_t).

Compliant with CENELEC EN 50128 SIL 4 and MISRA C:2012.

Definition in file rte_posix_osadapter_socket.c.

Macro Definition Documentation

◆ _POSIX_C_SOURCE

#define _POSIX_C_SOURCE   200809L

Definition at line 1 of file rte_posix_osadapter_socket.c.

Function Documentation

◆ posix_socket_bind()

rte_status_t posix_socket_bind ( rte_os_socket_handle_t handle,
const char * host,
uint16_t port )
static

Definition at line 73 of file rte_posix_osadapter_socket.c.

◆ posix_socket_close()

rte_status_t posix_socket_close ( rte_os_socket_handle_t handle)
static

Definition at line 348 of file rte_posix_osadapter_socket.c.

◆ posix_socket_connect()

rte_status_t posix_socket_connect ( rte_os_socket_handle_t handle,
const char * host,
uint16_t port )
static

Definition at line 107 of file rte_posix_osadapter_socket.c.

◆ posix_socket_open()

rte_status_t posix_socket_open ( rte_os_socket_type_t type,
rte_os_socket_handle_t * out_handle )
static

Definition at line 25 of file rte_posix_osadapter_socket.c.

◆ posix_socket_poll()

rte_status_t posix_socket_poll ( rte_os_socket_handle_t handle,
uint32_t events,
rte_duration_ms_t timeout_ms,
uint32_t * out_revents )
static

Definition at line 268 of file rte_posix_osadapter_socket.c.

◆ posix_socket_recv()

rte_status_t posix_socket_recv ( rte_os_socket_handle_t handle,
void * buf,
size_t len,
size_t * out_recv )
static

Definition at line 205 of file rte_posix_osadapter_socket.c.

◆ posix_socket_recvfrom()

rte_status_t posix_socket_recvfrom ( rte_os_socket_handle_t handle,
void * buf,
size_t len,
char * out_host,
size_t host_len,
uint16_t * out_port,
size_t * out_recv )
static

Definition at line 230 of file rte_posix_osadapter_socket.c.

◆ posix_socket_send()

rte_status_t posix_socket_send ( rte_os_socket_handle_t handle,
const void * buf,
size_t len,
size_t * out_sent )
static

Definition at line 138 of file rte_posix_osadapter_socket.c.

◆ posix_socket_sendto()

rte_status_t posix_socket_sendto ( rte_os_socket_handle_t handle,
const void * buf,
size_t len,
const char * host,
uint16_t port,
size_t * out_sent )
static

Definition at line 166 of file rte_posix_osadapter_socket.c.

◆ posix_socket_set_nonblocking()

rte_status_t posix_socket_set_nonblocking ( rte_os_socket_handle_t handle,
bool nonblocking )
static

Definition at line 323 of file rte_posix_osadapter_socket.c.

◆ rte_posix_osadapter_socket_ops()

const rte_os_socket_ops_t * rte_posix_osadapter_socket_ops ( void )

The POSIX raw OS socket operations vtable (UDP and TCP).

open returns a non-blocking socket (O_NONBLOCK, OSA rule R5): recv/send on it return RTE_STATUS_TIMEOUT instead of blocking; set_nonblocking(false) switches it to blocking. If O_NONBLOCK cannot be set, open closes the socket, leaves *out_handle unwritten and returns RTE_STATUS_INTERNAL_ERROR.

Returns
The adapter's static vtable (never NULL).

Definition at line 371 of file rte_posix_osadapter_socket.c.

Variable Documentation

◆ s_posix_socket_ops

const rte_os_socket_ops_t s_posix_socket_ops
static
Initial value:
= {
posix_socket_open,
posix_socket_bind,
posix_socket_connect,
posix_socket_send,
posix_socket_sendto,
posix_socket_recv,
posix_socket_recvfrom,
posix_socket_poll,
posix_socket_set_nonblocking,
posix_socket_close
}

Definition at line 358 of file rte_posix_osadapter_socket.c.