| 1833 | |
| 1834 | |
| 1835 | static int pv_get_cauthattr(struct sip_msg *msg, pv_param_t *param, |
| 1836 | pv_value_t *res) |
| 1837 | { |
| 1838 | struct authenticate_body *auth = NULL; |
| 1839 | str *s; |
| 1840 | |
| 1841 | if(msg==NULL) |
| 1842 | return -1; |
| 1843 | |
| 1844 | if (msg->first_line.type!=SIP_REPLY) { |
| 1845 | LM_DBG("{Proxy,WWW}-Authenticate header should be only in replies\n"); |
| 1846 | return pv_get_null(msg, param, res); |
| 1847 | } |
| 1848 | switch (msg->REPLY_STATUS) { |
| 1849 | case 401: |
| 1850 | parse_www_authenticate_header(msg, NULL, &auth); |
| 1851 | break; |
| 1852 | case 407: |
| 1853 | parse_proxy_authenticate_header(msg, NULL, &auth); |
| 1854 | break; |
| 1855 | default: |
| 1856 | LM_DBG("bad reply code for a challenge!\n"); |
| 1857 | break; |
| 1858 | } |
| 1859 | if (!auth) { |
| 1860 | LM_DBG("no {Proxy,WWW}-Authenticate header\n"); |
| 1861 | return pv_get_null(msg, param, res); |
| 1862 | } |
| 1863 | |
| 1864 | switch (param->pvn.u.isname.name.n) { |
| 1865 | case 1: |
| 1866 | s = (str *)print_digest_algorithm(auth->algorithm); |
| 1867 | break; |
| 1868 | case 2: |
| 1869 | s = &auth->realm; |
| 1870 | break; |
| 1871 | case 3: |
| 1872 | s = &auth->nonce; |
| 1873 | break; |
| 1874 | case 4: |
| 1875 | s = &auth->opaque; |
| 1876 | break; |
| 1877 | case 5: |
| 1878 | s = &auth->qop; |
| 1879 | break; |
| 1880 | case 6: |
| 1881 | s = &auth->ik; |
| 1882 | break; |
| 1883 | case 7: |
| 1884 | s = &auth->ck; |
| 1885 | break; |
| 1886 | default: |
| 1887 | LM_BUG("unhandled mode %d\n", param->pvn.u.isname.name.n); |
| 1888 | return pv_get_null(msg, param, res); |
| 1889 | } |
| 1890 | |
| 1891 | return pv_get_strval(msg, param, res, s); |
| 1892 | } |
nothing calls this directly
no test coverage detected