Returns 0 - nothing found * 1 - T found */
| 697 | * 1 - T found |
| 698 | */ |
| 699 | int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) |
| 700 | { |
| 701 | struct cell* p_cell; |
| 702 | unsigned int hash_index = 0; |
| 703 | unsigned int entry_label = 0; |
| 704 | unsigned int branch_id = 0; |
| 705 | char *hashi, *branchi, *p, *n; |
| 706 | int hashl, branchl; |
| 707 | int scan_space; |
| 708 | struct cseq_body *cseq; |
| 709 | |
| 710 | char *loopi; |
| 711 | int loopl; |
| 712 | char *syni; |
| 713 | int synl; |
| 714 | |
| 715 | /* make compiler warnings happy */ |
| 716 | loopi=0; |
| 717 | loopl=0; |
| 718 | syni=0; |
| 719 | synl=0; |
| 720 | |
| 721 | /* split the branch into pieces: loop_detection_check(ignored), |
| 722 | hash_table_id, synonym_id, branch_id */ |
| 723 | |
| 724 | if (!(p_msg->via1 && p_msg->via1->branch && p_msg->via1->branch->value.s)) |
| 725 | goto nomatch2; |
| 726 | |
| 727 | /* we do RFC 3261 tid matching and want to see first if there is |
| 728 | * magic cookie in branch */ |
| 729 | if (p_msg->via1->branch->value.len<=MCOOKIE_LEN) |
| 730 | goto nomatch2; |
| 731 | if (memcmp(p_msg->via1->branch->value.s, MCOOKIE, MCOOKIE_LEN)!=0) |
| 732 | goto nomatch2; |
| 733 | |
| 734 | p=p_msg->via1->branch->value.s+MCOOKIE_LEN; |
| 735 | scan_space=p_msg->via1->branch->value.len-MCOOKIE_LEN; |
| 736 | |
| 737 | |
| 738 | /* hash_id */ |
| 739 | n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR); |
| 740 | hashl=n-p; |
| 741 | scan_space-=hashl; |
| 742 | if (!hashl || scan_space<2 || *n!=BRANCH_SEPARATOR) goto nomatch2; |
| 743 | hashi=p; |
| 744 | p=n+1;scan_space--; |
| 745 | |
| 746 | if (!syn_branch) { |
| 747 | /* md5 value */ |
| 748 | n=eat_token2_end( p, p+scan_space, BRANCH_SEPARATOR ); |
| 749 | loopl = n-p; |
| 750 | scan_space-= loopl; |
| 751 | if (n==p || scan_space<2 || *n!=BRANCH_SEPARATOR) |
| 752 | goto nomatch2; |
| 753 | loopi=p; |
| 754 | p=n+1; scan_space--; |
| 755 | } else { |
| 756 | /* synonym id */ |
no test coverage detected