~ubuntu-branches/ubuntu/raring/sflphone/raring

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject/pjnath/src/pjturn-srv/auth.h

  • Committer: Package Import Robot
  • Author(s): Francois Marier
  • Date: 2011-11-25 13:24:12 UTC
  • mfrom: (4.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20111125132412-dc4qvhyosk74cd42
Tags: 1.0.1-4
Don't assume that arch:all packages will get built (closes: #649726)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: auth.h 3553 2011-05-05 06:14:19Z nanang $ */
 
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 __PJ_TURN_SRV_AUTH_H__
 
21
#define __PJ_TURN_SRV_AUTH_H__
 
22
 
 
23
#include <pjnath.h>
 
24
 
 
25
/**
 
26
 * Initialize TURN authentication subsystem.
 
27
 *
 
28
 * @return              PJ_SUCCESS on success.
 
29
 */
 
30
PJ_DECL(pj_status_t) pj_turn_auth_init(const char *realm);
 
31
 
 
32
/**
 
33
 * Shutdown TURN authentication subsystem.
 
34
 */
 
35
PJ_DECL(void) pj_turn_auth_dinit(void);
 
36
 
 
37
/**
 
38
 * This function is called by pj_stun_verify_credential() when
 
39
 * server needs to challenge the request with 401 response.
 
40
 *
 
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.
 
54
 *
 
55
 * @return              The callback should return PJ_SUCCESS, or
 
56
 *                      otherwise response message will not be 
 
57
 *                      created.
 
58
 */
 
59
PJ_DECL(pj_status_t) pj_turn_get_auth(void *user_data,
 
60
                                      pj_pool_t *pool,
 
61
                                      pj_str_t *realm,
 
62
                                      pj_str_t *nonce);
 
63
 
 
64
/**
 
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.
 
67
 *
 
68
 * @param msg           The STUN message where the password will be
 
69
 *                      applied to.
 
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
 
79
 *                      data_type.
 
80
 *
 
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.
 
86
 */
 
87
PJ_DECL(pj_status_t) pj_turn_get_password(const pj_stun_msg *msg,
 
88
                                          void *user_data, 
 
89
                                          const pj_str_t *realm,
 
90
                                          const pj_str_t *username,
 
91
                                          pj_pool_t *pool,
 
92
                                          pj_stun_passwd_type *data_type,
 
93
                                          pj_str_t *data);
 
94
 
 
95
/**
 
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.
 
99
 *
 
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.
 
105
 *
 
106
 * @return              The callback MUST return non-zero if the 
 
107
 *                      NONCE can be accepted.
 
108
 */
 
109
PJ_DECL(pj_bool_t) pj_turn_verify_nonce(const pj_stun_msg *msg,
 
110
                                        void *user_data,
 
111
                                        const pj_str_t *realm,
 
112
                                        const pj_str_t *username,
 
113
                                        const pj_str_t *nonce);
 
114
 
 
115
#endif  /* __PJ_TURN_SRV_AUTH_H__ */
 
116