| 510 | |
| 511 | |
| 512 | int dm_send_custom_rpl(struct dm_message *dm) |
| 513 | { |
| 514 | struct msg *ans = (struct msg *)dm->fd_req; |
| 515 | int rc, flags = 0; |
| 516 | |
| 517 | if (!dm_server_autoreply_error && dm_remove_unreplied_req(ans) != 0) { |
| 518 | LM_ERR("unable to build answer, request is no longer available " |
| 519 | "(timeout: %d s)\n", dm_unreplied_req_timeout); |
| 520 | return -1; |
| 521 | } |
| 522 | |
| 523 | if (dm->error_bit) |
| 524 | flags |= MSGFL_ANSW_ERROR; |
| 525 | |
| 526 | rc = fd_msg_new_answer_from_req(fd_g_config->cnf_dict, &ans, flags); |
| 527 | if (rc != 0) { |
| 528 | LM_ERR("failed to create answer message, error: %d\n", rc); |
| 529 | goto error; |
| 530 | } |
| 531 | |
| 532 | if (dm_server_autoreply_error) |
| 533 | FD_CHECK(fd_msg_rescode_set(ans, "DIAMETER_COMMAND_UNSUPPORTED", |
| 534 | "Command Not Implemented", NULL, 1)); |
| 535 | |
| 536 | /* App id */ |
| 537 | { |
| 538 | struct msg_hdr *h; |
| 539 | FD_CHECK(fd_msg_hdr(ans, &h)); |
| 540 | h->msg_appl = dm->app_id; |
| 541 | } |
| 542 | |
| 543 | /* include all AVPs passed from script level */ |
| 544 | if (!dm_server_autoreply_error && dm_pack_avps(ans, &dm->avps) != 0) { |
| 545 | LM_ERR("failed to pack AVPs\n"); |
| 546 | return -1; |
| 547 | } |
| 548 | |
| 549 | FD_CHECK(fd_msg_send(&ans, NULL, NULL)); |
| 550 | FD_CHECK(fd_msg_free(ans)); |
| 551 | return 0; |
| 552 | |
| 553 | error: |
| 554 | fd_msg_free(ans); |
| 555 | return -1; |
| 556 | } |
| 557 | |
| 558 | |
| 559 | static inline int dm_peer_send_msg(struct dm_message *msg) |
no test coverage detected