| 674 | } |
| 675 | |
| 676 | void cancel_invite(struct sip_msg *cancel_msg, |
| 677 | struct cell *t_cancel, struct cell *t_invite, int locked) |
| 678 | { |
| 679 | |
| 680 | branch_bm_t cancel_bitmap = BRANCH_BM_ZERO; |
| 681 | str reason; |
| 682 | |
| 683 | /* send back 200 OK as per RFC3261 */ |
| 684 | reason.s = CANCELING; |
| 685 | reason.len = sizeof(CANCELING)-1; |
| 686 | if (locked) |
| 687 | t_reply_unsafe( t_cancel, cancel_msg, 200, &reason ); |
| 688 | else |
| 689 | t_reply( t_cancel, cancel_msg, 200, &reason ); |
| 690 | |
| 691 | get_cancel_reason(cancel_msg, t_cancel->flags, &reason); |
| 692 | |
| 693 | LOCK_REPLIES(t_invite); |
| 694 | /* we need to check which branches should be canceled under lock to avoid |
| 695 | * concurrency with replies that are coming in the same time */ |
| 696 | /* generate local cancels for all branches */ |
| 697 | which_cancel(t_invite, cancel_bitmap ); |
| 698 | UNLOCK_REPLIES(t_invite); |
| 699 | |
| 700 | set_cancel_extra_hdrs( reason.s, reason.len); |
| 701 | cancel_uacs(t_invite, cancel_bitmap ); |
| 702 | set_cancel_extra_hdrs( NULL, 0); |
| 703 | |
| 704 | /* Do not do anything about branches with no received reply; |
| 705 | * continue the retransmission hoping to get something back; |
| 706 | * if still not, we will generate the 408 Timeout based on FR |
| 707 | * timer; this helps with better coping with missed/lated provisional |
| 708 | * replies in the context of cancelling the transaction |
| 709 | */ |
| 710 | |
| 711 | /* Handle a special case here, when there is only one PHONY |
| 712 | * branch (not a real signaling branch, just a fake one |
| 713 | * to force keeping the transaction alive) - if the case, |
| 714 | * it means there are no other real signaling branches, |
| 715 | * so we can force a 487 reply on the PHONY branch, in order |
| 716 | * to terminate the whole transaction on the spot */ |
| 717 | if ( (t_invite->nr_of_outgoings-t_invite->first_branch)==1 && |
| 718 | (TM_BRANCH(t_invite,t_invite->first_branch).flags & T_UAC_IS_PHONY) ) { |
| 719 | relay_reply( t_invite, FAKED_REPLY, t_invite->first_branch, |
| 720 | 487, cancel_bitmap); |
| 721 | } |
| 722 | #if 0 |
| 723 | /* internally cancel branches with no received reply */ |
| 724 | for (i=t_invite->first_branch; i<t_invite->nr_of_outgoings; i++) { |
| 725 | if (TM_BRANCH(t_invite,i).last_received==0){ |
| 726 | /* reset the "request" timers */ |
| 727 | reset_timer(&TM_BRANCH(t_invite,i).request.retr_timer); |
| 728 | reset_timer(&TM_BRANCH(t_invite,i).request.fr_timer); |
| 729 | LOCK_REPLIES( t_invite ); |
| 730 | relay_reply(t_invite,FAKED_REPLY,i,487,&dummy_bm); |
| 731 | } |
| 732 | } |
| 733 | #endif |
no test coverage detected