38 #ifndef _clib_included_socket_h 39 #define _clib_included_socket_h 41 #include <sys/types.h> 42 #include <sys/socket.h> 43 #include <netinet/in.h> 49 typedef struct _socket_t
58 #define SOCKET_IS_SERVER (1 << 0) 59 #define SOCKET_IS_CLIENT (0 << 0) 60 #define SOCKET_NON_BLOCKING_CONNECT (1 << 1) 61 #define SOCKET_ALLOW_GROUP_WRITE (1 << 2) 64 #define SOCKET_RX_END_OF_FILE (1 << 2) 73 struct sockaddr_in peer;
76 clib_error_t *(*read_func) (
struct _socket_t * sock,
int min_bytes);
111 vec_add2 (s->tx_buffer, result, n_bytes);
118 s->tx_buffer =
va_format (s->tx_buffer, fmt, va);
124 return s->write_func (s);
130 return s->read_func (s, n_bytes);
140 memset (s, 0,
sizeof (s[0]));
147 err = (*sock->close_func) (sock);
static uword clib_socket_is_server(clib_socket_t *sock)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static clib_error_t * clib_socket_close(clib_socket_t *sock)
#define SOCKET_RX_END_OF_FILE
static clib_error_t * clib_socket_rx(clib_socket_t *s, int n_bytes)
static clib_error_t * tx_buffer(void *transport, mc_transport_type_t type, u32 buffer_index)
struct _socket_t clib_socket_t
static void clib_socket_free(clib_socket_t *s)
static clib_error_t * clib_socket_tx(clib_socket_t *s)
static void clib_socket_tx_add_va_formatted(clib_socket_t *s, char *fmt, va_list *va)
#define vec_free(V)
Free vector's memory (no header).
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
static uword clib_socket_is_client(clib_socket_t *s)
static uword clib_mem_is_heap_object(void *p)
clib_error_t * clib_socket_init(clib_socket_t *socket)
static int clib_socket_rx_end_of_file(clib_socket_t *s)
static void * clib_socket_tx_add(clib_socket_t *s, int n_bytes)
void clib_socket_tx_add_formatted(clib_socket_t *s, char *fmt,...)