include optional callback support

This commit is contained in:
Paul Mackerras 1996-10-08 04:35:04 +00:00
parent 533d341328
commit 0e3ef87b18
7 changed files with 154 additions and 17 deletions

View File

@ -1,6 +1,6 @@
#
# pppd makefile for Linux
# $Id: Makefile.linux,v 1.16 1996/09/26 06:19:57 paulus Exp $
# $Id: Makefile.linux,v 1.17 1996/10/08 04:35:01 paulus Exp $
#
# Default installation locations
@ -8,10 +8,10 @@ BINDIR = /usr/sbin
MANDIR = /usr/man
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \
ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c cbcp.c \
demand.c
HEADERS = callout.h pathnames.h patchlevel.h chap.h md5.h chap_ms.h md4.h \
ipxcp.h
ipxcp.h cbcp.h
MANPAGES = pppd.8
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap.o md5.o ccp.o \
auth.o options.o demand.o sys-linux.o ipxcp.o

View File

@ -33,7 +33,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: auth.c,v 1.27 1996/09/26 06:20:35 paulus Exp $";
static char rcsid[] = "$Id: auth.c,v 1.28 1996/10/08 04:35:02 paulus Exp $";
#endif
#include <stdio.h>
@ -78,6 +78,9 @@ extern char *crypt();
#include "ipcp.h"
#include "upap.h"
#include "chap.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
#endif
#include "pathnames.h"
/* Used for storing a sequence of words. Usually malloced. */
@ -140,6 +143,9 @@ static int scan_authfile __P((FILE *, char *, char *, u_int32_t, char *,
struct wordlist **, char *));
static void free_wordlist __P((struct wordlist *));
static void auth_script __P((char *));
#ifdef CBCP_SUPPORT
static void callback_phase __P((int));
#endif
/*
* An Open on LCP has requested a change from Dead to Establish phase.
@ -276,6 +282,17 @@ network_phase(unit)
did_authup = 1;
}
#ifdef CBCP_SUPPORT
/*
* If we negotiated callback, do it now.
*/
if (go->neg_cbcp) {
phase = PHASE_CALLBACK;
(*cbcp_protent.open)(unit);
return;
}
#endif
phase = PHASE_NETWORK;
#if 0
if (!demand)
@ -337,7 +354,7 @@ auth_peer_success(unit, protocol, name, namelen)
/*
* If there is no more authentication still to be done,
* proceed to the network phase.
* proceed to the network (or callback) phase.
*/
if ((auth_pending[unit] &= ~bit) == 0)
network_phase(unit);
@ -385,7 +402,7 @@ auth_withpeer_success(unit, protocol)
/*
* If there is no more authentication still being done,
* proceed to the network phase.
* proceed to the network (or callback) phase.
*/
if ((auth_pending[unit] &= ~bit) == 0)
network_phase(unit);

View File

@ -18,7 +18,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: lcp.c,v 1.27 1996/07/01 01:15:19 paulus Exp $";
static char rcsid[] = "$Id: lcp.c,v 1.28 1996/10/08 04:35:02 paulus Exp $";
#endif
/*
@ -136,10 +136,12 @@ int lcp_loopbackfail = DEFLOOPBACKFAIL;
* Length of each type of configuration option (in octets)
*/
#define CILEN_VOID 2
#define CILEN_CHAR 3
#define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */
#define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */
#define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */
#define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */
#define CILEN_CBCP 3
#define CODENAME(x) ((x) == CONFACK ? "ACK" : \
(x) == CONFNAK ? "NAK" : "REJ")
@ -177,6 +179,7 @@ lcp_init(unit)
wo->neg_pcompression = 1;
wo->neg_accompression = 1;
wo->neg_lqr = 0; /* no LQR implementation yet */
wo->neg_cbcp = 0;
ao->neg_mru = 1;
ao->mru = MAXMRU;
@ -189,6 +192,11 @@ lcp_init(unit)
ao->neg_pcompression = 1;
ao->neg_accompression = 1;
ao->neg_lqr = 0; /* no LQR implementation yet */
#ifdef CBCP_SUPPORT
ao->neg_cbcp = 1;
#else
ao->neg_cbcp = 0;
#endif
memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
xmit_accm[unit][3] = 0x60000000;
@ -451,6 +459,7 @@ lcp_cilen(f)
#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0)
#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0)
#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0)
#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0)
/*
* NB: we only ask for one of CHAP and UPAP, even if we will
* accept either.
@ -460,6 +469,7 @@ lcp_cilen(f)
LENCICHAP(go->neg_chap) +
LENCISHORT(!go->neg_chap && go->neg_upap) +
LENCILQR(go->neg_lqr) +
LENCICBCP(go->neg_cbcp) +
LENCILONG(go->neg_magicnumber) +
LENCIVOID(go->neg_pcompression) +
LENCIVOID(go->neg_accompression));
@ -509,6 +519,12 @@ lcp_addci(f, ucp, lenp)
PUTSHORT(PPP_LQR, ucp); \
PUTLONG(val, ucp); \
}
#define ADDCICHAR(opt, neg, val) \
if (neg) { \
PUTCHAR(opt, ucp); \
PUTCHAR(CILEN_CHAR, ucp); \
PUTCHAR(val, ucp); \
}
ADDCISHORT(CI_MRU, go->neg_mru && go->mru != DEFMRU, go->mru);
ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF,
@ -516,6 +532,7 @@ lcp_addci(f, ucp, lenp)
ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
@ -574,6 +591,19 @@ lcp_ackci(f, p, len)
if (cishort != val) \
goto bad; \
}
#define ACKCICHAR(opt, neg, val) \
if (neg) { \
if ((len -= CILEN_CHAR) < 0) \
goto bad; \
GETCHAR(citype, p); \
GETCHAR(cilen, p); \
if (cilen != CILEN_CHAR || \
citype != opt) \
goto bad; \
GETCHAR(cichar, p); \
if (cichar != val) \
goto bad; \
}
#define ACKCICHAP(opt, neg, val, digest) \
if (neg) { \
if ((len -= CILEN_CHAP) < 0) \
@ -626,6 +656,7 @@ lcp_ackci(f, p, len)
ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype);
ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP);
ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period);
ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT);
ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber);
ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression);
ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression);
@ -697,6 +728,17 @@ lcp_nakci(f, p, len)
no.neg = 1; \
code \
}
#define NAKCICHAR(opt, neg, code) \
if (go->neg && \
len >= CILEN_CHAR && \
p[1] == CILEN_CHAR && \
p[0] == opt) { \
len -= CILEN_CHAR; \
INCPTR(2, p); \
GETCHAR(cichar, p); \
no.neg = 1; \
code \
}
#define NAKCISHORT(opt, neg, code) \
if (go->neg && \
len >= CILEN_SHORT && \
@ -821,6 +863,13 @@ lcp_nakci(f, p, len)
try.lqr_period = cilong;
);
/*
* Only implementing CBCP...not the rest of the callback options
*/
NAKCICHAR(CI_CALLBACK, neg_cbcp,
try.neg_cbcp = 0;
);
/*
* Check for a looped-back line.
*/
@ -1028,6 +1077,20 @@ lcp_rejci(f, p, len)
try.neg = 0; \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected LQR opt %d", opt)); \
}
#define REJCICBCP(opt, neg, val) \
if (go->neg && \
len >= CILEN_CBCP && \
p[1] == CILEN_CBCP && \
p[0] == opt) { \
len -= CILEN_CBCP; \
INCPTR(2, p); \
GETCHAR(cichar, p); \
/* Check rejected value. */ \
if (cichar != val) \
goto bad; \
try.neg = 0; \
LCPDEBUG((LOG_INFO,"lcp_rejci rejected Callback opt %d", opt)); \
}
REJCISHORT(CI_MRU, neg_mru, go->mru);
REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap);
@ -1036,6 +1099,7 @@ lcp_rejci(f, p, len)
REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP);
}
REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period);
REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT);
REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber);
REJCIVOID(CI_PCOMPRESSION, neg_pcompression);
REJCIVOID(CI_ACCOMPRESSION, neg_accompression);
@ -1580,6 +1644,20 @@ lcp_printpkt(p, plen, printer, arg)
}
}
break;
case CI_CALLBACK:
if (olen >= CILEN_CHAR) {
p += 2;
printer(arg, "callback ");
GETSHORT(cishort, p);
switch (cishort) {
case CBCP_OPT:
printer(arg, "CBCP");
break;
default:
printer(arg, "0x%x", cishort);
}
}
break;
case CI_MAGICNUMBER:
if (olen == CILEN_LONG) {
p += 2;

View File

@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: lcp.h,v 1.11 1996/08/28 06:40:44 paulus Exp $
* $Id: lcp.h,v 1.12 1996/10/08 04:35:02 paulus Exp $
*/
/*
@ -29,6 +29,7 @@
#define CI_MAGICNUMBER 5 /* Magic Number */
#define CI_PCOMPRESSION 7 /* Protocol Field Compression */
#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
#define CI_CALLBACK 13 /* callback */
/*
* LCP-specific packet types.
@ -37,6 +38,7 @@
#define ECHOREQ 9 /* Echo Request */
#define ECHOREP 10 /* Echo Reply */
#define DISCREQ 11 /* Discard Request */
#define CBCP_OPT 6 /* Use callback control protocol */
/*
* The state of options is described by an lcp_options structure.
@ -53,6 +55,7 @@ typedef struct lcp_options {
int neg_pcompression : 1; /* HDLC Protocol Field Compression? */
int neg_accompression : 1; /* HDLC Address/Control Field Compression? */
int neg_lqr : 1; /* Negotiate use of Link Quality Reports */
int neg_cbcp : 1; /* Negotiate use of CBCP */
u_short mru; /* Value of MRU */
u_char chap_mdtype; /* which MD type (hashing algorithm) */
u_int32_t asyncmap; /* Value of async map */

View File

@ -18,7 +18,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: main.c,v 1.37 1996/09/26 06:21:59 paulus Exp $";
static char rcsid[] = "$Id: main.c,v 1.38 1996/10/08 04:35:03 paulus Exp $";
#endif
#include <stdio.h>
@ -52,6 +52,10 @@ static char rcsid[] = "$Id: main.c,v 1.37 1996/09/26 06:21:59 paulus Exp $";
#include "pathnames.h"
#include "patchlevel.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
#endif
#if defined(SUNOS4)
extern char *strerror();
#endif
@ -133,6 +137,9 @@ struct protent *protocols[] = {
&lcp_protent,
&pap_protent,
&chap_protent,
#ifdef CBCP_SUPPORT
&cbcp_protent,
#endif
&ipcp_protent,
&ccp_protent,
#ifdef IPX_CHANGE

View File

@ -18,7 +18,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: options.c,v 1.35 1996/09/26 06:22:22 paulus Exp $";
static char rcsid[] = "$Id: options.c,v 1.36 1996/10/08 04:35:03 paulus Exp $";
#endif
#include <ctype.h>
@ -46,6 +46,9 @@ static char rcsid[] = "$Id: options.c,v 1.35 1996/09/26 06:22:22 paulus Exp $";
#include "upap.h"
#include "chap.h"
#include "ccp.h"
#ifdef CBCP_SUPPORT
#include "cbcp.h"
#endif
#ifdef IPX_CHANGE
#include "ipxcp.h"
@ -137,6 +140,9 @@ static int setasyncmap __P((char **));
static int setescape __P((char **));
static int setmru __P((char **));
static int setmtu __P((char **));
#ifdef CBCP_SUPPORT
static int setcbcp __P((char **));
#endif
static int nomru __P((void));
static int nopcomp __P((void));
static int setconnector __P((char **));
@ -199,10 +205,10 @@ static int setpapcrypt __P((void));
static int setidle __P((char **));
static int setholdoff __P((char **));
static int setdnsaddr __P((char **));
static int resetipxproto __P((void));
#ifdef IPX_CHANGE
static int setipxproto __P((void));
static int resetipxproto __P((void));
static int setipxanet __P((void));
static int setipxalcl __P((void));
static int setipxarmt __P((void));
@ -277,6 +283,9 @@ static struct cmd {
{"domain", 1, setdomain}, /* Add given domain name to hostname*/
{"mru", 1, setmru}, /* Set MRU value for negotiation */
{"mtu", 1, setmtu}, /* Set our MTU */
#ifdef CBCP_SUPPORT
{"callback", 1, setcbcp}, /* Ask for callback */
#endif
{"netmask", 1, setnetmask}, /* set netmask */
{"passive", 0, setpassive}, /* Set passive mode */
{"silent", 0, setsilent}, /* Set silent mode */
@ -336,6 +345,8 @@ static struct cmd {
{"idle", 1, setidle}, /* idle time limit (seconds) */
{"holdoff", 1, setholdoff}, /* set holdoff time (seconds) */
{"ms-dns", 1, setdnsaddr}, /* DNS address for the peer's use */
{"noipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
{"-ipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
#ifdef IPX_CHANGE
{"ipx-network", 1, setipxnetwork}, /* IPX network number */
@ -353,9 +364,7 @@ static struct cmd {
{"ipx-compression", 1, setipxcompression}, /* IPX compression number */
#endif
{"ipx", 0, setipxproto}, /* Enable IPXCP (and IPX) */
{"noipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
{"+ipx", 0, setipxproto}, /* Enable IPXCP (and IPX) */
{"-ipx", 0, resetipxproto}, /* Disable IPXCP (and IPX) */
#endif /* IPX_CHANGE */
{NULL, 0, NULL}
@ -1153,6 +1162,21 @@ setmtu(argv)
return (1);
}
#ifdef CBCP_SUPPORT
static int
setcbcp(argv)
char **argv;
{
lcp_wantoptions[0].neg_cbcp = 1;
cbcp_protent.enabled_flag = 1;
cbcp[0].us_number = strdup(*argv);
if (cbcp[0].us_number == 0)
novm("callback number");
cbcp[0].us_type |= (1 << CB_CONF_USER);
cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
return (1);
}
#endif
/*
* nopcomp - Disable Protocol field compression negotiation.
@ -2277,4 +2301,11 @@ resetipxproto()
ipxcp_protent.enabled_flag = 0;
return 1;
}
#else
static int
resetipxproto()
{
return 1;
}
#endif /* IPX_CHANGE */

View File

@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* $Id: pppd.h,v 1.16 1996/09/14 05:17:57 paulus Exp $
* $Id: pppd.h,v 1.17 1996/10/08 04:35:04 paulus Exp $
*/
/*
@ -114,9 +114,10 @@ extern int refuse_chap; /* Don't wanna auth. ourselves with CHAP */
#define PHASE_DORMANT 2
#define PHASE_ESTABLISH 3
#define PHASE_AUTHENTICATE 4
#define PHASE_NETWORK 5
#define PHASE_TERMINATE 6
#define PHASE_HOLDOFF 7
#define PHASE_CALLBACK 5
#define PHASE_NETWORK 6
#define PHASE_TERMINATE 7
#define PHASE_HOLDOFF 8
/*
* The following struct gives the addresses of procedures to call