version 1.1.1.3, 2016/11/01 09:56:12
|
version 1.1.1.4, 2019/10/22 13:49:55
|
Line 71
|
Line 71
|
|
|
/* Per link private info */ |
/* Per link private info */ |
struct pppoeinfo { |
struct pppoeinfo { |
|
char iface[IFNAMSIZ]; /* PPPoE interface name */ |
char path[MAX_PATH]; /* PPPoE node path */ |
char path[MAX_PATH]; /* PPPoE node path */ |
char hook[NG_HOOKSIZ]; /* hook on that node */ |
char hook[NG_HOOKSIZ]; /* hook on that node */ |
char session[MAX_SESSION]; /* session name */ |
char session[MAX_SESSION]; /* session name */ |
Line 165 static int PppoeListen(Link l);
|
Line 166 static int PppoeListen(Link l);
|
static int PppoeUnListen(Link l); |
static int PppoeUnListen(Link l); |
static void PppoeNodeUpdate(Link l); |
static void PppoeNodeUpdate(Link l); |
static void PppoeListenEvent(int type, void *arg); |
static void PppoeListenEvent(int type, void *arg); |
static int CreatePppoeNode(struct PppoeIf *PIf, const char *path, const char *hook); | static int CreatePppoeNode(struct PppoeIf *PIf, const char *iface, const char *path, const char *hook); |
|
|
static void PppoeDoClose(Link l); |
static void PppoeDoClose(Link l); |
|
|
Line 282 PppoeInit(Link l)
|
Line 283 PppoeInit(Link l)
|
pe = (PppoeInfo)(l->info = Malloc(MB_PHYS, sizeof(*pe))); |
pe = (PppoeInfo)(l->info = Malloc(MB_PHYS, sizeof(*pe))); |
pe->incoming = 0; |
pe->incoming = 0; |
pe->opened = 0; |
pe->opened = 0; |
|
snprintf(pe->iface, sizeof(pe->iface), "undefined"); |
snprintf(pe->path, sizeof(pe->path), "undefined:"); |
snprintf(pe->path, sizeof(pe->path), "undefined:"); |
snprintf(pe->hook, sizeof(pe->hook), "undefined"); |
snprintf(pe->hook, sizeof(pe->hook), "undefined"); |
snprintf(pe->session, sizeof(pe->session), "*"); |
snprintf(pe->session, sizeof(pe->session), "*"); |
Line 660 PppoeCtrlReadEvent(int type, void *arg)
|
Line 662 PppoeCtrlReadEvent(int type, void *arg)
|
break; |
break; |
} |
} |
#endif |
#endif |
|
#ifdef NGM_PPPOE_PADM_COOKIE |
|
case NGM_PPPOE_HURL: |
|
Log(LG_PHYS, ("PPPoE: rec'd HURL \"%s\"", |
|
((struct ngpppoe_padm *)u.resp.data)->msg)); |
|
break; |
|
case NGM_PPPOE_MOTM: |
|
Log(LG_PHYS, ("PPPoE: rec'd MOTM \"%s\"", |
|
((struct ngpppoe_padm *)u.resp.data)->msg)); |
|
break; |
|
#endif |
default: |
default: |
Log(LG_PHYS, ("PPPoE: rec'd command %lu from \"%s\"", |
Log(LG_PHYS, ("PPPoE: rec'd command %lu from \"%s\"", |
(u_long)u.resp.header.cmd, path)); |
(u_long)u.resp.header.cmd, path)); |
Line 695 PppoeStat(Context ctx)
|
Line 707 PppoeStat(Context ctx)
|
} |
} |
|
|
Printf("PPPoE configuration:\r\n"); |
Printf("PPPoE configuration:\r\n"); |
|
Printf("\tIface Name : %s\r\n", pe->iface); |
Printf("\tIface Node : %s\r\n", pe->path); |
Printf("\tIface Node : %s\r\n", pe->path); |
Printf("\tIface Hook : %s\r\n", pe->hook); |
Printf("\tIface Hook : %s\r\n", pe->hook); |
Printf("\tSession : %s\r\n", pe->session); |
Printf("\tSession : %s\r\n", pe->session); |
Line 748 static int
|
Line 761 static int
|
PppoePeerIface(Link l, void *buf, size_t buf_len) |
PppoePeerIface(Link l, void *buf, size_t buf_len) |
{ |
{ |
PppoeInfo const pppoe = (PppoeInfo)l->info; |
PppoeInfo const pppoe = (PppoeInfo)l->info; |
char iface[IFNAMSIZ]; |
|
|
|
strlcpy(iface, pppoe->path, sizeof(iface)); | strlcpy(buf, pppoe->iface, buf_len); |
if (iface[strlen(iface) - 1] == ':') | |
iface[strlen(iface) - 1] = '\0'; | |
strlcpy(buf, iface, buf_len); | |
return (0); |
return (0); |
} |
} |
|
|
Line 880 PppoeGetMru(Link l, int conf)
|
Line 889 PppoeGetMru(Link l, int conf)
|
} |
} |
|
|
static int |
static int |
CreatePppoeNode(struct PppoeIf *PIf, const char *path, const char *hook) | CreatePppoeNode(struct PppoeIf *PIf, const char *iface, const char *path, const char *hook) |
{ |
{ |
union { |
union { |
u_char buf[sizeof(struct ng_mesg) + 2048]; |
u_char buf[sizeof(struct ng_mesg) + 2048]; |
Line 892 CreatePppoeNode(struct PppoeIf *PIf, const char *path,
|
Line 901 CreatePppoeNode(struct PppoeIf *PIf, const char *path,
|
uint32_t f; |
uint32_t f; |
|
|
/* Make sure interface is up. */ |
/* Make sure interface is up. */ |
char iface[IFNAMSIZ]; |
|
|
|
strlcpy(iface, path, sizeof(iface)); |
|
if (iface[strlen(iface) - 1] == ':') |
|
iface[strlen(iface) - 1] = '\0'; |
|
if (ExecCmdNosh(LG_PHYS2, iface, "%s %s up", _PATH_IFCONFIG, iface) != 0) { |
if (ExecCmdNosh(LG_PHYS2, iface, "%s %s up", _PATH_IFCONFIG, iface) != 0) { |
Log(LG_ERR, ("PPPoE: can't bring up interface %s", |
Log(LG_ERR, ("PPPoE: can't bring up interface %s", |
iface)); |
iface)); |
Line 1501 PppoeGetNode(Link l)
|
Line 1505 PppoeGetNode(Link l)
|
l->name)); |
l->name)); |
return; |
return; |
} |
} |
if (CreatePppoeNode(&PppoeIfs[free], pi->path, pi->hook)) { | if (CreatePppoeNode(&PppoeIfs[free], pi->iface, pi->path, pi->hook)) { |
strlcpy(PppoeIfs[free].ifnodepath, |
strlcpy(PppoeIfs[free].ifnodepath, |
pi->path, |
pi->path, |
sizeof(PppoeIfs[free].ifnodepath)); |
sizeof(PppoeIfs[free].ifnodepath)); |
Line 1673 PppoeSetCommand(Context ctx, int ac, char *av[], void
|
Line 1677 PppoeSetCommand(Context ctx, int ac, char *av[], void
|
{ |
{ |
const PppoeInfo pi = (PppoeInfo) ctx->lnk->info; |
const PppoeInfo pi = (PppoeInfo) ctx->lnk->info; |
const char *hookname = ETHER_DEFAULT_HOOK; |
const char *hookname = ETHER_DEFAULT_HOOK; |
const char *colon; | int i; |
#ifdef NGM_PPPOE_SETMAXP_COOKIE |
#ifdef NGM_PPPOE_SETMAXP_COOKIE |
int ap; |
int ap; |
#endif |
#endif |
Line 1684 PppoeSetCommand(Context ctx, int ac, char *av[], void
|
Line 1688 PppoeSetCommand(Context ctx, int ac, char *av[], void
|
hookname = av[1]; |
hookname = av[1]; |
/* fall through */ |
/* fall through */ |
case 1: |
case 1: |
colon = (av[0][strlen(av[0]) - 1] == ':') ? "" : ":"; | strlcpy(pi->iface, av[0], sizeof(pi->iface)); |
snprintf(pi->path, sizeof(pi->path), | strlcpy(pi->path, pi->iface, sizeof(pi->path) - 1); |
"%s%s", av[0], colon); | for (i = 0; i < sizeof(pi->path) - 1; i++) { |
| if (pi->path[i] == '.' || pi->path[i] == ':') |
| pi->path[i] = '_'; |
| else if (pi->path[i] == '\0') { |
| pi->path[i] = ':'; |
| pi->path[i + 1] = '\0'; |
| break; |
| } |
| } |
strlcpy(pi->hook, hookname, sizeof(pi->hook)); |
strlcpy(pi->hook, hookname, sizeof(pi->hook)); |
break; |
break; |
default: |
default: |