Deleted Added
full compact
command.c (37955) command.c (37993)
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.156 1998/07/28 21:54:52 brian Exp $
20 * $Id: command.c,v 1.157 1998/07/29 18:21:13 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>

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

117#define NEG_PPPDDEFLATE 45
118#define NEG_PRED1 46
119#define NEG_PROTOCOMP 47
120#define NEG_SHORTSEQ 48
121#define NEG_VJCOMP 49
122#define NEG_DNS 50
123
124const char Version[] = "2.0";
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>

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

117#define NEG_PPPDDEFLATE 45
118#define NEG_PRED1 46
119#define NEG_PROTOCOMP 47
120#define NEG_SHORTSEQ 48
121#define NEG_VJCOMP 49
122#define NEG_DNS 50
123
124const char Version[] = "2.0";
125const char VersionDate[] = "$Date: 1998/07/28 21:54:52 $";
125const char VersionDate[] = "$Date: 1998/07/29 18:21:13 $";
126
127static int ShowCommand(struct cmdargs const *);
128static int TerminalCommand(struct cmdargs const *);
129static int QuitCommand(struct cmdargs const *);
130static int OpenCommand(struct cmdargs const *);
131static int CloseCommand(struct cmdargs const *);
132static int DownCommand(struct cmdargs const *);
133static int AllowCommand(struct cmdargs const *);

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

301 log_Printf(LogWARN, "Manual dial is only available for auto and"
302 " interactive links\n");
303 return 1;
304 }
305
306 if (arg->argc > arg->argn && (res = LoadCommand(arg)) != 0)
307 return res;
308
126
127static int ShowCommand(struct cmdargs const *);
128static int TerminalCommand(struct cmdargs const *);
129static int QuitCommand(struct cmdargs const *);
130static int OpenCommand(struct cmdargs const *);
131static int CloseCommand(struct cmdargs const *);
132static int DownCommand(struct cmdargs const *);
133static int AllowCommand(struct cmdargs const *);

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

301 log_Printf(LogWARN, "Manual dial is only available for auto and"
302 " interactive links\n");
303 return 1;
304 }
305
306 if (arg->argc > arg->argn && (res = LoadCommand(arg)) != 0)
307 return res;
308
309 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL,
310 arg->cmd->args ? 1 : 0);
309 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL, 1);
311
312 return 0;
313}
314
315static int
316ShellCommand(struct cmdargs const *arg, int bg)
317{
318 const char *shell;

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

453 {"delete", NULL, DeleteCommand, LOCAL_AUTH,
454 "delete route", "delete dest", NULL},
455 {NULL, "delete!", DeleteCommand, LOCAL_AUTH,
456 "delete a route if it exists", "delete! dest", (void *)1},
457 {"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
458 "Deny option request", "deny option .."},
459 {"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
460 "Dial and login", "dial|call [remote]", NULL},
310
311 return 0;
312}
313
314static int
315ShellCommand(struct cmdargs const *arg, int bg)
316{
317 const char *shell;

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

452 {"delete", NULL, DeleteCommand, LOCAL_AUTH,
453 "delete route", "delete dest", NULL},
454 {NULL, "delete!", DeleteCommand, LOCAL_AUTH,
455 "delete a route if it exists", "delete! dest", (void *)1},
456 {"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
457 "Deny option request", "deny option .."},
458 {"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
459 "Dial and login", "dial|call [remote]", NULL},
461 {NULL, "dial!", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
462 "Dial and login", "dial! [remote]", (void *)1},
463 {NULL, "call!", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT,
464 "Dial and login", "call! [remote]", (void *)1},
465 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
466 "Disable option", "disable option .."},
467 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
468 "Generate a down event", "down"},
469 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
470 "Enable option", "enable option .."},
471 {"link", "datalink", LinkCommand, LOCAL_AUTH,
472 "Link specific commands", "link name command ..."},
473 {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
474 "Load settings", "load [remote]"},
475 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
460 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
461 "Disable option", "disable option .."},
462 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT,
463 "Generate a down event", "down"},
464 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT,
465 "Enable option", "enable option .."},
466 {"link", "datalink", LinkCommand, LOCAL_AUTH,
467 "Link specific commands", "link name command ..."},
468 {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
469 "Load settings", "load [remote]"},
470 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
476 "Open an FSM", "open [lcp|ccp|ipcp]", NULL},
477 {NULL, "open!", OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
478 "Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1},
479 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
480 "Password for manipulation", "passwd LocalPassword"},
481 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
482 "Quit PPP program", "quit|bye [all]"},
483 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,
484 "Remove a link", "remove"},
485 {"rename", "mv", RenameCommand, LOCAL_AUTH | LOCAL_CX,

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

836
837 return 0;
838}
839
840static int
841OpenCommand(struct cmdargs const *arg)
842{
843 if (arg->argc == arg->argn)
471 "Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1},
472 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
473 "Password for manipulation", "passwd LocalPassword"},
474 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
475 "Quit PPP program", "quit|bye [all]"},
476 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX,
477 "Remove a link", "remove"},
478 {"rename", "mv", RenameCommand, LOCAL_AUTH | LOCAL_CX,

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

829
830 return 0;
831}
832
833static int
834OpenCommand(struct cmdargs const *arg)
835{
836 if (arg->argc == arg->argn)
844 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL,
845 arg->cmd->args ? 1 : 0);
837 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL, 1);
846 else if (arg->argc == arg->argn + 1) {
847 if (!strcasecmp(arg->argv[arg->argn], "lcp")) {
848 struct datalink *cx = arg->cx ?
849 arg->cx : bundle2datalink(arg->bundle, NULL);
850 if (cx) {
851 if (cx->physical->link.lcp.fsm.state == ST_OPENED)
852 fsm_Reopen(&cx->physical->link.lcp.fsm);
853 else
838 else if (arg->argc == arg->argn + 1) {
839 if (!strcasecmp(arg->argv[arg->argn], "lcp")) {
840 struct datalink *cx = arg->cx ?
841 arg->cx : bundle2datalink(arg->bundle, NULL);
842 if (cx) {
843 if (cx->physical->link.lcp.fsm.state == ST_OPENED)
844 fsm_Reopen(&cx->physical->link.lcp.fsm);
845 else
854 bundle_Open(arg->bundle, cx->name, PHYS_ALL,
855 arg->cmd->args ? 1 : 0);
846 bundle_Open(arg->bundle, cx->name, PHYS_ALL, 1);
856 } else
857 log_Printf(LogWARN, "open lcp: You must specify a link\n");
858 } else if (!strcasecmp(arg->argv[arg->argn], "ccp")) {
859 struct fsm *fp;
860
861 fp = &command_ChooseLink(arg)->ccp.fsm;
862 if (fp->link->lcp.fsm.state != ST_OPENED)
863 log_Printf(LogWARN, "open: LCP must be open before opening CCP\n");

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

874 }
875 }
876 } else if (!strcasecmp(arg->argv[arg->argn], "ipcp")) {
877 if (arg->cx)
878 log_Printf(LogWARN, "open ipcp: You need not specify a link\n");
879 if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED)
880 fsm_Reopen(&arg->bundle->ncp.ipcp.fsm);
881 else
847 } else
848 log_Printf(LogWARN, "open lcp: You must specify a link\n");
849 } else if (!strcasecmp(arg->argv[arg->argn], "ccp")) {
850 struct fsm *fp;
851
852 fp = &command_ChooseLink(arg)->ccp.fsm;
853 if (fp->link->lcp.fsm.state != ST_OPENED)
854 log_Printf(LogWARN, "open: LCP must be open before opening CCP\n");

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

865 }
866 }
867 } else if (!strcasecmp(arg->argv[arg->argn], "ipcp")) {
868 if (arg->cx)
869 log_Printf(LogWARN, "open ipcp: You need not specify a link\n");
870 if (arg->bundle->ncp.ipcp.fsm.state == ST_OPENED)
871 fsm_Reopen(&arg->bundle->ncp.ipcp.fsm);
872 else
882 bundle_Open(arg->bundle, NULL, PHYS_ALL, arg->cmd->args ? 1 : 0);
873 bundle_Open(arg->bundle, NULL, PHYS_ALL, 1);
883 } else
884 return -1;
885 } else
886 return -1;
887
888 return 0;
889}
890

--- 1230 unchanged lines hidden ---
874 } else
875 return -1;
876 } else
877 return -1;
878
879 return 0;
880}
881

--- 1230 unchanged lines hidden ---