/* * Register domain fifo functions */ int init_trusted_unixsock(void) { if (unixsock_register_cmd("trusted_reload", trusted_reload) < 0) { LOG(L_CRIT, "init_trusted_unixsock: Cannot register trusted_reload\n"); return -1; } if (unixsock_register_cmd("trusted_dump", trusted_dump) < 0) { LOG(L_CRIT, "init_trusted_unixsock: Cannot register trusted_dump\n"); return -1; } return 0; }
static int register_core_commands(void) { if (unixsock_register_cmd(PRINT_CMD, print_cmd) < 0) { return -1; } if (unixsock_register_cmd(VERSION_CMD, version_cmd) < 0) { return -1; } if (unixsock_register_cmd(UPTIME_CMD, uptime_cmd) < 0) { return -1; } if (unixsock_register_cmd(WHICH_CMD, which_cmd) < 0) { return -1; } if (unixsock_register_cmd(PS_CMD, ps_cmd) < 0) { return -1; } if (unixsock_register_cmd(PWD_CMD, pwd_cmd) < 0) { return -1; } if (unixsock_register_cmd(ARG_CMD, arg_cmd) < 0) { return -1; } if (unixsock_register_cmd(KILL_CMD, kill_cmd) < 0) { return -1; } return 0; }
int init_tm_stats(void) { int size; tm_stats=shm_malloc(sizeof(struct t_stats)); if (tm_stats==0) { LOG(L_ERR, "ERROR: init_tm_stats: no mem for stats\n"); goto error0; } memset(tm_stats, 0, sizeof(struct t_stats) ); size=sizeof(stat_counter)*process_count(); tm_stats->s_waiting=shm_malloc(size); if (tm_stats->s_waiting==0) { LOG(L_ERR, "ERROR: init_tm_stats: no mem for stats\n"); goto error1; } memset(tm_stats->s_waiting, 0, size ); tm_stats->s_transactions=shm_malloc(size); if (tm_stats->s_transactions==0) { LOG(L_ERR, "ERROR: init_tm_stats: no mem for stats\n"); goto error2; } memset(tm_stats->s_transactions, 0, size ); tm_stats->s_client_transactions=shm_malloc(size); if (tm_stats->s_client_transactions==0) { LOG(L_ERR, "ERROR: init_tm_stats: no mem for stats\n"); goto error3; } memset(tm_stats->s_client_transactions, 0, size ); if (register_fifo_cmd(fifo_stats, "t_stats", 0)<0) { LOG(L_CRIT, "cannot register fifo stats\n"); goto error4; } if (unixsock_register_cmd("t_stats", unixsock_stats) < 0) { LOG(L_CRIT, "cannot register fifo stats\n"); goto error4; } return 1; error4: shm_free(tm_stats->s_client_transactions); tm_stats->s_client_transactions=0; error3: shm_free(tm_stats->s_transactions); tm_stats->s_transactions=0; error2: shm_free(tm_stats->s_waiting); tm_stats->s_waiting=0; error1: shm_free(tm_stats); error0: return -1; }
static int mod_init(void) { DBG( "TM - (size of cell=%ld, sip_msg=%ld) initializing...\n", (long)sizeof(struct cell), (long)sizeof(struct sip_msg)); /* checking if we have sufficient bitmap capacity for given maximum number of branches */ if (MAX_BRANCHES+1>31) { LOG(L_CRIT, "Too many max UACs for UAC branch_bm_t bitmap: %d\n", MAX_BRANCHES ); return -1; } if (init_callid() < 0) { LOG(L_CRIT, "Error while initializing Call-ID generator\n"); return -1; } if (register_fifo_cmd(fifo_uac, "t_uac_dlg", 0) < 0) { LOG(L_CRIT, "cannot register fifo t_uac\n"); return -1; } if (register_fifo_cmd(fifo_uac_cancel, "t_uac_cancel", 0) < 0) { LOG(L_CRIT, "cannot register fifo t_uac_cancel\n"); return -1; } if (register_fifo_cmd(fifo_hash, "t_hash", 0)<0) { LOG(L_CRIT, "cannot register hash\n"); return -1; } if (register_fifo_cmd(fifo_t_reply, "t_reply", 0)<0) { LOG(L_CRIT, "cannot register t_reply\n"); return -1; } if (unixsock_register_cmd("t_uac_dlg", unixsock_uac) < 0) { LOG(L_CRIT, "cannot register t_uac with the unix server\n"); return -1; } if (unixsock_register_cmd("t_uac_cancel", unixsock_uac_cancel) < 0) { LOG(L_CRIT, "cannot register t_uac_cancel with the unix server\n"); return -1; } if (unixsock_register_cmd("t_hash", unixsock_hash) < 0) { LOG(L_CRIT, "cannot register t_hash with the unix server\n"); return -1; } if (unixsock_register_cmd("t_reply", unixsock_t_reply) < 0) { LOG(L_CRIT, "cannot register t_reply with the unix server\n"); return -1; } /* building the hash table*/ if (!init_hash_table()) { LOG(L_ERR, "ERROR: mod_init: initializing hash_table failed\n"); return -1; } /* init static hidden values */ init_t(); if (!tm_init_timers()) { LOG(L_ERR, "ERROR: mod_init: timer init failed\n"); return -1; } /* register the timer function */ register_timer( timer_routine , 0 /* empty attr */, 1 ); /* init_tm_stats calls process_count, which should * NOT be called from mod_init, because one does not * now, if a timer is used and thus how many processes * will be started; however we started already our * timers, so we know and process_count should not * change any more */ if (init_tm_stats()<0) { LOG(L_CRIT, "ERROR: mod_init: failed to init stats\n"); return -1; } if (uac_init()==-1) { LOG(L_ERR, "ERROR: mod_init: uac_init failed\n"); return -1; } if (init_tmcb_lists()!=1) { LOG(L_CRIT, "ERROR:tm:mod_init: failed to init tmcb lists\n"); return -1; } tm_init_tags(); init_twrite_lines(); if (init_twrite_sock() < 0) { LOG(L_ERR, "ERROR:tm:mod_init: Unable to create socket\n"); return -1; } /* register post-script clean-up function */ if (register_script_cb( w_t_unref, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0 ) { LOG(L_ERR,"ERROR:tm:mod_init: failed to register POST request " "callback\n"); return -1; } if (register_script_cb( script_init, PRE_SCRIPT_CB|REQ_TYPE_CB , 0)<0 ) { LOG(L_ERR,"ERROR:tm:mod_init: failed to register PRE request " "callback\n"); return -1; } if ( init_avp_params( fr_timer_param, fr_inv_timer_param)<0 ){ LOG(L_ERR,"ERROR:tm:mod_init: failed to process timer AVPs\n"); return -1; } if ( init_gf_mask( bf_mask_param )<0 ) { LOG(L_ERR,"ERROR:tm:mod_init: failed to process " "\"branch_flag_mask\" param\n"); return -1; } return 0; }