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

Function tr_eval_ip

transformations.c:1818–2059  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1816}
1817
1818int tr_eval_ip(struct sip_msg *msg, tr_param_t *tp,int subtype,
1819 pv_value_t *val)
1820{
1821 char *buffer, *_tr_buffer = get_tr_buffer();
1822 struct ip_addr *p_ip;
1823 str inet = str_init("INET");
1824 str inet6 = str_init("INET6");
1825 struct hostent *server;
1826 struct ip_addr ip;
1827 unsigned int len, rc;
1828 struct net *mask;
1829 pv_value_t v;
1830 str sv;
1831 char *p;
1832
1833 if (!val)
1834 return -1;
1835
1836 if (val->flags & PV_VAL_NULL)
1837 return 0;
1838
1839 if(!(val->flags&PV_VAL_STR) || val->rs.len<=0)
1840 goto error;
1841
1842 switch (subtype)
1843 {
1844 case TR_IP_FAMILY:
1845 if (val->rs.len == 4)
1846 {
1847 memcpy(val->rs.s,inet.s,inet.len);
1848 val->rs.len = inet.len;
1849 }
1850 else if (val->rs.len == 16)
1851 {
1852 memcpy(val->rs.s,inet6.s,inet6.len);
1853 val->rs.len = inet6.len;
1854 }
1855 else
1856 {
1857 LM_ERR("Invalid ip address provided for ip.family. "
1858 "Binary format expected !\n");
1859 goto error;
1860 }
1861
1862 val->flags = PV_VAL_STR;
1863 break;
1864 case TR_IP_NTOP:
1865 if (val->rs.len == 4)
1866 ip.af = AF_INET;
1867 else if (val->rs.len == 16)
1868 ip.af = AF_INET6;
1869 else
1870 {
1871 LM_ERR("Invalid ip address provided for ip.ntop. "
1872 "Binary format expected !\n");
1873 goto error;
1874 }
1875

Callers

nothing calls this directly

Calls 11

ip_addr2aFunction · 0.85
int2strFunction · 0.85
str2ipFunction · 0.85
str2ip6Function · 0.85
resolvehostFunction · 0.85
pv_get_spec_valueFunction · 0.85
q_memchrFunction · 0.85
str2intFunction · 0.85
mk_net_bitlenFunction · 0.85
matchnetFunction · 0.85
ip_addr_is_1918Function · 0.85

Tested by

no test coverage detected