| 788 | } |
| 789 | |
| 790 | static void term_entity(b2bl_entity_id_t *entity, int hash_index, str *key) |
| 791 | { |
| 792 | str bye = {BYE, BYE_LEN}; |
| 793 | b2b_req_data_t req_data; |
| 794 | b2b_rpl_data_t rpl_data; |
| 795 | struct b2b_context *ctx; |
| 796 | |
| 797 | if (entity->type == B2B_SERVER && |
| 798 | entity->state != B2BL_ENT_CONFIRMED) { |
| 799 | memset(&rpl_data, 0, sizeof(b2b_rpl_data_t)); |
| 800 | PREP_RPL_DATA(entity); |
| 801 | rpl_data.method = METHOD_INVITE; |
| 802 | rpl_data.body = NULL; |
| 803 | |
| 804 | if (entity->state == B2BL_ENT_CANCELING) { |
| 805 | rpl_data.code = 487; |
| 806 | rpl_data.text = &requestTerminated; |
| 807 | } else { |
| 808 | rpl_data.code = 408; |
| 809 | rpl_data.text = &requestTimeout; |
| 810 | } |
| 811 | |
| 812 | if(run_b2be_api(&b2b_api, send_reply, &rpl_data) < 0) |
| 813 | LM_ERR("Sending reply failed - %d, [%.*s]\n", |
| 814 | rpl_data.code, entity->key.len, |
| 815 | entity->key.s); |
| 816 | } else { |
| 817 | if ( key && ( !push_new_global_context() || |
| 818 | (ctx=b2b_api.get_context())==NULL || |
| 819 | pkg_str_dup(&ctx->b2bl_key, key)!=0 ) |
| 820 | ) { |
| 821 | LM_ERR("preparing ctx for request failed, entity [%.*s]\n", |
| 822 | entity->key.len, entity->key.s); |
| 823 | } else { |
| 824 | memset(&req_data, 0, sizeof(b2b_req_data_t)); |
| 825 | PREP_REQ_DATA(entity); |
| 826 | req_data.method =&bye; |
| 827 | run_b2be_api(&b2b_api, send_request, &req_data); |
| 828 | if (key) |
| 829 | pop_pushed_global_context(); |
| 830 | } |
| 831 | } |
| 832 | } |
| 833 | |
| 834 | void b2bl_clean(unsigned int ticks, void* param) |
| 835 | { |
no test coverage detected