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

Function tr_parse_ip

transformations.c:3771–3838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3769}
3770
3771int tr_parse_ip(str *in, trans_t *t)
3772{
3773 char *p;
3774 str name;
3775
3776 if (in == NULL || t == NULL)
3777 return -1;
3778
3779 p = in->s;
3780 name.s = in->s;
3781
3782 /* find next token */
3783 while (is_in_str(p,in) && *p!=TR_PARAM_MARKER && *p!=TR_RBRACKET) p++;
3784 if (*p == '\0')
3785 {
3786 LM_ERR("invalid transformation: %.*s\n",in->len,in->s);
3787 goto error;
3788 }
3789
3790 name.len = p - name.s;
3791 trim(&name);
3792
3793 if (name.len==6 && strncasecmp(name.s,"family",6)==0) {
3794 t->subtype = TR_IP_FAMILY;
3795 return 0;
3796 } else if (name.len==4 && strncasecmp(name.s,"ntop",4)==0) {
3797 t->subtype = TR_IP_NTOP;
3798 return 0;
3799 } else if (name.len == 4 && strncasecmp(name.s,"isip",4) == 0) {
3800 t->subtype = TR_IP_ISIP;
3801 return 0;
3802 } else if (name.len == 5 && strncasecmp(name.s,"isip4",5) == 0) {
3803 t->subtype = TR_IP_ISIP4;
3804 return 0;
3805 } else if (name.len == 5 && strncasecmp(name.s,"isip6",5) == 0) {
3806 t->subtype = TR_IP_ISIP6;
3807 return 0;
3808 } else if (name.len == 4 && strncasecmp(name.s,"pton",4) == 0) {
3809 t->subtype = TR_IP_PTON;
3810 return 0;
3811 } else if (name.len == 7 && strncasecmp(name.s,"resolve",7) == 0) {
3812 t->subtype = TR_IP_RESOLVE;
3813 return 0;
3814 } else if (name.len == 7 && strncasecmp(name.s,"matches",5) == 0) {
3815 t->subtype = TR_IP_MATCHES;
3816 if(*p!=TR_PARAM_MARKER)
3817 {
3818 LM_ERR("invalid value transformation: %.*s\n",
3819 in->len, in->s);
3820 goto error;
3821 }
3822 p++;
3823 LM_DBG("preparing to parse param\n");
3824 if (tr_parse_sparam(p, in, &t->params, 0) == NULL)
3825 goto error;
3826 return 0;
3827 } else if (name.len == 9 && strncasecmp(name.s,"isprivate",9) == 0) {
3828 t->subtype = TR_IP_ISPRIVATE;

Callers

nothing calls this directly

Calls 2

trimFunction · 0.85
tr_parse_sparamFunction · 0.85

Tested by

no test coverage detected