Tristan Matthews | 0a329cc | 2013-07-17 13:20:14 -0400 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
| 3 | * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) |
| 4 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
| 5 | * |
| 6 | * This program 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 | * This program 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | #ifndef __PJSIP_AUTH_SIP_AUTH_MSG_H__ |
| 21 | #define __PJSIP_AUTH_SIP_AUTH_MSG_H__ |
| 22 | |
| 23 | #include <pjsip/sip_msg.h> |
| 24 | |
| 25 | PJ_BEGIN_DECL |
| 26 | |
| 27 | /** |
| 28 | * @addtogroup PJSIP_MSG_HDR |
| 29 | * @{ |
| 30 | */ |
| 31 | |
| 32 | /** |
| 33 | * Common credential structure represents common credential fields |
| 34 | * present in Authorization/Proxy-Authorization header. |
| 35 | */ |
| 36 | struct pjsip_common_credential |
| 37 | { |
| 38 | pj_str_t realm; /**< Credential's realm. */ |
| 39 | pjsip_param other_param; /**< Other parameters. */ |
| 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * @see pjsip_common_credential |
| 44 | */ |
| 45 | typedef struct pjsip_common_credential pjsip_common_credential; |
| 46 | |
| 47 | |
| 48 | /** |
| 49 | * This structure describe credential used in Authorization and |
| 50 | * Proxy-Authorization header for digest authentication scheme. |
| 51 | */ |
| 52 | struct pjsip_digest_credential |
| 53 | { |
| 54 | pj_str_t realm; /**< Realm of the credential */ |
| 55 | pjsip_param other_param; /**< Other parameters. */ |
| 56 | pj_str_t username; /**< Username parameter. */ |
| 57 | pj_str_t nonce; /**< Nonce parameter. */ |
| 58 | pj_str_t uri; /**< URI parameter. */ |
| 59 | pj_str_t response; /**< Response digest. */ |
| 60 | pj_str_t algorithm; /**< Algorithm. */ |
| 61 | pj_str_t cnonce; /**< Cnonce. */ |
| 62 | pj_str_t opaque; /**< Opaque value. */ |
| 63 | pj_str_t qop; /**< Quality of protection. */ |
| 64 | pj_str_t nc; /**< Nonce count. */ |
| 65 | }; |
| 66 | |
| 67 | /** |
| 68 | * @see pjsip_digest_credential |
| 69 | */ |
| 70 | typedef struct pjsip_digest_credential pjsip_digest_credential; |
| 71 | |
| 72 | /** |
| 73 | * This structure describe credential used in Authorization and |
| 74 | * Proxy-Authorization header for PGP authentication scheme. |
| 75 | */ |
| 76 | struct pjsip_pgp_credential |
| 77 | { |
| 78 | pj_str_t realm; /**< Realm. */ |
| 79 | pjsip_param other_param; /**< Other parameters. */ |
| 80 | pj_str_t version; /**< Version parameter. */ |
| 81 | pj_str_t signature; /**< Signature parameter. */ |
| 82 | pj_str_t signed_by; /**< Signed by parameter. */ |
| 83 | pj_str_t nonce; /**< Nonce parameter. */ |
| 84 | }; |
| 85 | |
| 86 | /** |
| 87 | * @see pjsip_pgp_credential |
| 88 | */ |
| 89 | typedef struct pjsip_pgp_credential pjsip_pgp_credential; |
| 90 | |
| 91 | /** |
| 92 | * This structure describes SIP Authorization header (and also SIP |
| 93 | * Proxy-Authorization header). |
| 94 | */ |
| 95 | struct pjsip_authorization_hdr |
| 96 | { |
| 97 | /** Standard header fiends. */ |
| 98 | PJSIP_DECL_HDR_MEMBER(struct pjsip_authorization_hdr); |
| 99 | |
| 100 | /** Authorization scheme. */ |
| 101 | pj_str_t scheme; |
| 102 | |
| 103 | /** Type of credentials, depending on the scheme. */ |
| 104 | union |
| 105 | { |
| 106 | pjsip_common_credential common; /**< Common fields. */ |
| 107 | pjsip_digest_credential digest; /**< Digest credentials. */ |
| 108 | pjsip_pgp_credential pgp; /**< PGP credentials. */ |
| 109 | } credential; |
| 110 | }; |
| 111 | |
| 112 | /** |
| 113 | * @see pjsip_authorization_hdr. |
| 114 | */ |
| 115 | typedef struct pjsip_authorization_hdr pjsip_authorization_hdr; |
| 116 | |
| 117 | /** SIP Proxy-Authorization header shares the same structure as SIP |
| 118 | Authorization header. |
| 119 | */ |
| 120 | typedef struct pjsip_authorization_hdr pjsip_proxy_authorization_hdr; |
| 121 | |
| 122 | /** |
| 123 | * Create SIP Authorization header. |
| 124 | * @param pool Pool where memory will be allocated from. |
| 125 | * @return SIP Authorization header. |
| 126 | */ |
| 127 | PJ_DECL(pjsip_authorization_hdr*) |
| 128 | pjsip_authorization_hdr_create(pj_pool_t *pool); |
| 129 | |
| 130 | /** |
| 131 | * Create SIP Proxy-Authorization header. |
| 132 | * @param pool Pool where memory will be allocated from. |
| 133 | * @return SIP Proxy-Authorization header. |
| 134 | */ |
| 135 | PJ_DECL(pjsip_proxy_authorization_hdr*) |
| 136 | pjsip_proxy_authorization_hdr_create(pj_pool_t *pool); |
| 137 | |
| 138 | |
| 139 | /** |
| 140 | * This structure describes common fields in authentication challenge |
| 141 | * headers (WWW-Authenticate and Proxy-Authenticate). |
| 142 | */ |
| 143 | struct pjsip_common_challenge |
| 144 | { |
| 145 | pj_str_t realm; /**< Realm for the challenge. */ |
| 146 | pjsip_param other_param; /**< Other parameters. */ |
| 147 | }; |
| 148 | |
| 149 | /** |
| 150 | * @see pjsip_common_challenge |
| 151 | */ |
| 152 | typedef struct pjsip_common_challenge pjsip_common_challenge; |
| 153 | |
| 154 | /** |
| 155 | * This structure describes authentication challenge used in Proxy-Authenticate |
| 156 | * or WWW-Authenticate for digest authentication scheme. |
| 157 | */ |
| 158 | struct pjsip_digest_challenge |
| 159 | { |
| 160 | pj_str_t realm; /**< Realm for the challenge. */ |
| 161 | pjsip_param other_param; /**< Other parameters. */ |
| 162 | pj_str_t domain; /**< Domain. */ |
| 163 | pj_str_t nonce; /**< Nonce challenge. */ |
| 164 | pj_str_t opaque; /**< Opaque value. */ |
| 165 | int stale; /**< Stale parameter. */ |
| 166 | pj_str_t algorithm; /**< Algorithm parameter. */ |
| 167 | pj_str_t qop; /**< Quality of protection. */ |
| 168 | }; |
| 169 | |
| 170 | /** |
| 171 | * @see pjsip_digest_challenge |
| 172 | */ |
| 173 | typedef struct pjsip_digest_challenge pjsip_digest_challenge; |
| 174 | |
| 175 | /** |
| 176 | * This structure describes authentication challenge used in Proxy-Authenticate |
| 177 | * or WWW-Authenticate for PGP authentication scheme. |
| 178 | */ |
| 179 | struct pjsip_pgp_challenge |
| 180 | { |
| 181 | pj_str_t realm; /**< Realm for the challenge. */ |
| 182 | pjsip_param other_param; /**< Other parameters. */ |
| 183 | pj_str_t version; /**< PGP version. */ |
| 184 | pj_str_t micalgorithm; /**< micalgorithm parameter. */ |
| 185 | pj_str_t pubalgorithm; /**< pubalgorithm parameter. */ |
| 186 | pj_str_t nonce; /**< Nonce challenge. */ |
| 187 | }; |
| 188 | |
| 189 | /** |
| 190 | * @see pjsip_pgp_challenge |
| 191 | */ |
| 192 | typedef struct pjsip_pgp_challenge pjsip_pgp_challenge; |
| 193 | |
| 194 | /** |
| 195 | * This structure describe SIP WWW-Authenticate header (Proxy-Authenticate |
| 196 | * header also uses the same structure). |
| 197 | */ |
| 198 | struct pjsip_www_authenticate_hdr |
| 199 | { |
| 200 | /** Standard header fields. */ |
| 201 | PJSIP_DECL_HDR_MEMBER(struct pjsip_www_authenticate_hdr); |
| 202 | |
| 203 | /** Authentication scheme */ |
| 204 | pj_str_t scheme; |
| 205 | |
| 206 | /** This union contains structures that are only relevant |
| 207 | depending on the value of the scheme being used. |
| 208 | */ |
| 209 | union |
| 210 | { |
| 211 | pjsip_common_challenge common; /**< Common fields. */ |
| 212 | pjsip_digest_challenge digest; /**< Digest challenge. */ |
| 213 | pjsip_pgp_challenge pgp; /**< PGP challenge. */ |
| 214 | } challenge; |
| 215 | }; |
| 216 | |
| 217 | /** |
| 218 | * WWW-Authenticate header. |
| 219 | */ |
| 220 | typedef struct pjsip_www_authenticate_hdr pjsip_www_authenticate_hdr; |
| 221 | |
| 222 | /** |
| 223 | * Proxy-Authenticate header. |
| 224 | */ |
| 225 | typedef struct pjsip_www_authenticate_hdr pjsip_proxy_authenticate_hdr; |
| 226 | |
| 227 | |
| 228 | /** |
| 229 | * Create SIP WWW-Authenticate header. |
| 230 | * |
| 231 | * @param pool Pool where memory will be allocated from. |
| 232 | * @return SIP WWW-Authenticate header. |
| 233 | */ |
| 234 | PJ_DECL(pjsip_www_authenticate_hdr*) |
| 235 | pjsip_www_authenticate_hdr_create(pj_pool_t *pool); |
| 236 | |
| 237 | /** |
| 238 | * Create SIP Proxy-Authenticate header. |
| 239 | * |
| 240 | * @param pool Pool where memory will be allocated from. |
| 241 | * @return SIP Proxy-Authenticate header. |
| 242 | */ |
| 243 | PJ_DECL(pjsip_proxy_authenticate_hdr*) |
| 244 | pjsip_proxy_authenticate_hdr_create(pj_pool_t *pool); |
| 245 | |
| 246 | /** |
| 247 | * @} |
| 248 | */ |
| 249 | |
| 250 | PJ_END_DECL |
| 251 | |
| 252 | #endif /* __PJSIP_AUTH_SIP_AUTH_MSG_H__ */ |