1/*	$NetBSD: upap.h,v 1.1.1.1 2005/02/20 10:28:53 cube 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 * Id: upap.h,v 1.8 2002/12/04 23:03:33 paulus Exp
45 */
46
47/*
48 * Packet header = Code, id, length.
49 */
50#define UPAP_HEADERLEN	4
51
52
53/*
54 * UPAP codes.
55 */
56#define UPAP_AUTHREQ	1	/* Authenticate-Request */
57#define UPAP_AUTHACK	2	/* Authenticate-Ack */
58#define UPAP_AUTHNAK	3	/* Authenticate-Nak */
59
60
61/*
62 * Each interface is described by upap structure.
63 */
64typedef struct upap_state {
65    int us_unit;		/* Interface unit number */
66    char *us_user;		/* User */
67    int us_userlen;		/* User length */
68    char *us_passwd;		/* Password */
69    int us_passwdlen;		/* Password length */
70    int us_clientstate;		/* Client state */
71    int us_serverstate;		/* Server state */
72    u_char us_id;		/* Current id */
73    int us_timeouttime;		/* Timeout (seconds) for auth-req retrans. */
74    int us_transmits;		/* Number of auth-reqs sent */
75    int us_maxtransmits;	/* Maximum number of auth-reqs to send */
76    int us_reqtimeout;		/* Time to wait for auth-req from peer */
77} upap_state;
78
79
80/*
81 * Client states.
82 */
83#define UPAPCS_INITIAL	0	/* Connection down */
84#define UPAPCS_CLOSED	1	/* Connection up, haven't requested auth */
85#define UPAPCS_PENDING	2	/* Connection down, have requested auth */
86#define UPAPCS_AUTHREQ	3	/* We've sent an Authenticate-Request */
87#define UPAPCS_OPEN	4	/* We've received an Ack */
88#define UPAPCS_BADAUTH	5	/* We've received a Nak */
89
90/*
91 * Server states.
92 */
93#define UPAPSS_INITIAL	0	/* Connection down */
94#define UPAPSS_CLOSED	1	/* Connection up, haven't requested auth */
95#define UPAPSS_PENDING	2	/* Connection down, have requested auth */
96#define UPAPSS_LISTEN	3	/* Listening for an Authenticate */
97#define UPAPSS_OPEN	4	/* We've sent an Ack */
98#define UPAPSS_BADAUTH	5	/* We've sent a Nak */
99
100
101/*
102 * Timeouts.
103 */
104#define UPAP_DEFTIMEOUT	3	/* Timeout (seconds) for retransmitting req */
105#define UPAP_DEFREQTIME	30	/* Time to wait for auth-req from peer */
106
107extern upap_state upap[];
108
109void upap_authwithpeer __P((int, char *, char *));
110void upap_authpeer __P((int));
111
112extern struct protent pap_protent;
113