Deleted Added
full compact
command.c (25908) command.c (26031)
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.46 1997/05/14 01:18:50 brian Exp $
20 * $Id: command.c,v 1.47 1997/05/19 01:59:59 brian Exp $
21 *
22 */
23#include <sys/types.h>
24#include <ctype.h>
25#include <termios.h>
26#include <sys/wait.h>
27#include <time.h>
21 *
22 */
23#include <sys/types.h>
24#include <ctype.h>
25#include <termios.h>
26#include <sys/wait.h>
27#include <time.h>
28#include <netdb.h>
29#include <sys/socket.h>
30#include <netinet/in.h>
31#include <arpa/inet.h>
32#include <net/route.h>
33#include <paths.h>
34#include <alias.h>
28#include "fsm.h"
29#include "phase.h"
30#include "lcp.h"
31#include "ipcp.h"
32#include "modem.h"
33#include "filter.h"
34#include "command.h"
35#include "fsm.h"
36#include "phase.h"
37#include "lcp.h"
38#include "ipcp.h"
39#include "modem.h"
40#include "filter.h"
41#include "command.h"
42#include "alias_cmd.h"
35#include "hdlc.h"
36#include "vars.h"
37#include "systems.h"
38#include "chat.h"
43#include "hdlc.h"
44#include "vars.h"
45#include "systems.h"
46#include "chat.h"
39#include <netdb.h>
40#include <sys/socket.h>
41#include <arpa/inet.h>
42#include <net/route.h>
43#include "os.h"
47#include "os.h"
44#include <paths.h>
45#include "chat.h"
46
47extern void Cleanup(), TtyTermMode(), PacketMode();
48extern int EnableCommand(), DisableCommand(), DisplayCommand();
49extern int AcceptCommand(), DenyCommand();
48#include "chat.h"
49
50extern void Cleanup(), TtyTermMode(), PacketMode();
51extern int EnableCommand(), DisableCommand(), DisplayCommand();
52extern int AcceptCommand(), DenyCommand();
53static int AliasCommand();
50extern int LocalAuthCommand();
51extern int LoadCommand(), SaveCommand();
52extern int ChangeParity(char *);
53extern int SelectSystem();
54extern int ShowRoute();
55extern void TtyOldMode(), TtyCommandMode();
56extern struct pppvars pppVars;
57extern struct cmdtab const SetCommands[];

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

278 { "set", "setup", SetCommand, LOCAL_AUTH,
279 "Set parameters", "var value"},
280 { "shell", "!", ShellCommand, LOCAL_AUTH,
281 "Run a subshell", "[sh command]"},
282 { "show", NULL, ShowCommand, LOCAL_AUTH,
283 "Show status and statictics", "var"},
284 { "term", NULL, TerminalCommand,LOCAL_AUTH,
285 "Enter to terminal mode", StrNull},
54extern int LocalAuthCommand();
55extern int LoadCommand(), SaveCommand();
56extern int ChangeParity(char *);
57extern int SelectSystem();
58extern int ShowRoute();
59extern void TtyOldMode(), TtyCommandMode();
60extern struct pppvars pppVars;
61extern struct cmdtab const SetCommands[];

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

282 { "set", "setup", SetCommand, LOCAL_AUTH,
283 "Set parameters", "var value"},
284 { "shell", "!", ShellCommand, LOCAL_AUTH,
285 "Run a subshell", "[sh command]"},
286 { "show", NULL, ShowCommand, LOCAL_AUTH,
287 "Show status and statictics", "var"},
288 { "term", NULL, TerminalCommand,LOCAL_AUTH,
289 "Enter to terminal mode", StrNull},
290 { "alias", NULL, AliasCommand, LOCAL_AUTH,
291 "alias control", "option [yes|no]"},
286 { "quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
287 "Quit PPP program", "[all]"},
288 { "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
289 "Display this message", "[command]", (void *)Commands },
290 { NULL, "down", DownCommand, LOCAL_AUTH,
291 "Generate down event", StrNull},
292 { NULL, NULL, NULL },
293};

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

1203 } else if (argc == 1 && strcasecmp(argv[0], "ALL") == 0) {
1204 DeleteIfRoutes(0);
1205 } else {
1206 printf("Usage: %s %s\n", list->name, list->syntax);
1207 }
1208 return(1);
1209}
1210
292 { "quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
293 "Quit PPP program", "[all]"},
294 { "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
295 "Display this message", "[command]", (void *)Commands },
296 { NULL, "down", DownCommand, LOCAL_AUTH,
297 "Generate down event", StrNull},
298 { NULL, NULL, NULL },
299};

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

1209 } else if (argc == 1 && strcasecmp(argv[0], "ALL") == 0) {
1210 DeleteIfRoutes(0);
1211 } else {
1212 printf("Usage: %s %s\n", list->name, list->syntax);
1213 }
1214 return(1);
1215}
1216
1217
1218static int AliasEnable();
1219static int AliasOption();
1220
1221
1222static struct cmdtab const AliasCommands[] =
1223{
1224 { "enable", NULL, AliasEnable, LOCAL_AUTH,
1225 "enable IP aliasing", "[yes|no]"},
1226 { "port", NULL, AliasRedirectPort, LOCAL_AUTH,
1227 "port redirection", "[proto addr_local:port_local port_alias]"},
1228 { "addr", NULL, AliasRedirectAddr, LOCAL_AUTH,
1229 "static address translation", "[addr_local addr_alias]"},
1230 { "deny_incoming", NULL, AliasOption, LOCAL_AUTH,
1231 "stop incoming connections", "[yes|no]",
1232 (void*)PKT_ALIAS_DENY_INCOMING},
1233 { "log", NULL, AliasOption, LOCAL_AUTH,
1234 "log aliasing link creation", "[yes|no]",
1235 (void*)PKT_ALIAS_LOG},
1236 { "same_ports", NULL, AliasOption, LOCAL_AUTH,
1237 "try to leave port numbers unchanged", "[yes|no]",
1238 (void*)PKT_ALIAS_SAME_PORTS},
1239 { "use_sockets", NULL, AliasOption, LOCAL_AUTH,
1240 "allocate host sockets", "[yes|no]",
1241 (void*)PKT_ALIAS_USE_SOCKETS },
1242 { "unregistered_only", NULL, AliasOption, LOCAL_AUTH,
1243 "alias unregistered (private) IP address space only", "[yes|no]",
1244 (void*)PKT_ALIAS_UNREGISTERED_ONLY},
1245 { "help", "?", HelpCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
1246 "Display this message", StrNull,
1247 (void *)AliasCommands},
1248 { NULL, NULL, NULL },
1249};
1250
1251
1252static int
1253AliasCommand(list, argc, argv)
1254struct cmdtab *list;
1255int argc;
1256char **argv;
1257{
1258 int val = 1;
1259
1260 if (argc > 0)
1261 val = FindExec(AliasCommands, argc, argv);
1262 else
1263 printf("Use `alias help' to get a list or `alias help <option>' for syntax h
1264elp.\n");
1265 return(val);
1266}
1267
1268
1269static int
1270AliasEnable(list, argc, argv)
1271struct cmdtab *list;
1272int argc;
1273char **argv;
1274{
1275 if (argc == 1 && strcmp(argv[0], "yes") == 0) {
1276 mode |= MODE_ALIAS;
1277 } else if (argc == 1 && strcmp(argv[0], "no") == 0) {
1278 mode &= ~MODE_ALIAS;
1279 } else {
1280 printf("Usage: alias %s %s\n", list->name, list->syntax);
1281 }
1282 return(1);
1283}
1284
1285
1286static int
1287AliasOption(list, argc, argv, param)
1288struct cmdtab *list;
1289int argc;
1290char **argv;
1291void* param;
1292{
1293 if (argc == 1 && strcmp(argv[0], "yes") == 0) {
1294 SetPacketAliasMode((unsigned)param, (unsigned)param);
1295 } else if (argc == 1 && strcmp(argv[0], "no") == 0) {
1296 SetPacketAliasMode(0, (unsigned)param);
1297 } else {
1298 printf("Usage: alias %s %s\n", list->name, list->syntax);
1299 }
1300 return(1);
1301}