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 #ifndef __UPAP_H__
37*7c478bd9Sstevel@tonic-gate #define __UPAP_H__
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * Packet header = Code, id, length.
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate #define UPAP_HEADERLEN	4
47*7c478bd9Sstevel@tonic-gate 
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * UPAP codes.
51*7c478bd9Sstevel@tonic-gate  */
52*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHREQ	1	/* Authenticate-Request */
53*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHACK	2	/* Authenticate-Ack */
54*7c478bd9Sstevel@tonic-gate #define UPAP_AUTHNAK	3	/* Authenticate-Nak */
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate 
57*7c478bd9Sstevel@tonic-gate /*
58*7c478bd9Sstevel@tonic-gate  * Each interface is described by upap structure.
59*7c478bd9Sstevel@tonic-gate  */
60*7c478bd9Sstevel@tonic-gate typedef struct upap_state {
61*7c478bd9Sstevel@tonic-gate     int us_unit;		/* Interface unit number */
62*7c478bd9Sstevel@tonic-gate     char *us_user;		/* User */
63*7c478bd9Sstevel@tonic-gate     int us_userlen;		/* User length */
64*7c478bd9Sstevel@tonic-gate     char *us_passwd;		/* Password */
65*7c478bd9Sstevel@tonic-gate     int us_clientstate;		/* Client state */
66*7c478bd9Sstevel@tonic-gate     int us_serverstate;		/* Server state */
67*7c478bd9Sstevel@tonic-gate     u_char us_id;		/* Current id */
68*7c478bd9Sstevel@tonic-gate     int us_timeouttime;		/* Timeout (seconds) for auth-req retrans. */
69*7c478bd9Sstevel@tonic-gate     int us_transmits;		/* Number of auth-reqs sent */
70*7c478bd9Sstevel@tonic-gate     int us_maxtransmits;	/* Maximum number of auth-reqs to send */
71*7c478bd9Sstevel@tonic-gate     int us_receives;		/* Number of auth-reqs received */
72*7c478bd9Sstevel@tonic-gate     int us_maxreceives;		/* Maximum number of auth-reqs allowed */
73*7c478bd9Sstevel@tonic-gate     int us_reqtimeout;		/* Time to wait for auth-req from peer */
74*7c478bd9Sstevel@tonic-gate     char *us_msg;		/* Authentication response message */
75*7c478bd9Sstevel@tonic-gate     int us_msglen;		/*   and its length */
76*7c478bd9Sstevel@tonic-gate } upap_state;
77*7c478bd9Sstevel@tonic-gate 
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate /*
80*7c478bd9Sstevel@tonic-gate  * Client states.
81*7c478bd9Sstevel@tonic-gate  */
82*7c478bd9Sstevel@tonic-gate #define UPAPCS_INITIAL	0	/* Connection down */
83*7c478bd9Sstevel@tonic-gate #define UPAPCS_CLOSED	1	/* Connection up, haven't requested auth */
84*7c478bd9Sstevel@tonic-gate #define UPAPCS_PENDING	2	/* Connection down, have requested auth */
85*7c478bd9Sstevel@tonic-gate #define UPAPCS_AUTHREQ	3	/* We've sent an Authenticate-Request */
86*7c478bd9Sstevel@tonic-gate #define UPAPCS_OPEN	4	/* We've received an Ack */
87*7c478bd9Sstevel@tonic-gate #define UPAPCS_BADAUTH	5	/* We've received a Nak */
88*7c478bd9Sstevel@tonic-gate 
89*7c478bd9Sstevel@tonic-gate #define	UPAPCS__NAMES	\
90*7c478bd9Sstevel@tonic-gate 	"CliInitial", "CliClosed", "CliPending", "CliAuthReq", "CliOpen", \
91*7c478bd9Sstevel@tonic-gate 	"CliBadAuth"
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /*
94*7c478bd9Sstevel@tonic-gate  * Server states.
95*7c478bd9Sstevel@tonic-gate  */
96*7c478bd9Sstevel@tonic-gate #define UPAPSS_INITIAL	0	/* Connection down */
97*7c478bd9Sstevel@tonic-gate #define UPAPSS_CLOSED	1	/* Connection up, haven't requested auth */
98*7c478bd9Sstevel@tonic-gate #define UPAPSS_PENDING	2	/* Connection down, have requested auth */
99*7c478bd9Sstevel@tonic-gate #define UPAPSS_LISTEN	3	/* Listening for an Authenticate */
100*7c478bd9Sstevel@tonic-gate #define UPAPSS_OPEN	4	/* We've sent an Ack */
101*7c478bd9Sstevel@tonic-gate #define UPAPSS_BADAUTH	5	/* We've sent a Nak */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #define	UPAPSS__NAMES	\
104*7c478bd9Sstevel@tonic-gate 	"SrvInitial", "SrvClosed", "SrvPending", "SrvListen", "SrvOpen", \
105*7c478bd9Sstevel@tonic-gate 	"SrvBadAuth"
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate /*
108*7c478bd9Sstevel@tonic-gate  * Timeouts.
109*7c478bd9Sstevel@tonic-gate  */
110*7c478bd9Sstevel@tonic-gate #define UPAP_DEFTIMEOUT	3	/* Timeout (seconds) for retransmitting req */
111*7c478bd9Sstevel@tonic-gate #define UPAP_DEFREQTIME	30	/* Time to wait for auth-req from peer */
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate extern upap_state upap[];
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate void upap_authwithpeer __P((int, char *, char *));
116*7c478bd9Sstevel@tonic-gate void upap_authpeer __P((int));
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate extern struct protent pap_protent;
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
121*7c478bd9Sstevel@tonic-gate }
122*7c478bd9Sstevel@tonic-gate #endif
123*7c478bd9Sstevel@tonic-gate 
124*7c478bd9Sstevel@tonic-gate #endif /* __UPAP_H__ */
125