From 92b095588304eafcb4ba45699fe8afec726b5969 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Fri, 7 Aug 1998 18:42:51 +0000 Subject: [PATCH] o Support callback types NONE, E.164, AUTH and CBCP. (see the new ``set callback'' and ``set cbcp'' commands) o Add a ``cbcp'' log level and mbuf type. o Don't dump core when \T is given in ``set login'' or ``set hangup''. o Allow ``*'' and blanks as placeholders in ppp.secret and allow a fifth field for specifying auth/cbcp dialback parameters. o Remove a few extraneous #includes o Define the default number of REQs (restart counter) in defs.h rather than hardcoding ``5'' all over the place. o Fix a few man page inconsistencies. --- usr.sbin/ppp/Makefile | 4 +- usr.sbin/ppp/auth.c | 42 ++++++++- usr.sbin/ppp/auth.h | 5 +- usr.sbin/ppp/bundle.c | 5 +- usr.sbin/ppp/bundle.h | 3 +- usr.sbin/ppp/ccp.c | 5 +- usr.sbin/ppp/chap.c | 5 +- usr.sbin/ppp/chat.c | 11 ++- usr.sbin/ppp/command.c | 61 ++++++++++++- usr.sbin/ppp/datalink.c | 185 +++++++++++++++++++++++++++++++++++---- usr.sbin/ppp/datalink.h | 14 ++- usr.sbin/ppp/deflate.c | 3 +- usr.sbin/ppp/defs.h | 3 +- usr.sbin/ppp/hdlc.c | 11 ++- usr.sbin/ppp/ip.c | 4 +- usr.sbin/ppp/ipcp.c | 4 +- usr.sbin/ppp/lcp.c | 187 ++++++++++++++++++++++++++++++++++++++-- usr.sbin/ppp/lcp.h | 24 +++++- usr.sbin/ppp/lcpproto.h | 3 +- usr.sbin/ppp/link.c | 4 +- usr.sbin/ppp/log.c | 3 +- usr.sbin/ppp/log.h | 41 ++++----- usr.sbin/ppp/lqr.c | 3 +- usr.sbin/ppp/main.c | 3 +- usr.sbin/ppp/mbuf.c | 10 +-- usr.sbin/ppp/mbuf.h | 19 ++-- usr.sbin/ppp/modem.c | 5 +- usr.sbin/ppp/mp.c | 3 +- usr.sbin/ppp/pap.c | 4 +- usr.sbin/ppp/physical.c | 7 +- usr.sbin/ppp/ppp.8 | 137 +++++++++++++++++++++++++++-- usr.sbin/ppp/ppp.8.m4 | 137 +++++++++++++++++++++++++++-- usr.sbin/ppp/pred.c | 3 +- usr.sbin/ppp/prompt.c | 3 +- usr.sbin/ppp/vjcomp.c | 3 +- 35 files changed, 841 insertions(+), 123 deletions(-) diff --git a/usr.sbin/ppp/Makefile b/usr.sbin/ppp/Makefile index b33fd79093d1..759feef6c9c5 100644 --- a/usr.sbin/ppp/Makefile +++ b/usr.sbin/ppp/Makefile @@ -1,7 +1,7 @@ -# $Id: Makefile,v 1.43 1998/06/26 18:50:29 brian Exp $ +# $Id: Makefile,v 1.44 1998/06/27 14:17:22 brian Exp $ PROG= ppp -SRCS= arp.c async.c auth.c bundle.c ccp.c chap.c chat.c command.c \ +SRCS= arp.c async.c auth.c bundle.c cbcp.c ccp.c chap.c chat.c command.c \ datalink.c deflate.c defs.c filter.c fsm.c hdlc.c id.c ip.c \ ipcp.c iplist.c lcp.c link.c log.c lqr.c main.c mbuf.c modem.c \ mp.c pap.c physical.c pred.c probe.c prompt.c route.c server.c \ diff --git a/usr.sbin/ppp/auth.c b/usr.sbin/ppp/auth.c index 420a32b1b87c..811709e0fa59 100644 --- a/usr.sbin/ppp/auth.c +++ b/usr.sbin/ppp/auth.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.c,v 1.30 1998/06/15 19:06:35 brian Exp $ + * $Id: auth.c,v 1.31 1998/07/19 21:07:24 brian Exp $ * * TODO: * o Implement check against with registered IP addresses. @@ -87,7 +87,40 @@ auth_CheckPasswd(const char *name, const char *data, const char *key) } int -auth_Select(struct bundle *bundle, const char *name, struct physical *physical) +auth_SetPhoneList(const char *name, char *phone, int phonelen) +{ + FILE *fp; + int n; + char *vector[6]; + char buff[LINE_LEN]; + + fp = OpenSecret(SECRETFILE); + if (fp != NULL) { + while (fgets(buff, sizeof buff, fp)) { + if (buff[0] == '#') + continue; + buff[strlen(buff) - 1] = '\0'; + memset(vector, '\0', sizeof vector); + n = MakeArgs(buff, vector, VECSIZE(vector)); + if (n < 5) + continue; + if (strcmp(vector[0], name) == 0) { + CloseSecret(fp); + if (*vector[4] == '\0') + return 0; + strncpy(phone, vector[4], phonelen - 1); + phone[phonelen - 1] = '\0'; + return 1; /* Valid */ + } + } + CloseSecret(fp); + } + *phone = '\0'; + return 0; +} + +int +auth_Select(struct bundle *bundle, const char *name) { FILE *fp; int n; @@ -111,10 +144,11 @@ auth_Select(struct bundle *bundle, const char *name, struct physical *physical) continue; if (strcmp(vector[0], name) == 0) { CloseSecret(fp); - if (n > 2 && !ipcp_UseHisaddr(bundle, vector[2], 1)) + if (n > 2 && *vector[2] && strcmp(vector[2], "*") && + !ipcp_UseHisaddr(bundle, vector[2], 1)) return 0; ipcp_Setup(&bundle->ncp.ipcp); - if (n > 3) + if (n > 3 && *vector[3] && strcmp(vector[3], "*")) bundle_SetLabel(bundle, vector[3]); return 1; /* Valid */ } diff --git a/usr.sbin/ppp/auth.h b/usr.sbin/ppp/auth.h index 8e751becccdb..3766f03816d2 100644 --- a/usr.sbin/ppp/auth.h +++ b/usr.sbin/ppp/auth.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: auth.h,v 1.10.2.9 1998/05/01 19:23:54 brian Exp $ + * $Id: auth.h,v 1.11 1998/05/21 21:44:03 brian Exp $ * * TODO: */ @@ -45,4 +45,5 @@ extern int auth_Validate(struct bundle *, const char *, const char *, struct physical *); extern char *auth_GetSecret(struct bundle *, const char *, int, struct physical *); -extern int auth_Select(struct bundle *, const char *, struct physical *); +extern int auth_SetPhoneList(const char *, char *, int); +extern int auth_Select(struct bundle *, const char *); diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index c59bad4e263f..217fc4061c9d 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.c,v 1.29 1998/07/29 18:21:11 brian Exp $ + * $Id: bundle.c,v 1.30 1998/08/02 06:56:40 brian Exp $ */ #include @@ -82,6 +82,7 @@ #include "tun.h" #include "prompt.h" #include "chat.h" +#include "cbcp.h" #include "datalink.h" #include "ip.h" @@ -318,7 +319,7 @@ bundle_LinkAdded(struct bundle *bundle, struct datalink *dl) bundle_StartIdleTimer(bundle); } -static void +void bundle_LinksRemoved(struct bundle *bundle) { struct datalink *dl; diff --git a/usr.sbin/ppp/bundle.h b/usr.sbin/ppp/bundle.h index 9e90ec4be26b..25ce43f4d15e 100644 --- a/usr.sbin/ppp/bundle.h +++ b/usr.sbin/ppp/bundle.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bundle.h,v 1.10 1998/07/28 21:54:51 brian Exp $ + * $Id: bundle.h,v 1.11 1998/07/29 18:21:13 brian Exp $ */ #define PHASE_DEAD 0 /* Link is dead */ @@ -137,6 +137,7 @@ extern void bundle_Destroy(struct bundle *); extern const char *bundle_PhaseName(struct bundle *); #define bundle_Phase(b) ((b)->phase) extern void bundle_NewPhase(struct bundle *, u_int); +extern void bundle_LinksRemoved(struct bundle *); extern int bundle_LinkIsUp(const struct bundle *); extern int bundle_SetRoute(struct bundle *, int, struct in_addr, struct in_addr, struct in_addr, int, int); diff --git a/usr.sbin/ppp/ccp.c b/usr.sbin/ppp/ccp.c index 9141d774967f..dc33e77ae963 100644 --- a/usr.sbin/ppp/ccp.c +++ b/usr.sbin/ppp/ccp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ccp.c,v 1.36 1998/06/27 23:48:40 brian Exp $ + * $Id: ccp.c,v 1.37 1998/06/30 23:04:10 brian Exp $ * * TODO: * o Support other compression protocols @@ -30,7 +30,6 @@ #include #include -#include #include #include "defs.h" @@ -213,7 +212,7 @@ CcpInitRestartCounter(struct fsm *fp) struct ccp *ccp = fsm2ccp(fp); fp->FsmTimer.load = ccp->cfg.fsmretry * SECTICKS; - fp->restart = 5; + fp->restart = DEF_REQs; } static void diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index bc2ed507365f..66ffe732698b 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.34 1998/06/27 23:48:41 brian Exp $ + * $Id: chap.c,v 1.35 1998/07/28 21:54:29 brian Exp $ * * TODO: */ @@ -29,10 +29,10 @@ #ifdef HAVE_DES #include +#include #endif #include #include -#include #include #include "mbuf.h" @@ -59,6 +59,7 @@ #include "mp.h" #include "bundle.h" #include "chat.h" +#include "cbcp.h" #include "datalink.h" #ifdef HAVE_DES #include "chap_ms.h" diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index 76699fb8e34f..fa81677b5820 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: chat.c,v 1.49 1998/06/24 19:33:31 brian Exp $ + * $Id: chat.c,v 1.50 1998/06/27 14:18:01 brian Exp $ */ #include @@ -64,6 +64,7 @@ #include "iplist.h" #include "ipcp.h" #include "filter.h" +#include "cbcp.h" #include "datalink.h" #include "bundle.h" @@ -673,9 +674,11 @@ ExpandString(struct chat *c, const char *str, char *result, int reslen, result += strlen(result); break; case 'T': - strncpy(result, c->phone, reslen); - reslen -= strlen(result); - result += strlen(result); + if (c->phone) { + strncpy(result, c->phone, reslen); + reslen -= strlen(result); + result += strlen(result); + } break; case 'U': strncpy(result, c->physical->dl->bundle->cfg.auth.name, reslen); diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 69ca69cc00a7..bdd6aaf41d7f 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.157 1998/07/29 18:21:13 brian Exp $ + * $Id: command.c,v 1.158 1998/07/31 19:50:24 brian Exp $ * */ #include @@ -76,6 +76,7 @@ #include "prompt.h" #include "chat.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" /* ``set'' values */ @@ -103,6 +104,8 @@ #define VAR_DNS 21 #define VAR_NBNS 22 #define VAR_MODE 23 +#define VAR_CALLBACK 24 +#define VAR_CBCP 25 /* ``accept|deny|disable|enable'' masks */ #define NEG_HISMASK (1) @@ -122,7 +125,7 @@ #define NEG_DNS 50 const char Version[] = "2.0"; -const char VersionDate[] = "$Date: 1998/07/29 18:21:13 $"; +const char VersionDate[] = "$Date: 1998/07/31 19:50:24 $"; static int ShowCommand(struct cmdargs const *); static int TerminalCommand(struct cmdargs const *); @@ -1348,6 +1351,7 @@ SetVariable(struct cmdargs const *arg) case VAR_PHONE: strncpy(cx->cfg.phone.list, argp, sizeof cx->cfg.phone.list - 1); cx->cfg.phone.list[sizeof cx->cfg.phone.list - 1] = '\0'; + cx->phone.alt = cx->phone.next = NULL; break; case VAR_HANGUP: @@ -1446,6 +1450,53 @@ SetVariable(struct cmdargs const *arg) addr[0].s_addr = addr[1].s_addr; } break; + + case VAR_CALLBACK: + cx->cfg.callback.opmask = 0; + for (dummyint = arg->argn; dummyint < arg->argc; dummyint++) { + if (!strcasecmp(arg->argv[dummyint], "auth")) + cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_AUTH); + else if (!strcasecmp(arg->argv[dummyint], "cbcp")) + cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_CBCP); + else if (!strcasecmp(arg->argv[dummyint], "e.164")) { + if (dummyint == arg->argc - 1) + log_Printf(LogWARN, "No E.164 arg (E.164 ignored) !\n"); + else { + cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_E164); + strncpy(cx->cfg.callback.msg, arg->argv[++dummyint], + sizeof cx->cfg.callback.msg - 1); + cx->cfg.callback.msg[sizeof cx->cfg.callback.msg - 1] = '\0'; + } + } else if (!strcasecmp(arg->argv[dummyint], "none")) + cx->cfg.callback.opmask |= CALLBACK_BIT(CALLBACK_NONE); + else + return -1; + } + if (cx->cfg.callback.opmask == CALLBACK_BIT(CALLBACK_NONE)) + cx->cfg.callback.opmask = 0; + break; + + case VAR_CBCP: + cx->cfg.cbcp.delay = 0; + *cx->cfg.cbcp.phone = '\0'; + cx->cfg.cbcp.fsmretry = DEF_FSMRETRY; + if (arg->argc > arg->argn) { + strncpy(cx->cfg.cbcp.phone, arg->argv[arg->argn], + sizeof cx->cfg.cbcp.phone - 1); + cx->cfg.cbcp.phone[sizeof cx->cfg.cbcp.phone - 1] = '\0'; + if (arg->argc > arg->argn + 1) { + cx->cfg.cbcp.delay = atoi(arg->argv[arg->argn + 1]); + if (arg->argc > arg->argn + 2) { + long_val = atol(arg->argv[arg->argn + 2]); + if (long_val < MIN_FSMRETRY) + log_Printf(LogWARN, "%ld: Invalid CBCP FSM retry period - min %d\n", + long_val, MIN_FSMRETRY); + else + cx->cfg.cbcp.fsmretry = long_val; + } + } + } + break; } return err ? 1 : 0; @@ -1476,6 +1527,12 @@ static struct cmdtab const SetCommands[] = { {"autoload", NULL, SetVariable, LOCAL_AUTH, "auto link [de]activation", "set autoload maxtime maxload mintime minload", (const void *)VAR_AUTOLOAD}, + {"callback", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, + "callback control", "set callback [none|auth|cbcp|" + "E.164 *|number[,number]...]...", (const void *)VAR_CALLBACK}, + {"cbcp", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, + "CBCP control", "set cbcp [*|phone[,phone...] [delay [timeout]]]", + (const void *)VAR_CBCP}, {"ccpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, "FSM retry period", "set ccpretry value", (const void *)VAR_CCPRETRY}, {"chapretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c index 5ab9794c63a1..92264f4d19a6 100644 --- a/usr.sbin/ppp/datalink.c +++ b/usr.sbin/ppp/datalink.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.c,v 1.15 1998/06/30 23:04:14 brian Exp $ + * $Id: datalink.c,v 1.16 1998/07/03 17:24:37 brian Exp $ */ #include @@ -67,6 +67,7 @@ #include "pap.h" #include "chap.h" #include "command.h" +#include "cbcp.h" #include "datalink.h" static void datalink_LoginDone(struct datalink *); @@ -87,7 +88,7 @@ datalink_StartDialTimer(struct datalink *dl, int Timeout) { timer_Stop(&dl->dial_timer); - if (Timeout) { + if (Timeout) { if (Timeout > 0) dl->dial_timer.load = Timeout * SECTICKS; else @@ -115,7 +116,26 @@ datalink_HangupDone(struct datalink *dl) modem_Close(dl->physical); dl->phone.chosen = "N/A"; - if (dl->bundle->CleaningUp || + if (dl->cbcp.required) { + log_Printf(LogPHASE, "Call peer back on %s\n", dl->cbcp.fsm.phone); + dl->cfg.callback.opmask = 0; + strncpy(dl->cfg.phone.list, dl->cbcp.fsm.phone, + sizeof dl->cfg.phone.list - 1); + dl->cfg.phone.list[sizeof dl->cfg.phone.list - 1] = '\0'; + dl->phone.alt = dl->phone.next = NULL; + dl->reconnect_tries = dl->cfg.reconnect.max; + dl->dial_tries = dl->cfg.dial.max; + dl->script.run = 1; + dl->script.packetmode = 1; + if (!physical_SetMode(dl->physical, PHYS_BACKGROUND)) + log_Printf(LogERROR, "Oops - can't change mode to BACKGROUND (gulp) !\n"); + bundle_LinksRemoved(dl->bundle); + if (dl->cbcp.fsm.delay < dl->cfg.dial.timeout) + dl->cbcp.fsm.delay = dl->cfg.dial.timeout; + datalink_StartDialTimer(dl, dl->cbcp.fsm.delay); + cbcp_Down(&dl->cbcp); + datalink_NewState(dl, DATALINK_OPENING); + } else if (dl->bundle->CleaningUp || (dl->physical->type == PHYS_DIRECT) || ((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) && !(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)))) { @@ -301,6 +321,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e, case DATALINK_READY: case DATALINK_LCP: case DATALINK_AUTH: + case DATALINK_CBCP: case DATALINK_OPEN: result = descriptor_UpdateSet(&dl->physical->desc, r, w, e, n); break; @@ -332,6 +353,7 @@ datalink_IsSet(struct descriptor *d, const fd_set *fdset) case DATALINK_READY: case DATALINK_LCP: case DATALINK_AUTH: + case DATALINK_CBCP: case DATALINK_OPEN: return descriptor_IsSet(&dl->physical->desc, fdset); } @@ -357,6 +379,7 @@ datalink_Read(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) case DATALINK_READY: case DATALINK_LCP: case DATALINK_AUTH: + case DATALINK_CBCP: case DATALINK_OPEN: descriptor_Read(&dl->physical->desc, bundle, fdset); break; @@ -383,6 +406,7 @@ datalink_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) case DATALINK_READY: case DATALINK_LCP: case DATALINK_AUTH: + case DATALINK_CBCP: case DATALINK_OPEN: result = descriptor_Write(&dl->physical->desc, bundle, fdset); break; @@ -460,7 +484,7 @@ datalink_GotAuthname(struct datalink *dl, const char *name, int len) } void -datalink_AuthOk(struct datalink *dl) +datalink_NCPUp(struct datalink *dl) { int ccpok = ccp_SetOpenMode(&dl->physical->link.ccp); @@ -472,7 +496,7 @@ datalink_AuthOk(struct datalink *dl) return; case MP_UP: /* First link in the bundle */ - auth_Select(dl->bundle, dl->peer.authname, dl->physical); + auth_Select(dl->bundle, dl->peer.authname); /* fall through */ case MP_ADDED: /* We're in multilink mode ! */ @@ -490,7 +514,7 @@ datalink_AuthOk(struct datalink *dl) } else { dl->bundle->ncp.mp.peer = dl->peer; ipcp_SetLink(&dl->bundle->ncp.ipcp, &dl->physical->link); - auth_Select(dl->bundle, dl->peer.authname, dl->physical); + auth_Select(dl->bundle, dl->peer.authname); } if (ccpok) { @@ -502,6 +526,80 @@ datalink_AuthOk(struct datalink *dl) (*dl->parent->LayerUp)(dl->parent->object, &dl->physical->link.lcp.fsm); } +void +datalink_CBCPComplete(struct datalink *dl) +{ + datalink_NewState(dl, DATALINK_LCP); + fsm_Close(&dl->physical->link.lcp.fsm); +} + +void +datalink_CBCPFailed(struct datalink *dl) +{ + cbcp_Down(&dl->cbcp); + datalink_CBCPComplete(dl); +} + +void +datalink_AuthOk(struct datalink *dl) +{ + if (dl->physical->link.lcp.his_callback.opmask == + CALLBACK_BIT(CALLBACK_CBCP) || + dl->physical->link.lcp.want_callback.opmask == + CALLBACK_BIT(CALLBACK_CBCP)) { + datalink_NewState(dl, DATALINK_CBCP); + cbcp_Up(&dl->cbcp); + } else if (dl->physical->link.lcp.want_callback.opmask) { + log_Printf(LogPHASE, "%s: Shutdown and await peer callback\n", dl->name); + datalink_NewState(dl, DATALINK_LCP); + fsm_Close(&dl->physical->link.lcp.fsm); + } else + switch (dl->physical->link.lcp.his_callback.opmask) { + case 0: + datalink_NCPUp(dl); + break; + + case CALLBACK_BIT(CALLBACK_AUTH): + auth_SetPhoneList(dl->peer.authname, dl->cbcp.fsm.phone, + sizeof dl->cbcp.fsm.phone); + if (*dl->cbcp.fsm.phone == '\0' || !strcmp(dl->cbcp.fsm.phone, "*")) { + log_Printf(LogPHASE, "%s: %s cannot be called back\n", dl->name, + dl->peer.authname); + *dl->cbcp.fsm.phone = '\0'; + } else { + char *ptr = strchr(dl->cbcp.fsm.phone, ','); + if (ptr) + *ptr = '\0'; /* Call back on the first number */ + log_Printf(LogPHASE, "%s: Calling peer back on %s\n", dl->name, + dl->cbcp.fsm.phone); + dl->cbcp.required = 1; + } + dl->cbcp.fsm.delay = 0; + datalink_NewState(dl, DATALINK_LCP); + fsm_Close(&dl->physical->link.lcp.fsm); + break; + + case CALLBACK_BIT(CALLBACK_E164): + strncpy(dl->cbcp.fsm.phone, dl->physical->link.lcp.his_callback.msg, + sizeof dl->cbcp.fsm.phone - 1); + dl->cbcp.fsm.phone[sizeof dl->cbcp.fsm.phone - 1] = '\0'; + log_Printf(LogPHASE, "%s: Calling peer back on %s\n", dl->name, + dl->cbcp.fsm.phone); + dl->cbcp.required = 1; + dl->cbcp.fsm.delay = 0; + datalink_NewState(dl, DATALINK_LCP); + fsm_Close(&dl->physical->link.lcp.fsm); + break; + + default: + log_Printf(LogPHASE, "%s: Oops - Should have NAK'd peer callback !\n", + dl->name); + datalink_NewState(dl, DATALINK_LCP); + fsm_Close(&dl->physical->link.lcp.fsm); + break; + } +} + void datalink_AuthNotOk(struct datalink *dl) { @@ -522,7 +620,12 @@ datalink_LayerDown(void *v, struct fsm *fp) fsm2initial(&dl->physical->link.ccp.fsm); datalink_NewState(dl, DATALINK_LCP); /* before parent TLD */ (*dl->parent->LayerDown)(dl->parent->object, fp); - /* fall through */ + /* fall through (just in case) */ + + case DATALINK_CBCP: + if (!dl->cbcp.required) + cbcp_Down(&dl->cbcp); + /* fall through (just in case) */ case DATALINK_AUTH: timer_Stop(&dl->pap.authtimer); @@ -590,6 +693,11 @@ datalink_Create(const char *name, struct bundle *bundle, int type) dl->cfg.reconnect.max = 0; dl->cfg.reconnect.timeout = RECONNECT_TIMEOUT; + dl->cfg.callback.opmask = 0; + dl->cfg.cbcp.delay = 0; + *dl->cfg.cbcp.phone = '\0'; + dl->cfg.cbcp.fsmretry = DEF_FSMRETRY; + dl->name = strdup(name); peerid_Init(&dl->peer); dl->parent = &bundle->fsm; @@ -607,6 +715,7 @@ datalink_Create(const char *name, struct bundle *bundle, int type) free(dl); return NULL; } + cbcp_Init(&dl->cbcp, dl->physical); chat_Init(&dl->chat, dl->physical, NULL, 1, NULL); log_Printf(LogPHASE, "%s: Created in %s state\n", @@ -667,6 +776,7 @@ datalink_Clone(struct datalink *odl, const char *name) memcpy(&dl->physical->async.cfg, &odl->physical->async.cfg, sizeof dl->physical->async.cfg); + cbcp_Init(&dl->cbcp, dl->physical); chat_Init(&dl->chat, dl->physical, NULL, 1, NULL); log_Printf(LogPHASE, "%s: Cloned in %s state\n", @@ -747,6 +857,7 @@ datalink_Close(struct datalink *dl, int how) fsm2initial(&dl->physical->link.ccp.fsm); /* fall through */ + case DATALINK_CBCP: case DATALINK_AUTH: case DATALINK_LCP: fsm_Close(&dl->physical->link.lcp.fsm); @@ -773,6 +884,7 @@ datalink_Down(struct datalink *dl, int how) fsm2initial(&dl->physical->link.ccp.fsm); /* fall through */ + case DATALINK_CBCP: case DATALINK_AUTH: case DATALINK_LCP: fsm2initial(&dl->physical->link.lcp.fsm); @@ -800,30 +912,30 @@ int datalink_Show(struct cmdargs const *arg) { prompt_Printf(arg->prompt, "Name: %s\n", arg->cx->name); - prompt_Printf(arg->prompt, " State: %s\n", + prompt_Printf(arg->prompt, " State: %s\n", datalink_State(arg->cx)); - prompt_Printf(arg->prompt, " CHAP Encryption: %s\n", + prompt_Printf(arg->prompt, " CHAP Encryption: %s\n", arg->cx->chap.using_MSChap ? "MSChap" : "MD5" ); - prompt_Printf(arg->prompt, " Peer name: "); + prompt_Printf(arg->prompt, " Peer name: "); if (*arg->cx->peer.authname) prompt_Printf(arg->prompt, "%s\n", arg->cx->peer.authname); else if (arg->cx->state == DATALINK_OPEN) prompt_Printf(arg->prompt, "None requested\n"); else prompt_Printf(arg->prompt, "N/A\n"); - prompt_Printf(arg->prompt, " Discriminator: %s\n", + prompt_Printf(arg->prompt, " Discriminator: %s\n", mp_Enddisc(arg->cx->peer.enddisc.class, arg->cx->peer.enddisc.address, arg->cx->peer.enddisc.len)); prompt_Printf(arg->prompt, "\nDefaults:\n"); - prompt_Printf(arg->prompt, " Phone List: %s\n", + prompt_Printf(arg->prompt, " Phone List: %s\n", arg->cx->cfg.phone.list); if (arg->cx->cfg.dial.max) - prompt_Printf(arg->prompt, " Dial tries: %d, delay ", + prompt_Printf(arg->prompt, " Dial tries: %d, delay ", arg->cx->cfg.dial.max); else - prompt_Printf(arg->prompt, " Dial tries: infinite, delay "); + prompt_Printf(arg->prompt, " Dial tries: infinite, delay "); if (arg->cx->cfg.dial.next_timeout > 0) prompt_Printf(arg->prompt, "%ds/", arg->cx->cfg.dial.next_timeout); else @@ -832,17 +944,50 @@ datalink_Show(struct cmdargs const *arg) prompt_Printf(arg->prompt, "%ds\n", arg->cx->cfg.dial.timeout); else prompt_Printf(arg->prompt, "random\n"); - prompt_Printf(arg->prompt, " Reconnect tries: %d, delay ", + prompt_Printf(arg->prompt, " Reconnect tries: %d, delay ", arg->cx->cfg.reconnect.max); if (arg->cx->cfg.reconnect.timeout > 0) prompt_Printf(arg->prompt, "%ds\n", arg->cx->cfg.reconnect.timeout); else prompt_Printf(arg->prompt, "random\n"); - prompt_Printf(arg->prompt, " Dial Script: %s\n", + prompt_Printf(arg->prompt, " Callback %s ", arg->cx->physical->type == + PHYS_DIRECT ? "accepted: " : "requested:"); + if (!arg->cx->cfg.callback.opmask) + prompt_Printf(arg->prompt, "none\n"); + else { + int comma = 0; + + if (arg->cx->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_NONE)) { + prompt_Printf(arg->prompt, "none"); + comma = 1; + } + if (arg->cx->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) { + prompt_Printf(arg->prompt, "%sauth", comma ? ", " : ""); + comma = 1; + } + if (arg->cx->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_E164)) { + prompt_Printf(arg->prompt, "%sE.164", comma ? ", " : ""); + if (arg->cx->physical->type != PHYS_DIRECT) + prompt_Printf(arg->prompt, " (%s)", arg->cx->cfg.callback.msg); + comma = 1; + } + if (arg->cx->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) { + prompt_Printf(arg->prompt, "%scbcp\n", comma ? ", " : ""); + prompt_Printf(arg->prompt, " CBCP: delay: %ds\n", + arg->cx->cfg.cbcp.delay); + prompt_Printf(arg->prompt, " phone: %s\n", + arg->cx->cfg.cbcp.phone); + prompt_Printf(arg->prompt, " timeout: %lds\n", + arg->cx->cfg.cbcp.fsmretry); + } else + prompt_Printf(arg->prompt, "\n"); + } + + prompt_Printf(arg->prompt, " Dial Script: %s\n", arg->cx->cfg.script.dial); - prompt_Printf(arg->prompt, " Login Script: %s\n", + prompt_Printf(arg->prompt, " Login Script: %s\n", arg->cx->cfg.script.login); - prompt_Printf(arg->prompt, " Hangup Script: %s\n", + prompt_Printf(arg->prompt, " Hangup Script: %s\n", arg->cx->cfg.script.hangup); return 0; } @@ -923,6 +1068,7 @@ static const char *states[] = { "ready", "lcp", "auth", + "cbcp", "open" }; @@ -1025,6 +1171,7 @@ iov2datalink(struct bundle *bundle, struct iovec *iov, int *niov, int maxiov, free(dl); dl = NULL; } else { + cbcp_Init(&dl->cbcp, dl->physical); chat_Init(&dl->chat, dl->physical, NULL, 1, NULL); log_Printf(LogPHASE, "%s: Transferred in %s state\n", @@ -1043,6 +1190,8 @@ datalink2iov(struct datalink *dl, struct iovec *iov, int *niov, int maxiov, if (dl) { timer_Stop(&dl->dial_timer); + /* The following is purely for the sake of paranoia */ + cbcp_Down(&dl->cbcp); timer_Stop(&dl->pap.authtimer); timer_Stop(&dl->chap.auth.authtimer); } diff --git a/usr.sbin/ppp/datalink.h b/usr.sbin/ppp/datalink.h index 680350331ad8..40801997e31b 100644 --- a/usr.sbin/ppp/datalink.h +++ b/usr.sbin/ppp/datalink.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: datalink.h,v 1.3 1998/05/28 23:15:35 brian Exp $ + * $Id: datalink.h,v 1.4 1998/06/15 19:05:19 brian Exp $ */ #define DATALINK_CLOSED (0) @@ -34,7 +34,8 @@ #define DATALINK_READY (5) #define DATALINK_LCP (6) #define DATALINK_AUTH (7) -#define DATALINK_OPEN (8) +#define DATALINK_CBCP (8) +#define DATALINK_OPEN (9) #define DATALINK_MAXNAME (20) /* Maximum datalink::name length */ @@ -61,7 +62,7 @@ struct datalink { unsigned packetmode : 1; /* Go into packet mode after login ? */ } script; - struct pppTimer dial_timer; /* For timing between opens & scripts */ + struct pppTimer dial_timer; /* For timing between close & open */ struct { struct { @@ -81,6 +82,8 @@ struct datalink { int max; /* initially try again this number of times */ int timeout; /* Timeout before reconnect on carrier loss */ } reconnect; + struct callback callback; /* Direction depends on physical type */ + struct cbcpcfg cbcp; /* Direction depends on phys type & callback */ } cfg; /* All our config data is in here */ struct { @@ -90,6 +93,8 @@ struct datalink { const char *chosen; /* Chosen phone number after DIAL */ } phone; + struct cbcp cbcp; + int dial_tries; /* currently try again this number of times */ unsigned reconnect_tries; /* currently try again this number of times */ @@ -126,6 +131,9 @@ extern void datalink_StayDown(struct datalink *); extern void datalink_DontHangup(struct datalink *); extern void datalink_AuthOk(struct datalink *); extern void datalink_AuthNotOk(struct datalink *); +extern void datalink_NCPUp(struct datalink *); +extern void datalink_CBCPComplete(struct datalink *); +extern void datalink_CBCPFailed(struct datalink *); extern int datalink_Show(struct cmdargs const *); extern int datalink_SetRedial(struct cmdargs const *); extern int datalink_SetReconnect(struct cmdargs const *); diff --git a/usr.sbin/ppp/deflate.c b/usr.sbin/ppp/deflate.c index c0d83cf19ce8..4b0c930e1f07 100644 --- a/usr.sbin/ppp/deflate.c +++ b/usr.sbin/ppp/deflate.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: deflate.c,v 1.9 1998/06/15 19:06:39 brian Exp $ + * $Id: deflate.c,v 1.10 1998/06/16 19:40:36 brian Exp $ */ #include @@ -32,6 +32,7 @@ #include #include +#include "defs.h" #include "mbuf.h" #include "log.h" #include "timer.h" diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index cf222532df5d..1c1ae88e0e5b 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: defs.h,v 1.33 1998/06/27 23:48:43 brian Exp $ + * $Id: defs.h,v 1.34 1998/07/11 02:48:36 brian Exp $ * * TODO: */ @@ -52,6 +52,7 @@ #define DEF_LQRPERIOD 30 /* Default LQR frequency */ #define MIN_FSMRETRY 3 /* Minimum FSM retry frequency */ #define DEF_FSMRETRY 3 /* FSM retry frequency */ +#define DEF_REQs 5 /* This number of REQs in IRC */ #define CONFFILE "ppp.conf" #define LINKUPFILE "ppp.linkup" diff --git a/usr.sbin/ppp/hdlc.c b/usr.sbin/ppp/hdlc.c index 5a2152bd412c..d03c9f377163 100644 --- a/usr.sbin/ppp/hdlc.c +++ b/usr.sbin/ppp/hdlc.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: hdlc.c,v 1.34 1998/06/27 23:48:44 brian Exp $ + * $Id: hdlc.c,v 1.35 1998/08/01 01:02:12 brian Exp $ * * TODO: */ @@ -58,6 +58,7 @@ #include "prompt.h" #include "chat.h" #include "mp.h" +#include "cbcp.h" #include "datalink.h" #include "filter.h" #include "bundle.h" @@ -395,6 +396,14 @@ hdlc_DecodePacket(struct bundle *bundle, u_short proto, struct mbuf * bp, mbuf_Free(bp); } break; + case PROTO_CBCP: + if (p) + cbcp_Input(p, bp); + else { + log_Printf(LogERROR, "DecodePacket: CBCP: Not a physical link !\n"); + mbuf_Free(bp); + } + break; case PROTO_LQR: if (p) { p->hdlc.lqm.lqr.SaveInLQRs++; diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 55e0a59ad95d..9d80c24b6736 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -17,14 +17,16 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ip.c,v 1.48 1998/06/27 23:48:45 brian Exp $ + * $Id: ip.c,v 1.49 1998/07/11 19:05:24 brian Exp $ * * TODO: * o Return ICMP message for filterd packet * and optionaly record it into log. */ #include +#ifdef __OpenBSD__ #include +#endif #include #include #include diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c index 7edbd0c884f8..d61016f64b52 100644 --- a/usr.sbin/ppp/ipcp.c +++ b/usr.sbin/ppp/ipcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: ipcp.c,v 1.61 1998/06/27 16:24:52 brian Exp $ + * $Id: ipcp.c,v 1.62 1998/06/27 23:48:45 brian Exp $ * * TODO: * o More RFC1772 backward compatibility @@ -548,7 +548,7 @@ IpcpInitRestartCounter(struct fsm * fp) struct ipcp *ipcp = fsm2ipcp(fp); fp->FsmTimer.load = ipcp->cfg.fsmretry * SECTICKS; - fp->restart = 5; + fp->restart = DEF_REQs; } static void diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index 897eb2323bdb..47d20746cc5e 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.60 1998/06/25 22:33:28 brian Exp $ + * $Id: lcp.c,v 1.61 1998/06/27 23:48:47 brian Exp $ * * TODO: * o Limit data field length by MRU @@ -61,6 +61,7 @@ #include "chat.h" #include "auth.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" #include "bundle.h" @@ -237,6 +238,7 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->his_lqrperiod = 0; lcp->his_acfcomp = 0; lcp->his_auth = 0; + lcp->his_callback.opmask = 0; lcp->his_shortseq = 0; lcp->want_mru = lcp->cfg.mru; @@ -245,6 +247,8 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->want_acfcomp = IsEnabled(lcp->cfg.acfcomp) ? 1 : 0; if (lcp->fsm.parent) { + struct physical *p = link2physical(lcp->fsm.link); + lcp->his_accmap = 0xffffffff; lcp->want_accmap = lcp->cfg.accmap; lcp->his_protocomp = 0; @@ -252,6 +256,10 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->want_magic = GenerateMagic(); lcp->want_auth = IsEnabled(lcp->cfg.chap) ? PROTO_CHAP : IsEnabled(lcp->cfg.pap) ? PROTO_PAP : 0; + if (p->type != PHYS_DIRECT) + memcpy(&lcp->want_callback, &p->dl->cfg.callback, sizeof(struct callback)); + else + lcp->want_callback.opmask = 0; lcp->want_lqrperiod = IsEnabled(lcp->cfg.lqr) ? lcp->cfg.lqrperiod * 100 : 0; } else { @@ -259,6 +267,7 @@ lcp_Setup(struct lcp *lcp, int openmode) lcp->his_protocomp = lcp->want_protocomp = 1; lcp->want_magic = 0; lcp->want_auth = 0; + lcp->want_callback.opmask = 0; lcp->want_lqrperiod = 0; } @@ -274,7 +283,7 @@ LcpInitRestartCounter(struct fsm * fp) struct lcp *lcp = fsm2lcp(fp); fp->FsmTimer.load = lcp->cfg.fsmretry * SECTICKS; - fp->restart = 5; + fp->restart = DEF_REQs; } static void @@ -336,6 +345,26 @@ LcpSendConfigReq(struct fsm *fp) break; } + if (!REJECTED(lcp, TY_CALLBACK)) { + if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) { + *o->data = CALLBACK_AUTH; + INC_LCP_OPT(TY_CALLBACK, 3, o); + } else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) { + *o->data = CALLBACK_CBCP; + INC_LCP_OPT(TY_CALLBACK, 3, o); + } else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_E164)) { + int sz = strlen(lcp->want_callback.msg); + + if (sz > sizeof o->data - 1) { + sz = sizeof o->data - 1; + log_Printf(LogWARN, "Truncating E164 data to %d octets (oops!)\n", sz); + } + *o->data = CALLBACK_E164; + memcpy(o->data + 1, lcp->want_callback.msg, sz); + INC_LCP_OPT(TY_CALLBACK, sz + 3, o); + } + } + if (lcp->want_mrru && !REJECTED(lcp, TY_MRRU)) { *(u_int16_t *)o->data = htons(lcp->want_mrru); INC_LCP_OPT(TY_MRRU, 4, o); @@ -371,6 +400,11 @@ static void LcpSendTerminateAck(struct fsm *fp, u_char id) { /* Send Term ACK please */ + struct physical *p = link2physical(fp->link); + + if (p && p->dl->state == DATALINK_CBCP) + cbcp_ReceiveTerminateReq(p); + fsm_Output(fp, CODE_TERMACK, id, NULL, 0); } @@ -417,13 +451,32 @@ LcpLayerDown(struct fsm *fp) lcp_Setup(fsm2lcp(fp), 0); } +static int +E164ok(struct callback *cb, char *req, int sz) +{ + char list[sizeof cb->msg], *next; + int len; + + if (!strcmp(cb->msg, "*")) + return 1; + + strncpy(list, cb->msg, sizeof list - 1); + list[sizeof list - 1] = '\0'; + for (next = strtok(list, ","); next; next = strtok(NULL, ",")) { + len = strlen(next); + if (sz == len && !memcmp(list, req, sz)) + return 1; + } + return 0; +} + static void LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, struct fsm_decode *dec) { /* Deal with incoming PROTO_LCP */ struct lcp *lcp = fsm2lcp(fp); - int type, length, sz, pos; + int type, length, sz, pos, op, callback_req; u_int32_t magic, accmap; u_short mtu, mru, proto; u_int16_t *sp; @@ -432,20 +485,22 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, struct mp *mp; struct physical *p = link2physical(fp->link); + callback_req = 0; + while (plen >= sizeof(struct fsmconfig)) { type = *cp; length = cp[1]; - if (length == 0) { - log_Printf(LogLCP, "%s: LCP size zero\n", fp->link->name); - break; - } - if (type < 0 || type >= NCFTYPES) snprintf(request, sizeof request, " <%d>[%d]", type, length); else snprintf(request, sizeof request, " %s[%d]", cftypes[type], length); + if (length < 2) { + log_Printf(LogLCP, "%s:%s: Bad LCP length\n", fp->link->name, request); + break; + } + switch (type) { case TY_MRRU: mp = &lcp->fsm.bundle->ncp.mp; @@ -782,6 +837,103 @@ LcpDecodeConfig(struct fsm *fp, u_char *cp, int plen, int mode_type, } break; + case TY_CALLBACK: + if (length == 2) + op = CALLBACK_NONE; + else + op = (int)cp[2]; + sz = length - 3; + switch (op) { + case CALLBACK_AUTH: + log_Printf(LogLCP, "%s Auth\n", request); + break; + case CALLBACK_DIALSTRING: + log_Printf(LogLCP, "%s Dialstring %.*s\n", request, sz, cp + 3); + break; + case CALLBACK_LOCATION: + log_Printf(LogLCP, "%s Location %.*s\n", request, sz, cp + 3); + break; + case CALLBACK_E164: + log_Printf(LogLCP, "%s E.164 (%.*s)\n", request, sz, cp + 3); + break; + case CALLBACK_NAME: + log_Printf(LogLCP, "%s Name %.*s\n", request, sz, cp + 3); + break; + case CALLBACK_CBCP: + log_Printf(LogLCP, "%s CBCP\n", request); + break; + default: + log_Printf(LogLCP, "%s ???\n", request); + break; + } + + switch (mode_type) { + case MODE_REQ: + callback_req = 1; + if (p->type != PHYS_DIRECT) + goto reqreject; + if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(op)) && + (op != CALLBACK_AUTH || p->link.lcp.auth_ineed) && + (op != CALLBACK_E164 || + E164ok(&p->dl->cfg.callback, cp + 3, sz))) { + lcp->his_callback.opmask = CALLBACK_BIT(op); + if (sz > sizeof lcp->his_callback.msg - 1) { + sz = sizeof lcp->his_callback.msg - 1; + log_Printf(LogWARN, "Truncating option arg to %d octets\n", sz); + } + memcpy(lcp->his_callback.msg, cp + 3, sz); + lcp->his_callback.msg[sz] = '\0'; + memcpy(dec->ackend, cp, sz + 3); + dec->ackend += sz + 3; + } else if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) && + p->link.lcp.auth_ineed) { + *dec->nakend++ = *cp; + *dec->nakend++ = 3; + *dec->nakend++ = CALLBACK_AUTH; + } else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) { + *dec->nakend++ = *cp; + *dec->nakend++ = 3; + *dec->nakend++ = CALLBACK_CBCP; + } else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_E164)) { + *dec->nakend++ = *cp; + *dec->nakend++ = 3; + *dec->nakend++ = CALLBACK_E164; + } else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) { + log_Printf(LogWARN, "Cannot insist on auth callback without" + " PAP or CHAP enabled !\n"); + *dec->nakend++ = *cp; + *dec->nakend++ = 2; + } else + goto reqreject; + break; + case MODE_NAK: + /* We don't do what he NAKs want, we do things in our preferred order */ + if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) + lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_AUTH); + else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) + lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_CBCP); + else if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_E164)) + lcp->want_callback.opmask &= ~CALLBACK_BIT(CALLBACK_E164); + if (lcp->want_callback.opmask == CALLBACK_BIT(CALLBACK_NONE)) { + log_Printf(LogPHASE, "Peer NAKd all callbacks, trying none\n"); + lcp->want_callback.opmask = 0; + } else if (!lcp->want_callback.opmask) { + log_Printf(LogPHASE, "Peer NAKd last configured callback\n"); + fsm_Close(&lcp->fsm); + } + break; + case MODE_REJ: + if (lcp->want_callback.opmask & CALLBACK_BIT(CALLBACK_NONE)) { + lcp->his_reject |= (1 << type); + lcp->want_callback.opmask = 0; + } else { + log_Printf(LogPHASE, "Peer rejected *required* callback\n"); + fsm_Close(&lcp->fsm); + } + break; + } + break; + case TY_SHORTSEQ: mp = &lcp->fsm.bundle->ncp.mp; log_Printf(LogLCP, "%s\n", request); @@ -874,6 +1026,25 @@ reqreject: } if (mode_type != MODE_NOP) { + if (mode_type == MODE_REQ && p && p->type == PHYS_DIRECT && + p->dl->cfg.callback.opmask && !callback_req && + !(p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_NONE))) { + /* We *REQUIRE* that the peer requests callback */ + *dec->nakend++ = TY_CALLBACK; + *dec->nakend++ = 3; + if ((p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_AUTH)) && + p->link.lcp.auth_ineed) + *dec->nakend++ = CALLBACK_AUTH; + else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_CBCP)) + *dec->nakend++ = CALLBACK_CBCP; + else if (p->dl->cfg.callback.opmask & CALLBACK_BIT(CALLBACK_E164)) + *dec->nakend++ = CALLBACK_E164; + else { + log_Printf(LogWARN, "Cannot insist on auth callback without" + " PAP or CHAP enabled !\n"); + dec->nakend[-1] = 2; /* XXX: Silly ! */ + } + } if (dec->rejend != dec->rej) { /* rejects are preferred */ dec->ackend = dec->ack; diff --git a/usr.sbin/ppp/lcp.h b/usr.sbin/ppp/lcp.h index 03e87a4ee62a..62dce126d978 100644 --- a/usr.sbin/ppp/lcp.h +++ b/usr.sbin/ppp/lcp.h @@ -15,11 +15,27 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.h,v 1.17 1998/05/21 21:46:03 brian Exp $ + * $Id: lcp.h,v 1.18 1998/06/27 23:48:48 brian Exp $ * * TODO: */ +/* callback::opmask values */ +#define CALLBACK_AUTH (0) +#define CALLBACK_DIALSTRING (1) /* Don't do this */ +#define CALLBACK_LOCATION (2) /* Don't do this */ +#define CALLBACK_E164 (3) +#define CALLBACK_NAME (4) /* Don't do this */ +#define CALLBACK_CBCP (6) +#define CALLBACK_NONE (14) /* No callback is ok */ + +#define CALLBACK_BIT(n) ((n) < 0 ? 0 : 1 << (n)) + +struct callback { + int opmask; /* want these types of callback */ + char msg[SCRIPT_LEN]; /* with this data (E.164) */ +}; + #define REJECTED(p, x) ((p)->his_reject & (1<<(x))) struct lcp { @@ -30,6 +46,7 @@ struct lcp { u_int32_t his_magic; /* Peers magic number */ u_int32_t his_lqrperiod; /* Peers LQR frequency (100ths of seconds) */ u_short his_auth; /* Peer wants this type of authentication */ + struct callback his_callback; /* Peer wants callback ? */ unsigned his_shortseq : 1; /* Peer would like only 12bit seqs (MP) */ unsigned his_protocomp : 1; /* Does peer do Protocol field compression */ unsigned his_acfcomp : 1; /* Does peer do addr & cntrl fld compression */ @@ -40,6 +57,7 @@ struct lcp { u_int32_t want_magic; /* Our magic number */ u_int32_t want_lqrperiod; /* Our LQR frequency (100ths of seconds) */ u_short want_auth; /* We want this type of authentication */ + struct callback want_callback;/* We want callback ? */ unsigned want_shortseq : 1; /* I'd like only 12bit seqs (MP) */ unsigned want_protocomp : 1; /* Do we do protocol field compression */ unsigned want_acfcomp : 1; /* Do we do addr & cntrl fld compression */ @@ -80,11 +98,13 @@ struct lcp { #define TY_ACFCOMP 8 /* Address-and-Control-Field-Compression */ #define TY_FCSALT 9 /* FCS-Alternatives */ #define TY_SDP 10 /* Self-Describing-Padding */ +#define TY_CALLBACK 13 /* Callback */ +#define TY_CFRAMES 15 /* Compound-frames */ #define TY_MRRU 17 /* Max Reconstructed Receive Unit (MP) */ #define TY_SHORTSEQ 18 /* Want short seqs (12bit) please (see mp.h) */ #define TY_ENDDISC 19 /* Endpoint discriminator */ -#define MAX_LCP_OPT_LEN 10 +#define MAX_LCP_OPT_LEN 20 struct lcp_opt { u_char id; u_char len; diff --git a/usr.sbin/ppp/lcpproto.h b/usr.sbin/ppp/lcpproto.h index 8f15fe6c6c8e..8434822459c5 100644 --- a/usr.sbin/ppp/lcpproto.h +++ b/usr.sbin/ppp/lcpproto.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcpproto.h,v 1.10.2.2 1998/05/15 18:21:07 brian Exp $ + * $Id: lcpproto.h,v 1.11 1998/05/21 21:46:05 brian Exp $ * * TODO: */ @@ -38,5 +38,6 @@ #define PROTO_LCP 0xc021 #define PROTO_PAP 0xc023 +#define PROTO_CBCP 0xc029 #define PROTO_LQR 0xc025 #define PROTO_CHAP 0xc223 diff --git a/usr.sbin/ppp/link.c b/usr.sbin/ppp/link.c index 21be93929a80..88a9010f8019 100644 --- a/usr.sbin/ppp/link.c +++ b/usr.sbin/ppp/link.c @@ -23,16 +23,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: link.c,v 1.2 1998/05/21 21:46:10 brian Exp $ + * $Id: link.c,v 1.3 1998/06/27 23:48:49 brian Exp $ * */ #include #include -#include #include +#include "defs.h" #include "mbuf.h" #include "log.h" #include "timer.h" diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index acc76f5767a7..afb336fb0d7c 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: log.c,v 1.31 1998/06/15 19:06:48 brian Exp $ + * $Id: log.c,v 1.32 1998/08/02 13:01:15 brian Exp $ */ #include @@ -43,6 +43,7 @@ static const char *LogNames[] = { "Async", + "CBCP", "CCP", "Chat", "Command", diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h index 399cde98f131..87c96182610b 100644 --- a/usr.sbin/ppp/log.h +++ b/usr.sbin/ppp/log.h @@ -23,30 +23,31 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: log.h,v 1.20 1998/05/23 22:24:41 brian Exp $ + * $Id: log.h,v 1.21 1998/08/02 13:01:16 brian Exp $ */ #define LogMIN (1) #define LogASYNC (1) /* syslog(LOG_INFO, ....) */ -#define LogCCP (2) -#define LogCHAT (3) -#define LogCOMMAND (4) -#define LogCONNECT (5) -#define LogDEBUG (6) /* syslog(LOG_DEBUG, ....) */ -#define LogHDLC (7) -#define LogID0 (8) -#define LogIPCP (9) -#define LogLCP (10) -#define LogLQM (11) -#define LogPHASE (12) -#define LogTCPIP (13) -#define LogTIMER (14) /* syslog(LOG_DEBUG, ....) */ -#define LogTUN (15) /* If set, tun%d is output with each message */ -#define LogMAXCONF (15) -#define LogWARN (16) /* Sent to VarTerm else syslog(LOG_WARNING, ) */ -#define LogERROR (17) /* syslog(LOG_ERR, ....), + sent to VarTerm */ -#define LogALERT (18) /* syslog(LOG_ALERT, ....) */ -#define LogMAX (18) +#define LogCBCP (2) +#define LogCCP (3) +#define LogCHAT (4) +#define LogCOMMAND (5) +#define LogCONNECT (6) +#define LogDEBUG (7) /* syslog(LOG_DEBUG, ....) */ +#define LogHDLC (8) +#define LogID0 (9) +#define LogIPCP (10) +#define LogLCP (11) +#define LogLQM (12) +#define LogPHASE (13) +#define LogTCPIP (14) +#define LogTIMER (15) /* syslog(LOG_DEBUG, ....) */ +#define LogTUN (16) /* If set, tun%d is output with each message */ +#define LogMAXCONF (16) +#define LogWARN (17) /* Sent to VarTerm else syslog(LOG_WARNING, ) */ +#define LogERROR (18) /* syslog(LOG_ERR, ....), + sent to VarTerm */ +#define LogALERT (19) /* syslog(LOG_ALERT, ....) */ +#define LogMAX (19) struct mbuf; struct cmdargs; diff --git a/usr.sbin/ppp/lqr.c b/usr.sbin/ppp/lqr.c index 4970672dfc13..a54af4168d5a 100644 --- a/usr.sbin/ppp/lqr.c +++ b/usr.sbin/ppp/lqr.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lqr.c,v 1.28 1998/06/26 19:02:40 brian Exp $ + * $Id: lqr.c,v 1.29 1998/06/27 23:48:49 brian Exp $ * * o LQR based on RFC1333 * @@ -52,6 +52,7 @@ #include "auth.h" #include "chap.h" #include "command.h" +#include "cbcp.h" #include "datalink.h" struct echolqr { diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 0ac478583345..408e5e93701c 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.139 1998/06/27 14:18:07 brian Exp $ + * $Id: main.c,v 1.140 1998/08/02 06:56:40 brian Exp $ * * TODO: */ @@ -66,6 +66,7 @@ #include "prompt.h" #include "chat.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" #ifndef O_NONBLOCK diff --git a/usr.sbin/ppp/mbuf.c b/usr.sbin/ppp/mbuf.c index 2f5df24579b8..5b4434889287 100644 --- a/usr.sbin/ppp/mbuf.c +++ b/usr.sbin/ppp/mbuf.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.c,v 1.17 1998/06/16 19:40:20 brian Exp $ + * $Id: mbuf.c,v 1.18 1998/06/27 23:48:50 brian Exp $ * */ #include @@ -154,8 +154,8 @@ mbuf_Show(struct cmdargs const *arg) { int i; static const char *mbuftype[] = { - "async", "fsm", "hdlcout", "ipin", "echo", "lqr", "link", "vjcomp", - "ipq", "mp" }; + "async", "fsm", "cbcp", "hdlcout", "ipin", "echo", "lqr", "link", + "vjcomp", "ipq", "mp" }; for (i = 1; i < MB_MAX; i += 2) prompt_Printf(arg->prompt, "%10.10s: %04d\t%10.10s: %04d\n", @@ -176,8 +176,8 @@ mbuf_Log() MemMap[1].count, MemMap[2].count, MemMap[3].count, MemMap[4].count); log_Printf(LogDEBUG, "mbuf_Log: 5: %d 6: %d 7: %d 8: %d\n", MemMap[5].count, MemMap[6].count, MemMap[7].count, MemMap[8].count); - log_Printf(LogDEBUG, "mbuf_Log: 9: %d 10: %d\n", - MemMap[9].count, MemMap[10].count); + log_Printf(LogDEBUG, "mbuf_Log: 9: %d 10: %d 11: %d\n", + MemMap[9].count, MemMap[10].count, MemMap[11].count); } struct mbuf * diff --git a/usr.sbin/ppp/mbuf.h b/usr.sbin/ppp/mbuf.h index 4c7612f313e7..4ee8e402e964 100644 --- a/usr.sbin/ppp/mbuf.h +++ b/usr.sbin/ppp/mbuf.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: mbuf.h,v 1.11.2.5 1998/05/01 19:25:24 brian Exp $ + * $Id: mbuf.h,v 1.12 1998/05/21 21:46:49 brian Exp $ * * TODO: */ @@ -40,14 +40,15 @@ struct mqueue { #define MB_ASYNC 1 #define MB_FSM 2 -#define MB_HDLCOUT 3 -#define MB_IPIN 4 -#define MB_ECHO 5 -#define MB_LQR 6 -#define MB_LINK 7 -#define MB_VJCOMP 8 -#define MB_IPQ 9 -#define MB_MP 10 +#define MB_CBCP 3 +#define MB_HDLCOUT 4 +#define MB_IPIN 5 +#define MB_ECHO 6 +#define MB_LQR 7 +#define MB_LINK 8 +#define MB_VJCOMP 9 +#define MB_IPQ 10 +#define MB_MP 11 #define MB_MAX MB_MP struct cmdargs; diff --git a/usr.sbin/ppp/modem.c b/usr.sbin/ppp/modem.c index 4041d93c85bf..94da68ea5056 100644 --- a/usr.sbin/ppp/modem.c +++ b/usr.sbin/ppp/modem.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: modem.c,v 1.95 1998/07/03 17:24:38 brian Exp $ + * $Id: modem.c,v 1.96 1998/07/29 18:20:53 brian Exp $ * * TODO: */ @@ -36,12 +36,12 @@ #include #include #include -#include #include #include #include #include #ifdef __OpenBSD__ +#include #include #else #include @@ -74,6 +74,7 @@ #include "chat.h" #include "auth.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" diff --git a/usr.sbin/ppp/mp.c b/usr.sbin/ppp/mp.c index 46a686e87fc7..b4223cddfb14 100644 --- a/usr.sbin/ppp/mp.c +++ b/usr.sbin/ppp/mp.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: mp.c,v 1.11 1998/06/24 19:33:34 brian Exp $ + * $Id: mp.c,v 1.12 1998/06/30 23:04:17 brian Exp $ */ #include @@ -68,6 +68,7 @@ #include "filter.h" #include "mp.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" #include "bundle.h" #include "ip.h" diff --git a/usr.sbin/ppp/pap.c b/usr.sbin/ppp/pap.c index afbc3a25b2ea..cc1430037c48 100644 --- a/usr.sbin/ppp/pap.c +++ b/usr.sbin/ppp/pap.c @@ -18,7 +18,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: pap.c,v 1.24 1998/06/27 23:48:51 brian Exp $ + * $Id: pap.c,v 1.25 1998/07/28 21:54:30 brian Exp $ * * TODO: */ @@ -28,7 +28,6 @@ #include #include -#include #include #include "mbuf.h" @@ -56,6 +55,7 @@ #include "bundle.h" #include "chat.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" static const char *papcodes[] = { "???", "REQUEST", "SUCCESS", "FAILURE" }; diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index 952d2e6530d8..578a7dea8ab8 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -16,7 +16,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: physical.c,v 1.3 1998/05/23 22:24:47 brian Exp $ + * $Id: physical.c,v 1.4 1998/06/27 14:18:09 brian Exp $ * */ @@ -217,8 +217,9 @@ physical_Logout(struct physical *phys) int physical_SetMode(struct physical *p, int mode) { - if (p->type & (PHYS_DIRECT|PHYS_DEDICATED) - || mode & (PHYS_DIRECT|PHYS_DEDICATED)) { + if ((p->type & (PHYS_DIRECT|PHYS_DEDICATED) || + mode & (PHYS_DIRECT|PHYS_DEDICATED)) && + (!(p->type & PHYS_DIRECT) || !(mode & PHYS_BACKGROUND))) { log_Printf(LogWARN, "%s: Cannot change mode %s to %s\n", p->link.name, mode2Nam(p->type), mode2Nam(mode)); return 0; diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index 2b09f56a8f91..15c70319237a 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.112 1998/07/29 18:21:17 brian Exp $ +.\" $Id: ppp.8,v 1.113 1998/07/31 19:50:24 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -74,6 +74,10 @@ command via its diagnostic socket. A will force an LCP renegotiation, and a .Dv SIGTERM will force it to exit. +.It Supports client callback. +.Nm Ppp +can use either the standard LCP callback protocol or the Microsoft +CallBack Control Protocol (ftp://ftp.microsoft.com/developr/rfc/cbcp.txt). .It Supports packet aliasing. Packet aliasing (a.k.a. IP masquerading) allows computers on a private, unregistered network to access the Internet. The @@ -161,7 +165,7 @@ is installed as user and group .Dv network , with permissions -.Dv 4550 . +.Dv 4554 . By default, .Nm will not run if the invoking user id is not zero. This may be overridden @@ -278,6 +282,15 @@ lines to the file Refer to the .Xr resolv.conf 5 manual page for details. +.Pp +Alternatively, if the peer supports it, +.Nm +can be configured to ask the peer for the nameserver address(es) and to +update +.Pa /etc/resolv.conf +automatically. Refer to the +.Dq enable dns +command below for details. .El .Sh MANUAL DIALING In the following examples, we assume that your machine name is @@ -477,11 +490,20 @@ portion of the prompt will change to # ppp MyISP ... ppp ON awfulhak> dial -dial OK! -login OK! +Ppp ON awfulhak> +PPp ON awfulhak> PPP ON awfulhak> .Ed .Pp +The Ppp prompt indicates that +.Nm +has entered the authentication phase. The PPp prompt indicates that +.Nm +has entered the network phase. The PPP prompt indicates that +.Nm +has successfully negotiated a network layer protocol and is in +a usable state. +.Pp If the .Pa /etc/ppp/ppp.linkup file is available, its contents are executed @@ -905,7 +927,9 @@ Instead of running over a serial link, it is possible to use a TCP connection instead by specifying a host and port as the device: +.Pp .Dl set device ui-gate:6669 +.Pp Instead of opening a serial device, .Nm will open a TCP connection to the given machine on the given @@ -918,13 +942,17 @@ connection on the receiving machine (ui-gate). This is done by first updating .Pa /etc/services to name the service: +.Pp .Dl ppp-in 6669/tcp # Incoming PPP connections over TCP +.Pp and updating .Pa /etc/inetd.conf to tell .Xr inetd 8 how to deal with incoming connections on that port: +.Pp .Dl ppp-in stream tcp nowait root /usr/sbin/ppp ppp -direct ppp-in +.Pp Don't forget to send a .Dv HUP signal to @@ -986,7 +1014,9 @@ Again, if you're enabling PAP, you'll also need: We're assigning the address of 10.0.4.1 to ui-gate, and the address 10.0.4.2 to awfulhak. To open the connection, just type +.Pp .Dl awfulhak # ppp -background ui-gate +.Pp The result will be an additional "route" on awfulhak to the 10.0.2.0/24 network via the TCP connection, and an additional "route" on ui-gate to the 10.0.1.0/24 network. @@ -1442,7 +1472,10 @@ logging) so that the actual password is not compromised .Ar chat logging is active rather than the actual password. .Pp -Login scripts vary greatly between ISPs. +Login scripts vary greatly between ISPs. If you're setting one up +for the first time, +.Em ENABLE CHAT LOGGING +so that you can see if your script is behaving as you expect. .It Use .Dq set line @@ -1531,6 +1564,20 @@ set authkey MyPassword Both are accepted by default, so .Nm will provide whatever your ISP requires. +.Pp +It should be noted that a login script is rarely (if ever) required +when PAP or CHAP are in use. +.It +Ask your ISP to authenticate your nameserver address(es) with the line +.Bd -literal -offset indent +enable dns +.Ed +Do +.Em NOT +do this if you are running an local DNS, as +.Nm +will simply circumvent its use by entering some nameserver lines in +.Pa /etc/resolv.conf . .El .Pp Please refer to @@ -1540,12 +1587,13 @@ and for some real examples. The pmdemand label should be appropriate for most ISPs. .Sh LOGGING FACILITY -.Nm +.Nm Ppp is able to generate the following log info either via .Xr syslog 3 or directly to the screen: .Bl -column SMMMMMM -offset indent .It Li Async Dump async level packet in hex +.It Li CBCP Generate CBCP (CallBack Control Protocol) logs .It Li CCP Generate a CCP packet trace .It Li Chat Generate Chat script trace log .It Li Command Log commands executed @@ -2571,6 +2619,83 @@ If is zero, this timer is disabled. Because both values default to zero, .Ar demand-dial links will stay active until the bundle idle timer expires. +.It set callback [none|auth|cbcp|E.164 *|number[,number]...]... +If no arguments are given, callback is disabled, otherwise, +.Nm +will request (or in +.Ar direct +mode, will accept) one of the given protocols. If a request is NAK'd +.Nm +will request another, until no options remain at which point +.Nm +will terminate negotiations. +The options are as follows (in this order of preference): +.Pp +.Bl -tag +.It auth +The callee is expected to decide the callback number based on +authentication. If +.Nm +is the callee, the number should be specified as the fifth field of +the peers entry in +.Pa /etc/ppp/ppp.secret . +.It cbcp +Microsofts callback control protocol is used. See +.Dq set cbcp +below. +.It E.164 *|number[,number]... +The caller specifies the +.Ar number . +If +.Nm +is the callee, +.Ar number +should be either a comma seperated list of allowable numbers or a +.Dq \&* , +meaning any number is permitted. If +.Nm +is the caller, only a single number should be specified. +.Pp +Note, this option is very unsafe when used with a +.Dq \&* +as a malicious caller can tell +.Nm +to call any (possibly international) number without first authenticating +themselves. +.It none +If the peer does not wish to do callback at all, +.Nm +will accept the fact and continue without callback rather than terminating +the connection. +.El +.Pp +.It set cbcp Op *|number[,number]... Op delay Op retry +If no arguments are given, CBCP (Microsofts CallBack Control Protocol) +is disabled - ie, configuring CBCP in the +.Dq set callback +command will result in +.Nm +requesting no callback in the CBCP phase. +Otherwise, +.Nm +attempts to use the given phone +.Ar number Ns No (s). +.Pp +In server mode +.Pq Fl direct , +.Nm +will insist that the client uses one of these numbers, unless +.Dq \&* +is used in which case the client is expected to specify the number. +.Pp +In client mode, +.Nm +will attempt to use one of the given numbers (whichever it finds to +be agreeable with the peer), or if +.Dq \&* +is specified, +.Nm +will expect the peer to specify the number. .It set ctsrts|crtscts on|off This sets hardware flow control. Hardware flow control is .Ar on diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 2b09f56a8f91..15c70319237a 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,4 +1,4 @@ -.\" $Id: ppp.8,v 1.112 1998/07/29 18:21:17 brian Exp $ +.\" $Id: ppp.8,v 1.113 1998/07/31 19:50:24 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -74,6 +74,10 @@ command via its diagnostic socket. A will force an LCP renegotiation, and a .Dv SIGTERM will force it to exit. +.It Supports client callback. +.Nm Ppp +can use either the standard LCP callback protocol or the Microsoft +CallBack Control Protocol (ftp://ftp.microsoft.com/developr/rfc/cbcp.txt). .It Supports packet aliasing. Packet aliasing (a.k.a. IP masquerading) allows computers on a private, unregistered network to access the Internet. The @@ -161,7 +165,7 @@ is installed as user and group .Dv network , with permissions -.Dv 4550 . +.Dv 4554 . By default, .Nm will not run if the invoking user id is not zero. This may be overridden @@ -278,6 +282,15 @@ lines to the file Refer to the .Xr resolv.conf 5 manual page for details. +.Pp +Alternatively, if the peer supports it, +.Nm +can be configured to ask the peer for the nameserver address(es) and to +update +.Pa /etc/resolv.conf +automatically. Refer to the +.Dq enable dns +command below for details. .El .Sh MANUAL DIALING In the following examples, we assume that your machine name is @@ -477,11 +490,20 @@ portion of the prompt will change to # ppp MyISP ... ppp ON awfulhak> dial -dial OK! -login OK! +Ppp ON awfulhak> +PPp ON awfulhak> PPP ON awfulhak> .Ed .Pp +The Ppp prompt indicates that +.Nm +has entered the authentication phase. The PPp prompt indicates that +.Nm +has entered the network phase. The PPP prompt indicates that +.Nm +has successfully negotiated a network layer protocol and is in +a usable state. +.Pp If the .Pa /etc/ppp/ppp.linkup file is available, its contents are executed @@ -905,7 +927,9 @@ Instead of running over a serial link, it is possible to use a TCP connection instead by specifying a host and port as the device: +.Pp .Dl set device ui-gate:6669 +.Pp Instead of opening a serial device, .Nm will open a TCP connection to the given machine on the given @@ -918,13 +942,17 @@ connection on the receiving machine (ui-gate). This is done by first updating .Pa /etc/services to name the service: +.Pp .Dl ppp-in 6669/tcp # Incoming PPP connections over TCP +.Pp and updating .Pa /etc/inetd.conf to tell .Xr inetd 8 how to deal with incoming connections on that port: +.Pp .Dl ppp-in stream tcp nowait root /usr/sbin/ppp ppp -direct ppp-in +.Pp Don't forget to send a .Dv HUP signal to @@ -986,7 +1014,9 @@ Again, if you're enabling PAP, you'll also need: We're assigning the address of 10.0.4.1 to ui-gate, and the address 10.0.4.2 to awfulhak. To open the connection, just type +.Pp .Dl awfulhak # ppp -background ui-gate +.Pp The result will be an additional "route" on awfulhak to the 10.0.2.0/24 network via the TCP connection, and an additional "route" on ui-gate to the 10.0.1.0/24 network. @@ -1442,7 +1472,10 @@ logging) so that the actual password is not compromised .Ar chat logging is active rather than the actual password. .Pp -Login scripts vary greatly between ISPs. +Login scripts vary greatly between ISPs. If you're setting one up +for the first time, +.Em ENABLE CHAT LOGGING +so that you can see if your script is behaving as you expect. .It Use .Dq set line @@ -1531,6 +1564,20 @@ set authkey MyPassword Both are accepted by default, so .Nm will provide whatever your ISP requires. +.Pp +It should be noted that a login script is rarely (if ever) required +when PAP or CHAP are in use. +.It +Ask your ISP to authenticate your nameserver address(es) with the line +.Bd -literal -offset indent +enable dns +.Ed +Do +.Em NOT +do this if you are running an local DNS, as +.Nm +will simply circumvent its use by entering some nameserver lines in +.Pa /etc/resolv.conf . .El .Pp Please refer to @@ -1540,12 +1587,13 @@ and for some real examples. The pmdemand label should be appropriate for most ISPs. .Sh LOGGING FACILITY -.Nm +.Nm Ppp is able to generate the following log info either via .Xr syslog 3 or directly to the screen: .Bl -column SMMMMMM -offset indent .It Li Async Dump async level packet in hex +.It Li CBCP Generate CBCP (CallBack Control Protocol) logs .It Li CCP Generate a CCP packet trace .It Li Chat Generate Chat script trace log .It Li Command Log commands executed @@ -2571,6 +2619,83 @@ If is zero, this timer is disabled. Because both values default to zero, .Ar demand-dial links will stay active until the bundle idle timer expires. +.It set callback [none|auth|cbcp|E.164 *|number[,number]...]... +If no arguments are given, callback is disabled, otherwise, +.Nm +will request (or in +.Ar direct +mode, will accept) one of the given protocols. If a request is NAK'd +.Nm +will request another, until no options remain at which point +.Nm +will terminate negotiations. +The options are as follows (in this order of preference): +.Pp +.Bl -tag +.It auth +The callee is expected to decide the callback number based on +authentication. If +.Nm +is the callee, the number should be specified as the fifth field of +the peers entry in +.Pa /etc/ppp/ppp.secret . +.It cbcp +Microsofts callback control protocol is used. See +.Dq set cbcp +below. +.It E.164 *|number[,number]... +The caller specifies the +.Ar number . +If +.Nm +is the callee, +.Ar number +should be either a comma seperated list of allowable numbers or a +.Dq \&* , +meaning any number is permitted. If +.Nm +is the caller, only a single number should be specified. +.Pp +Note, this option is very unsafe when used with a +.Dq \&* +as a malicious caller can tell +.Nm +to call any (possibly international) number without first authenticating +themselves. +.It none +If the peer does not wish to do callback at all, +.Nm +will accept the fact and continue without callback rather than terminating +the connection. +.El +.Pp +.It set cbcp Op *|number[,number]... Op delay Op retry +If no arguments are given, CBCP (Microsofts CallBack Control Protocol) +is disabled - ie, configuring CBCP in the +.Dq set callback +command will result in +.Nm +requesting no callback in the CBCP phase. +Otherwise, +.Nm +attempts to use the given phone +.Ar number Ns No (s). +.Pp +In server mode +.Pq Fl direct , +.Nm +will insist that the client uses one of these numbers, unless +.Dq \&* +is used in which case the client is expected to specify the number. +.Pp +In client mode, +.Nm +will attempt to use one of the given numbers (whichever it finds to +be agreeable with the peer), or if +.Dq \&* +is specified, +.Nm +will expect the peer to specify the number. .It set ctsrts|crtscts on|off This sets hardware flow control. Hardware flow control is .Ar on diff --git a/usr.sbin/ppp/pred.c b/usr.sbin/ppp/pred.c index ccbf0737830a..dcf8b8b8b4a1 100644 --- a/usr.sbin/ppp/pred.c +++ b/usr.sbin/ppp/pred.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pred.c,v 1.20.2.12 1998/05/01 19:25:40 brian Exp $ + * $Id: pred.c,v 1.21 1998/05/21 21:47:53 brian Exp $ */ #include @@ -34,6 +34,7 @@ #include #include +#include "defs.h" #include "mbuf.h" #include "log.h" #include "timer.h" diff --git a/usr.sbin/ppp/prompt.c b/usr.sbin/ppp/prompt.c index af01a0dcd6f5..5c5e1e0af0e8 100644 --- a/usr.sbin/ppp/prompt.c +++ b/usr.sbin/ppp/prompt.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: prompt.c,v 1.8 1998/06/24 19:33:35 brian Exp $ + * $Id: prompt.c,v 1.9 1998/07/04 22:04:12 brian Exp $ */ #include @@ -66,6 +66,7 @@ #include "bundle.h" #include "chat.h" #include "chap.h" +#include "cbcp.h" #include "datalink.h" #include "server.h" #include "main.h" diff --git a/usr.sbin/ppp/vjcomp.c b/usr.sbin/ppp/vjcomp.c index 79dca0970a3e..ba1ef1be2c47 100644 --- a/usr.sbin/ppp/vjcomp.c +++ b/usr.sbin/ppp/vjcomp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: vjcomp.c,v 1.20 1998/06/16 19:40:42 brian Exp $ + * $Id: vjcomp.c,v 1.21 1998/06/27 23:48:54 brian Exp $ * * TODO: */ @@ -28,7 +28,6 @@ #include #include -#include #include "mbuf.h" #include "log.h"