document rlm_otp fd leak fix
[freeradius.git] / src / modules / rlm_otp / extern.h
1 /*
2  * $Id$
3  *
4  *   This program is free software; you can redistribute it and/or modify
5  *   it under the terms of the GNU General Public License as published by
6  *   the Free Software Foundation; either version 2 of the License, or
7  *   (at your option) any later version.
8  *
9  *   This program is distributed in the hope that it will be useful,
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *   GNU General Public License for more details.
13  *
14  *   You should have received a copy of the GNU General Public License
15  *   along with this program; if not, write to the Free Software
16  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  *
18  * Copyright 2001,2002  Google, Inc.
19  * Copyright 2005,2006 TRI-D Systems, Inc.
20  */
21
22 #ifndef EXTERN_H
23 #define EXTERN_H
24
25 #include "ident.h"
26 RCSIDH(extern_h, "$Id$")
27
28 #include <freeradius-devel/autoconf.h>
29 #include <freeradius-devel/radiusd.h>
30 #include <freeradius-devel/modules.h>
31
32 #include <sys/types.h>
33 #include <pthread.h>
34
35 #include "otp.h"        /* OTP_MAX_CHALLENGE_LEN, otp_pwe_t */
36
37 /* otpd rendezvous point */
38 #define OTP_OTPD_RP "/var/run/otpd/socket"
39
40 /* Default prompt for presentation of challenge */
41 #define OTP_CHALLENGE_PROMPT "Challenge: %s\n Response: "
42
43
44 /*
45  * You shouldn't change anything past this point
46  */
47
48
49 /* struct used for instance/option data */
50 typedef struct otp_option_t {
51   const char *name;     /* instance name for otp_token_authorize()         */
52   char *otpd_rp;        /* otpd rendezvous point                           */
53   char *chal_prompt;    /* text to present challenge to user, must have %s */
54   int challenge_len;    /* challenge length, min 5 digits                  */
55   int challenge_delay;  /* max delay time for response, in seconds         */
56   int allow_sync;       /* useful to override pwdfile card_type settings   */
57   int allow_async;      /* C/R mode allowed?                               */
58
59   int mschapv2_mppe_policy;     /* whether or not do to mppe for mschapv2  */
60   int mschapv2_mppe_types;      /* key type/length for mschapv2/mppe       */
61   int mschap_mppe_policy;       /* whether or not do to mppe for mschap    */
62   int mschap_mppe_types;        /* key type/length for mschap/mppe         */
63 } otp_option_t;
64
65 /* otp_mppe.c */
66 void otp_mppe(REQUEST *, otp_pwe_t, const otp_option_t *, const char *);
67
68 /* otp_pw_valid.c */
69 extern int otp_pw_valid(REQUEST *, int, const char *, const otp_option_t *,
70                         char []);
71
72 /* otp_radstate.c */
73 #define OTP_MAX_RADSTATE_LEN 2 + (OTP_MAX_CHALLENGE_LEN * 2 + 8 + 8 + 32)*2 + 1
74 extern int otp_gen_state(char [OTP_MAX_RADSTATE_LEN],
75                          unsigned char [OTP_MAX_RADSTATE_LEN],
76                          const unsigned char [OTP_MAX_CHALLENGE_LEN], size_t,
77                          int32_t, int32_t, const unsigned char [16]);
78
79 /* otp_pwe.c */
80 extern int pwattr[8];
81 extern void otp_pwe_init(void);
82 extern otp_pwe_t otp_pwe_present(const REQUEST *);
83
84 /* otp_util.c */
85 extern void otp_get_random(char *, size_t);
86 extern void otp_async_challenge(char [OTP_MAX_CHALLENGE_LEN + 1], int);
87 extern int otp_a2x(const char *, unsigned char *);
88 extern void otp_x2a(const unsigned char *, size_t, char *);
89 extern void _otp_pthread_mutex_init(pthread_mutex_t *,
90                                     const pthread_mutexattr_t *, const char *);
91 extern void _otp_pthread_mutex_lock(pthread_mutex_t *, const char *);
92 extern int _otp_pthread_mutex_trylock(pthread_mutex_t *, const char *);
93 extern void _otp_pthread_mutex_unlock(pthread_mutex_t *, const char *);
94
95 #define otp_pthread_mutex_init(a, b) _otp_pthread_mutex_init((a), (b), __func__)
96 #define otp_pthread_mutex_lock(a) _otp_pthread_mutex_lock((a), __func__)
97 #define otp_pthread_mutex_trylock(a) _otp_pthread_mutex_trylock((a), __func__)
98 #define otp_pthread_mutex_unlock(a) _otp_pthread_mutex_unlock((a), __func__)
99
100 #endif /* EXTERN_H */