#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.
|
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) |
|
#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 |
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.
static void run_bus |
( |
example_state * |
s, |
|
|
struct bus * |
b |
|
) |
| |
|
static |
Definition at line 454 of file bus_example.c.
References Bus_RegisterSocket(), Bus_SendRequest(), BUS_SOCKET_PLAIN, completion_cb(), construct_msg(), DEFAULT_BUF_SIZE, bus_user_msg::fd, get_cur_second(), LOG, open_sockets(), register_signal_handlers(), and tick_handler().
static void parse_args |
( |
int |
argc, |
|
|
char ** |
argv, |
|
|
example_state * |
s |
|
) |
| |
|
static |
static time_t get_cur_second |
( |
void |
| ) |
|
|
static |
static void log_cb |
( |
log_event_t |
event, |
|
|
int |
log_level, |
|
|
const char * |
msg, |
|
|
void * |
udata |
|
) |
| |
|
static |
static bus_sink_cb_res_t sink_cb |
( |
uint8_t * |
read_buf, |
|
|
size_t |
read_size, |
|
|
void * |
socket_udata |
|
) |
| |
|
static |
static void unexpected_msg_cb |
( |
void * |
msg, |
|
|
int64_t |
seq_id, |
|
|
void * |
bus_udata, |
|
|
void * |
socket_udata |
|
) |
| |
|
static |
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 241 of file bus_example.c.
References bus_result::bus, Bus_Free(), Bus_Init(), Bus_Shutdown(), executable_name, get_cur_second(), LOG, log_cb(), bus_config::log_cb, parse_args(), run_bus(), sink_cb(), state, bus_result::status, unexpected_msg_cb(), and unpack_cb().
static void signal_handler |
( |
int |
arg | ) |
|
|
static |
static sig_t register_signal_handler |
( |
int |
sig | ) |
|
|
static |
static void register_signal_handlers |
( |
void |
| ) |
|
|
static |
static void usage |
( |
void |
| ) |
|
|
static |
static void open_sockets |
( |
example_state * |
s | ) |
|
|
static |
static size_t construct_msg |
( |
uint8_t * |
buf, |
|
|
size_t |
buf_size, |
|
|
size_t |
payload_size, |
|
|
int64_t |
seq_id |
|
) |
| |
|
static |
Definition at line 398 of file bus_example.c.
References ATOMIC_BOOL_COMPARE_AND_SWAP, BUS_SEND_RX_FAILURE, BUS_SEND_RX_TIMEOUT, BUS_SEND_SUCCESS, BUS_SEND_TX_FAILURE, BUS_SEND_TX_TIMEOUT, LOG, bus_msg_result_t::response, state, bus_msg_result_t::status, and bus_msg_result_t::u.
static void tick_handler |
( |
example_state * |
s | ) |
|
|
static |
const char* executable_name = NULL |
|
static |
sig_t old_sigint_handler = NULL |
|
static |