MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / isn_query

Function isn_query

modules/enum/enum.c:692–741  ·  view source on GitHub ↗

* See documentation in README file. */

Source from the content-addressed store, hash-verified

690 * See documentation in README file.
691 */
692int isn_query(struct sip_msg* _msg, str* suffix, str* service)
693{
694 char *user_s = NULL;
695 int user_len, i, j;
696 char name[MAX_DOMAIN_SIZE] = {0};
697 char string[17] = {0};
698 char szItad[17] = {0};
699 size_t nItlen = 0;
700
701 if (parse_sip_msg_uri(_msg) < 0) {
702 LM_ERR("Parsing of R-URI failed\n");
703 return -1;
704 }
705
706 user_s = _msg->parsed_uri.user.s;
707 user_len = _msg->parsed_uri.user.len;
708
709 memcpy(&(string[0]), user_s, user_len);
710 string[user_len] = (char)0;
711
712 /* Do primitive test for correct ISN format, */
713 /* and set szItad to the ISN ITAD (RFC 3872/2871). */
714 /* Correct ISN format guessed from freenum.org and IANA */
715 /* doc http://www.iana.org/assignments/trip-parameters/ */
716 {
717 char *pAster = strchr(string, '*');
718 if (pAster && (nItlen = strspn(pAster + sizeof(char), "0123456789")))
719 strncpy(szItad, pAster + sizeof(char), nItlen);
720 else {
721 LM_ERR("R-URI user does not contain a valid ISN\n");
722 return -1;
723 }
724 }
725
726 /* Ammend the original ENUM E.164 string logic to process */
727 /* ISN numbers instead, which include a nonreversed ITAD. */
728 i = user_len - nItlen - sizeof(char); /* Ex: *1212 */
729 j = 0;
730 while (i--) {
731 name[j] = user_s[i];
732 name[j + 1] = '.';
733 j = j + 2;
734 }
735
736 strcat(name + j, szItad); /* Copy the unreversed ITAD, */
737 name[j + nItlen] = '.'; /* and append a trailing dot. */
738 memcpy(name + j + nItlen + sizeof(char), suffix->s, suffix->len + 1);
739
740 return do_query(_msg, string, name, service);
741}
742
743
744/*********** INFRASTRUCTURE ENUM ***************/

Callers

nothing calls this directly

Calls 2

parse_sip_msg_uriFunction · 0.85
do_queryFunction · 0.85

Tested by

no test coverage detected