kinetic-c  v0.12.0
Seagate Kinetic Protocol Client Library for C
Macros | Enumerations | Functions | Variables
bus_example.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <err.h>
#include <signal.h>
#include <sys/time.h>
#include <poll.h>
#include "bus.h"
#include "atomic.h"
#include "socket99.h"
#include "util.h"

Go to the source code of this file.

Macros

#define MAGIC_NUMBER   3
 
#define MAX_SOCKETS   1000
 
#define DEFAULT_BUF_SIZE   (1024 * 1024 + sizeof(prot_header_t))
 
#define PRINT_RESPONSES   0
 
#define LOG(VERBOSITY,...)   do { if (state.verbosity >= VERBOSITY) { printf(__VA_ARGS__); } } while(0)
 
#define INCREMENT_COMPLETION_COUNTER   1
 

Enumerations

enum  socket_state
 

Functions

static void run_bus (example_state *s, struct bus *b)
 
static void parse_args (int argc, char **argv, example_state *s)
 
static time_t get_cur_second (void)
 
static void log_cb (log_event_t event, int log_level, const char *msg, void *udata)
 
static bus_sink_cb_res_t reset_transfer (socket_info *si)
 
static bus_sink_cb_res_t sink_cb (uint8_t *read_buf, size_t read_size, void *socket_udata)
 
static bus_unpack_cb_res_t unpack_cb (void *msg, void *socket_udata)
 
static void unexpected_msg_cb (void *msg, int64_t seq_id, void *bus_udata, void *socket_udata)
 
int main (int argc, char **argv)
 
static void signal_handler (int arg)
 
static sig_t register_signal_handler (int sig)
 
static void register_signal_handlers (void)
 
static void usage (void)
 
static void open_sockets (example_state *s)
 
static size_t construct_msg (uint8_t *buf, size_t buf_size, size_t payload_size, int64_t seq_id)
 
static void completion_cb (bus_msg_result_t *res, void *udata)
 
static void tick_handler (example_state *s)
 

Variables

example_state state
 
static const char * executable_name = NULL
 
static bool loop_flag = true
 
static sig_t old_sigint_handler = NULL
 

Macro Definition Documentation

#define MAGIC_NUMBER   3

Definition at line 46 of file bus_example.c.

#define MAX_SOCKETS   1000

Definition at line 48 of file bus_example.c.

#define DEFAULT_BUF_SIZE   (1024 * 1024 + sizeof(prot_header_t))

Definition at line 49 of file bus_example.c.

#define PRINT_RESPONSES   0

Definition at line 50 of file bus_example.c.

#define LOG (   VERBOSITY,
  ... 
)    do { if (state.verbosity >= VERBOSITY) { printf(__VA_ARGS__); } } while(0)

Definition at line 96 of file bus_example.c.

#define INCREMENT_COMPLETION_COUNTER   1

Definition at line 396 of file bus_example.c.

Enumeration Type Documentation

Enumerator
STATE_UNINIT 
STATE_AWAITING_HEADER 
STATE_AWAITING_BODY 
STATE_UNINIT 
STATE_AWAITING_HEADER 
STATE_AWAITING_BODY 

Definition at line 52 of file bus_example.c.

Function Documentation

static void run_bus ( example_state *  s,
struct bus b 
)
static
static void parse_args ( int  argc,
char **  argv,
example_state *  s 
)
static

Definition at line 307 of file bus_example.c.

References DEFAULT_BUF_SIZE, and usage().

static time_t get_cur_second ( void  )
static

Definition at line 446 of file bus_example.c.

References Util_Timestamp().

static void log_cb ( log_event_t  event,
int  log_level,
const char *  msg,
void *  udata 
)
static

Definition at line 89 of file bus_example.c.

References Bus_LogEventStr().

static bus_sink_cb_res_t reset_transfer ( socket_info *  si)
static

Definition at line 101 of file bus_example.c.

References bus_sink_cb_res_t::next_read, and STATE_AWAITING_HEADER.

static bus_sink_cb_res_t sink_cb ( uint8_t *  read_buf,
size_t  read_size,
void *  socket_udata 
)
static
static bus_unpack_cb_res_t unpack_cb ( void *  msg,
void *  socket_udata 
)
static

Definition at line 210 of file bus_example.c.

static void unexpected_msg_cb ( void *  msg,
int64_t  seq_id,
void *  bus_udata,
void *  socket_udata 
)
static

Definition at line 233 of file bus_example.c.

int main ( int  argc,
char **  argv 
)
static void signal_handler ( int  arg)
static

Definition at line 278 of file bus_example.c.

References LOG.

static sig_t register_signal_handler ( int  sig)
static

Definition at line 287 of file bus_example.c.

References signal_handler().

static void register_signal_handlers ( void  )
static

Definition at line 293 of file bus_example.c.

References register_signal_handler().

static void usage ( void  )
static

Definition at line 298 of file bus_example.c.

References executable_name.

static void open_sockets ( example_state *  s)
static

Definition at line 347 of file bus_example.c.

static size_t construct_msg ( uint8_t *  buf,
size_t  buf_size,
size_t  payload_size,
int64_t  seq_id 
)
static

Definition at line 377 of file bus_example.c.

References MAGIC_NUMBER.

static void completion_cb ( bus_msg_result_t res,
void *  udata 
)
static
static void tick_handler ( example_state *  s)
static

Definition at line 439 of file bus_example.c.

References LOG.

Variable Documentation

example_state state

Definition at line 83 of file bus_example.c.

const char* executable_name = NULL
static

Definition at line 99 of file bus_example.c.

bool loop_flag = true
static

Definition at line 275 of file bus_example.c.

sig_t old_sigint_handler = NULL
static

Definition at line 276 of file bus_example.c.