]> git.ozlabs.org Git - ppp.git/blob - pppd/upap.h
CI: Updated the 'checkout' actions that were using Node.js 16 to Node.js 20. (#489)
[ppp.git] / pppd / upap.h
1 #include "pppdconf.h"
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 /*
50  * Packet header = Code, id, length.
51  */
52 #define UPAP_HEADERLEN  4
53
54
55 /*
56  * UPAP codes.
57  */
58 #define UPAP_AUTHREQ    1       /* Authenticate-Request */
59 #define UPAP_AUTHACK    2       /* Authenticate-Ack */
60 #define UPAP_AUTHNAK    3       /* Authenticate-Nak */
61
62
63 /*
64  * Each interface is described by upap structure.
65  */
66 typedef struct upap_state {
67     int us_unit;                /* Interface unit number */
68     char *us_user;              /* User */
69     int us_userlen;             /* User length */
70     char *us_passwd;            /* Password */
71     int us_passwdlen;           /* Password length */
72     int us_clientstate;         /* Client state */
73     int us_serverstate;         /* Server state */
74     unsigned char us_id;                /* Current id */
75     int us_timeouttime;         /* Timeout (seconds) for auth-req retrans. */
76     int us_transmits;           /* Number of auth-reqs sent */
77     int us_maxtransmits;        /* Maximum number of auth-reqs to send */
78     int us_reqtimeout;          /* Time to wait for auth-req from peer */
79 } upap_state;
80
81
82 /*
83  * Client states.
84  */
85 #define UPAPCS_INITIAL  0       /* Connection down */
86 #define UPAPCS_CLOSED   1       /* Connection up, haven't requested auth */
87 #define UPAPCS_PENDING  2       /* Connection down, have requested auth */
88 #define UPAPCS_AUTHREQ  3       /* We've sent an Authenticate-Request */
89 #define UPAPCS_OPEN     4       /* We've received an Ack */
90 #define UPAPCS_BADAUTH  5       /* We've received a Nak */
91
92 /*
93  * Server states.
94  */
95 #define UPAPSS_INITIAL  0       /* Connection down */
96 #define UPAPSS_CLOSED   1       /* Connection up, haven't requested auth */
97 #define UPAPSS_PENDING  2       /* Connection down, have requested auth */
98 #define UPAPSS_LISTEN   3       /* Listening for an Authenticate */
99 #define UPAPSS_OPEN     4       /* We've sent an Ack */
100 #define UPAPSS_BADAUTH  5       /* We've sent a Nak */
101
102
103 /*
104  * Timeouts.
105  */
106 #define UPAP_DEFTIMEOUT 3       /* Timeout (seconds) for retransmitting req */
107 #define UPAP_DEFREQTIME 30      /* Time to wait for auth-req from peer */
108
109 extern upap_state upap[];
110
111 void upap_authwithpeer(int, char *, char *);
112 void upap_authpeer(int);
113
114 extern struct protent pap_protent;
115
116 typedef int  (pap_check_hook_fn)(void);
117 typedef int  (pap_auth_hook_fn)(char *user, char *passwd, char **msgp,
118                 struct wordlist **paddrs,
119                 struct wordlist **popts);
120 typedef void (pap_logout_hook_fn)(void);
121 typedef int  (pap_passwd_hook_fn)(char *user, char *passwd);
122
123 /*
124  * This function will return a value of 1 to indicate that a plugin intent to
125  *   supply a username or a password through the pap_auth_hook callback.
126  *
127  * A return value of > 0 will avoid parsing pap-secrets file.
128  */
129 extern pap_check_hook_fn  *pap_check_hook;
130
131 /*
132  * This hook is used to check if a username and password matches against the
133  *   PAP secrets.
134  */
135 extern pap_auth_hook_fn   *pap_auth_hook;
136
137 /*
138  * Hook for plugin to know about PAP user logout.
139  */
140 extern pap_logout_hook_fn *pap_logout_hook;
141
142 /*
143  * A plugin can chose to supply its own user and password overriding what
144  * previously has been configured. Hook is only valid when pppd is acting
145  * as a client
146  */
147 extern pap_passwd_hook_fn *pap_passwd_hook;
148
149 #endif // PPP_UPAP_H