From 0a36b82adc4660322dc9d1423fa8966917e60ed2 Mon Sep 17 00:00:00 2001 From: glebius Date: Thu, 29 Jul 2004 05:59:43 +0000 Subject: Add configuration option "set pppoe [standard|3Com]" which allows to configure mode for ng_pppoe(4) node under control. Reviewed by: brian Approved by: julian (mentor) --- usr.sbin/ppp/command.c | 16 ++++++++++++++++ usr.sbin/ppp/ether.c | 16 ++++++++++++++-- usr.sbin/ppp/physical.c | 8 ++++++++ usr.sbin/ppp/physical.h | 3 +++ usr.sbin/ppp/ppp.8.m4 | 7 ++++++- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index f233ee2..034a306 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -143,6 +143,7 @@ #define VAR_MPPE 36 #define VAR_IPV6CPRETRY 37 #define VAR_RAD_ALIVE 38 +#define VAR_PPPOE 39 /* ``accept|deny|disable|enable'' masks */ #define NEG_HISMASK (1) @@ -2294,6 +2295,18 @@ SetVariable(struct cmdargs const *arg) } } break; + + case VAR_PPPOE: + if (strcasecmp(argp, "3Com") == 0) + physical_SetPPPoEnonstandard(arg->cx->physical, 1); + else if (strcasecmp(argp, "standard") == 0) + physical_SetPPPoEnonstandard(arg->cx->physical, 0); + else { + log_Printf(LogWARN, "PPPoE standard value must be \"standard\" or \"3Com\"\n"); + res = 1; + } + break; + } return res; @@ -2422,6 +2435,9 @@ static struct cmdtab const SetCommands[] = { "vj values", "set vj slots|slotcomp [value]"}, {"help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH, "Display this message", "set help|? [command]", SetCommands}, + {"pppoe", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, + "Connect using standard/3Com mode", "set pppoe [standard|3Com]", + (const char *)VAR_PPPOE}, {NULL, NULL, NULL}, }; diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c index 77ad7e5..ce0bfd2 100644 --- a/usr.sbin/ppp/ether.c +++ b/usr.sbin/ppp/ether.c @@ -443,7 +443,7 @@ ether_Create(struct physical *p) struct ng_mesg *resp; const struct hooklist *hlist; const struct nodeinfo *ninfo; - char *path, *sessionid; + char *path, *sessionid, *mode; int ifacelen, f; dev = NULL; @@ -621,6 +621,19 @@ ether_Create(struct physical *p) log_Printf(LogWARN, "%s: Failed to set the IFF_UP flag on %s\n", p->link.name, path); + snprintf(connectpath, sizeof connectpath, ".:%s", dev->hook); + + /* Configure node to 3Com mode if needed */ + if (p->cfg.pppoe_configured) { + mode = p->cfg.nonstandard_pppoe ? NG_PPPOE_NONSTANDARD : NG_PPPOE_STANDARD; + if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE, + NGM_PPPOE_SETMODE, mode, strlen(mode) + 1) == -1) { + log_Printf(LogWARN, "``%s'': Cannot configure netgraph node: %s\n", + connectpath, strerror(errno)); + return ether_Abandon(dev, p); + } + } + /* And finally, request a connection to the given provider */ data = (struct ngpppoe_init_data *)alloca(sizeof *data + providerlen); @@ -628,7 +641,6 @@ ether_Create(struct physical *p) memcpy(data->data, provider, providerlen); data->data_len = providerlen; - snprintf(connectpath, sizeof connectpath, ".:%s", dev->hook); log_Printf(LogDEBUG, "Sending PPPOE_CONNECT to %s\n", connectpath); if (NgSendMsg(dev->cs, connectpath, NGM_PPPOE_COOKIE, NGM_PPPOE_CONNECT, data, sizeof *data + providerlen) == -1) { diff --git a/usr.sbin/ppp/physical.c b/usr.sbin/ppp/physical.c index ec93fcc..1483b66 100644 --- a/usr.sbin/ppp/physical.c +++ b/usr.sbin/ppp/physical.c @@ -1129,3 +1129,11 @@ physical_Slot(struct physical *p) return -1; } + +int +physical_SetPPPoEnonstandard(struct physical *p, int enable) +{ + p->cfg.nonstandard_pppoe = enable ? 1 : 0; + p->cfg.pppoe_configured = 1; + return 1; +} diff --git a/usr.sbin/ppp/physical.h b/usr.sbin/ppp/physical.h index f1e3ec5..222c5e6 100644 --- a/usr.sbin/ppp/physical.h +++ b/usr.sbin/ppp/physical.h @@ -104,6 +104,8 @@ struct physical { struct { unsigned rts_cts : 1; /* Is rts/cts enabled ? */ + unsigned nonstandard_pppoe : 1; /* Is PPPoE mode nonstandard */ + unsigned pppoe_configured : 1; /* temporary hack */ unsigned parity; /* What parity is enabled? (tty flags) */ unsigned speed; /* tty speed */ @@ -171,3 +173,4 @@ extern int physical_AwaitCarrier(struct physical *); extern void physical_SetDescriptor(struct physical *); extern void physical_SetAsyncParams(struct physical *, u_int32_t, u_int32_t); extern int physical_Slot(struct physical *); +extern int physical_SetPPPoEnonstandatd(struct physical *, int); diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index 1f8dce4..e0d2743 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -27,7 +27,7 @@ changecom(,)dnl .\" .\" $FreeBSD$ .\" -.Dd September 20, 1995 +.Dd July 20, 2004 .Dt PPP 8 .Os .Sh NAME @@ -5256,6 +5256,11 @@ below. In .Fl background mode, each number is attempted at most once. +.It set pppoe Op standard|3Com +This option configures the underlying +.Xr ng_pppoe 4 +node to either standard RFC2516 PPPoE or proprietary 3Com mode. +If not set the system default will be used. .It set Op proc Ns Xo .No title Op Ar value .Xc -- cgit v1.1