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