00001 /***************************************************************************** 00002 * pap.h - PPP Password Authentication Protocol header file. 00003 * 00004 * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. 00005 * portions Copyright (c) 1997 Global Election Systems Inc. 00006 * 00007 * The authors hereby grant permission to use, copy, modify, distribute, 00008 * and license this software and its documentation for any purpose, provided 00009 * that existing copyright notices are retained in all copies and that this 00010 * notice and the following disclaimer are included verbatim in any 00011 * distributions. No written agreement, license, or royalty fee is required 00012 * for any of the authorized uses. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 * 00025 ****************************************************************************** 00026 * REVISION HISTORY 00027 * 00028 * 03-01-01 Marc Boucher <marc@mbsi.ca> 00029 * Ported to lwIP. 00030 * 97-12-04 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc. 00031 * Original derived from BSD codes. 00032 *****************************************************************************/ 00033 /* 00034 * upap.h - User/Password Authentication Protocol definitions. 00035 * 00036 * Copyright (c) 1989 Carnegie Mellon University. 00037 * All rights reserved. 00038 * 00039 * Redistribution and use in source and binary forms are permitted 00040 * provided that the above copyright notice and this paragraph are 00041 * duplicated in all such forms and that any documentation, 00042 * advertising materials, and other materials related to such 00043 * distribution and use acknowledge that the software was developed 00044 * by Carnegie Mellon University. The name of the 00045 * University may not be used to endorse or promote products derived 00046 * from this software without specific prior written permission. 00047 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 00048 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 00049 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00050 */ 00051 00052 #ifndef PAP_H 00053 #define PAP_H 00054 00055 #if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ 00056 00057 /************************* 00058 *** PUBLIC DEFINITIONS *** 00059 *************************/ 00060 /* 00061 * Packet header = Code, id, length. 00062 */ 00063 #define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) 00064 00065 00066 /* 00067 * UPAP codes. 00068 */ 00069 #define UPAP_AUTHREQ 1 /* Authenticate-Request */ 00070 #define UPAP_AUTHACK 2 /* Authenticate-Ack */ 00071 #define UPAP_AUTHNAK 3 /* Authenticate-Nak */ 00072 00073 /* 00074 * Client states. 00075 */ 00076 #define UPAPCS_INITIAL 0 /* Connection down */ 00077 #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ 00078 #define UPAPCS_PENDING 2 /* Connection down, have requested auth */ 00079 #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ 00080 #define UPAPCS_OPEN 4 /* We've received an Ack */ 00081 #define UPAPCS_BADAUTH 5 /* We've received a Nak */ 00082 00083 /* 00084 * Server states. 00085 */ 00086 #define UPAPSS_INITIAL 0 /* Connection down */ 00087 #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ 00088 #define UPAPSS_PENDING 2 /* Connection down, have requested auth */ 00089 #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ 00090 #define UPAPSS_OPEN 4 /* We've sent an Ack */ 00091 #define UPAPSS_BADAUTH 5 /* We've sent a Nak */ 00092 00093 00094 /************************ 00095 *** PUBLIC DATA TYPES *** 00096 ************************/ 00097 00098 /* 00099 * Each interface is described by upap structure. 00100 */ 00101 typedef struct upap_state { 00102 int us_unit; /* Interface unit number */ 00103 const char *us_user; /* User */ 00104 int us_userlen; /* User length */ 00105 const char *us_passwd; /* Password */ 00106 int us_passwdlen; /* Password length */ 00107 int us_clientstate; /* Client state */ 00108 int us_serverstate; /* Server state */ 00109 u_char us_id; /* Current id */ 00110 int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ 00111 int us_transmits; /* Number of auth-reqs sent */ 00112 int us_maxtransmits; /* Maximum number of auth-reqs to send */ 00113 int us_reqtimeout; /* Time to wait for auth-req from peer */ 00114 } upap_state; 00115 00116 00117 /*********************** 00118 *** PUBLIC FUNCTIONS *** 00119 ***********************/ 00120 00121 extern upap_state upap[]; 00122 00123 void upap_setloginpasswd(int unit, const char *luser, const char *lpassword); 00124 void upap_authwithpeer (int, char *, char *); 00125 void upap_authpeer (int); 00126 00127 extern struct protent pap_protent; 00128 00129 #endif /* PAP_SUPPORT */ 00130 00131 #endif /* PAP_H */