--- embedaddon/mpd/src/command.c 2016/11/01 09:56:12 1.1.1.3 +++ embedaddon/mpd/src/command.c 2021/03/17 00:39:23 1.1.1.4 @@ -101,21 +101,21 @@ */ /* Commands */ - static int ShowVersion(Context ctx, int ac, char *av[], void *arg); - static int ShowLayers(Context ctx, int ac, char *av[], void *arg); - static int ShowTypes(Context ctx, int ac, char *av[], void *arg); - static int ShowSummary(Context ctx, int ac, char *av[], void *arg); - static int ShowSessions(Context ctx, int ac, char *av[], void *arg); - static int ShowCustomer(Context ctx, int ac, char *av[], void *arg); - static int ShowEvents(Context ctx, int ac, char *av[], void *arg); - static int ShowGlobal(Context ctx, int ac, char *av[], void *arg); - static int OpenCommand(Context ctx, int ac, char *av[], void *arg); - static int CloseCommand(Context ctx, int ac, char *av[], void *arg); - static int LoadCommand(Context ctx, int ac, char *av[], void *arg); - static int ExitCommand(Context ctx, int ac, char *av[], void *arg); - static int QuitCommand(Context ctx, int ac, char *av[], void *arg); - static int GlobalSetCommand(Context ctx, int ac, char *av[], void *arg); - static int SetDebugCommand(Context ctx, int ac, char *av[], void *arg); + static int ShowVersion(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowLayers(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowTypes(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowSummary(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowSessions(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowCustomer(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowEvents(Context ctx, int ac, const char *const av[], const void *arg); + static int ShowGlobal(Context ctx, int ac, const char *const av[], const void *arg); + static int OpenCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int CloseCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int LoadCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int ExitCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int QuitCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int GlobalSetCommand(Context ctx, int ac, const char *const av[], const void *arg); + static int SetDebugCommand(Context ctx, int ac, const char *const av[], const void *arg); /* Other stuff */ static Layer GetLayer(const char *name); @@ -124,7 +124,7 @@ * INTERNAL VARIABLES */ - const struct cmdtab GlobalSetCmds[] = { + static const struct cmdtab GlobalSetCmds[] = { { "enable {opt ...}", "Enable option" , GlobalSetCommand, NULL, 2, (void *) SET_ENABLE }, { "disable {opt ...}", "Disable option" , @@ -159,7 +159,7 @@ { "filter {num} add|clear [\"{flt}\"]", "Global traffic filters management", GlobalSetCommand, NULL, 2, (void *) SET_FILTER }, #endif - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct confinfo gGlobalConfList[] = { @@ -177,7 +177,7 @@ LinkCreate, NULL, 2, NULL }, { "bundle [template|static] {name} {template}", "Create bundle/template", BundCreate, NULL, 2, NULL }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct cmdtab DestroyCommands[] = { @@ -185,7 +185,7 @@ LinkDestroy, NULL, 2, NULL }, { "bundle [{name}]", "Destroy bundle/template", BundDestroy, NULL, 2, NULL }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct cmdtab ShowSessCmds[] = { @@ -205,7 +205,7 @@ ShowSessions, NULL, 0, (void *) SHOW_LINK }, { "peer {name}", "Filter by peer name", ShowSessions, NULL, 0, (void *) SHOW_PEER }, - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct cmdtab ShowCommands[] = { @@ -282,80 +282,80 @@ { "version", "Version string", ShowVersion, NULL, 0, NULL }, { "sessions [ {param} {value} ]", "Active sessions", - CMD_SUBMENU, NULL, 0, (void *) ShowSessCmds}, + CMD_SUBMENU, NULL, 0, ShowSessCmds}, { "summary", "Daemon status summary", ShowSummary, NULL, 0, NULL }, #ifdef USE_NG_NETFLOW { "netflow", "Netflow settings", ShowNetflow, NULL, 0, NULL }, #endif - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct cmdtab UnSetCommands[] = { { "radius ...", "RADIUS specific stuff", - CMD_SUBMENU, AdmitLink, 2, (void *) RadiusUnSetCmds }, + CMD_SUBMENU, AdmitLink, 2, RadiusUnSetCmds }, #ifdef NG_NAT_DESC_LENGTH { "nat ...", "NAT specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) NatUnSetCmds }, + CMD_SUBMENU, AdmitBund, 2, NatUnSetCmds }, #endif - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; static const struct cmdtab SetCommands[] = { { "bundle ...", "Bundle specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) BundSetCmds }, + CMD_SUBMENU, AdmitBund, 2, BundSetCmds }, { "link ...", "Link specific stuff", - CMD_SUBMENU, AdmitLink, 2, (void *) LinkSetCmds }, + CMD_SUBMENU, AdmitLink, 2, LinkSetCmds }, { "iface ...", "Interface specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) IfaceSetCmds }, + CMD_SUBMENU, AdmitBund, 2, IfaceSetCmds }, { "ipcp ...", "IPCP specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) IpcpSetCmds }, + CMD_SUBMENU, AdmitBund, 2, IpcpSetCmds }, { "ipv6cp ...", "IPV6CP specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) Ipv6cpSetCmds }, + CMD_SUBMENU, AdmitBund, 2, Ipv6cpSetCmds }, { "ippool ...", "IP pool specific stuff", - CMD_SUBMENU, NULL, 2, (void *) IPPoolSetCmds }, + CMD_SUBMENU, NULL, 2, IPPoolSetCmds }, { "ccp ...", "CCP specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) CcpSetCmds }, + CMD_SUBMENU, AdmitBund, 2, CcpSetCmds }, #ifdef CCP_MPPC { "mppc ...", "MPPC specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) MppcSetCmds }, + CMD_SUBMENU, AdmitBund, 2, MppcSetCmds }, #endif { "ecp ...", "ECP specific stuff", - CMD_SUBMENU, AdmitBund, 2, (void *) EcpSetCmds }, + CMD_SUBMENU, AdmitBund, 2, EcpSetCmds }, { "eap ...", "EAP specific stuff", - CMD_SUBMENU, AdmitLink, 2, (void *) EapSetCmds }, + CMD_SUBMENU, AdmitLink, 2, EapSetCmds }, { "auth ...", "Auth specific stuff", - CMD_SUBMENU, AdmitLink, 2, (void *) AuthSetCmds }, + CMD_SUBMENU, AdmitLink, 2, AuthSetCmds }, { "radius ...", "RADIUS specific stuff", - CMD_SUBMENU, AdmitLink, 2, (void *) RadiusSetCmds }, + CMD_SUBMENU, AdmitLink, 2, RadiusSetCmds }, #ifdef RAD_COA_REQUEST { "radsrv ...", "RADIUS server specific stuff", - CMD_SUBMENU, NULL, 2, (void *) RadsrvSetCmds }, + CMD_SUBMENU, NULL, 2, RadsrvSetCmds }, #endif { "console ...", "Console specific stuff", - CMD_SUBMENU, NULL, 0, (void *) ConsoleSetCmds }, + CMD_SUBMENU, NULL, 0, ConsoleSetCmds }, #ifndef NOWEB { "web ...", "Web specific stuff", - CMD_SUBMENU, NULL, 2, (void *) WebSetCmds }, + CMD_SUBMENU, NULL, 2, WebSetCmds }, #endif { "user {name} {password} [{priv}]", "Add console user" , UserCommand, NULL, 2, NULL }, { "global ...", "Global settings", - CMD_SUBMENU, NULL, 2, (void *) GlobalSetCmds }, + CMD_SUBMENU, NULL, 2, GlobalSetCmds }, #ifdef USE_NG_NETFLOW { "netflow ...", "NetFlow settings", - CMD_SUBMENU, NULL, 2, (void *) NetflowSetCmds }, + CMD_SUBMENU, NULL, 2, NetflowSetCmds }, #endif #ifdef USE_NG_NAT { "nat ...", "Nat settings", - CMD_SUBMENU, NULL, 2, (void *) NatSetCmds }, + CMD_SUBMENU, NULL, 2, NatSetCmds }, #endif { "debug level", "Set netgraph debug level", SetDebugCommand, NULL, 2, NULL }, #define _WANT_DEVICE_CMDS #include "devices.h" - { NULL }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; const struct cmdtab gCommands[] = { @@ -366,9 +366,9 @@ { "close [{layer}]", "Close a layer", CloseCommand, NULL, 1, NULL }, { "create ...", "Create new item", - CMD_SUBMENU, NULL, 2, (void *) CreateCommands }, + CMD_SUBMENU, NULL, 2, CreateCommands }, { "destroy ...", "Destroy item", - CMD_SUBMENU, NULL, 2, (void *) DestroyCommands }, + CMD_SUBMENU, NULL, 2, DestroyCommands }, { "exit", "Exit console", ExitCommand, NULL, 0, NULL }, { "iface {iface}", "Choose bundle by iface", @@ -392,12 +392,12 @@ { "session {sesid}", "Choose link by session-id", SessionCommand, NULL, 0, NULL }, { "set ...", "Set parameters", - CMD_SUBMENU, NULL, 0, (void *) SetCommands }, + CMD_SUBMENU, NULL, 0, SetCommands }, { "unset ...", "Unset parameters", - CMD_SUBMENU, NULL, 0, (void *) UnSetCommands }, + CMD_SUBMENU, NULL, 0, UnSetCommands }, { "show ...", "Show status", - CMD_SUBMENU, NULL, 0, (void *) ShowCommands }, - { NULL }, + CMD_SUBMENU, NULL, 0, ShowCommands }, + { NULL, NULL, NULL, NULL, 0, NULL }, }; @@ -406,7 +406,7 @@ * Layers */ - struct layer gLayers[] = { + static struct layer gLayers[] = { { "iface", IfaceOpenCmd, IfaceCloseCmd, @@ -466,7 +466,7 @@ */ int -DoCommand(Context ctx, int ac, char *av[], const char *file, int line) +DoCommand(Context ctx, int ac, const char *const av[], const char *file, int line) { int rtn, i; char filebuf[100], cmd[256]; @@ -530,7 +530,7 @@ DoCommand(Context ctx, int ac, char *av[], const char */ int -DoCommandTab(Context ctx, CmdTab cmdlist, int ac, char *av[]) +DoCommandTab(Context ctx, CmdTab cmdlist, int ac, const char *const av[]) { CmdTab cmd; int rtn = 0; @@ -567,7 +567,7 @@ DoCommandTab(Context ctx, CmdTab cmdlist, int ac, char */ int -FindCommand(Context ctx, CmdTab cmds, char *str, CmdTab *cmdp) +FindCommand(Context ctx, CmdTab cmds, const char *str, CmdTab *cmdp) { int nmatch; int len = strlen(str); @@ -597,7 +597,7 @@ FindCommand(Context ctx, CmdTab cmds, char *str, CmdTa */ static int -GlobalSetCommand(Context ctx, int ac, char *av[], void *arg) +GlobalSetCommand(Context ctx, int ac, const char *const av[], const void *arg) { int val; @@ -677,7 +677,7 @@ GlobalSetCommand(Context ctx, int ac, char *av[], void if (val < 0 || val > 65536) Error("Incorrect L2TP call limit"); else - gL2TPtunlimit = val; + gL2TPtunlimit = (unsigned)val; break; #endif @@ -695,7 +695,7 @@ GlobalSetCommand(Context ctx, int ac, char *av[], void if (val <= 0 || val > 65536) Error("Incorrect PPTP call limit"); else - gPPTPtunlimit = val; + gPPTPtunlimit = (unsigned)val; break; #endif @@ -791,7 +791,7 @@ GlobalSetCommand(Context ctx, int ac, char *av[], void */ int -HelpCommand(Context ctx, int ac, char *av[], void *arg) +HelpCommand(Context ctx, int ac, const char *const av[], const void *arg) { int depth, i; CmdTab menu, cmd; @@ -814,7 +814,7 @@ HelpCommand(Context ctx, int ac, char *av[], void *arg else errfmt = "%sUnknown command: '%s'.\r\n"; if (arg) { - Printf(errfmt, (char*)arg, buf); + Printf(errfmt, (const char*)arg, buf); } else { Printf(errfmt, "", buf); } @@ -858,8 +858,11 @@ HelpCommand(Context ctx, int ac, char *av[], void *arg */ static int -SetDebugCommand(Context ctx, int ac, char *av[], void *arg) +SetDebugCommand(Context ctx, int ac, const char *const av[], const void *arg) { + (void)arg; + (void)ctx; + switch (ac) { case 1: NgSetDebug(atoi(av[0])); @@ -875,8 +878,12 @@ SetDebugCommand(Context ctx, int ac, char *av[], void */ static int -ShowVersion(Context ctx, int ac, char *av[], void *arg) +ShowVersion(Context ctx, int ac, const char *const av[], const void *arg) { + (void)ac; + (void)av; + (void)arg; + Printf("MPD version: %s\r\n", gVersion); Printf(" Available features:\r\n"); #ifdef USE_IPFW @@ -959,9 +966,13 @@ ShowVersion(Context ctx, int ac, char *av[], void *arg */ static int -ShowEvents(Context ctx, int ac, char *av[], void *arg) +ShowEvents(Context ctx, int ac, const char *const av[], const void *arg) { - EventDump(ctx, "mpd events"); + (void)ac; + (void)av; + (void)arg; + + EventDump(ctx); return(0); } @@ -970,12 +981,16 @@ ShowEvents(Context ctx, int ac, char *av[], void *arg) */ static int -ShowGlobal(Context ctx, int ac, char *av[], void *arg) +ShowGlobal(Context ctx, int ac, const char *const av[], const void *arg) { #ifdef USE_NG_BPF int k; #endif + (void)ac; + (void)av; + (void)arg; + Printf("Global settings:\r\n"); #ifdef USE_IPFW Printf(" startrule : %d\r\n", rule_pool_start); @@ -985,11 +1000,11 @@ ShowGlobal(Context ctx, int ac, char *av[], void *arg) #endif #ifdef PHYSTYPE_L2TP Printf(" l2tptimeout : %d\r\n", gL2TPto); - Printf(" l2tplimit : %d\r\n", gL2TPtunlimit); + Printf(" l2tplimit : %u\r\n", gL2TPtunlimit); #endif #ifdef PHYSTYPE_PPTP Printf(" pptptimeout : %d\r\n", gPPTPto); - Printf(" pptplimit : %d\r\n", gPPTPtunlimit); + Printf(" pptplimit : %u\r\n", gPPTPtunlimit); #endif Printf(" max-children : %d\r\n", gMaxChildren); Printf(" qthreshold : %d %d\r\n", gQThresMin, gQThresMax); @@ -1016,8 +1031,13 @@ ShowGlobal(Context ctx, int ac, char *av[], void *arg) */ static int -ExitCommand(Context ctx, int ac, char *av[], void *arg) +ExitCommand(Context ctx, int ac, const char *const av[], const void *arg) { + + (void)ac; + (void)av; + (void)arg; + if (ctx->cs) ctx->cs->exit = TRUE; return(0); @@ -1028,8 +1048,12 @@ ExitCommand(Context ctx, int ac, char *av[], void *arg */ static int -QuitCommand(Context ctx, int ac, char *av[], void *arg) +QuitCommand(Context ctx, int ac, const char *const av[], const void *arg) { + (void)ac; + (void)av; + (void)arg; + if (ctx->cs) ctx->cs->exit = TRUE; SendSignal(SIGTERM); @@ -1041,7 +1065,7 @@ QuitCommand(Context ctx, int ac, char *av[], void *arg */ static int -LoadCommand(Context ctx, int ac, char *av[], void *arg) +LoadCommand(Context ctx, int ac, const char *const av[], const void *arg) { char filename[128]; #ifdef USE_FETCH @@ -1051,6 +1075,7 @@ LoadCommand(Context ctx, int ac, char *av[], void *arg int fetch = 0; #endif + (void)arg; if (ac < 1 || ac > 2) return(-1); else { @@ -1107,11 +1132,12 @@ out: if (fetch) */ static int -OpenCommand(Context ctx, int ac, char *av[], void *arg) +OpenCommand(Context ctx, int ac, const char *const av[], const void *arg) { Layer layer; const char *name; + (void)arg; switch (ac) { case 0: name = DEFAULT_OPEN_LAYER; @@ -1137,11 +1163,12 @@ OpenCommand(Context ctx, int ac, char *av[], void *arg */ static int -CloseCommand(Context ctx, int ac, char *av[], void *arg) +CloseCommand(Context ctx, int ac, const char *const av[], const void *arg) { Layer layer; const char *name; + (void)arg; switch (ac) { case 0: name = DEFAULT_OPEN_LAYER; @@ -1195,10 +1222,14 @@ GetLayer(const char *name) */ static int -ShowLayers(Context ctx, int ac, char *av[], void *arg) +ShowLayers(Context ctx, int ac, const char *const av[], const void *arg) { size_t k; + (void)ac; + (void)av; + (void)arg; + Printf("\tName\t\tDescription\r\n"); Printf("\t----\t\t-----------\r\n"); for (k = 0; k < NUM_LAYERS; k++) @@ -1211,11 +1242,15 @@ ShowLayers(Context ctx, int ac, char *av[], void *arg) */ static int -ShowTypes(Context ctx, int ac, char *av[], void *arg) +ShowTypes(Context ctx, int ac, const char *const av[], const void *arg) { - PhysType pt; + const struct phystype *pt; int k; + (void)ac; + (void)av; + (void)arg; + Printf("\tName\t\tDescription\r\n"); Printf("\t----\t\t-----------\r\n"); for (k = 0; (pt = gPhysTypes[k]); k++) @@ -1228,7 +1263,7 @@ ShowTypes(Context ctx, int ac, char *av[], void *arg) */ static int -ShowSummary(Context ctx, int ac, char *av[], void *arg) +ShowSummary(Context ctx, int ac, const char *const av[], const void *arg) { int b, l, f; Bund B; @@ -1236,6 +1271,10 @@ ShowSummary(Context ctx, int ac, char *av[], void *arg Rep R; char buf[64]; + (void)ac; + (void)av; + (void)arg; + Printf("Current daemon status summary\r\n"); Printf("Iface\tBund\t\tLink\tLCP\tDevice\t\tUser\t\tFrom\r\n"); for (b = 0; blnk; Bund b = ctx->bund; @@ -1418,6 +1457,10 @@ ShowCustomer(Context ctx, int ac, char *av[], void *ar struct acl *a; #endif + (void)ac; + (void)av; + (void)arg; + if (b && b->iface.ifname[0]) { iface = &b->iface; Printf("Interface:\r\n"); @@ -1546,7 +1589,6 @@ ShowCustomer(Context ctx, int ac, char *av[], void *ar else if (j != 0) l = NULL; if (l) { - char buf[64]; Printf("Link %s:\r\n", l->name); Printf("\tDevice type : %s\r\n", l->type?l->type->name:""); Printf("\tStatus : %s/%s\r\n", @@ -1597,6 +1639,7 @@ ShowCustomer(Context ctx, int ac, char *av[], void *ar int AdmitBund(Context ctx, CmdTab cmd) { + (void)cmd; if (!ctx->bund) return(FALSE); return(TRUE); @@ -1609,6 +1652,7 @@ AdmitBund(Context ctx, CmdTab cmd) int AdmitLink(Context ctx, CmdTab cmd) { + (void)cmd; if (!ctx->lnk) return(FALSE); return(TRUE); @@ -1621,6 +1665,7 @@ AdmitLink(Context ctx, CmdTab cmd) int AdmitRep(Context ctx, CmdTab cmd) { + (void)cmd; if (!ctx->rep) return(FALSE); return(TRUE);