|
|
| version 1.1.1.1, 2012/02/21 23:32:47 | version 1.1.1.3, 2016/11/01 09:56:12 |
|---|---|
| Line 11 | Line 11 |
| * See ``COPYRIGHT.whistle'' | * See ``COPYRIGHT.whistle'' |
| */ | */ |
| #include "msg.h" | |
| #include "ppp.h" | #include "ppp.h" |
| #include "console.h" | #include "console.h" |
| #ifndef NOWEB | #ifndef NOWEB |
| Line 40 | Line 41 |
| #ifdef USE_FETCH | #ifdef USE_FETCH |
| #include <fetch.h> | #include <fetch.h> |
| #endif | #endif |
| #ifdef USE_NG_NETFLOW | |
| #include <netgraph/netflow/ng_netflow.h> | |
| #endif | |
| /* | /* |
| * DEFINITIONS | * DEFINITIONS |
| Line 75 | Line 79 |
| SET_L2TPLIMIT, | SET_L2TPLIMIT, |
| #endif | #endif |
| SET_MAX_CHILDREN, | SET_MAX_CHILDREN, |
| SET_QTHRESHOLD, | |
| #ifdef USE_NG_BPF | #ifdef USE_NG_BPF |
| SET_FILTER | SET_FILTER |
| #endif | #endif |
| Line 148 | Line 153 |
| #endif | #endif |
| { "max-children {num}", "Max number of children", | { "max-children {num}", "Max number of children", |
| GlobalSetCommand, NULL, 2, (void *) SET_MAX_CHILDREN }, | GlobalSetCommand, NULL, 2, (void *) SET_MAX_CHILDREN }, |
| { "qthreshold {min} {max}", "Message queue limit thresholds", | |
| GlobalSetCommand, NULL, 2, (void *) SET_QTHRESHOLD }, | |
| #ifdef USE_NG_BPF | #ifdef USE_NG_BPF |
| { "filter {num} add|clear [\"{flt}\"]", "Global traffic filters management", | { "filter {num} add|clear [\"{flt}\"]", "Global traffic filters management", |
| GlobalSetCommand, NULL, 2, (void *) SET_FILTER }, | GlobalSetCommand, NULL, 2, (void *) SET_FILTER }, |
| Line 160 | Line 167 |
| { 0, GLOBAL_CONF_TCPWRAPPER, "tcp-wrapper" }, | { 0, GLOBAL_CONF_TCPWRAPPER, "tcp-wrapper" }, |
| #endif | #endif |
| { 0, GLOBAL_CONF_ONESHOT, "one-shot" }, | { 0, GLOBAL_CONF_ONESHOT, "one-shot" }, |
| { 0, GLOBAL_CONF_AGENT_CID, "agent-cid" }, | |
| { 0, GLOBAL_CONF_SESS_TIME, "session-time" }, | |
| { 0, 0, NULL }, | { 0, 0, NULL }, |
| }; | }; |
| Line 181 | Line 190 |
| static const struct cmdtab ShowSessCmds[] = { | static const struct cmdtab ShowSessCmds[] = { |
| { "iface {name}", "Filter by iface name", | { "iface {name}", "Filter by iface name", |
| ShowSessions, NULL, 2, (void *) SHOW_IFACE }, | ShowSessions, NULL, 0, (void *) SHOW_IFACE }, |
| { "ip {ip}", "Filter by IP address", | { "ip {ip}", "Filter by IP address", |
| ShowSessions, NULL, 2, (void *) SHOW_IP }, | ShowSessions, NULL, 0, (void *) SHOW_IP }, |
| { "user {name}", "Filter by user name", | { "user {name}", "Filter by user name", |
| ShowSessions, NULL, 2, (void *) SHOW_USER }, | ShowSessions, NULL, 0, (void *) SHOW_USER }, |
| { "session {ID}", "Filter by session ID", | { "session {ID}", "Filter by session ID", |
| ShowSessions, NULL, 2, (void *) SHOW_SESSION }, | ShowSessions, NULL, 0, (void *) SHOW_SESSION }, |
| { "msession {ID}", "Filter by msession ID", | { "msession {ID}", "Filter by msession ID", |
| ShowSessions, NULL, 2, (void *) SHOW_MSESSION }, | ShowSessions, NULL, 0, (void *) SHOW_MSESSION }, |
| { "bundle {name}", "Filter by bundle name", | { "bundle {name}", "Filter by bundle name", |
| ShowSessions, NULL, 2, (void *) SHOW_BUNDLE }, | ShowSessions, NULL, 0, (void *) SHOW_BUNDLE }, |
| { "link {name}", "Filter by link name", | { "link {name}", "Filter by link name", |
| ShowSessions, NULL, 2, (void *) SHOW_LINK }, | ShowSessions, NULL, 0, (void *) SHOW_LINK }, |
| { "peer {name}", "Filter by peer name", | { "peer {name}", "Filter by peer name", |
| ShowSessions, NULL, 2, (void *) SHOW_PEER }, | ShowSessions, NULL, 0, (void *) SHOW_PEER }, |
| { NULL }, | { NULL }, |
| }; | }; |
| Line 273 | Line 282 |
| { "version", "Version string", | { "version", "Version string", |
| ShowVersion, NULL, 0, NULL }, | ShowVersion, NULL, 0, NULL }, |
| { "sessions [ {param} {value} ]", "Active sessions", | { "sessions [ {param} {value} ]", "Active sessions", |
| CMD_SUBMENU, NULL, 2, (void *) ShowSessCmds}, | CMD_SUBMENU, NULL, 0, (void *) ShowSessCmds}, |
| { "summary", "Daemon status summary", | { "summary", "Daemon status summary", |
| ShowSummary, NULL, 0, NULL }, | ShowSummary, NULL, 0, NULL }, |
| #ifdef USE_NG_NETFLOW | |
| { "netflow", "Netflow settings", | |
| ShowNetflow, NULL, 0, NULL }, | |
| #endif | |
| { NULL }, | { NULL }, |
| }; | }; |
| static const struct cmdtab UnSetCommands[] = { | |
| { "radius ...", "RADIUS specific stuff", | |
| CMD_SUBMENU, AdmitLink, 2, (void *) RadiusUnSetCmds }, | |
| #ifdef NG_NAT_DESC_LENGTH | |
| { "nat ...", "NAT specific stuff", | |
| CMD_SUBMENU, AdmitBund, 2, (void *) NatUnSetCmds }, | |
| #endif | |
| { NULL }, | |
| }; | |
| static const struct cmdtab SetCommands[] = { | static const struct cmdtab SetCommands[] = { |
| { "bundle ...", "Bundle specific stuff", | { "bundle ...", "Bundle specific stuff", |
| CMD_SUBMENU, AdmitBund, 2, (void *) BundSetCmds }, | CMD_SUBMENU, AdmitBund, 2, (void *) BundSetCmds }, |
| Line 336 | Line 359 |
| }; | }; |
| const struct cmdtab gCommands[] = { | const struct cmdtab gCommands[] = { |
| { "authname {name}", "Choose link by auth name", | { "authname {name} [CI]", "Choose link by auth name", |
| AuthnameCommand, NULL, 0, NULL }, | AuthnameCommand, NULL, 0, NULL }, |
| { "bundle [{name}]", "Choose/list bundles", | { "bundle [{name}]", "Choose/list bundles", |
| BundCommand, NULL, 0, NULL }, | BundCommand, NULL, 0, NULL }, |
| Line 362 | Line 385 |
| MSessionCommand, NULL, 0, NULL }, | MSessionCommand, NULL, 0, NULL }, |
| { "open [{layer}]", "Open a layer", | { "open [{layer}]", "Open a layer", |
| OpenCommand, NULL, 1, NULL }, | OpenCommand, NULL, 1, NULL }, |
| { "quit", "Quit program", | { "shutdown", "Shutdown program", |
| QuitCommand, NULL, 2, NULL }, | QuitCommand, NULL, 2, NULL }, |
| { "repeater [{name}]", "Choose/list repeaters", | { "repeater [{name}]", "Choose/list repeaters", |
| RepCommand, NULL, 0, NULL }, | RepCommand, NULL, 0, NULL }, |
| Line 370 | Line 393 |
| SessionCommand, NULL, 0, NULL }, | SessionCommand, NULL, 0, NULL }, |
| { "set ...", "Set parameters", | { "set ...", "Set parameters", |
| CMD_SUBMENU, NULL, 0, (void *) SetCommands }, | CMD_SUBMENU, NULL, 0, (void *) SetCommands }, |
| { "unset ...", "Unset parameters", | |
| CMD_SUBMENU, NULL, 0, (void *) UnSetCommands }, | |
| { "show ...", "Show status", | { "show ...", "Show status", |
| CMD_SUBMENU, NULL, 0, (void *) ShowCommands }, | CMD_SUBMENU, NULL, 0, (void *) ShowCommands }, |
| { NULL }, | { NULL }, |
| Line 734 GlobalSetCommand(Context ctx, int ac, char *av[], void | Line 759 GlobalSetCommand(Context ctx, int ac, char *av[], void |
| break; | break; |
| #endif /* USE_NG_BPF */ | #endif /* USE_NG_BPF */ |
| case SET_QTHRESHOLD: | |
| if (ac == 2) { | |
| int val_max; | |
| val = atoi(av[0]); | |
| if (val < 0 || val >= MSG_QUEUE_LEN-1) | |
| Error("Incorrect minimum threshold for message queue, " | |
| "must be between 0 and %d", MSG_QUEUE_LEN-1); | |
| val_max = atoi(av[1]); | |
| if (val_max <= val || val_max >= MSG_QUEUE_LEN) | |
| Error("Incorrect maximum threshold for message queue, " | |
| "must be greater than minimum and less than %d", | |
| MSG_QUEUE_LEN); | |
| gQThresMin = val; | |
| gQThresMax = val_max; | |
| gQThresDiff = val_max - val; | |
| } | |
| else | |
| return (-1); | |
| break; | |
| default: | default: |
| return(-1); | return(-1); |
| } | } |
| Line 844 ShowVersion(Context ctx, int ac, char *av[], void *arg | Line 889 ShowVersion(Context ctx, int ac, char *av[], void *arg |
| #else | #else |
| Printf(" config fetch : no\r\n"); | Printf(" config fetch : no\r\n"); |
| #endif | #endif |
| #ifdef USE_BACKTRACE | |
| Printf(" backtrace() : yes\r\n"); | |
| #else | |
| Printf(" backtrace() : no\r\n"); | |
| #endif | |
| #ifdef USE_NG_BPF | #ifdef USE_NG_BPF |
| Printf(" ng_bpf : yes\r\n"); | Printf(" ng_bpf : yes\r\n"); |
| #else | #else |
| Line 883 ShowVersion(Context ctx, int ac, char *av[], void *arg | Line 933 ShowVersion(Context ctx, int ac, char *av[], void *arg |
| #endif | #endif |
| #ifdef USE_NG_NETFLOW | #ifdef USE_NG_NETFLOW |
| Printf(" ng_netflow : yes\r\n"); | Printf(" ng_netflow : yes\r\n"); |
| #if NGM_NETFLOW_COOKIE >= 1309868867 | |
| Printf(" netflow v9 : yes\r\n"); | |
| #else | #else |
| Printf(" netflow v9 : no\r\n"); | |
| #endif | |
| #else | |
| Printf(" ng_netflow : no\r\n"); | Printf(" ng_netflow : no\r\n"); |
| #endif | #endif |
| #ifdef USE_NG_PRED1 | #ifdef USE_NG_PRED1 |
| Line 937 ShowGlobal(Context ctx, int ac, char *av[], void *arg) | Line 992 ShowGlobal(Context ctx, int ac, char *av[], void *arg) |
| Printf(" pptplimit : %d\r\n", gPPTPtunlimit); | Printf(" pptplimit : %d\r\n", gPPTPtunlimit); |
| #endif | #endif |
| Printf(" max-children : %d\r\n", gMaxChildren); | Printf(" max-children : %d\r\n", gMaxChildren); |
| Printf(" qthreshold : %d %d\r\n", gQThresMin, gQThresMax); | |
| Printf("Global options:\r\n"); | Printf("Global options:\r\n"); |
| OptStat(ctx, &gGlobalConf.options, gGlobalConfList); | OptStat(ctx, &gGlobalConf.options, gGlobalConfList); |
| #ifdef USE_NG_BPF | #ifdef USE_NG_BPF |
| Line 949 ShowGlobal(Context ctx, int ac, char *av[], void *arg) | Line 1005 ShowGlobal(Context ctx, int ac, char *av[], void *arg) |
| } | } |
| } | } |
| #endif | #endif |
| Printf("Global state:\r\n"); | |
| Printf(" children : %d\r\n", gChildren); | |
| return 0; | return 0; |
| } | } |
| Line 1111 CloseCommand(Context ctx, int ac, char *av[], void *ar | Line 1169 CloseCommand(Context ctx, int ac, char *av[], void *ar |
| static Layer | static Layer |
| GetLayer(const char *name) | GetLayer(const char *name) |
| { | { |
| int k, found; | size_t k; |
| int found; | |
| if (name == NULL) | if (name == NULL) |
| name = "iface"; | name = "iface"; |
| Line 1138 GetLayer(const char *name) | Line 1197 GetLayer(const char *name) |
| static int | static int |
| ShowLayers(Context ctx, int ac, char *av[], void *arg) | ShowLayers(Context ctx, int ac, char *av[], void *arg) |
| { | { |
| int k; | size_t k; |
| Printf("\tName\t\tDescription\r\n"); | Printf("\tName\t\tDescription\r\n"); |
| Printf("\t----\t\t-----------\r\n"); | Printf("\t----\t\t-----------\r\n"); |
| Line 1260 ShowSessions(Context ctx, int ac, char *av[], void *ar | Line 1319 ShowSessions(Context ctx, int ac, char *av[], void *ar |
| int l; | int l; |
| Bund B; | Bund B; |
| Link L; | Link L; |
| char peer[64], addr[64]; | char peer[64], addr[64], buf[64]; |
| if (ac != 0 && ac != 1) | if (ac != 0 && ac != 1) |
| return (-1); | return (-1); |
| Line 1328 out: | Line 1387 out: |
| L->lcp.auth.params.authname, | L->lcp.auth.params.authname, |
| peer | peer |
| ); | ); |
| if (Enabled(&gGlobalConf.options, GLOBAL_CONF_AGENT_CID)) { | |
| PhysGetSelfName(L, buf, sizeof(buf)); | |
| Printf("\t%s", buf); | |
| } | |
| if (Enabled(&gGlobalConf.options, GLOBAL_CONF_SESS_TIME)) { | |
| if (L->state == PHYS_STATE_UP) | |
| Printf("\t%ld", (long int)(time(NULL) - L->last_up)); | |
| } | |
| Printf("\r\n"); | Printf("\r\n"); |
| } | } |
| } | } |
| Line 1379 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1446 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| if (!SLIST_EMPTY(&iface->routes) || !SLIST_EMPTY(&b->params.routes)) { | if (!SLIST_EMPTY(&iface->routes) || !SLIST_EMPTY(&b->params.routes)) { |
| Printf("\tRoutes via peer :\r\n"); | Printf("\tRoutes via peer :\r\n"); |
| SLIST_FOREACH(r, &iface->routes, next) | SLIST_FOREACH(r, &iface->routes, next) |
| Printf("\t\t%s\r\n", u_rangetoa(&r->dest,buf,sizeof(buf))); | Printf("\t\t: %s\r\n", u_rangetoa(&r->dest,buf,sizeof(buf))); |
| SLIST_FOREACH(r, &b->params.routes, next) | SLIST_FOREACH(r, &b->params.routes, next) |
| Printf("\t\t%s\r\n", u_rangetoa(&r->dest,buf,sizeof(buf))); | Printf("\t\t: %s\r\n", u_rangetoa(&r->dest,buf,sizeof(buf))); |
| } | } |
| #ifdef USE_IPFW | #ifdef USE_IPFW |
| if (b->params.acl_pipe) { | if (b->params.acl_pipe) { |
| Printf("\tIPFW pipes :\r\n"); | Printf("\tIPFW pipes :\r\n"); |
| a = b->params.acl_pipe; | a = b->params.acl_pipe; |
| while (a) { | while (a) { |
| Printf("\t\t%d (%d)\t'%s'\r\n", a->number, a->real_number, a->rule); | Printf("\t\t%d (%d)\t: '%s'\r\n", a->number, a->real_number, a->rule); |
| a = a->next; | a = a->next; |
| } | } |
| } | } |
| Line 1396 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1463 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| Printf("\tIPFW queues :\r\n"); | Printf("\tIPFW queues :\r\n"); |
| a = b->params.acl_queue; | a = b->params.acl_queue; |
| while (a) { | while (a) { |
| Printf("\t\t%d (%d)\t'%s'\r\n", a->number, a->real_number, a->rule); | Printf("\t\t%d (%d)\t: '%s'\r\n", a->number, a->real_number, a->rule); |
| a = a->next; | a = a->next; |
| } | } |
| } | } |
| Line 1405 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1472 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| a = b->params.acl_table; | a = b->params.acl_table; |
| while (a) { | while (a) { |
| if (a->number != 0) | if (a->number != 0) |
| Printf("\t\t%d (%d)\t'%s'\r\n", a->number, a->real_number, a->rule); | Printf("\t\t%d (%d)\t: '%s'\r\n", a->number, a->real_number, a->rule); |
| else | else |
| Printf("\t\t(%d)\t'%s'\r\n", a->real_number, a->rule); | Printf("\t\t(%d)\t: '%s'\r\n", a->real_number, a->rule); |
| a = a->next; | a = a->next; |
| } | } |
| } | } |
| Line 1415 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1482 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| Printf("\tIPFW rules :\r\n"); | Printf("\tIPFW rules :\r\n"); |
| a = b->params.acl_rule; | a = b->params.acl_rule; |
| while (a) { | while (a) { |
| Printf("\t\t%d (%d)\t'%s'\r\n", a->number, a->real_number, a->rule); | Printf("\t\t%d (%d)\t: '%s'\r\n", a->number, a->real_number, a->rule); |
| a = a->next; | a = a->next; |
| } | } |
| } | } |
| Line 1429 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1496 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| if (a == NULL) | if (a == NULL) |
| a = acl_filters[k]; | a = acl_filters[k]; |
| while (a) { | while (a) { |
| Printf("\t\t%d#%d\t'%s'\r\n", (k + 1), a->number, a->rule); | Printf("\t\t%d#%d\t: '%s'\r\n", (k + 1), a->number, a->rule); |
| a = a->next; | a = a->next; |
| } | } |
| } | } |
| Line 1437 ShowCustomer(Context ctx, int ac, char *av[], void *ar | Line 1504 ShowCustomer(Context ctx, int ac, char *av[], void *ar |
| for (k = 0; k < 2; k++) { | for (k = 0; k < 2; k++) { |
| a = b->params.acl_limits[k]; | a = b->params.acl_limits[k]; |
| while (a) { | while (a) { |
| Printf("\t\t%s#%d%s%s\t'%s'\r\n", (k?"out":"in"), a->number, | Printf("\t\t%s#%d%s%s\t: '%s'\r\n", (k?"out":"in"), a->number, |
| ((a->name[0])?"#":""), a->name, a->rule); | ((a->name[0])?"#":""), a->name, a->rule); |
| a = a->next; | a = a->next; |
| } | } |