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