Both Diameter requests and replies arrive here */
| 629 | |
| 630 | /* Both Diameter requests and replies arrive here */ |
| 631 | static int dm_receive_msg(struct msg **_msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act) |
| 632 | { |
| 633 | cJSON *avps = NULL; |
| 634 | struct msg_hdr *hdr = NULL; |
| 635 | struct msg *msg = *_msg; |
| 636 | struct avp *a = NULL; |
| 637 | struct avp_hdr * h = NULL; |
| 638 | int rc; |
| 639 | str tid; |
| 640 | struct dm_cond **prpl_cond, *rpl_cond; |
| 641 | unsigned int hentry; |
| 642 | |
| 643 | FD_CHECK(fd_msg_hdr(msg, &hdr)); |
| 644 | |
| 645 | if (hdr->msg_flags & CMD_FLAG_REQUEST) |
| 646 | return dm_receive_req(_msg, avp, sess, data, act); |
| 647 | |
| 648 | LM_DBG("received Diameter answer (appl: %u, cmd: %u)\n", |
| 649 | hdr->msg_appl, hdr->msg_code); |
| 650 | |
| 651 | cJSON_InitHooks(&shm_mem_hooks); |
| 652 | avps = cJSON_CreateArray(); |
| 653 | if (!avps) { |
| 654 | LM_ERR("oom 1\n"); |
| 655 | goto out; |
| 656 | } |
| 657 | |
| 658 | if (dm_avps2json(msg, avps) != 0) { |
| 659 | LM_ERR("failed to pack Message AVPs as JSON string\n"); |
| 660 | goto out; |
| 661 | } |
| 662 | |
| 663 | rc = fd_msg_search_avp(msg, dm_dict.Session_Id, &a); |
| 664 | if (rc != 0) { |
| 665 | LM_DBG("Missing Session-Id AVP in Diameter Answer %d/%d (rc: %d), " |
| 666 | "looking for Transaction-Id\n", hdr->msg_appl, hdr->msg_code, rc); |
| 667 | rc = fd_msg_search_avp(msg, dm_dict.Transaction_Id, &a); |
| 668 | if (rc != 0) { |
| 669 | LM_WARN("Missing Transaction-Id AVP in Diameter Answer %d/%d (rc: %d)\n", |
| 670 | hdr->msg_appl, hdr->msg_code, rc); |
| 671 | goto out; |
| 672 | } |
| 673 | |
| 674 | FD_CHECK_GT(fd_msg_avp_hdr(a, &h)); |
| 675 | tid.s = (char *)h->avp_value->os.data; |
| 676 | tid.len = (int)h->avp_value->os.len; |
| 677 | |
| 678 | LM_DBG("%d/%d reply, Transaction-Id: %.*s\n", hdr->msg_appl, |
| 679 | hdr->msg_code, tid.len, tid.s); |
| 680 | } else { |
| 681 | FD_CHECK_GT(fd_msg_avp_hdr(a, &h)); |
| 682 | tid.s = (char *)h->avp_value->os.data; |
| 683 | tid.len = (int)h->avp_value->os.len; |
| 684 | |
| 685 | LM_DBG("%d/%d reply, Session-Id: %.*s\n", hdr->msg_appl, |
| 686 | hdr->msg_code, tid.len, tid.s); |
| 687 | } |
| 688 |
nothing calls this directly
no test coverage detected