| 1816 | } |
| 1817 | |
| 1818 | int 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 |
nothing calls this directly
no test coverage detected