version 1.1.1.1, 2013/07/22 08:44:29
|
version 1.1.1.4.2.1, 2023/09/27 11:08:00
|
Line 52
|
Line 52
|
SET_NO |
SET_NO |
}; |
}; |
|
|
|
/* Used to prevent auto-up on links closed manually */ |
|
enum { |
|
LINK_ADMINSTATE_DOWN = 0, |
|
LINK_ADMINSTATE_OPERATIONAL |
|
}; |
|
|
|
static const char *linkAdminStateNames[] = { |
|
"DOWN", |
|
"OPERATIONAL" |
|
}; |
|
|
#define RBUF_SIZE 100 |
#define RBUF_SIZE 100 |
|
|
/* |
/* |
* INTERNAL FUNCTIONS |
* INTERNAL FUNCTIONS |
*/ |
*/ |
|
|
static int LinkSetCommand(Context ctx, int ac, char *av[], void *arg); | static int LinkSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
static void LinkMsg(int type, void *cookie); |
static void LinkMsg(int type, void *cookie); |
static void LinkNgDataEvent(int type, void *cookie); |
static void LinkNgDataEvent(int type, void *cookie); |
static void LinkReopenTimeout(void *arg); |
static void LinkReopenTimeout(void *arg); |
Line 67
|
Line 78
|
* GLOBAL VARIABLES |
* GLOBAL VARIABLES |
*/ |
*/ |
|
|
const struct cmdtab LinkSetActionCmds[] = { | static const struct cmdtab LinkSetActionCmds[] = { |
{ "bundle {bundle} [{regex}]", "Terminate incomings locally", |
{ "bundle {bundle} [{regex}]", "Terminate incomings locally", |
LinkSetCommand, NULL, 2, (void *) SET_BUNDLE }, |
LinkSetCommand, NULL, 2, (void *) SET_BUNDLE }, |
{ "forward {link} [{regex}]", "Forward incomings", |
{ "forward {link} [{regex}]", "Forward incomings", |
Line 76
|
Line 87
|
LinkSetCommand, NULL, 2, (void *) SET_DROP }, |
LinkSetCommand, NULL, 2, (void *) SET_DROP }, |
{ "clear", "Clear actions", |
{ "clear", "Clear actions", |
LinkSetCommand, NULL, 2, (void *) SET_CLEAR }, |
LinkSetCommand, NULL, 2, (void *) SET_CLEAR }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
const struct cmdtab LinkSetCmds[] = { |
const struct cmdtab LinkSetCmds[] = { |
{ "action ...", "Set action on incoming", |
{ "action ...", "Set action on incoming", |
CMD_SUBMENU, NULL, 2, (void *) LinkSetActionCmds }, | CMD_SUBMENU, NULL, 2, LinkSetActionCmds }, |
{ "bandwidth {bps}", "Link bandwidth", |
{ "bandwidth {bps}", "Link bandwidth", |
LinkSetCommand, NULL, 2, (void *) SET_BANDWIDTH }, |
LinkSetCommand, NULL, 2, (void *) SET_BANDWIDTH }, |
{ "latency {microsecs}", "Link latency", |
{ "latency {microsecs}", "Link latency", |
Line 118
|
Line 129
|
LinkSetCommand, NULL, 2, (void *) SET_YES }, |
LinkSetCommand, NULL, 2, (void *) SET_YES }, |
{ "no {opt ...}", "Disable and deny option", |
{ "no {opt ...}", "Disable and deny option", |
LinkSetCommand, NULL, 2, (void *) SET_NO }, |
LinkSetCommand, NULL, 2, (void *) SET_NO }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
/* |
/* |
* INTERNAL VARIABLES |
* INTERNAL VARIABLES |
*/ |
*/ |
|
|
static struct confinfo gConfList[] = { | static const struct confinfo gConfList[] = { |
{ 0, LINK_CONF_INCOMING, "incoming" }, |
{ 0, LINK_CONF_INCOMING, "incoming" }, |
{ 1, LINK_CONF_PAP, "pap" }, |
{ 1, LINK_CONF_PAP, "pap" }, |
{ 1, LINK_CONF_CHAPMD5, "chap-md5" }, |
{ 1, LINK_CONF_CHAPMD5, "chap-md5" }, |
Line 145
|
Line 156
|
{ 0, LINK_CONF_TIMEREMAIN, "time-remain" }, |
{ 0, LINK_CONF_TIMEREMAIN, "time-remain" }, |
{ 0, LINK_CONF_PEER_AS_CALLING, "peer-as-calling" }, |
{ 0, LINK_CONF_PEER_AS_CALLING, "peer-as-calling" }, |
{ 0, LINK_CONF_REPORT_MAC, "report-mac" }, |
{ 0, LINK_CONF_REPORT_MAC, "report-mac" }, |
|
{ 0, LINK_CONF_REMOVE_TEE, "remove-tee" }, |
{ 0, 0, NULL }, |
{ 0, 0, NULL }, |
}; |
}; |
|
|
int gLinksCsock = -1; /* Socket node control socket */ |
int gLinksCsock = -1; /* Socket node control socket */ |
int gLinksDsock = -1; /* Socket node data socket */ |
int gLinksDsock = -1; /* Socket node data socket */ |
EventRef gLinksDataEvent; | static EventRef gLinksDataEvent; |
|
|
int |
int |
LinksInit(void) |
LinksInit(void) |
Line 184 LinksShutdown(void)
|
Line 196 LinksShutdown(void)
|
} |
} |
|
|
/* |
/* |
|
* LinkOpenAdm() |
|
*/ |
|
|
|
void |
|
LinkOpenAdm(Link l) |
|
{ |
|
l->admin_state = LINK_ADMINSTATE_OPERATIONAL; |
|
RecordLinkUpDownReason(NULL, l, 1, STR_MANUALLY, NULL); |
|
LinkOpen(l); |
|
} |
|
|
|
/* |
* LinkOpenCmd() |
* LinkOpenCmd() |
*/ |
*/ |
|
|
Line 192 LinkOpenCmd(Context ctx)
|
Line 216 LinkOpenCmd(Context ctx)
|
{ |
{ |
if (ctx->lnk->tmpl) |
if (ctx->lnk->tmpl) |
Error("impossible to open template"); |
Error("impossible to open template"); |
RecordLinkUpDownReason(NULL, ctx->lnk, 1, STR_MANUALLY, NULL); | LinkOpenAdm(ctx->lnk); |
LinkOpen(ctx->lnk); | |
return (0); |
return (0); |
} |
} |
|
|
/* |
/* |
|
* LinkCloseAdm() |
|
*/ |
|
|
|
void |
|
LinkCloseAdm(Link l) |
|
{ |
|
l->admin_state = LINK_ADMINSTATE_DOWN; |
|
RecordLinkUpDownReason(NULL, l, 0, STR_MANUALLY, NULL); |
|
LinkClose(l); |
|
} |
|
|
|
/* |
* LinkCloseCmd() |
* LinkCloseCmd() |
*/ |
*/ |
|
|
Line 206 LinkCloseCmd(Context ctx)
|
Line 241 LinkCloseCmd(Context ctx)
|
{ |
{ |
if (ctx->lnk->tmpl) |
if (ctx->lnk->tmpl) |
Error("impossible to close template"); |
Error("impossible to close template"); |
|
ctx->lnk->admin_state = LINK_ADMINSTATE_DOWN; |
RecordLinkUpDownReason(NULL, ctx->lnk, 0, STR_MANUALLY, NULL); |
RecordLinkUpDownReason(NULL, ctx->lnk, 0, STR_MANUALLY, NULL); |
LinkClose(ctx->lnk); |
LinkClose(ctx->lnk); |
return (0); |
return (0); |
Line 257 LinkDown(Link l)
|
Line 293 LinkDown(Link l)
|
{ |
{ |
Log(LG_LINK, ("[%s] Link: DOWN event", l->name)); |
Log(LG_LINK, ("[%s] Link: DOWN event", l->name)); |
|
|
if (OPEN_STATE(l->lcp.fsm.state)) { | if (OPEN_STATE(l->lcp.fsm.state) || l->admin_state != LINK_ADMINSTATE_DOWN) { |
if (((l->conf.max_redial != 0) && (l->num_redial >= l->conf.max_redial)) || |
if (((l->conf.max_redial != 0) && (l->num_redial >= l->conf.max_redial)) || |
gShutdownInProgress) { |
gShutdownInProgress) { |
if (l->conf.max_redial >= 0) { |
if (l->conf.max_redial >= 0) { |
Log(LG_LINK, ("[%s] Link: giving up after %d reconnection attempts", | Log(LG_LINK, ("[%s] Link: giving up after %hu reconnection attempts", |
l->name, l->num_redial)); |
l->name, l->num_redial)); |
} |
} |
if (!l->stay) |
if (!l->stay) |
Line 279 LinkDown(Link l)
|
Line 315 LinkDown(Link l)
|
LcpDown(l); |
LcpDown(l); |
|
|
l->num_redial++; |
l->num_redial++; |
Log(LG_LINK, ("[%s] Link: reconnection attempt %d in %d seconds", | Log(LG_LINK, ("[%s] Link: reconnection attempt %hu in %d seconds", |
l->name, l->num_redial, delay)); |
l->name, l->num_redial, delay)); |
} |
} |
} else { |
} else { |
Line 303 LinkReopenTimeout(void *arg)
|
Line 339 LinkReopenTimeout(void *arg)
|
return; |
return; |
} |
} |
|
|
Log(LG_LINK, ("[%s] Link: reconnection attempt %d", | Log(LG_LINK, ("[%s] Link: reconnection attempt %hu", |
l->name, l->num_redial)); |
l->name, l->num_redial)); |
RecordLinkUpDownReason(NULL, l, 1, STR_REDIAL, NULL); |
RecordLinkUpDownReason(NULL, l, 1, STR_REDIAL, NULL); |
|
if (!OPEN_STATE(l->lcp.fsm.state)) |
|
LinkOpen(l); |
PhysOpen(l); |
PhysOpen(l); |
} |
} |
|
|
Line 348 LinkMsg(int type, void *arg)
|
Line 386 LinkMsg(int type, void *arg)
|
*/ |
*/ |
|
|
int |
int |
LinkCreate(Context ctx, int ac, char *av[], void *arg) | LinkCreate(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Link l, lt = NULL; |
Link l, lt = NULL; |
PhysType pt = NULL; | const struct phystype *pt = NULL; |
u_char tmpl = 0; |
u_char tmpl = 0; |
u_char stay = 0; |
u_char stay = 0; |
int k; |
int k; |
|
|
|
(void)arg; |
RESETREF(ctx->lnk, NULL); |
RESETREF(ctx->lnk, NULL); |
RESETREF(ctx->bund, NULL); |
RESETREF(ctx->bund, NULL); |
RESETREF(ctx->rep, NULL); |
RESETREF(ctx->rep, NULL); |
Line 409 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
Line 448 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
strlcpy(l->name, av[0 + stay], sizeof(l->name)); |
strlcpy(l->name, av[0 + stay], sizeof(l->name)); |
l->type = pt; |
l->type = pt; |
l->tmpl = tmpl; |
l->tmpl = tmpl; |
|
l->admin_state = LINK_ADMINSTATE_OPERATIONAL; |
l->stay = stay; |
l->stay = stay; |
l->parent = -1; |
l->parent = -1; |
SLIST_INIT(&l->actions); |
SLIST_INIT(&l->actions); |
|
|
/* Initialize link configuration with defaults */ |
/* Initialize link configuration with defaults */ |
l->conf.mru = LCP_DEFAULT_MRU; |
l->conf.mru = LCP_DEFAULT_MRU; |
l->conf.mtu = LCP_DEFAULT_MRU; | /* Do not assume any MTU value for this moment */ |
| l->conf.mtu = 0; |
l->conf.mrru = MP_DEFAULT_MRRU; |
l->conf.mrru = MP_DEFAULT_MRRU; |
l->conf.accmap = 0x000a0000; |
l->conf.accmap = 0x000a0000; |
l->conf.max_redial = -1; |
l->conf.max_redial = -1; |
Line 428 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
Line 469 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
l->upReasonValid = 0; |
l->upReasonValid = 0; |
l->downReason = NULL; |
l->downReason = NULL; |
l->downReasonValid = 0; |
l->downReasonValid = 0; |
|
l->tee_removed = 0; |
|
|
Disable(&l->conf.options, LINK_CONF_CHAPMD5); |
Disable(&l->conf.options, LINK_CONF_CHAPMD5); |
Accept(&l->conf.options, LINK_CONF_CHAPMD5); |
Accept(&l->conf.options, LINK_CONF_CHAPMD5); |
Line 485 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
Line 527 LinkCreate(Context ctx, int ac, char *av[], void *arg)
|
*/ |
*/ |
|
|
int |
int |
LinkDestroy(Context ctx, int ac, char *av[], void *arg) | LinkDestroy(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Link l; |
Link l; |
|
|
|
(void)arg; |
if (ac > 1) |
if (ac > 1) |
return(-1); |
return(-1); |
|
|
Line 526 LinkDestroy(Context ctx, int ac, char *av[], void *arg
|
Line 569 LinkDestroy(Context ctx, int ac, char *av[], void *arg
|
*/ |
*/ |
|
|
Link |
Link |
LinkInst(Link lt, char *name, int tmpl, int stay) | LinkInst(Link lt, const char *name, int tmpl, int stay) |
{ |
{ |
Link l; |
Link l; |
int k; |
int k; |
Line 547 LinkInst(Link lt, char *name, int tmpl, int stay)
|
Line 590 LinkInst(Link lt, char *name, int tmpl, int stay)
|
SLIST_INSERT_AFTER(ap, a, next); |
SLIST_INSERT_AFTER(ap, a, next); |
ap = a; |
ap = a; |
} |
} |
|
l->admin_state = LINK_ADMINSTATE_OPERATIONAL; |
l->tmpl = tmpl; |
l->tmpl = tmpl; |
l->stay = stay; |
l->stay = stay; |
/* Count link as one more child of parent. */ |
/* Count link as one more child of parent. */ |
Line 717 LinkNgJoin(Link l)
|
Line 761 LinkNgJoin(Link l)
|
} |
} |
|
|
NgFuncDisconnect(gLinksCsock, l->name, path, NG_TEE_HOOK_LEFT2RIGHT); |
NgFuncDisconnect(gLinksCsock, l->name, path, NG_TEE_HOOK_LEFT2RIGHT); |
|
|
|
if (Enabled(&l->conf.options, LINK_CONF_REMOVE_TEE)) { |
|
if (l->stay == 0) { |
|
Log(LG_LINK, ("[%s] Link: Removing ng_tee node", l->name)); |
|
NgFuncShutdownNode(gLinksCsock, NG_TEE_NODE_TYPE, path); |
|
l->tee_removed = 1; |
|
} else |
|
Log(LG_LINK, ("[%s] Link: Can't remove ng_tee node on static link", |
|
l->name)); |
|
} |
return (0); |
return (0); |
} |
} |
|
|
Line 730 LinkNgLeave(Link l)
|
Line 784 LinkNgLeave(Link l)
|
char path[NG_PATHSIZ]; |
char path[NG_PATHSIZ]; |
struct ngm_connect cn; |
struct ngm_connect cn; |
|
|
|
/* ng_tee is already removed */ |
|
if (l->tee_removed == 1) |
|
return(0); |
|
|
memset(&cn, 0, sizeof(cn)); |
memset(&cn, 0, sizeof(cn)); |
snprintf(cn.path, sizeof(cn.path), "[%lx]:", (u_long)l->nodeID); |
snprintf(cn.path, sizeof(cn.path), "[%lx]:", (u_long)l->nodeID); |
strcpy(cn.ourhook, l->hook); |
strcpy(cn.ourhook, l->hook); |
Line 799 LinkNgDataEvent(int type, void *cookie)
|
Line 857 LinkNgDataEvent(int type, void *cookie)
|
Bund b; |
Bund b; |
u_char *buf; |
u_char *buf; |
u_int16_t proto; |
u_int16_t proto; |
int ptr; | unsigned ptr; |
Mbuf bp; |
Mbuf bp; |
struct sockaddr_ng naddr; |
struct sockaddr_ng naddr; |
socklen_t nsize; |
socklen_t nsize; |
char *name, *rest; |
char *name, *rest; |
int id, num = 0; |
int id, num = 0; |
|
|
|
(void)cookie; |
|
(void)type; |
|
|
/* Read all available packets */ |
/* Read all available packets */ |
while (1) { |
while (1) { |
if (num > 20) |
if (num > 20) |
Line 818 LinkNgDataEvent(int type, void *cookie)
|
Line 879 LinkNgDataEvent(int type, void *cookie)
|
mbfree(bp); |
mbfree(bp); |
if (errno == EAGAIN) |
if (errno == EAGAIN) |
return; |
return; |
Log(LG_LINK, ("Link socket read error: %s", strerror(errno))); | Perror("Link: Link socket read error"); |
return; |
return; |
} |
} |
num++; |
num++; |
Line 829 LinkNgDataEvent(int type, void *cookie)
|
Line 890 LinkNgDataEvent(int type, void *cookie)
|
name++; |
name++; |
id = strtol(name, &rest, 10); |
id = strtol(name, &rest, 10); |
if (rest[0] != 0 || !gLinks[id]) { |
if (rest[0] != 0 || !gLinks[id]) { |
Log(LG_ERR, ("Link: packet from unexisting link \"%s\"", | Log(LG_ERR, ("Link: Packet from unexisting link \"%s\"", |
name)); |
name)); |
mbfree(bp); |
mbfree(bp); |
continue; |
continue; |
Line 851 LinkNgDataEvent(int type, void *cookie)
|
Line 912 LinkNgDataEvent(int type, void *cookie)
|
|
|
if (MBLEN(bp) <= ptr) { |
if (MBLEN(bp) <= ptr) { |
LogDumpBp(LG_FRAME|LG_ERR, bp, |
LogDumpBp(LG_FRAME|LG_ERR, bp, |
"[%s] rec'd truncated %d bytes frame from link", | "[%s] rec'd truncated %zu bytes frame from link", |
l->name, MBLEN(bp)); |
l->name, MBLEN(bp)); |
mbfree(bp); |
mbfree(bp); |
continue; |
continue; |
Line 859 LinkNgDataEvent(int type, void *cookie)
|
Line 920 LinkNgDataEvent(int type, void *cookie)
|
|
|
/* Debugging */ |
/* Debugging */ |
LogDumpBp(LG_FRAME, bp, |
LogDumpBp(LG_FRAME, bp, |
"[%s] rec'd %d bytes frame from link proto=0x%04x", | "[%s] rec'd %zu bytes frame from link proto=0x%04x", |
l->name, MBLEN(bp), proto); |
l->name, MBLEN(bp), proto); |
|
|
bp = mbadj(bp, ptr); |
bp = mbadj(bp, ptr); |
Line 889 LinkNgDataEvent(int type, void *cookie)
|
Line 950 LinkNgDataEvent(int type, void *cookie)
|
|
|
/* A PPP frame from the bypass hook? */ |
/* A PPP frame from the bypass hook? */ |
if (naddr.sg_data[0] == 'b') { |
if (naddr.sg_data[0] == 'b') { |
Link l; | Link ll; |
u_int16_t linkNum, proto; | u_int16_t linkNum, lproto; |
|
|
if (MBLEN(bp) <= 4) { |
if (MBLEN(bp) <= 4) { |
LogDumpBp(LG_FRAME|LG_ERR, bp, |
LogDumpBp(LG_FRAME|LG_ERR, bp, |
"[%s] rec'd truncated %d bytes frame", | "[%s] rec'd truncated %zu bytes frame", |
b->name, MBLEN(bp)); |
b->name, MBLEN(bp)); |
continue; |
continue; |
} |
} |
Line 902 LinkNgDataEvent(int type, void *cookie)
|
Line 963 LinkNgDataEvent(int type, void *cookie)
|
/* Extract link number and protocol */ |
/* Extract link number and protocol */ |
bp = mbread(bp, &linkNum, 2); |
bp = mbread(bp, &linkNum, 2); |
linkNum = ntohs(linkNum); |
linkNum = ntohs(linkNum); |
bp = mbread(bp, &proto, 2); | bp = mbread(bp, &lproto, 2); |
proto = ntohs(proto); | lproto = ntohs(lproto); |
|
|
/* Debugging */ |
/* Debugging */ |
LogDumpBp(LG_FRAME, bp, |
LogDumpBp(LG_FRAME, bp, |
"[%s] rec'd %d bytes bypass frame link=%d proto=0x%04x", | "[%s] rec'd %zu bytes bypass frame link=%d proto=0x%04x", |
b->name, MBLEN(bp), (int16_t)linkNum, proto); | b->name, MBLEN(bp), (int16_t)linkNum, lproto); |
|
|
/* Set link */ |
/* Set link */ |
assert(linkNum == NG_PPP_BUNDLE_LINKNUM || linkNum < NG_PPP_MAX_LINKS); |
assert(linkNum == NG_PPP_BUNDLE_LINKNUM || linkNum < NG_PPP_MAX_LINKS); |
|
|
if (linkNum != NG_PPP_BUNDLE_LINKNUM) |
if (linkNum != NG_PPP_BUNDLE_LINKNUM) |
l = b->links[linkNum]; | ll = b->links[linkNum]; |
else |
else |
l = NULL; | ll = NULL; |
|
|
InputFrame(b, l, proto, bp); | InputFrame(b, ll, lproto, bp); |
continue; |
continue; |
} |
} |
|
|
/* Debugging */ |
/* Debugging */ |
LogDumpBp(LG_FRAME, bp, |
LogDumpBp(LG_FRAME, bp, |
"[%s] rec'd %d bytes frame on %s hook", b->name, MBLEN(bp), naddr.sg_data); | "[%s] rec'd %zu bytes frame on %s hook", b->name, MBLEN(bp), naddr.sg_data); |
|
|
#ifndef USE_NG_TCPMSS |
#ifndef USE_NG_TCPMSS |
/* A snooped, outgoing TCP SYN frame */ |
/* A snooped, outgoing TCP SYN frame */ |
Line 996 LinkFind(const char *name)
|
Line 1057 LinkFind(const char *name)
|
*/ |
*/ |
|
|
int |
int |
LinkCommand(Context ctx, int ac, char *av[], void *arg) | LinkCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Link l; |
Link l; |
int k; |
int k; |
|
|
|
(void)arg; |
if (ac > 1) |
if (ac > 1) |
return (-1); |
return (-1); |
|
|
Line 1042 LinkCommand(Context ctx, int ac, char *av[], void *arg
|
Line 1104 LinkCommand(Context ctx, int ac, char *av[], void *arg
|
*/ |
*/ |
|
|
int |
int |
SessionCommand(Context ctx, int ac, char *av[], void *arg) | SessionCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
int k; |
int k; |
|
|
|
(void)arg; |
if (ac > 1) |
if (ac > 1) |
return (-1); |
return (-1); |
|
|
Line 1084 SessionCommand(Context ctx, int ac, char *av[], void *
|
Line 1147 SessionCommand(Context ctx, int ac, char *av[], void *
|
*/ |
*/ |
|
|
int |
int |
AuthnameCommand(Context ctx, int ac, char *av[], void *arg) | AuthnameCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
int k; |
int k; |
|
|
if (ac > 1) | (void)arg; |
| if (ac > 2) |
return (-1); |
return (-1); |
|
|
if (ac == 0) { |
if (ac == 0) { |
Line 1100 AuthnameCommand(Context ctx, int ac, char *av[], void
|
Line 1164 AuthnameCommand(Context ctx, int ac, char *av[], void
|
return (0); |
return (0); |
} |
} |
|
|
/* Find link */ | if (ac == 2 && strcasecmp(av[1], "ci") == 0) { |
for (k = 0; | /* Find link */ |
k < gNumLinks && (gLinks[k] == NULL || | for (k = 0; |
strcmp(gLinks[k]->lcp.auth.params.authname, av[0])); | k < gNumLinks && (gLinks[k] == NULL || |
k++); | strcasecmp(gLinks[k]->lcp.auth.params.authname, av[0])); |
| k++); |
| } else { |
| /* Find link */ |
| for (k = 0; |
| k < gNumLinks && (gLinks[k] == NULL || |
| strcmp(gLinks[k]->lcp.auth.params.authname, av[0])); |
| k++); |
| } |
if (k == gNumLinks) { |
if (k == gNumLinks) { |
/* Change default link and bundle */ |
/* Change default link and bundle */ |
RESETREF(ctx->lnk, NULL); |
RESETREF(ctx->lnk, NULL); |
Line 1238 LinkMatchAction(Link l, int stage, char *login)
|
Line 1310 LinkMatchAction(Link l, int stage, char *login)
|
*/ |
*/ |
|
|
int |
int |
LinkStat(Context ctx, int ac, char *av[], void *arg) | LinkStat(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Link l = ctx->lnk; |
Link l = ctx->lnk; |
struct linkaction *a; |
struct linkaction *a; |
|
|
|
(void)ac; |
|
(void)av; |
|
(void)arg; |
|
|
Printf("Link %s%s:\r\n", l->name, l->tmpl?" (template)":(l->stay?" (static)":"")); |
Printf("Link %s%s:\r\n", l->name, l->tmpl?" (template)":(l->stay?" (static)":"")); |
|
|
Printf("Configuration:\r\n"); |
Printf("Configuration:\r\n"); |
Line 1285 LinkStat(Context ctx, int ac, char *av[], void *arg)
|
Line 1361 LinkStat(Context ctx, int ac, char *av[], void *arg)
|
Printf("\tChildren : %d\r\n", l->children); |
Printf("\tChildren : %d\r\n", l->children); |
else { |
else { |
Printf("\tState : %s\r\n", gPhysStateNames[l->state]); |
Printf("\tState : %s\r\n", gPhysStateNames[l->state]); |
|
Printf("\tAdmin. state : %s\r\n", linkAdminStateNames[l->admin_state]); |
Printf("\tSession Id : %s\r\n", l->session_id); |
Printf("\tSession Id : %s\r\n", l->session_id); |
Printf("\tPeer ident : %s\r\n", l->lcp.peer_ident); |
Printf("\tPeer ident : %s\r\n", l->lcp.peer_ident); |
if (l->state == PHYS_STATE_UP) |
if (l->state == PHYS_STATE_UP) |
Line 1335 LinkUpdateStats(Link l)
|
Line 1412 LinkUpdateStats(Link l)
|
l->stats.runts += abs(stats.runts - l->oldStats.runts); |
l->stats.runts += abs(stats.runts - l->oldStats.runts); |
l->stats.dupFragments += abs(stats.dupFragments - l->oldStats.dupFragments); |
l->stats.dupFragments += abs(stats.dupFragments - l->oldStats.dupFragments); |
l->stats.dropFragments += abs(stats.dropFragments - l->oldStats.dropFragments); |
l->stats.dropFragments += abs(stats.dropFragments - l->oldStats.dropFragments); |
|
l->oldStats = stats; |
} |
} |
|
|
l->oldStats = stats; |
|
#else |
#else |
NgFuncGetStats64(l->bund, l->bundleIndex, &l->stats); |
NgFuncGetStats64(l->bund, l->bundleIndex, &l->stats); |
#endif |
#endif |
Line 1363 LinkResetStats(Link l)
|
Line 1440 LinkResetStats(Link l)
|
*/ |
*/ |
|
|
static int |
static int |
LinkSetCommand(Context ctx, int ac, char *av[], void *arg) | LinkSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Link l = ctx->lnk; |
Link l = ctx->lnk; |
int val, nac = 0; |
int val, nac = 0; |
const char *name; |
const char *name; |
char *nav[ac]; | const char *nav[ac]; |
const char *av2[] = { "chap-md5", "chap-msv1", "chap-msv2" }; |
const char *av2[] = { "chap-md5", "chap-msv1", "chap-msv2" }; |
|
|
/* make "chap" as an alias for all chap-variants, this should keep BC */ |
/* make "chap" as an alias for all chap-variants, this should keep BC */ |
Line 1383 LinkSetCommand(Context ctx, int ac, char *av[], void *
|
Line 1460 LinkSetCommand(Context ctx, int ac, char *av[], void *
|
int i = 0; |
int i = 0; |
for ( ; i < ac; i++) { |
for ( ; i < ac; i++) { |
if (strcasecmp(av[i], "chap") == 0) { |
if (strcasecmp(av[i], "chap") == 0) { |
LinkSetCommand(ctx, 3, (char **)av2, arg); | LinkSetCommand(ctx, 3, (const char **)av2, arg); |
} else { |
} else { |
nav[nac++] = av[i]; |
nav[nac++] = av[i]; |
} |
} |
Line 1493 LinkSetCommand(Context ctx, int ac, char *av[], void *
|
Line 1570 LinkSetCommand(Context ctx, int ac, char *av[], void *
|
name = ((intptr_t)arg == SET_MTU) ? "MTU" : "MRU"; |
name = ((intptr_t)arg == SET_MTU) ? "MTU" : "MRU"; |
if (val < LCP_MIN_MRU) |
if (val < LCP_MIN_MRU) |
Error("min %s is %d", name, LCP_MIN_MRU); |
Error("min %s is %d", name, LCP_MIN_MRU); |
else if (l->type && (val > l->type->mru)) { | else if (l->type && (val > l->type->mtu)) { |
Error("max %s on type \"%s\" links is %d", |
Error("max %s on type \"%s\" links is %d", |
name, l->type->name, l->type->mru); | name, l->type->name, l->type->mtu); |
} else if ((intptr_t)arg == SET_MTU) |
} else if ((intptr_t)arg == SET_MTU) |
l->conf.mtu = val; |
l->conf.mtu = val; |
else |
else |