command.c (9c81b87d1e56d3a7bbb680c3d2dab59d88d29481) command.c (30291ffb15d7e4b02d0e8de225a57dd49f655d4e)
1/*
2 * PPP User command processing module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
1/*
2 * PPP User command processing module
3 *
4 * Written by Toshiharu OHNO (tony-o@iij.ad.jp)
5 *
6 * Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
7 *
8 * Redistribution and use in source and binary forms are permitted
9 * provided that the above copyright notice and this paragraph are
10 * duplicated in all such forms and that any documentation,
11 * advertising materials, and other materials related to such
12 * distribution and use acknowledge that the software was developed
13 * by the Internet Initiative Japan, Inc. The name of the
14 * IIJ may not be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 *
20 * $Id: command.c,v 1.141 1998/06/12 20:12:25 brian Exp $
20 * $Id: command.c,v 1.142 1998/06/15 19:05:12 brian Exp $
21 *
22 */
23#include <sys/types.h>
24#include <netinet/in_systm.h>
25#include <netinet/in.h>
26#include <netinet/ip.h>
27#include <arpa/inet.h>
28#include <sys/socket.h>

--- 90 unchanged lines hidden (view full) ---

119#define NEG_PPPDDEFLATE 45
120#define NEG_PRED1 46
121#define NEG_PROTOCOMP 47
122#define NEG_SHORTSEQ 48
123#define NEG_VJCOMP 49
124#define NEG_DNS 50
125
126const char Version[] = "2.0-beta";
21 *
22 */
23#include <sys/types.h>
24#include <netinet/in_systm.h>
25#include <netinet/in.h>
26#include <netinet/ip.h>
27#include <arpa/inet.h>
28#include <sys/socket.h>

--- 90 unchanged lines hidden (view full) ---

119#define NEG_PPPDDEFLATE 45
120#define NEG_PRED1 46
121#define NEG_PROTOCOMP 47
122#define NEG_SHORTSEQ 48
123#define NEG_VJCOMP 49
124#define NEG_DNS 50
125
126const char Version[] = "2.0-beta";
127const char VersionDate[] = "$Date: 1998/06/12 20:12:25 $";
127const char VersionDate[] = "$Date: 1998/06/15 19:05:12 $";
128
129static int ShowCommand(struct cmdargs const *);
130static int TerminalCommand(struct cmdargs const *);
131static int QuitCommand(struct cmdargs const *);
132static int OpenCommand(struct cmdargs const *);
133static int CloseCommand(struct cmdargs const *);
134static int DownCommand(struct cmdargs const *);
135static int AllowCommand(struct cmdargs const *);

--- 134 unchanged lines hidden (view full) ---

270 log_Printf(LogERROR, "%s: Label not allowed\n", name);
271 return 1;
272 } else {
273 /*
274 * Set the label before & after so that `set enddisc' works and
275 * we handle nested `load' commands.
276 */
277 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
128
129static int ShowCommand(struct cmdargs const *);
130static int TerminalCommand(struct cmdargs const *);
131static int QuitCommand(struct cmdargs const *);
132static int OpenCommand(struct cmdargs const *);
133static int CloseCommand(struct cmdargs const *);
134static int DownCommand(struct cmdargs const *);
135static int AllowCommand(struct cmdargs const *);

--- 134 unchanged lines hidden (view full) ---

270 log_Printf(LogERROR, "%s: Label not allowed\n", name);
271 return 1;
272 } else {
273 /*
274 * Set the label before & after so that `set enddisc' works and
275 * we handle nested `load' commands.
276 */
277 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
278 if (system_Select(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
278 if (system_Select(arg->bundle, name, CONFFILE, arg->prompt, arg->cx) < 0) {
279 bundle_SetLabel(arg->bundle, NULL);
280 log_Printf(LogWARN, "%s: label not found.\n", name);
281 return -1;
282 }
283 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
284 }
285 return 0;
286}

--- 175 unchanged lines hidden (view full) ---

462 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
463 "Disable option", "disable option .."},
464 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
465 "Generate a down event", "down"},
466 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
467 "Enable option", "enable option .."},
468 {"link", "datalink", LinkCommand, LOCAL_AUTH,
469 "Link specific commands", "link name command ..."},
279 bundle_SetLabel(arg->bundle, NULL);
280 log_Printf(LogWARN, "%s: label not found.\n", name);
281 return -1;
282 }
283 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
284 }
285 return 0;
286}

--- 175 unchanged lines hidden (view full) ---

462 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
463 "Disable option", "disable option .."},
464 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
465 "Generate a down event", "down"},
466 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
467 "Enable option", "enable option .."},
468 {"link", "datalink", LinkCommand, LOCAL_AUTH,
469 "Link specific commands", "link name command ..."},
470 {"load", NULL, LoadCommand, LOCAL_AUTH,
470 {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
471 "Load settings", "load [remote]"},
472 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
473 "Open an FSM", "open [lcp|ccp]"},
474 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
475 "Password for manipulation", "passwd LocalPassword"},
476 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
477 "Quit PPP program", "quit|bye [all]"},
478 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,

--- 266 unchanged lines hidden (view full) ---

745 !strncasecmp(argv[1], "se", 2))
746 return 1;
747
748 return 0;
749}
750
751void
752command_Run(struct bundle *bundle, int argc, char const *const *argv,
471 "Load settings", "load [remote]"},
472 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
473 "Open an FSM", "open [lcp|ccp]"},
474 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
475 "Password for manipulation", "passwd LocalPassword"},
476 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
477 "Quit PPP program", "quit|bye [all]"},
478 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,

--- 266 unchanged lines hidden (view full) ---

745 !strncasecmp(argv[1], "se", 2))
746 return 1;
747
748 return 0;
749}
750
751void
752command_Run(struct bundle *bundle, int argc, char const *const *argv,
753 struct prompt *prompt, const char *label)
753 struct prompt *prompt, const char *label, struct datalink *cx)
754{
755 if (argc > 0) {
756 if (log_IsKept(LogCOMMAND)) {
757 static char buf[LINE_LEN];
758 int f, n;
759
760 *buf = '\0';
761 if (label) {

--- 8 unchanged lines hidden (view full) ---

770 if (arghidden(argc, argv, f))
771 strncpy(buf+n, "********", sizeof buf - n - 1);
772 else
773 strncpy(buf+n, argv[f], sizeof buf - n - 1);
774 n += strlen(buf+n);
775 }
776 log_Printf(LogCOMMAND, "%s\n", buf);
777 }
754{
755 if (argc > 0) {
756 if (log_IsKept(LogCOMMAND)) {
757 static char buf[LINE_LEN];
758 int f, n;
759
760 *buf = '\0';
761 if (label) {

--- 8 unchanged lines hidden (view full) ---

770 if (arghidden(argc, argv, f))
771 strncpy(buf+n, "********", sizeof buf - n - 1);
772 else
773 strncpy(buf+n, argv[f], sizeof buf - n - 1);
774 n += strlen(buf+n);
775 }
776 log_Printf(LogCOMMAND, "%s\n", buf);
777 }
778 FindExec(bundle, Commands, argc, 0, argv, prompt, NULL);
778 FindExec(bundle, Commands, argc, 0, argv, prompt, cx);
779 }
780}
781
782void
783command_Decode(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
784 const char *label)
785{
786 int argc;
787 char **argv;
788
789 command_Interpret(buff, nb, &argc, &argv);
779 }
780}
781
782void
783command_Decode(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
784 const char *label)
785{
786 int argc;
787 char **argv;
788
789 command_Interpret(buff, nb, &argc, &argv);
790 command_Run(bundle, argc, (char const *const *)argv, prompt, label);
790 command_Run(bundle, argc, (char const *const *)argv, prompt, label, NULL);
791}
792
793static int
794ShowCommand(struct cmdargs const *arg)
795{
796 if (!arg->prompt)
797 log_Printf(LogWARN, "show: Cannot show without a prompt\n");
798 else if (arg->argc > arg->argn)

--- 1282 unchanged lines hidden ---
791}
792
793static int
794ShowCommand(struct cmdargs const *arg)
795{
796 if (!arg->prompt)
797 log_Printf(LogWARN, "show: Cannot show without a prompt\n");
798 else if (arg->argc > arg->argn)

--- 1282 unchanged lines hidden ---