| 730 | /******* Very simple hash for retransmission detection *******/ |
| 731 | |
| 732 | unsigned long call::hash(const char * msg) |
| 733 | { |
| 734 | unsigned long hash = 0; |
| 735 | int c; |
| 736 | |
| 737 | if (rtcheck == RTCHECK_FULL) { |
| 738 | while ((c = *msg++)) |
| 739 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 740 | } else if (rtcheck == RTCHECK_LOOSE) { |
| 741 | /* Based on section 11.5 (bullet 2) of RFC2543 we only take into account |
| 742 | * the To, From, Call-ID, and CSeq values. */ |
| 743 | const char *hdr = get_header_content(msg, "To:"); |
| 744 | while ((c = *hdr++)) |
| 745 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 746 | hdr = get_header_content(msg, "From:"); |
| 747 | while ((c = *hdr++)) |
| 748 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 749 | hdr = get_header_content(msg, "Call-ID:"); |
| 750 | while ((c = *hdr++)) |
| 751 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 752 | hdr = get_header_content(msg, "CSeq:"); |
| 753 | while ((c = *hdr++)) |
| 754 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 755 | /* For responses, we should also consider the code and body (if any), |
| 756 | * because they are not nearly as well defined as the request retransmission. */ |
| 757 | if (!strncmp(msg, "SIP/2.0", strlen("SIP/2.0"))) { |
| 758 | /* Add the first line into the hash. */ |
| 759 | hdr = msg + strlen("SIP/2.0"); |
| 760 | while ((c = *hdr++) && (c != '\r')) |
| 761 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 762 | /* Add the body (if any) into the hash. */ |
| 763 | hdr = strstr(msg, "\r\n\r\n"); |
| 764 | if (hdr) { |
| 765 | hdr += strlen("\r\n\r\n"); |
| 766 | while ((c = *hdr++)) |
| 767 | hash = c + (hash << 6) + (hash << 16) - hash; |
| 768 | } |
| 769 | } |
| 770 | } else { |
| 771 | ERROR("Internal error: Invalid rtcheck %d", rtcheck); |
| 772 | } |
| 773 | |
| 774 | return hash; |
| 775 | } |
| 776 | |
| 777 | /******************* Call class implementation ****************/ |
| 778 | call::call(scenario *call_scenario, const char *p_id, bool use_ipv6, int userId, struct sockaddr_storage *dest) : listener(p_id, true) |
nothing calls this directly
no test coverage detected