2 * session.c - PPP session control.
4 * Copyright (c) 2007 Diego Rivera. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. The name(s) of the authors of this software must not be used to
14 * endorse or promote products derived from this software without
15 * prior written permission.
17 * 3. Redistributions of any form whatsoever must retain the following
19 * "This product includes software developed by Paul Mackerras
20 * <paulus@ozlabs.org>".
22 * THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
23 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24 * AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
25 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
27 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
28 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
39 #define SESS_AUTH 1 /* Check User Authentication */
40 #define SESS_ACCT 2 /* Check Account Validity */
42 /* Convenience parameter to do the whole enchilada */
43 #define SESS_ALL (SESS_AUTH | SESS_ACCT)
46 * int session_start(...)
48 * Start a session, performing any necessary validations.
52 * Any combination of the SESS_XXX flags, to indicate what the function
53 * should do as part of its checks
56 * The username to validate. May safely be null.
58 * const char* passwd :
59 * The password to validate the user with. May safely be null.
62 * The TTY the user is connected on. May safely be null.
65 * A char* to return an error or success message. This message will be returned
66 * regardless of the result. May safely be null.
69 * Zero value for failure, non-zero value for successful session verification.
72 session_start(const int flags, const char* user, const char* passwd, const char* tty, char** msg);
74 /* Added these macros for convenience... */
75 #define session_auth(user, pass, tty, msg) \
76 session_start(SESS_AUTH, user, pass, tty, msg)
78 #define session_check(user, pass, tty, msg) \
79 session_start(SESS_ACCT, user, pass, tty, msg)
81 #define session_full(user, pass, tty, msg) \
82 session_start(SESS_ALL, user, pass, tty, msg)
85 * void session_end(...)
87 * End a previously-started session.
91 * The TTY the user is connected on. May safely be null.
94 session_end(const char* tty);
100 #endif // PPP_SESSION_H