* Check if there is an unused and supported originate destination from an AVP * avpid - osp_origdest_avpid * value - osp_dest wrapped in a string * search unused (used==0) & supported (support==1) * return 0 success, -1 failure */
| 226 | * return 0 success, -1 failure |
| 227 | */ |
| 228 | int ospCheckOrigDestination(void) |
| 229 | { |
| 230 | struct usr_avp* destavp = NULL; |
| 231 | int_str destval; |
| 232 | osp_dest* dest = NULL; |
| 233 | int result = -1; |
| 234 | |
| 235 | for (destavp = search_first_avp(AVP_VAL_STR, _osp_origdest_avpid, NULL, 0); |
| 236 | destavp != NULL; |
| 237 | destavp = search_next_avp(destavp, NULL)) |
| 238 | { |
| 239 | get_avp_val(destavp, &destval); |
| 240 | |
| 241 | /* OSP destintaion is wrapped in a string */ |
| 242 | dest = (osp_dest*)destval.s.s; |
| 243 | |
| 244 | if (dest->used == 0) { |
| 245 | if (dest->supported == 1) { |
| 246 | LM_DBG("orig dest exist\n"); |
| 247 | result = 0; |
| 248 | break; |
| 249 | } else { |
| 250 | /* Make it looks like used */ |
| 251 | dest->used = 1; |
| 252 | /* 111 means wrong protocol */ |
| 253 | dest->lastcode = 111; |
| 254 | LM_DBG("destination does not been supported\n"); |
| 255 | } |
| 256 | } else { |
| 257 | LM_DBG("destination has already been used\n"); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | if (result == -1) { |
| 262 | LM_DBG("there is not unused destination\n"); |
| 263 | ospReportOrigSetupUsage(); |
| 264 | } |
| 265 | |
| 266 | return result; |
| 267 | } |
| 268 | |
| 269 | /* |
| 270 | * Retrieved an unused and supported originate destination from an AVP |
no test coverage detected