--- src/pppoe.c.orig 2013-06-11 16:00:00.000000000 +0700 +++ src/pppoe.c 2013-06-25 19:06:51.000000000 +0700 @@ -24,6 +24,8 @@ #include #include +#include + /* * DEFINITIONS */ @@ -60,6 +62,7 @@ struct pppoeinfo { struct PppoeIf *PIf; /* pointer on parent ng_pppoe info */ struct PppoeList *list; struct pppTimer connectTimer; /* connection timeout timer */ + struct timespec pado_delay; }; typedef struct pppoeinfo *PppoeInfo; @@ -67,6 +70,7 @@ static u_char gNgEtherLoaded = FALSE; /* Set menu options */ enum { + SET_PADO_DELAY, SET_IFACE, SET_SESSION, SET_ACNAME @@ -158,6 +162,8 @@ const struct phystype gPppoePhysType = { }; const struct cmdtab PppoeSetCmds[] = { + { "pado-delay {sec} {nsec}", "Set PADO delay value", + PppoeSetCommand, NULL, 2, (void *)SET_PADO_DELAY }, { "iface {name}", "Set ethernet interface to use", PppoeSetCommand, NULL, 2, (void *)SET_IFACE }, { "service {name}", "Set PPPoE session name", @@ -205,6 +211,8 @@ PppoeInit(Link l) pe = (PppoeInfo)(l->info = Malloc(MB_PHYS, sizeof(*pe))); pe->incoming = 0; pe->opened = 0; + pe->pado_delay.tv_sec = 0; + pe->pado_delay.tv_nsec = 0; snprintf(pe->path, sizeof(pe->path), "undefined:"); snprintf(pe->hook, sizeof(pe->hook), "undefined"); snprintf(pe->session, sizeof(pe->session), "*"); @@ -371,7 +379,7 @@ PppoeConnectTimeout(void *arg) const Link l = (Link)arg; /* Cancel connection. */ - Log(LG_PHYS, ("[%s] PPPoE connection timeout after %d seconds", + Log(LG_PHYS2, ("[%s] PPPoE connection timeout after %d seconds", l->name, PPPOE_CONNECT_TIMEOUT)); PppoeDoClose(l); PhysDown(l, STR_CON_FAILED0, NULL); @@ -489,7 +497,7 @@ PppoeCtrlReadEvent(int type, void *arg) !gLinks[id] || gLinks[id]->type != &gPppoePhysType || PIf != ((PppoeInfo)gLinks[id]->info)->PIf) { - Log((u.resp.header.cmd == NGM_PPPOE_SUCCESS)?LG_ERR:LG_PHYS, + Log((u.resp.header.cmd == NGM_PPPOE_SUCCESS)?LG_ERR:LG_PHYS2, ("PPPoE: message %d from unexisting link \"%s\"", u.resp.header.cmd, linkname)); return; @@ -552,6 +560,8 @@ PppoeStat(Context ctx) char buf[32]; Printf("PPPoE configuration:\r\n"); + Printf("\tPADO delay : %ld %ld\r\n", (long)pe->pado_delay.tv_sec, + pe->pado_delay.tv_nsec); Printf("\tIface Node : %s\r\n", pe->path); Printf("\tIface Hook : %s\r\n", pe->hook); Printf("\tSession : %s\r\n", pe->session); @@ -1013,7 +1023,7 @@ PppoeListenEvent(int type, void *arg) l = LinkInst(l, NULL, 0, 0); if (l == NULL) { - Log(LG_PHYS, ("No free PPPoE link with requested parameters " + Log(LG_PHYS2, ("No free PPPoE link with requested parameters " "was found")); return; } @@ -1071,6 +1081,9 @@ PppoeListenEvent(int type, void *arg) } idata->data_len=strlen(idata->data); + if (pi->pado_delay.tv_sec || pi->pado_delay.tv_nsec) + nanosleep(&(pi->pado_delay), NULL); + if (NgSendMsg(pi->PIf->csock, path, NGM_PPPOE_COOKIE, NGM_PPPOE_OFFER, idata, sizeof(*idata) + idata->data_len) < 0) { Perror("[%s] PPPoE: can't send NGM_PPPOE_OFFER to %s,%s ", @@ -1377,6 +1390,12 @@ PppoeSetCommand(Context ctx, int ac, cha return(-1); strlcpy(pi->acname, av[0], sizeof(pi->acname)); break; + case SET_PADO_DELAY: + if (ac != 2) + return(-1); + pi->pado_delay.tv_sec = (time_t)atol(av[0]); + pi->pado_delay.tv_nsec = atol(av[1]); + break; default: assert(0); }