| 203 | }; |
| 204 | |
| 205 | static int mod_init(void) |
| 206 | { |
| 207 | str stmp; |
| 208 | LM_INFO("initializing...\n"); |
| 209 | |
| 210 | /* load SIGNALING API */ |
| 211 | if(load_sig_api(&sigb)< 0){ |
| 212 | LM_ERR("can't load signaling functions\n"); |
| 213 | return -1; |
| 214 | } |
| 215 | |
| 216 | ncp = dauth_noncer_new(); |
| 217 | if (ncp == NULL) { |
| 218 | LM_ERR("can't init nonce generator\n"); |
| 219 | return -1; |
| 220 | } |
| 221 | |
| 222 | /* If the parameter was not used */ |
| 223 | if (sec_param == 0) { |
| 224 | /* Generate secret using random generator */ |
| 225 | if (generate_random_secret(ncp) < 0) { |
| 226 | LM_ERR("failed to generate random secret\n"); |
| 227 | return -3; |
| 228 | } |
| 229 | } else { |
| 230 | /* Otherwise use the parameter's value */ |
| 231 | ncp->secret.s = sec_param; |
| 232 | ncp->secret.len = strlen(sec_param); |
| 233 | |
| 234 | if (ncp->secret.len != AUTH_SECRET_LEN) { |
| 235 | LM_ERR("bad secret length, must be exactly 32 bytes" |
| 236 | " (256-bit AES key), given: %d (changed in OpenSIPS 3.2+)\n", |
| 237 | ncp->secret.len); |
| 238 | return -1; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | if (dauth_noncer_init(ncp) < 0) { |
| 243 | LM_ERR("dauth_noncer_init() failed\n"); |
| 244 | return -1; |
| 245 | } |
| 246 | |
| 247 | |
| 248 | if ( init_rpid_avp(rpid_avp_param)<0 ) { |
| 249 | LM_ERR("failed to process rpid AVPs\n"); |
| 250 | return -4; |
| 251 | } |
| 252 | |
| 253 | rpid_prefix.len = strlen(rpid_prefix.s); |
| 254 | rpid_suffix.len = strlen(rpid_suffix.s); |
| 255 | realm_prefix.len = strlen(realm_prefix.s); |
| 256 | |
| 257 | if(user_spec_param!=0) |
| 258 | { |
| 259 | stmp.s = user_spec_param; stmp.len = strlen(stmp.s); |
| 260 | if(pv_parse_spec(&stmp, &user_spec)==NULL) |
| 261 | { |
| 262 | LM_ERR("failed to parse username spec\n"); |
nothing calls this directly
no test coverage detected