*/
#ifndef lint
-static char rcsid[] = "$Id: upap.c,v 1.7 1995/12/18 03:46:48 paulus Exp $";
+static char rcsid[] = "$Id: upap.c,v 1.10 1996/07/01 01:21:35 paulus Exp $";
#endif
/*
#include "pppd.h"
#include "upap.h"
+/*
+ * Protocol entry points.
+ */
+static void upap_init __P((int));
+static void upap_lowerup __P((int));
+static void upap_lowerdown __P((int));
+static void upap_input __P((int, u_char *, int));
+static void upap_protrej __P((int));
+static int upap_printpkt __P((u_char *, int,
+ void (*) __P((void *, char *, ...)), void *));
+
struct protent pap_protent = {
- PPP_PAP, upap_init, upap_input, upap_protrej,
- upap_lowerup, upap_lowerdown, NULL, NULL,
- upap_printpkt, NULL, 1, "PAP"
+ PPP_PAP,
+ upap_init,
+ upap_input,
+ upap_protrej,
+ upap_lowerup,
+ upap_lowerdown,
+ NULL,
+ NULL,
+ upap_printpkt,
+ NULL,
+ 1,
+ "PAP",
+ NULL,
+ NULL,
+ NULL
};
upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */
/*
* upap_init - Initialize a UPAP unit.
*/
-void
+static void
upap_init(unit)
int unit;
{
*
* Start authenticating if pending.
*/
-void
+static void
upap_lowerup(unit)
int unit;
{
*
* Cancel all timeouts.
*/
-void
+static void
upap_lowerdown(unit)
int unit;
{
*
* This shouldn't happen. In any case, pretend lower layer went down.
*/
-void
+static void
upap_protrej(unit)
int unit;
{
/*
* upap_input - Input UPAP packet.
*/
-void
+static void
upap_input(unit, inpacket, l)
int unit;
u_char *inpacket;
*/
inp = inpacket;
if (l < UPAP_HEADERLEN) {
- UPAPDEBUG((LOG_INFO, "upap_input: rcvd short header."));
+ UPAPDEBUG((LOG_INFO, "pap_input: rcvd short header."));
return;
}
GETCHAR(code, inp);
GETCHAR(id, inp);
GETSHORT(len, inp);
if (len < UPAP_HEADERLEN) {
- UPAPDEBUG((LOG_INFO, "upap_input: rcvd illegal length."));
+ UPAPDEBUG((LOG_INFO, "pap_input: rcvd illegal length."));
return;
}
if (len > l) {
- UPAPDEBUG((LOG_INFO, "upap_input: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_input: rcvd short packet."));
return;
}
len -= UPAP_HEADERLEN;
char *msg;
int msglen;
- UPAPDEBUG((LOG_INFO, "upap_rauth: Rcvd id %d.", id));
+ UPAPDEBUG((LOG_INFO, "pap_rauth: Rcvd id %d.", id));
if (u->us_serverstate < UPAPSS_LISTEN)
return;
* Parse user/passwd.
*/
if (len < sizeof (u_char)) {
- UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet."));
return;
}
GETCHAR(ruserlen, inp);
len -= sizeof (u_char) + ruserlen + sizeof (u_char);
if (len < 0) {
- UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet."));
return;
}
ruser = (char *) inp;
INCPTR(ruserlen, inp);
GETCHAR(rpasswdlen, inp);
if (len < rpasswdlen) {
- UPAPDEBUG((LOG_INFO, "upap_rauth: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet."));
return;
}
rpasswd = (char *) inp;
*/
retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd,
rpasswdlen, &msg, &msglen);
+ BZERO(rpasswd, rpasswdlen);
upap_sresp(u, retcode, id, msg, msglen);
if (retcode == UPAP_AUTHACK) {
u->us_serverstate = UPAPSS_OPEN;
- auth_peer_success(u->us_unit, PPP_PAP);
+ auth_peer_success(u->us_unit, PPP_PAP, ruser, ruserlen);
} else {
u->us_serverstate = UPAPSS_BADAUTH;
auth_peer_fail(u->us_unit, PPP_PAP);
u_char msglen;
char *msg;
- UPAPDEBUG((LOG_INFO, "upap_rauthack: Rcvd id %d.", id));
+ UPAPDEBUG((LOG_INFO, "pap_rauthack: Rcvd id %d.", id));
if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */
return;
* Parse message.
*/
if (len < sizeof (u_char)) {
- UPAPDEBUG((LOG_INFO, "upap_rauthack: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet."));
return;
}
GETCHAR(msglen, inp);
len -= sizeof (u_char);
if (len < msglen) {
- UPAPDEBUG((LOG_INFO, "upap_rauthack: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet."));
return;
}
msg = (char *) inp;
u_char msglen;
char *msg;
- UPAPDEBUG((LOG_INFO, "upap_rauthnak: Rcvd id %d.", id));
+ UPAPDEBUG((LOG_INFO, "pap_rauthnak: Rcvd id %d.", id));
if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */
return;
* Parse message.
*/
if (len < sizeof (u_char)) {
- UPAPDEBUG((LOG_INFO, "upap_rauthnak: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet."));
return;
}
GETCHAR(msglen, inp);
len -= sizeof (u_char);
if (len < msglen) {
- UPAPDEBUG((LOG_INFO, "upap_rauthnak: rcvd short packet."));
+ UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet."));
return;
}
msg = (char *) inp;
output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
- UPAPDEBUG((LOG_INFO, "upap_sauth: Sent id %d.", u->us_id));
+ UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d.", u->us_id));
TIMEOUT(upap_timeout, (caddr_t) u, u->us_timeouttime);
++u->us_transmits;
BCOPY(msg, outp, msglen);
output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
- UPAPDEBUG((LOG_INFO, "upap_sresp: Sent code %d, id %d.", code, id));
+ UPAPDEBUG((LOG_INFO, "pap_sresp: Sent code %d, id %d.", code, id));
}
/*
* upap_printpkt - print the contents of a PAP packet.
*/
-char *upap_codenames[] = {
+static char *upap_codenames[] = {
"AuthReq", "AuthAck", "AuthNak"
};
-int
+static int
upap_printpkt(p, plen, printer, arg)
u_char *p;
int plen;
msg = (char *) (p + 1);
p += mlen + 1;
len -= mlen + 1;
- printer(arg, "msg=");
+ printer(arg, " ");
print_string(msg, mlen, printer, arg);
break;
}