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 CLIB_SOCKET_F_IS_SERVER (1 << 0) 59 #define CLIB_SOCKET_F_IS_CLIENT (0 << 0) 60 #define CLIB_SOCKET_F_RX_END_OF_FILE (1 << 2) 61 #define CLIB_SOCKET_F_NON_BLOCKING_CONNECT (1 << 3) 62 #define CLIB_SOCKET_F_ALLOW_GROUP_WRITE (1 << 4) 63 #define CLIB_SOCKET_F_SEQPACKET (1 << 5) 64 #define CLIB_SOCKET_F_PASSCRED (1 << 6) 74 struct sockaddr_in peer;
82 clib_error_t *(*read_func) (
struct _socket_t * sock,
int min_bytes);
84 clib_error_t *(*recvmsg_func) (
struct _socket_t * s,
void *msg,
int msglen,
85 int fds[],
int num_fds);
86 clib_error_t *(*sendmsg_func) (
struct _socket_t * s,
void *msg,
int msglen,
87 int fds[],
int num_fds);
128 vec_add2 (s->tx_buffer, result, n_bytes);
135 s->tx_buffer =
va_format (s->tx_buffer, fmt, va);
141 return s->write_func (s);
147 return s->read_func (s, n_bytes);
152 int fds[],
int num_fds)
154 return s->sendmsg_func (s, msg, msglen, fds, num_fds);
159 int fds[],
int num_fds)
161 return s->recvmsg_func (s, msg, msglen, fds, num_fds);
178 err = (*sock->close_func) (sock);
static uword clib_socket_is_connected(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.
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
clib_error_t * clib_socket_accept(clib_socket_t *server, clib_socket_t *client)
#define CLIB_SOCKET_F_IS_SERVER
static clib_error_t * tx_buffer(void *transport, mc_transport_type_t type, u32 buffer_index)
static clib_error_t * clib_socket_sendmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
clib_error_t * clib_socket_init(clib_socket_t *socket)
static clib_error_t * clib_socket_recvmsg(clib_socket_t *s, void *msg, int msglen, int fds[], int num_fds)
static clib_error_t * clib_socket_close(clib_socket_t *sock)
static void clib_socket_tx_add_va_formatted(clib_socket_t *s, char *fmt, va_list *va)
#define CLIB_SOCKET_F_RX_END_OF_FILE
static uword clib_socket_is_server(clib_socket_t *sock)
#define vec_free(V)
Free vector's memory (no header).
static uword clib_mem_is_heap_object(void *p)
struct _socket_t clib_socket_t
static void clib_socket_free(clib_socket_t *s)
static clib_error_t * clib_socket_rx(clib_socket_t *s, int n_bytes)
static void * clib_socket_tx_add(clib_socket_t *s, int n_bytes)
static int clib_socket_rx_end_of_file(clib_socket_t *s)
void clib_socket_tx_add_formatted(clib_socket_t *s, char *fmt,...)
static clib_error_t * clib_socket_tx(clib_socket_t *s)
static uword clib_socket_is_client(clib_socket_t *s)