/src/opensips/parser/parse_authenticate.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2011 VoIP Embedded Inc. <http://www.voipembedded.com/> |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | * |
20 | | * History: |
21 | | * -------- |
22 | | * 2005-01-31 first version (ramona) |
23 | | * 2011-03-07 Initial revision (Ovidiu Sas) |
24 | | */ |
25 | | |
26 | | #ifndef PARSE_AUTHENTICATE_H |
27 | | #define PARSE_AUTHENTICATE_H |
28 | | |
29 | | |
30 | | #include "msg_parser.h" |
31 | | #include "digest/digest_parser.h" |
32 | | |
33 | 0 | #define AUTHENTICATE_STALE (1<<0) |
34 | 0 | #define QOP_AUTH (1<<1) |
35 | 0 | #define QOP_AUTH_INT (1<<2) |
36 | | |
37 | | struct authenticate_body { |
38 | | alg_t algorithm; |
39 | | int flags; |
40 | | str realm; |
41 | | str domain; |
42 | | str nonce; |
43 | | str opaque; |
44 | | str qop; |
45 | | str ik; |
46 | | str ck; |
47 | | }; |
48 | | |
49 | | /* casting macro for accessing the topmost www/proxy authenticate body */ |
50 | | #define get_www_authenticate(p_msg) ((struct authenticate_body*)(p_msg)->www_authenticate->parsed) |
51 | | #define get_proxy_authenticate(p_msg) ((struct authenticate_body*)(p_msg)->proxy_authenticate->parsed) |
52 | | |
53 | | /* |
54 | | * WWW/Proxy-Authenticate header field parser |
55 | | */ |
56 | | struct match_auth_hf_desc; |
57 | | typedef int (*match_auth_hf_function)(const struct authenticate_body *, |
58 | | const struct match_auth_hf_desc *); |
59 | | |
60 | | struct match_auth_hf_desc { |
61 | | match_auth_hf_function matchf; |
62 | | const void *argp; |
63 | | }; |
64 | | |
65 | | #define MATCH_AUTH_HF(_fn, _argp) (const struct match_auth_hf_desc){ \ |
66 | | .matchf = (_fn), .argp = (_argp)} |
67 | | |
68 | | int parse_proxy_authenticate_header(struct sip_msg *msg, |
69 | | const struct match_auth_hf_desc *md, struct authenticate_body **picked_auth); |
70 | | int parse_www_authenticate_header(struct sip_msg *msg, |
71 | | const struct match_auth_hf_desc *md, struct authenticate_body **picked_auth); |
72 | | int parse_authenticate_header(struct hdr_field *authenticate, |
73 | | const struct match_auth_hf_desc *md, struct authenticate_body **picked_auth); |
74 | | static inline int _parse_authenticate_header(struct hdr_field *authenticate) |
75 | 0 | { |
76 | 0 | struct authenticate_body *_; |
77 | 0 | return parse_authenticate_header(authenticate, NULL, &_); |
78 | 0 | } Unexecuted instantiation: hf.c:_parse_authenticate_header Unexecuted instantiation: pvar.c:_parse_authenticate_header Unexecuted instantiation: parse_authenticate.c:_parse_authenticate_header |
79 | | |
80 | | |
81 | | int parse_qop_value(str val, struct authenticate_body *auth); |
82 | | int parse_authenticate_body(str body, struct authenticate_body *auth); |
83 | | |
84 | | void free_authenticate(struct authenticate_body *authenticate_b); |
85 | | |
86 | | #endif /* ! PARSE_AUTHENTICATE_H */ |