/** Module init function */ static int mod_init(void) { pv_spec_t user_spec; pv_spec_t realm_spec; pv_spec_t pwd_spec; LM_DBG("start\n"); /* parse the auth AVP spesc, if any */ if ( auth_username_avp || auth_password_avp || auth_realm_avp) { if (!auth_username_avp || !auth_password_avp || !auth_realm_avp) { LM_ERR("partial definition of auth AVP!"); return -1; } if ( parse_auth_avp(auth_realm_avp, &realm_spec, "realm")<0 || parse_auth_avp(auth_username_avp, &user_spec, "username")<0 || parse_auth_avp(auth_password_avp, &pwd_spec, "password")<0 || pv_get_avp_name(0, &(realm_spec.pvp), &(realm_avp_name), &(realm_avp_type) )!=0 || pv_get_avp_name(0, &(user_spec.pvp), &(user_avp_name), &(user_avp_type) )!=0 || pv_get_avp_name(0, &(pwd_spec.pvp), &(pwd_avp_name), &(pwd_avp_type) )!=0 ) { LM_ERR("invalid AVP definition for AUTH avps\n"); return -1; } } return 0; }
static int mod_init(void) { pv_spec_t avp_spec; if (restore_mode_str && *restore_mode_str) { if (strcasecmp(restore_mode_str,"none")==0) { restore_mode = UAC_NO_RESTORE; } else if (strcasecmp(restore_mode_str,"manual")==0) { restore_mode = UAC_MANUAL_RESTORE; } else if (strcasecmp(restore_mode_str,"auto")==0) { restore_mode = UAC_AUTO_RESTORE; } else { LM_ERR("unsupported value '%s' for restore_mode\n", restore_mode_str); goto error; } } if ( (rr_from_param.len==0 || rr_to_param.len==0) && restore_mode!=UAC_NO_RESTORE) { LM_ERR("rr_store_param cannot be empty if FROM is restoreable\n"); goto error; } /* parse the auth AVP spesc, if any */ if ( auth_username_avp || auth_password_avp || auth_realm_avp) { if (!auth_username_avp || !auth_password_avp || !auth_realm_avp) { LM_ERR("partial definition of auth AVP!"); goto error; } if ( parse_auth_avp(auth_realm_avp, &auth_realm_spec, "realm")<0 || parse_auth_avp(auth_username_avp, &auth_username_spec, "username")<0 || parse_auth_avp(auth_password_avp, &auth_password_spec, "password")<0 ) { goto error; } } else { memset( &auth_realm_spec, 0, sizeof(pv_spec_t)); memset( &auth_password_spec, 0, sizeof(pv_spec_t)); memset( &auth_username_spec, 0, sizeof(pv_spec_t)); } /* load the TM API - FIXME it should be loaded only * if NO_RESTORE and AUTH */ if (load_tm_api(&uac_tmb)!=0) { LM_ERR("can't load TM API\n"); goto error; } if (restore_mode!=UAC_NO_RESTORE) { /* load the RR API */ if (load_rr_api(&uac_rrb)!=0) { LM_ERR("can't load RR API\n"); goto error; } if(restore_from_avp.s) { if (pv_parse_spec(&restore_from_avp, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %.*s AVP definition\n", restore_from_avp.len, restore_from_avp.s); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &restore_from_avp_name, &restore_from_avp_type)!=0) { LM_ERR("[%.*s]- invalid AVP definition\n", restore_from_avp.len, restore_from_avp.s); return -1; } restore_from_avp_type |= AVP_VAL_STR; } if(restore_to_avp.s) { if (pv_parse_spec(&restore_to_avp, &avp_spec)==0 || avp_spec.type!=PVT_AVP) { LM_ERR("malformed or non AVP %.*s AVP definition\n", restore_to_avp.len, restore_to_avp.s); return -1; } if(pv_get_avp_name(0, &avp_spec.pvp, &restore_to_avp_name, &restore_to_avp_type)!=0) { LM_ERR("[%.*s]- invalid AVP definition\n", restore_to_avp.len, restore_to_avp.s); return -1; } restore_to_avp_type |= AVP_VAL_STR; } if (restore_mode==UAC_AUTO_RESTORE) { /* we need the append_fromtag on in RR */ memset(&dlg_api, 0, sizeof(struct dlg_binds)); if (uac_restore_dlg==0 || load_dlg_api(&dlg_api)!=0) { if (!uac_rrb.append_fromtag) { LM_ERR("'append_fromtag' RR param is not enabled!" " - required by AUTO restore mode\n"); goto error; } if (uac_restore_dlg!=0) LM_DBG("failed to find dialog API - is dialog module loaded?\n"); } /* get all requests doing loose route */ if (uac_rrb.register_rrcb( rr_checker, 0)!=0) { LM_ERR("failed to install RR callback\n"); goto error; } } } if(reg_db_url.s && reg_db_url.len>=0) { if(!reg_contact_addr.s || reg_contact_addr.len<=0) { LM_ERR("contact address parameter not set\n"); goto error; } if(reg_htable_size>14) reg_htable_size = 14; if(reg_htable_size<2) reg_htable_size = 2; reg_htable_size = 1<<reg_htable_size; if(uac_reg_init_rpc()!=0) { LM_ERR("failed to register RPC commands\n"); goto error; } if(uac_reg_init_ht(reg_htable_size)<0) { LM_ERR("failed to init reg htable\n"); goto error; } register_procs(1); /* add child to update local config framework structures */ cfg_register_child(1); } init_from_replacer(); uac_req_init(); return 0; error: return -1; }