kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
Macros | Functions | Variables
echosrv.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <err.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
#include "socket99.h"
#include "util.h"
#include <poll.h>

Go to the source code of this file.

Macros

#define BUF_SZ   (2 * 1024L * 1024)
 
#define MAX_CLIENTS   10
 
#define NO_CLIENT   ((int)-1)
 
#define LOG(VERBOSITY,...)
 
#define MAX_TIMEOUT   1000
 

Functions

static void init_polling (config *cfg)
 
static void open_ports (config *cfg)
 
static void handle_incoming_connections (config *cfg, int available)
 
static void handle_client_io (config *cfg, int available)
 
static void listen_loop_poll (config *cfg)
 
static void register_client (config *cfg, int cfd, struct sockaddr *addr, socklen_t addr_len)
 
static void disconnect_client (config *cfg, int fd)
 
static void enqueue_write (config *cfg, int fd, uint8_t *buf, size_t write_size)
 
static void usage (void)
 
static void parse_args (int argc, char **argv, config *cfg)
 
int main (int argc, char **argv)
 
static void tick_handler (config *cfg)
 

Variables

static uint8_t read_buf [(2 *1024L *1024)]
 

Macro Definition Documentation

#define BUF_SZ   (2 * 1024L * 1024)

Definition at line 39 of file echosrv.c.

#define MAX_CLIENTS   10

Definition at line 40 of file echosrv.c.

#define NO_CLIENT   ((int)-1)

Definition at line 42 of file echosrv.c.

#define LOG (   VERBOSITY,
  ... 
)
Value:
do { \
if (VERBOSITY <= cfg->verbosity) { \
printf(__VA_ARGS__); \
} \
} \
while(0)

Definition at line 46 of file echosrv.c.

#define MAX_TIMEOUT   1000

Definition at line 187 of file echosrv.c.

Function Documentation

static void init_polling ( config *  cfg)
static

Definition at line 137 of file echosrv.c.

References MAX_CLIENTS, and NO_CLIENT.

static void open_ports ( config *  cfg)
static

Definition at line 162 of file echosrv.c.

References LOG.

static void handle_incoming_connections ( config *  cfg,
int  available 
)
static

Definition at line 275 of file echosrv.c.

References LOG, and register_client().

static void handle_client_io ( config *  cfg,
int  available 
)
static
static void listen_loop_poll ( config *  cfg)
static
static void register_client ( config *  cfg,
int  cfd,
struct sockaddr *  addr,
socklen_t  addr_len 
)
static

Definition at line 304 of file echosrv.c.

References LOG, MAX_CLIENTS, and NO_CLIENT.

static void disconnect_client ( config *  cfg,
int  fd 
)
static

Definition at line 416 of file echosrv.c.

References LOG, MAX_CLIENTS, and NO_CLIENT.

static void enqueue_write ( config *  cfg,
int  fd,
uint8_t *  buf,
size_t  write_size 
)
static

Definition at line 392 of file echosrv.c.

References BUF_SZ, and LOG.

static void usage ( void  )
static

Definition at line 91 of file echosrv.c.

static void parse_args ( int  argc,
char **  argv,
config *  cfg 
)
static

Definition at line 99 of file echosrv.c.

References usage().

int main ( int  argc,
char **  argv 
)

Definition at line 125 of file echosrv.c.

References init_polling(), listen_loop_poll(), open_ports(), and parse_args().

static void tick_handler ( config *  cfg)
static

Definition at line 189 of file echosrv.c.

References LOG.

Variable Documentation

uint8_t read_buf[(2 *1024L *1024)]
static

Definition at line 44 of file echosrv.c.