1 /* $NetBSD: upap.h,v 1.6 2025/01/08 19:59:39 christos Exp $ */ 2 3 /* 4 * upap.h - User/Password Authentication Protocol definitions. 5 * 6 * Copyright (c) 1984-2000 Carnegie Mellon University. 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. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * 3. The name "Carnegie Mellon University" must not be used to 21 * endorse or promote products derived from this software without 22 * prior written permission. For permission or any legal 23 * details, please contact 24 * Office of Technology Transfer 25 * Carnegie Mellon University 26 * 5000 Forbes Avenue 27 * Pittsburgh, PA 15213-3890 28 * (412) 268-4387, fax: (412) 268-7395 29 * tech-transfer@andrew.cmu.edu 30 * 31 * 4. Redistributions of any form whatsoever must retain the following 32 * acknowledgment: 33 * "This product includes software developed by Computing Services 34 * at Carnegie Mellon University (http://www.cmu.edu/computing/)." 35 * 36 * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO 37 * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 38 * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE 39 * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 40 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 41 * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING 42 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 43 */ 44 #ifndef PPP_UPAP_H 45 #define PPP_UPAP_H 46 47 #include "pppdconf.h" 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 54 /* 55 * Packet header = Code, id, length. 56 */ 57 #define UPAP_HEADERLEN 4 58 59 60 /* 61 * UPAP codes. 62 */ 63 #define UPAP_AUTHREQ 1 /* Authenticate-Request */ 64 #define UPAP_AUTHACK 2 /* Authenticate-Ack */ 65 #define UPAP_AUTHNAK 3 /* Authenticate-Nak */ 66 67 68 /* 69 * Each interface is described by upap structure. 70 */ 71 typedef struct upap_state { 72 int us_unit; /* Interface unit number */ 73 char *us_user; /* User */ 74 int us_userlen; /* User length */ 75 char *us_passwd; /* Password */ 76 int us_passwdlen; /* Password length */ 77 int us_clientstate; /* Client state */ 78 int us_serverstate; /* Server state */ 79 unsigned char us_id; /* Current id */ 80 int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ 81 int us_transmits; /* Number of auth-reqs sent */ 82 int us_maxtransmits; /* Maximum number of auth-reqs to send */ 83 int us_reqtimeout; /* Time to wait for auth-req from peer */ 84 } upap_state; 85 86 87 /* 88 * Client states. 89 */ 90 #define UPAPCS_INITIAL 0 /* Connection down */ 91 #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ 92 #define UPAPCS_PENDING 2 /* Connection down, have requested auth */ 93 #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ 94 #define UPAPCS_OPEN 4 /* We've received an Ack */ 95 #define UPAPCS_BADAUTH 5 /* We've received a Nak */ 96 97 /* 98 * Server states. 99 */ 100 #define UPAPSS_INITIAL 0 /* Connection down */ 101 #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ 102 #define UPAPSS_PENDING 2 /* Connection down, have requested auth */ 103 #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ 104 #define UPAPSS_OPEN 4 /* We've sent an Ack */ 105 #define UPAPSS_BADAUTH 5 /* We've sent a Nak */ 106 107 108 /* 109 * Timeouts. 110 */ 111 #define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ 112 #define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ 113 114 extern upap_state upap[]; 115 116 void upap_authwithpeer(int, char *, char *); 117 void upap_authpeer(int); 118 119 extern struct protent pap_protent; 120 121 typedef int (pap_check_hook_fn)(void); 122 typedef int (pap_auth_hook_fn)(char *user, char *passwd, char **msgp, 123 struct wordlist **paddrs, 124 struct wordlist **popts); 125 typedef void (pap_logout_hook_fn)(void); 126 typedef int (pap_passwd_hook_fn)(char *user, char *passwd); 127 128 /* 129 * This function will return a value of 1 to indicate that a plugin intent to 130 * supply a username or a password through the pap_auth_hook callback. 131 * 132 * A return value of > 0 will avoid parsing pap-secrets file. 133 */ 134 extern pap_check_hook_fn *pap_check_hook; 135 136 /* 137 * This hook is used to check if a username and password matches against the 138 * PAP secrets. 139 */ 140 extern pap_auth_hook_fn *pap_auth_hook; 141 142 /* 143 * Hook for plugin to know about PAP user logout. 144 */ 145 extern pap_logout_hook_fn *pap_logout_hook; 146 147 /* 148 * A plugin can chose to supply its own user and password overriding what 149 * previously has been configured. Hook is only valid when pppd is acting 150 * as a client 151 */ 152 extern pap_passwd_hook_fn *pap_passwd_hook; 153 154 #ifdef __cplusplus 155 } 156 #endif 157 158 #endif // PPP_UPAP_H 159