void init_chibach( int *argc, char ***argv ) { assert( argc != NULL ); assert( argv != NULL ); chibach_log = NULL; initialized = false; chibach_started = false; run_as_daemon = false; chibach_name = xstrdup( basename( *argv[ 0 ] ) ); parse_argv( argc, argv ); set_chibach_home(); set_chibach_tmp(); check_chibach_tmp(); if ( run_as_daemon ) { init_log( get_chibach_name(), get_chibach_log(), LOGGING_TYPE_FILE ); } else { init_log( get_chibach_name(), get_chibach_log(), LOGGING_TYPE_FILE | LOGGING_TYPE_STDOUT ); } ignore_sigpipe(); set_exit_handler(); set_usr1_handler(); init_stat(); init_timer(); init_messenger( get_chibach_tmp() ); if ( datapath_id != 0 ) { init_openflow_switch_interface( datapath_id, controller.ip, controller.port ); } initialized = true; }
static void finalize_chibach() { die_unless_initialized(); debug( "Terminating chibach..." ); maybe_finalize_openflow_switch_interface(); finalize_messenger(); finalize_stat(); finalize_timer(); chibach_started = false; unlink_pid( get_chibach_pid(), get_chibach_name() ); unset_chibach_home(); unset_chibach_tmp(); xfree( chibach_name ); chibach_name = NULL; xfree( chibach_log ); chibach_log = NULL; initialized = false; }
static void start_chibach_up() { debug( "Starting chibach ... (CHIBACH_HOME = %s)", get_chibach_home() ); maybe_daemonize(); write_pid( get_chibach_pid(), get_chibach_name() ); chibach_started = true; start_messenger(); }
void usage() { printf( "Usage: %s [OPTION]...\n" "\n" " -i, --datapath_id=DATAPATH_ID set datapath id\n" " -c, --controller=IP_ADDR set controller host\n" " -p, --port=TCP_PORT set controller TCP port\n" " -d, --daemonize run in the background\n" " -l, --logging_level=LEVEL set logging level\n" " -h, --help display this help and exit\n", get_chibach_name() ); }