1
/* $Id: auth.h 3553 2011-05-05 06:14:19Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
4
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
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.
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.
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
20
#ifndef __PJ_TURN_SRV_AUTH_H__
21
#define __PJ_TURN_SRV_AUTH_H__
26
* Initialize TURN authentication subsystem.
28
* @return PJ_SUCCESS on success.
30
PJ_DECL(pj_status_t) pj_turn_auth_init(const char *realm);
33
* Shutdown TURN authentication subsystem.
35
PJ_DECL(void) pj_turn_auth_dinit(void);
38
* This function is called by pj_stun_verify_credential() when
39
* server needs to challenge the request with 401 response.
41
* @param user_data Should be ignored.
42
* @param pool Pool to allocate memory.
43
* @param realm On return, the function should fill in with
44
* realm if application wants to use long term
45
* credential. Otherwise application should set
46
* empty string for the realm.
47
* @param nonce On return, if application wants to use long
48
* term credential, it MUST fill in the nonce
49
* with some value. Otherwise if short term
50
* credential is wanted, it MAY set this value.
51
* If short term credential is wanted and the
52
* application doesn't want to include NONCE,
53
* then it must set this to empty string.
55
* @return The callback should return PJ_SUCCESS, or
56
* otherwise response message will not be
59
PJ_DECL(pj_status_t) pj_turn_get_auth(void *user_data,
65
* This function is called to get the password for the specified username.
66
* This function is also used to check whether the username is valid.
68
* @param msg The STUN message where the password will be
70
* @param user_data Should be ignored.
71
* @param realm The realm as specified in the message.
72
* @param username The username as specified in the message.
73
* @param pool Pool to allocate memory when necessary.
74
* @param data_type On return, application should fill up this
75
* argument with the type of data (which should
76
* be zero if data is a plaintext password).
77
* @param data On return, application should fill up this
78
* argument with the password according to
81
* @return The callback should return PJ_SUCCESS if
82
* username has been successfully verified
83
* and password was obtained. If non-PJ_SUCCESS
84
* is returned, it is assumed that the
85
* username is not valid.
87
PJ_DECL(pj_status_t) pj_turn_get_password(const pj_stun_msg *msg,
89
const pj_str_t *realm,
90
const pj_str_t *username,
92
pj_stun_passwd_type *data_type,
96
* This function will be called to verify that the NONCE given
97
* in the message can be accepted. If this callback returns
98
* PJ_FALSE, 438 (Stale Nonce) response will be created.
100
* @param msg The STUN message where the nonce was received.
101
* @param user_data Should be ignored.
102
* @param realm The realm as specified in the message.
103
* @param username The username as specified in the message.
104
* @param nonce The nonce to be verified.
106
* @return The callback MUST return non-zero if the
107
* NONCE can be accepted.
109
PJ_DECL(pj_bool_t) pj_turn_verify_nonce(const pj_stun_msg *msg,
111
const pj_str_t *realm,
112
const pj_str_t *username,
113
const pj_str_t *nonce);
115
#endif /* __PJ_TURN_SRV_AUTH_H__ */