command.c (32102) | command.c (32109) |
---|---|
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.120 1997/12/27 13:45:45 brian Exp $ | 20 * $Id: command.c,v 1.121 1997/12/29 22:23:10 brian Exp $ |
21 * 22 */ 23#include <sys/param.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> --- 311 unchanged lines hidden (view full) --- 340{ 341 return ShellCommand(arg, 0); 342} 343 344static struct cmdtab const Commands[] = { 345 {"accept", NULL, AcceptCommand, LOCAL_AUTH, 346 "accept option request", "accept option .."}, 347 {"add", NULL, AddCommand, LOCAL_AUTH, | 21 * 22 */ 23#include <sys/param.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> --- 311 unchanged lines hidden (view full) --- 340{ 341 return ShellCommand(arg, 0); 342} 343 344static struct cmdtab const Commands[] = { 345 {"accept", NULL, AcceptCommand, LOCAL_AUTH, 346 "accept option request", "accept option .."}, 347 {"add", NULL, AddCommand, LOCAL_AUTH, |
348 "add route", "add dest mask gateway"}, | 348 "add route", "add dest mask gateway", NULL}, 349 {"add!", NULL, AddCommand, LOCAL_AUTH, 350 "add or change route", "add! dest mask gateway", (void *)1}, |
349 {"allow", "auth", AllowCommand, LOCAL_AUTH, 350 "Allow ppp access", "allow users|modes ...."}, 351 {"bg", "!bg", BgShellCommand, LOCAL_AUTH, 352 "Run a background command", "[!]bg command"}, 353 {"close", NULL, CloseCommand, LOCAL_AUTH, 354 "Close connection", "close"}, 355 {"delete", NULL, DeleteCommand, LOCAL_AUTH, | 351 {"allow", "auth", AllowCommand, LOCAL_AUTH, 352 "Allow ppp access", "allow users|modes ...."}, 353 {"bg", "!bg", BgShellCommand, LOCAL_AUTH, 354 "Run a background command", "[!]bg command"}, 355 {"close", NULL, CloseCommand, LOCAL_AUTH, 356 "Close connection", "close"}, 357 {"delete", NULL, DeleteCommand, LOCAL_AUTH, |
356 "delete route", "delete dest"}, | 358 "delete route", "delete dest", NULL}, 359 {"delete!", NULL, DeleteCommand, LOCAL_AUTH, 360 "delete a route if it exists", "delete! dest", (void *)1}, |
357 {"deny", NULL, DenyCommand, LOCAL_AUTH, 358 "Deny option request", "deny option .."}, 359 {"dial", "call", DialCommand, LOCAL_AUTH, 360 "Dial and login", "dial|call [remote]"}, 361 {"disable", NULL, DisableCommand, LOCAL_AUTH, 362 "Disable option", "disable option .."}, 363 {"display", NULL, DisplayCommand, LOCAL_AUTH, 364 "Display option configs", "display"}, --- 1158 unchanged lines hidden (view full) --- 1523 gw = 2; 1524 } 1525 if (strcasecmp(arg->argv[gw], "HISADDR") == 0) 1526 gateway = IpcpInfo.his_ipaddr; 1527 else if (strcasecmp(arg->argv[gw], "INTERFACE") == 0) 1528 gateway.s_addr = INADDR_ANY; 1529 else 1530 gateway = GetIpAddr(arg->argv[gw]); | 361 {"deny", NULL, DenyCommand, LOCAL_AUTH, 362 "Deny option request", "deny option .."}, 363 {"dial", "call", DialCommand, LOCAL_AUTH, 364 "Dial and login", "dial|call [remote]"}, 365 {"disable", NULL, DisableCommand, LOCAL_AUTH, 366 "Disable option", "disable option .."}, 367 {"display", NULL, DisplayCommand, LOCAL_AUTH, 368 "Display option configs", "display"}, --- 1158 unchanged lines hidden (view full) --- 1527 gw = 2; 1528 } 1529 if (strcasecmp(arg->argv[gw], "HISADDR") == 0) 1530 gateway = IpcpInfo.his_ipaddr; 1531 else if (strcasecmp(arg->argv[gw], "INTERFACE") == 0) 1532 gateway.s_addr = INADDR_ANY; 1533 else 1534 gateway = GetIpAddr(arg->argv[gw]); |
1531 OsSetRoute(RTM_ADD, dest, gateway, netmask); | 1535 OsSetRoute(RTM_ADD, dest, gateway, netmask, arg->data ? 1 : 0); |
1532 return 0; 1533} 1534 1535static int 1536DeleteCommand(struct cmdargs const *arg) 1537{ 1538 struct in_addr dest, none; 1539 1540 if (arg->argc == 1) 1541 if(strcasecmp(arg->argv[0], "all") == 0) 1542 DeleteIfRoutes(0); 1543 else { 1544 if (strcasecmp(arg->argv[0], "MYADDR") == 0) 1545 dest = IpcpInfo.want_ipaddr; 1546 else if (strcasecmp(arg->argv[0], "default") == 0) 1547 dest.s_addr = INADDR_ANY; 1548 else 1549 dest = GetIpAddr(arg->argv[0]); 1550 none.s_addr = INADDR_ANY; | 1536 return 0; 1537} 1538 1539static int 1540DeleteCommand(struct cmdargs const *arg) 1541{ 1542 struct in_addr dest, none; 1543 1544 if (arg->argc == 1) 1545 if(strcasecmp(arg->argv[0], "all") == 0) 1546 DeleteIfRoutes(0); 1547 else { 1548 if (strcasecmp(arg->argv[0], "MYADDR") == 0) 1549 dest = IpcpInfo.want_ipaddr; 1550 else if (strcasecmp(arg->argv[0], "default") == 0) 1551 dest.s_addr = INADDR_ANY; 1552 else 1553 dest = GetIpAddr(arg->argv[0]); 1554 none.s_addr = INADDR_ANY; |
1551 OsSetRoute(RTM_DELETE, dest, none, none); | 1555 OsSetRoute(RTM_DELETE, dest, none, none, arg->data ? 1 : 0); |
1552 } 1553 else 1554 return -1; 1555 1556 return 0; 1557} 1558 1559#ifndef NOALIAS --- 114 unchanged lines hidden --- | 1556 } 1557 else 1558 return -1; 1559 1560 return 0; 1561} 1562 1563#ifndef NOALIAS --- 114 unchanged lines hidden --- |