command.c (0f781a72523acc386d0202547e14c36069445d5a) | command.c (7cf368eb42edc6d7738f431289a1e3e2203421e6) |
---|---|
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.173 1998/10/27 22:53:19 brian Exp $ | 20 * $Id: command.c,v 1.174 1998/10/27 22:53:22 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> --- 100 unchanged lines hidden (view full) --- 129#define NEG_PPPDDEFLATE 45 130#define NEG_PRED1 46 131#define NEG_PROTOCOMP 47 132#define NEG_SHORTSEQ 48 133#define NEG_VJCOMP 49 134#define NEG_DNS 50 135 136const 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> --- 100 unchanged lines hidden (view full) --- 129#define NEG_PPPDDEFLATE 45 130#define NEG_PRED1 46 131#define NEG_PROTOCOMP 47 132#define NEG_SHORTSEQ 48 133#define NEG_VJCOMP 49 134#define NEG_DNS 50 135 136const char Version[] = "2.0"; |
137const char VersionDate[] = "$Date: 1998/10/27 22:53:19 $"; | 137const char VersionDate[] = "$Date: 1998/10/27 22:53:22 $"; |
138 139static int ShowCommand(struct cmdargs const *); 140static int TerminalCommand(struct cmdargs const *); 141static int QuitCommand(struct cmdargs const *); 142static int OpenCommand(struct cmdargs const *); 143static int CloseCommand(struct cmdargs const *); 144static int DownCommand(struct cmdargs const *); 145static int SetCommand(struct cmdargs const *); --- 123 unchanged lines hidden (view full) --- 269 log_Printf(LogWARN, "%s -> %s: target name already exists\n", 270 arg->cx->name, arg->argv[arg->argn]); 271 return 1; 272} 273 274int 275LoadCommand(struct cmdargs const *arg) 276{ | 138 139static int ShowCommand(struct cmdargs const *); 140static int TerminalCommand(struct cmdargs const *); 141static int QuitCommand(struct cmdargs const *); 142static int OpenCommand(struct cmdargs const *); 143static int CloseCommand(struct cmdargs const *); 144static int DownCommand(struct cmdargs const *); 145static int SetCommand(struct cmdargs const *); --- 123 unchanged lines hidden (view full) --- 269 log_Printf(LogWARN, "%s -> %s: target name already exists\n", 270 arg->cx->name, arg->argv[arg->argn]); 271 return 1; 272} 273 274int 275LoadCommand(struct cmdargs const *arg) 276{ |
277 const char *name; | 277 const char *err; 278 int n, mode; |
278 | 279 |
279 if (arg->argc > arg->argn) 280 name = arg->argv[arg->argn]; 281 else 282 name = "default"; | 280 mode = arg->bundle->phys_type.all; |
283 | 281 |
284 if (!system_IsValid(name, arg->prompt, arg->bundle->phys_type.all)) { 285 log_Printf(LogWARN, "%s: Label not allowed\n", name); | 282 if (arg->argn < arg->argc) { 283 for (n = arg->argn; n < arg->argc; n++) 284 if ((err = system_IsValid(arg->argv[n], arg->prompt, mode)) != NULL) { 285 log_Printf(LogWARN, "%s: %s\n", arg->argv[n], err); 286 return 1; 287 } 288 289 for (n = arg->argn; n < arg->argc; n++) { 290 bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]); 291 system_Select(arg->bundle, arg->argv[n], CONFFILE, arg->prompt, arg->cx); 292 } 293 bundle_SetLabel(arg->bundle, arg->argv[arg->argc - 1]); 294 } else if ((err = system_IsValid("default", arg->prompt, mode)) != NULL) { 295 log_Printf(LogWARN, "default: %s\n", err); |
286 return 1; 287 } else { | 296 return 1; 297 } else { |
288 /* 289 * Set the label before & after so that `set enddisc' works and 290 * we handle nested `load' commands. 291 */ 292 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL); 293 if (system_Select(arg->bundle, name, CONFFILE, arg->prompt, arg->cx) < 0) { 294 bundle_SetLabel(arg->bundle, NULL); 295 log_Printf(LogWARN, "%s: label not found.\n", name); 296 return -1; 297 } 298 bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL); | 298 bundle_SetLabel(arg->bundle, "default"); 299 system_Select(arg->bundle, "default", CONFFILE, arg->prompt, arg->cx); 300 bundle_SetLabel(arg->bundle, "default"); |
299 } | 301 } |
302 |
|
300 return 0; 301} 302 303int 304SaveCommand(struct cmdargs const *arg) 305{ 306 log_Printf(LogWARN, "save command is not implemented (yet).\n"); 307 return 1; --- 301 unchanged lines hidden (view full) --- 609 "Close an FSM", "close [lcp|ccp]"}, 610 {"delete", NULL, DeleteCommand, LOCAL_AUTH, 611 "delete route", "delete dest", NULL}, 612 {NULL, "delete!", DeleteCommand, LOCAL_AUTH, 613 "delete a route if it exists", "delete! dest", (void *)1}, 614 {"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 615 "Deny option request", "deny option .."}, 616 {"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT, | 303 return 0; 304} 305 306int 307SaveCommand(struct cmdargs const *arg) 308{ 309 log_Printf(LogWARN, "save command is not implemented (yet).\n"); 310 return 1; --- 301 unchanged lines hidden (view full) --- 612 "Close an FSM", "close [lcp|ccp]"}, 613 {"delete", NULL, DeleteCommand, LOCAL_AUTH, 614 "delete route", "delete dest", NULL}, 615 {NULL, "delete!", DeleteCommand, LOCAL_AUTH, 616 "delete a route if it exists", "delete! dest", (void *)1}, 617 {"deny", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 618 "Deny option request", "deny option .."}, 619 {"dial", "call", DialCommand, LOCAL_AUTH | LOCAL_CX_OPT, |
617 "Dial and login", "dial|call [remote]", NULL}, | 620 "Dial and login", "dial|call [system ...]", NULL}, |
618 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 619 "Disable option", "disable option .."}, 620 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT, 621 "Generate a down event", "down"}, 622 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 623 "Enable option", "enable option .."}, 624 {"iface", "interface", RunListCommand, LOCAL_AUTH, 625 "interface control", "iface option ...", IfaceCommands}, 626 {"link", "datalink", LinkCommand, LOCAL_AUTH, 627 "Link specific commands", "link name command ..."}, 628 {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT, | 621 {"disable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 622 "Disable option", "disable option .."}, 623 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX_OPT, 624 "Generate a down event", "down"}, 625 {"enable", NULL, NegotiateCommand, LOCAL_AUTH | LOCAL_CX_OPT, 626 "Enable option", "enable option .."}, 627 {"iface", "interface", RunListCommand, LOCAL_AUTH, 628 "interface control", "iface option ...", IfaceCommands}, 629 {"link", "datalink", LinkCommand, LOCAL_AUTH, 630 "Link specific commands", "link name command ..."}, 631 {"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT, |
629 "Load settings", "load [remote]"}, | 632 "Load settings", "load [system ...]"}, |
630 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT, 631 "Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1}, 632 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH, 633 "Password for manipulation", "passwd LocalPassword"}, 634 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH, 635 "Quit PPP program", "quit|bye [all]"}, 636 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX, 637 "Remove a link", "remove"}, --- 1826 unchanged lines hidden --- | 633 {"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT, 634 "Open an FSM", "open! [lcp|ccp|ipcp]", (void *)1}, 635 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH, 636 "Password for manipulation", "passwd LocalPassword"}, 637 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH, 638 "Quit PPP program", "quit|bye [all]"}, 639 {"remove", "rm", RemoveCommand, LOCAL_AUTH | LOCAL_CX, 640 "Remove a link", "remove"}, --- 1826 unchanged lines hidden --- |