Home | History | Annotate | Line # | Download | only in pppd
      1 /*	$NetBSD: session.h,v 1.5 2025/01/08 19:59:39 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 (at) ozlabs.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 #ifndef PPP_SESSION_H
     33 #define PPP_SESSION_H
     34 
     35 #include "pppdconf.h"
     36 
     37 #ifdef __cplusplus
     38 extern "C" {
     39 #endif
     40 
     41 #define SESS_AUTH  1	/* Check User Authentication */
     42 #define SESS_ACCT  2	/* Check Account Validity */
     43 
     44 /* Convenience parameter to do the whole enchilada */
     45 #define SESS_ALL   (SESS_AUTH | SESS_ACCT)
     46 
     47 /*
     48  * int session_start(...)
     49  *
     50  * Start a session, performing any necessary validations.
     51  *
     52  * Parameters:
     53  * 	const int flags :
     54  * 		Any combination of the SESS_XXX flags, to indicate what the function
     55  *		should do as part of its checks
     56  *
     57  *	const char* user :
     58  *		The username to validate.  May safely be null.
     59  *
     60  *	const char* passwd :
     61  *		The password to validate the user with. May safely be null.
     62  *
     63  *	const char* tty :
     64  *		The TTY the user is connected on. May safely be null.
     65  *
     66  *	char** msg :
     67  *		A char* to return an error or success message.  This message will be returned
     68  *		regardless of the result.  May safely be null.
     69  *
     70  * Return Value:
     71  * 	Zero value for failure, non-zero value for successful session verification.
     72  */
     73 int
     74 session_start(const int flags, const char* user, const char* passwd, const char* tty, char** msg);
     75 
     76 /* Added these macros for convenience... */
     77 #define session_auth(user, pass, tty, msg) \
     78 	session_start(SESS_AUTH, user, pass, tty, msg)
     79 
     80 #define session_check(user, pass, tty, msg) \
     81 	session_start(SESS_ACCT, user, pass, tty, msg)
     82 
     83 #define session_full(user, pass, tty, msg) \
     84 	session_start(SESS_ALL, user, pass, tty, msg)
     85 
     86 /*
     87  * void session_end(...)
     88  *
     89  * End a previously-started session.
     90  *
     91  * Parameters:
     92  *	const char* tty :
     93  *		The TTY the user is connected on. May safely be null.
     94  */
     95 void
     96 session_end(const char* tty);
     97 
     98 #ifdef __cplusplus
     99 }
    100 #endif
    101 
    102 #endif // PPP_SESSION_H
    103