1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * upap.h - User/Password Authentication Protocol definitions. 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * Copyright (c) 2000 by Sun Microsystems, Inc. 5*7c478bd9Sstevel@tonic-gate * All rights reserved. 6*7c478bd9Sstevel@tonic-gate * 7*7c478bd9Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software and its 8*7c478bd9Sstevel@tonic-gate * documentation is hereby granted, provided that the above copyright 9*7c478bd9Sstevel@tonic-gate * notice appears in all copies. 10*7c478bd9Sstevel@tonic-gate * 11*7c478bd9Sstevel@tonic-gate * SUN MAKES NO REPRESENTATION OR WARRANTIES ABOUT THE SUITABILITY OF 12*7c478bd9Sstevel@tonic-gate * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 13*7c478bd9Sstevel@tonic-gate * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 14*7c478bd9Sstevel@tonic-gate * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR 15*7c478bd9Sstevel@tonic-gate * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR 16*7c478bd9Sstevel@tonic-gate * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES 17*7c478bd9Sstevel@tonic-gate * 18*7c478bd9Sstevel@tonic-gate * Copyright (c) 1989 Carnegie Mellon University. 19*7c478bd9Sstevel@tonic-gate * All rights reserved. 20*7c478bd9Sstevel@tonic-gate * 21*7c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 22*7c478bd9Sstevel@tonic-gate * provided that the above copyright notice and this paragraph are 23*7c478bd9Sstevel@tonic-gate * duplicated in all such forms and that any documentation, 24*7c478bd9Sstevel@tonic-gate * advertising materials, and other materials related to such 25*7c478bd9Sstevel@tonic-gate * distribution and use acknowledge that the software was developed 26*7c478bd9Sstevel@tonic-gate * by Carnegie Mellon University. The name of the 27*7c478bd9Sstevel@tonic-gate * University may not be used to endorse or promote products derived 28*7c478bd9Sstevel@tonic-gate * from this software without specific prior written permission. 29*7c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 30*7c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 31*7c478bd9Sstevel@tonic-gate * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 32*7c478bd9Sstevel@tonic-gate * 33*7c478bd9Sstevel@tonic-gate * $Id: upap.h,v 1.7 1999/11/15 01:51:54 paulus Exp $ 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifndef __UPAP_H__ 39*7c478bd9Sstevel@tonic-gate #define __UPAP_H__ 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 42*7c478bd9Sstevel@tonic-gate extern "C" { 43*7c478bd9Sstevel@tonic-gate #endif 44*7c478bd9Sstevel@tonic-gate 45*7c478bd9Sstevel@tonic-gate /* 46*7c478bd9Sstevel@tonic-gate * Packet header = Code, id, length. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define UPAP_HEADERLEN 4 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate * UPAP codes. 53*7c478bd9Sstevel@tonic-gate */ 54*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHREQ 1 /* Authenticate-Request */ 55*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHACK 2 /* Authenticate-Ack */ 56*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHNAK 3 /* Authenticate-Nak */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate * Each interface is described by upap structure. 61*7c478bd9Sstevel@tonic-gate */ 62*7c478bd9Sstevel@tonic-gate typedef struct upap_state { 63*7c478bd9Sstevel@tonic-gate int us_unit; /* Interface unit number */ 64*7c478bd9Sstevel@tonic-gate char *us_user; /* User */ 65*7c478bd9Sstevel@tonic-gate int us_userlen; /* User length */ 66*7c478bd9Sstevel@tonic-gate char *us_passwd; /* Password */ 67*7c478bd9Sstevel@tonic-gate int us_clientstate; /* Client state */ 68*7c478bd9Sstevel@tonic-gate int us_serverstate; /* Server state */ 69*7c478bd9Sstevel@tonic-gate u_char us_id; /* Current id */ 70*7c478bd9Sstevel@tonic-gate int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ 71*7c478bd9Sstevel@tonic-gate int us_transmits; /* Number of auth-reqs sent */ 72*7c478bd9Sstevel@tonic-gate int us_maxtransmits; /* Maximum number of auth-reqs to send */ 73*7c478bd9Sstevel@tonic-gate int us_receives; /* Number of auth-reqs received */ 74*7c478bd9Sstevel@tonic-gate int us_maxreceives; /* Maximum number of auth-reqs allowed */ 75*7c478bd9Sstevel@tonic-gate int us_reqtimeout; /* Time to wait for auth-req from peer */ 76*7c478bd9Sstevel@tonic-gate char *us_msg; /* Authentication response message */ 77*7c478bd9Sstevel@tonic-gate int us_msglen; /* and its length */ 78*7c478bd9Sstevel@tonic-gate } upap_state; 79*7c478bd9Sstevel@tonic-gate 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate /* 82*7c478bd9Sstevel@tonic-gate * Client states. 83*7c478bd9Sstevel@tonic-gate */ 84*7c478bd9Sstevel@tonic-gate #define UPAPCS_INITIAL 0 /* Connection down */ 85*7c478bd9Sstevel@tonic-gate #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ 86*7c478bd9Sstevel@tonic-gate #define UPAPCS_PENDING 2 /* Connection down, have requested auth */ 87*7c478bd9Sstevel@tonic-gate #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ 88*7c478bd9Sstevel@tonic-gate #define UPAPCS_OPEN 4 /* We've received an Ack */ 89*7c478bd9Sstevel@tonic-gate #define UPAPCS_BADAUTH 5 /* We've received a Nak */ 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate #define UPAPCS__NAMES \ 92*7c478bd9Sstevel@tonic-gate "CliInitial", "CliClosed", "CliPending", "CliAuthReq", "CliOpen", \ 93*7c478bd9Sstevel@tonic-gate "CliBadAuth" 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate /* 96*7c478bd9Sstevel@tonic-gate * Server states. 97*7c478bd9Sstevel@tonic-gate */ 98*7c478bd9Sstevel@tonic-gate #define UPAPSS_INITIAL 0 /* Connection down */ 99*7c478bd9Sstevel@tonic-gate #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ 100*7c478bd9Sstevel@tonic-gate #define UPAPSS_PENDING 2 /* Connection down, have requested auth */ 101*7c478bd9Sstevel@tonic-gate #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ 102*7c478bd9Sstevel@tonic-gate #define UPAPSS_OPEN 4 /* We've sent an Ack */ 103*7c478bd9Sstevel@tonic-gate #define UPAPSS_BADAUTH 5 /* We've sent a Nak */ 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate #define UPAPSS__NAMES \ 106*7c478bd9Sstevel@tonic-gate "SrvInitial", "SrvClosed", "SrvPending", "SrvListen", "SrvOpen", \ 107*7c478bd9Sstevel@tonic-gate "SrvBadAuth" 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* 110*7c478bd9Sstevel@tonic-gate * Timeouts. 111*7c478bd9Sstevel@tonic-gate */ 112*7c478bd9Sstevel@tonic-gate #define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ 113*7c478bd9Sstevel@tonic-gate #define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate extern upap_state upap[]; 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate void upap_authwithpeer __P((int, char *, char *)); 118*7c478bd9Sstevel@tonic-gate void upap_authpeer __P((int)); 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate extern struct protent pap_protent; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 123*7c478bd9Sstevel@tonic-gate } 124*7c478bd9Sstevel@tonic-gate #endif 125*7c478bd9Sstevel@tonic-gate 126*7c478bd9Sstevel@tonic-gate #endif /* __UPAP_H__ */ 127