int mod_register(char *path, int *dlflags, void *p1, void *p2) { if (tls_disable) { LOG(L_WARN, "tls support is disabled " "(set enable_tls=1 in the config to enable it)\n"); return 0; } /* shm is used, be sure it is initialized */ if(!shm_initialized() && init_shm()<0) return -1; if(tls_pre_init()<0) return -1; register_tls_hooks(&tls_h); return 0; }
static int mod_init(void) { int method; if (tls_disable){ LOG(L_WARN, "WARNING: tls: mod_init: tls support is disabled " "(set enable_tls=1 in the config to enable it)\n"); return 0; } if (cfg_get(tcp, tcp_cfg, async) && !tls_force_run){ ERR("tls does not support tcp in async mode, please use" " tcp_async=no in the config file\n"); return -1; } /* Convert tls_method parameter to integer */ method = tls_parse_method(&tls_method); if (method < 0) { ERR("Invalid tls_method parameter value\n"); return -1; } mod_params.method = method; /* Update relative paths of files configured through modparams, relative * pathnames will be converted to absolute and the directory of the main * SER configuration file will be used as reference. */ if (fix_rel_pathnames() < 0) return -1; tls_cfg = (tls_cfg_t**)shm_malloc(sizeof(tls_cfg_t*)); if (!tls_cfg) { ERR("Not enough shared memory left\n"); return -1; } *tls_cfg = NULL; register_tls_hooks(&tls_h); register_select_table(tls_sel); /* if (init_tls() < 0) return -1; */ tls_cfg_lock = lock_alloc(); if (tls_cfg_lock == 0) { ERR("Unable to create TLS configuration lock\n"); return -1; } if (lock_init(tls_cfg_lock) == 0) { lock_dealloc(tls_cfg_lock); ERR("Unable to initialize TLS configuration lock\n"); return -1; } if (tls_cfg_file.s) { *tls_cfg = tls_load_config(&tls_cfg_file); if (!(*tls_cfg)) return -1; } else { *tls_cfg = tls_new_cfg(); if (!(*tls_cfg)) return -1; } if (tls_check_sockets(*tls_cfg) < 0) return -1; /* fix the timeouts from s to ticks */ if (tls_con_lifetime<0){ /* set to max value (~ 1/2 MAX_INT) */ tls_con_lifetime=MAX_TLS_CON_LIFETIME; }else{ if ((unsigned)tls_con_lifetime > (unsigned)TICKS_TO_S(MAX_TLS_CON_LIFETIME)){ LOG(L_WARN, "tls: mod_init: tls_con_lifetime too big (%u s), " " the maximum value is %u\n", tls_con_lifetime, TICKS_TO_S(MAX_TLS_CON_LIFETIME)); tls_con_lifetime=MAX_TLS_CON_LIFETIME; }else{ tls_con_lifetime=S_TO_TICKS(tls_con_lifetime); } } return 0; }