Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __PJNATH_STUN_AUTH_H__
00021 #define __PJNATH_STUN_AUTH_H__
00022
00028 #include <pjnath/stun_msg.h>
00029
00030
00031 PJ_BEGIN_DECL
00032
00033
00034
00045 typedef enum pj_stun_auth_type
00046 {
00050 PJ_STUN_AUTH_NONE = 0,
00051
00055 PJ_STUN_AUTH_SHORT_TERM = 1,
00056
00060 PJ_STUN_AUTH_LONG_TERM = 2
00061
00062 } pj_stun_auth_type;
00063
00064
00068 typedef enum pj_stun_auth_cred_type
00069 {
00075 PJ_STUN_AUTH_CRED_STATIC,
00076
00083 PJ_STUN_AUTH_CRED_DYNAMIC
00084
00085 } pj_stun_auth_cred_type;
00086
00087
00091 typedef enum pj_stun_passwd_type
00092 {
00096 PJ_STUN_PASSWD_PLAIN = 0,
00097
00103 PJ_STUN_PASSWD_HASHED = 1
00104
00105 } pj_stun_passwd_type;
00106
00107
00114 typedef struct pj_stun_auth_cred
00115 {
00119 pj_stun_auth_cred_type type;
00120
00124 union
00125 {
00131 struct
00132 {
00136 pj_str_t realm;
00137
00141 pj_str_t username;
00142
00146 pj_stun_passwd_type data_type;
00147
00153 pj_str_t data;
00154
00158 pj_str_t nonce;
00159
00160 } static_cred;
00161
00166 struct
00167 {
00171 void *user_data;
00172
00195 pj_status_t (*get_auth)(void *user_data,
00196 pj_pool_t *pool,
00197 pj_str_t *realm,
00198 pj_str_t *nonce);
00199
00225 pj_status_t (*get_cred)(const pj_stun_msg *msg,
00226 void *user_data,
00227 pj_pool_t *pool,
00228 pj_str_t *realm,
00229 pj_str_t *username,
00230 pj_str_t *nonce,
00231 pj_stun_passwd_type *data_type,
00232 pj_str_t *data);
00233
00257 pj_status_t (*get_password)(const pj_stun_msg *msg,
00258 void *user_data,
00259 const pj_str_t *realm,
00260 const pj_str_t *username,
00261 pj_pool_t *pool,
00262 pj_stun_passwd_type *data_type,
00263 pj_str_t *data);
00264
00281 pj_bool_t (*verify_nonce)(const pj_stun_msg *msg,
00282 void *user_data,
00283 const pj_str_t *realm,
00284 const pj_str_t *username,
00285 const pj_str_t *nonce);
00286
00287 } dyn_cred;
00288
00289 } data;
00290
00291 } pj_stun_auth_cred;
00292
00293
00299 typedef struct pj_stun_req_cred_info
00300 {
00305 pj_str_t realm;
00306
00310 pj_str_t username;
00311
00315 pj_str_t nonce;
00316
00323 pj_str_t auth_key;
00324
00325 } pj_stun_req_cred_info;
00326
00327
00335 PJ_DECL(void) pj_stun_auth_cred_dup(pj_pool_t *pool,
00336 pj_stun_auth_cred *dst,
00337 const pj_stun_auth_cred *src);
00338
00346 PJ_DECL(void) pj_stun_req_cred_info_dup(pj_pool_t *pool,
00347 pj_stun_req_cred_info *dst,
00348 const pj_stun_req_cred_info *src);
00349
00350
00367 PJ_DECL(void) pj_stun_create_key(pj_pool_t *pool,
00368 pj_str_t *key,
00369 const pj_str_t *realm,
00370 const pj_str_t *username,
00371 pj_stun_passwd_type data_type,
00372 const pj_str_t *data);
00373
00402 PJ_DECL(pj_status_t) pj_stun_authenticate_request(const pj_uint8_t *pkt,
00403 unsigned pkt_len,
00404 const pj_stun_msg *msg,
00405 pj_stun_auth_cred *cred,
00406 pj_pool_t *pool,
00407 pj_stun_req_cred_info *info,
00408 pj_stun_msg **p_response);
00409
00410
00421 PJ_DECL(pj_bool_t) pj_stun_auth_valid_for_msg(const pj_stun_msg *msg);
00422
00423
00442 PJ_DECL(pj_status_t) pj_stun_authenticate_response(const pj_uint8_t *pkt,
00443 unsigned pkt_len,
00444 const pj_stun_msg *msg,
00445 const pj_str_t *key);
00446
00447
00453 PJ_END_DECL
00454
00455
00456 #endif
00457