* Verify parameters for OSP module * return 0 success, -1 failure */
| 406 | * return 0 success, -1 failure |
| 407 | */ |
| 408 | static int ospVerifyParameters(void) |
| 409 | { |
| 410 | int i; |
| 411 | char hostname[OSP_STRBUF_SIZE]; |
| 412 | int result = 0; |
| 413 | |
| 414 | if ((_osp_work_mode < 0) || (_osp_work_mode > 1)) { |
| 415 | _osp_work_mode = OSP_DEF_MODE; |
| 416 | LM_WARN("work mode is out of range, reset to %d\n", OSP_DEF_MODE); |
| 417 | } |
| 418 | |
| 419 | if ((_osp_service_type < 0) || (_osp_service_type > 3)) { |
| 420 | _osp_service_type = OSP_DEF_SERVICE; |
| 421 | LM_WARN("service type is out of range, reset to %d\n", OSP_DEF_SERVICE); |
| 422 | } |
| 423 | |
| 424 | _osp_sp_number = 0; |
| 425 | for (i = 0; i < OSP_DEF_SPS; i++) { |
| 426 | if (_osp_sp_uris[i] != NULL) { |
| 427 | if (_osp_sp_number != i) { |
| 428 | _osp_sp_uris[_osp_sp_number] = _osp_sp_uris[i]; |
| 429 | _osp_sp_weights[_osp_sp_number] = _osp_sp_weights[i]; |
| 430 | _osp_sp_uris[i] = NULL; |
| 431 | _osp_sp_weights[i] = OSP_DEF_WEIGHT; |
| 432 | } |
| 433 | osp_index[_osp_sp_number] = i + 1; |
| 434 | _osp_sp_number++; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | if (_osp_sp_number == 0) { |
| 439 | LM_ERR("at least one service point uri must be configured\n"); |
| 440 | result = -1; |
| 441 | } |
| 442 | |
| 443 | if (_osp_device_ip == NULL) { |
| 444 | gethostname(hostname, sizeof(hostname)); |
| 445 | _osp_device_ip = hostname; |
| 446 | } |
| 447 | ospConvertToOutAddress(_osp_device_ip, _osp_out_device, sizeof(_osp_out_device)); |
| 448 | ospConvertToInAddress(_osp_device_ip, _osp_in_device, sizeof(_osp_in_device)); |
| 449 | |
| 450 | /* If use_security_features is 0, ignroe the certificate files */ |
| 451 | if (_osp_use_security != 0) { |
| 452 | /* Default location for the cert files is in the compile time variable CFG_DIR */ |
| 453 | if (_osp_private_key == NULL) { |
| 454 | sprintf(_osp_PRIVATE_KEY, "%spkey.pem", CFG_DIR); |
| 455 | _osp_private_key = _osp_PRIVATE_KEY; |
| 456 | } |
| 457 | |
| 458 | if (_osp_local_certificate == NULL) { |
| 459 | sprintf(_osp_LOCAL_CERTIFICATE, "%slocalcert.pem", CFG_DIR); |
| 460 | _osp_local_certificate = _osp_LOCAL_CERTIFICATE; |
| 461 | } |
| 462 | |
| 463 | if (_osp_ca_certificate == NULL) { |
| 464 | sprintf(_osp_CA_CERTIFICATE, "%scacert_0.pem", CFG_DIR); |
| 465 | _osp_ca_certificate = _osp_CA_CERTIFICATE; |
no test coverage detected