| 390 | } |
| 391 | |
| 392 | static int |
| 393 | cdb_pack_ping_data(const str *aor, const cdb_pair_t *contact, |
| 394 | unsigned int ct_match_cflags, char **cpos, |
| 395 | int *len, int pack_coords) |
| 396 | { |
| 397 | enum { |
| 398 | COL_CONTACT = 1 << 0, |
| 399 | COL_RECEIVED = 1 << 1, |
| 400 | COL_PATH = 1 << 2, |
| 401 | COL_CFLAGS = 1 << 3, |
| 402 | }; |
| 403 | |
| 404 | ucontact_sip_coords *coords = NULL; |
| 405 | cdb_dict_t *ct_fields = (cdb_dict_t *)&contact->val.val.dict; |
| 406 | cdb_pair_t *pair; |
| 407 | struct sip_uri puri; |
| 408 | struct list_head *_; |
| 409 | unsigned int cflags = 0; |
| 410 | const struct socket_info *sock = NULL; |
| 411 | struct proxy_l next_hop; |
| 412 | str ct_uri, received = STR_NULL, path = STR_NULL; |
| 413 | int needed; |
| 414 | char *cp = *cpos; |
| 415 | int cols_needed = COL_CONTACT | COL_RECEIVED | COL_PATH | COL_CFLAGS; |
| 416 | |
| 417 | if (!pack_coords) |
| 418 | goto skip_coords; |
| 419 | |
| 420 | coords = shm_malloc(sizeof *coords + aor->len + contact->key.name.len); |
| 421 | if (!coords) { |
| 422 | LM_ERR("oom\n"); |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | coords->aor.s = (char *)(coords + 1); |
| 427 | str_cpy(&coords->aor, aor); |
| 428 | |
| 429 | coords->ct_key.s = coords->aor.s + aor->len; |
| 430 | str_cpy(&coords->ct_key, &contact->key.name); |
| 431 | |
| 432 | skip_coords: |
| 433 | list_for_each (_, ct_fields) { |
| 434 | if (!cols_needed) |
| 435 | break; |
| 436 | |
| 437 | pair = list_entry(_, cdb_pair_t, list); |
| 438 | switch (pair->key.name.s[0]) { |
| 439 | case 'c': |
| 440 | switch (pair->key.name.s[1]) { |
| 441 | case 'o': |
| 442 | ct_uri = pair->val.val.st; |
| 443 | cols_needed &= ~COL_CONTACT; |
| 444 | break; |
| 445 | |
| 446 | case 'f': |
| 447 | cflags = flag_list_to_bitmask(str2const(&pair->val.val.st), |
| 448 | FLAG_TYPE_BRANCH, FLAG_DELIM, 0); |
| 449 | cols_needed &= ~COL_CFLAGS; |
no test coverage detected