Determine current transaction * * Found Not Found Error (e.g. parsing) Not Here (e.g. anycast) * Return Value 1 0 -1 -2 * T ptr 0 T_UNDEFINED T_UNDEFINED */
| 867 | * T ptr 0 T_UNDEFINED T_UNDEFINED |
| 868 | */ |
| 869 | int t_check( struct sip_msg* p_msg , int *param_branch ) |
| 870 | { |
| 871 | int local_branch; |
| 872 | |
| 873 | /* is T still up-to-date ? */ |
| 874 | LM_DBG("start=%p\n", T); |
| 875 | if ( T==T_UNDEFINED ) |
| 876 | { |
| 877 | /* transaction lookup */ |
| 878 | if ( p_msg->first_line.type==SIP_REQUEST ) { |
| 879 | /* force parsing all the needed headers*/ |
| 880 | if (parse_headers(p_msg, HDR_EOH_F, 0 )==-1) { |
| 881 | LM_ERR("parsing error\n"); |
| 882 | return -1; |
| 883 | } |
| 884 | /* in case, we act as UAS for INVITE and reply with 200, |
| 885 | * we will need to run dialog-matching for subsequent |
| 886 | * ACK, for which we need From-tag; We also need from-tag |
| 887 | * in case people want to have proxied e2e ACKs accounted |
| 888 | */ |
| 889 | if (p_msg->REQ_METHOD==METHOD_INVITE |
| 890 | && parse_from_header(p_msg)<0) { |
| 891 | LM_ERR("from parsing failed\n"); |
| 892 | return -1; |
| 893 | } |
| 894 | t_lookup_request( p_msg , 0 /* unlock before returning */ ); |
| 895 | } else { |
| 896 | /* we need Via for branch and Cseq method to distinguish |
| 897 | replies with the same branch/cseqNr (CANCEL) |
| 898 | */ |
| 899 | if ( parse_headers(p_msg, HDR_VIA1_F|HDR_CSEQ_F, 0 )==-1 |
| 900 | || !p_msg->via1 || !p_msg->cseq ) { |
| 901 | LM_ERR("reply cannot be parsed\n"); |
| 902 | return -1; |
| 903 | } |
| 904 | |
| 905 | /* if that is an INVITE, we will also need to-tag |
| 906 | for later ACK matching */ |
| 907 | if ( get_cseq(p_msg)->method_id==METHOD_INVITE ) { |
| 908 | if (parse_headers(p_msg, HDR_TO_F, 0)==-1 || !p_msg->to) { |
| 909 | LM_ERR("INVITE reply cannot be parsed\n"); |
| 910 | return -1; |
| 911 | } |
| 912 | } |
| 913 | /* first check if the transaction is addressed to us */ |
| 914 | if (!tm_reply_replicate(p_msg)) |
| 915 | t_reply_matching(p_msg , |
| 916 | param_branch!=0?param_branch:&local_branch); |
| 917 | else |
| 918 | return -2; /* reply replicated |
| 919 | should have never got here */ |
| 920 | |
| 921 | } |
| 922 | #ifdef EXTRA_DEBUG |
| 923 | if ( T && T!=T_UNDEFINED && T->damocles) { |
| 924 | LM_ERR("transaction %p scheduled for deletion " |
| 925 | "and called from t_check\n", T); |
| 926 | abort(); |
no test coverage detected