* Retrieved an unused and supported originate destination from an AVP * avpid - osp_origdest_avpid * value - osp_dest wrapped in a string * There can be 0, 1 or more originate destinations. * Find the 1st unused destination (used==0) & supported (support==1), * return it, and mark it as used (used==1). * return NULL on failure */
| 276 | * return NULL on failure |
| 277 | */ |
| 278 | osp_dest* ospGetNextOrigDestination(void) |
| 279 | { |
| 280 | struct usr_avp* destavp = NULL; |
| 281 | int_str destval; |
| 282 | osp_dest* dest = NULL; |
| 283 | osp_dest* result = NULL; |
| 284 | |
| 285 | for (destavp = search_first_avp(AVP_VAL_STR, _osp_origdest_avpid, NULL, 0); |
| 286 | destavp != NULL; |
| 287 | destavp = search_next_avp(destavp, NULL)) |
| 288 | { |
| 289 | get_avp_val(destavp, &destval); |
| 290 | |
| 291 | /* OSP destintaion is wrapped in a string */ |
| 292 | dest = (osp_dest*)destval.s.s; |
| 293 | |
| 294 | if (dest->used == 0) { |
| 295 | if (dest->supported == 1) { |
| 296 | LM_DBG("orig dest found\n"); |
| 297 | dest->used = 1; |
| 298 | result = dest; |
| 299 | break; |
| 300 | } else { |
| 301 | /* Make it looks like used */ |
| 302 | dest->used = 1; |
| 303 | /* 111 means wrong protocol */ |
| 304 | dest->lastcode = 111; |
| 305 | LM_DBG("destination does not been supported\n"); |
| 306 | } |
| 307 | } else { |
| 308 | LM_DBG("destination has already been used\n"); |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | if (result == NULL) { |
| 313 | LM_DBG("there is not unused destination\n"); |
| 314 | } |
| 315 | |
| 316 | return result; |
| 317 | } |
| 318 | |
| 319 | /* |
| 320 | * Retrieved the last used originate destination from an AVP |
no test coverage detected