command.c (44279) | command.c (44305) |
---|---|
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.182 1999/02/18 00:52:12 brian Exp $ | 20 * $Id: command.c,v 1.183 1999/02/25 20:05:54 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> --- 107 unchanged lines hidden (view full) --- 136#define NEG_PPPDDEFLATE 47 137#define NEG_PRED1 48 138#define NEG_PROTOCOMP 49 139#define NEG_SHORTSEQ 50 140#define NEG_VJCOMP 51 141#define NEG_DNS 52 142 143const char Version[] = "2.11"; | 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> --- 107 unchanged lines hidden (view full) --- 136#define NEG_PPPDDEFLATE 47 137#define NEG_PRED1 48 138#define NEG_PROTOCOMP 49 139#define NEG_SHORTSEQ 50 140#define NEG_VJCOMP 51 141#define NEG_DNS 52 142 143const char Version[] = "2.11"; |
144const char VersionDate[] = "$Date: 1999/02/18 00:52:12 $"; | 144const char VersionDate[] = "$Date: 1999/02/25 20:05:54 $"; |
145 146static int ShowCommand(struct cmdargs const *); 147static int TerminalCommand(struct cmdargs const *); 148static int QuitCommand(struct cmdargs const *); 149static int OpenCommand(struct cmdargs const *); 150static int CloseCommand(struct cmdargs const *); 151static int DownCommand(struct cmdargs const *); 152static int SetCommand(struct cmdargs const *); --- 1161 unchanged lines hidden (view full) --- 1314 if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr, 1315 arg->bundle->phys_type.all & PHYS_AUTO)) 1316 return 4; 1317 1318 return 0; 1319} 1320 1321static int | 145 146static int ShowCommand(struct cmdargs const *); 147static int TerminalCommand(struct cmdargs const *); 148static int QuitCommand(struct cmdargs const *); 149static int OpenCommand(struct cmdargs const *); 150static int CloseCommand(struct cmdargs const *); 151static int DownCommand(struct cmdargs const *); 152static int SetCommand(struct cmdargs const *); --- 1161 unchanged lines hidden (view full) --- 1314 if (hisaddr && !ipcp_UseHisaddr(arg->bundle, hisaddr, 1315 arg->bundle->phys_type.all & PHYS_AUTO)) 1316 return 4; 1317 1318 return 0; 1319} 1320 1321static int |
1322SetRetry(int argc, char const *const *argv, u_int *timeout, u_int *maxreq, 1323 u_int *maxtrm, int def) 1324{ 1325 if (argc == 0) { 1326 *timeout = DEF_FSMRETRY; 1327 *maxreq = def; 1328 if (maxtrm != NULL) 1329 *maxtrm = def; 1330 } else { 1331 long l = atol(argv[0]); 1332 1333 if (l < MIN_FSMRETRY) { 1334 log_Printf(LogWARN, "%ld: Invalid FSM retry period - min %d\n", 1335 l, MIN_FSMRETRY); 1336 return 1; 1337 } else 1338 *timeout = l; 1339 1340 if (argc > 1) { 1341 l = atol(argv[1]); 1342 if (l < 1) { 1343 log_Printf(LogWARN, "%ld: Invalid FSM REQ tries - changed to 1\n", l); 1344 l = 1; 1345 } 1346 *maxreq = l; 1347 1348 if (argc > 2 && maxtrm != NULL) { 1349 l = atol(argv[2]); 1350 if (l < 1) { 1351 log_Printf(LogWARN, "%ld: Invalid FSM TRM tries - changed to 1\n", l); 1352 l = 1; 1353 } 1354 *maxtrm = l; 1355 } 1356 } 1357 } 1358 1359 return 0; 1360} 1361 1362static int |
|
1322SetVariable(struct cmdargs const *arg) 1323{ 1324 long long_val, param = (long)arg->cmd->args; 1325 int mode, dummyint; 1326 const char *argp; 1327 struct datalink *cx = arg->cx; /* LOCAL_CX uses this */ 1328 const char *err = NULL; 1329 struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */ --- 213 unchanged lines hidden (view full) --- 1543 log_Printf(LogWARN, "%ld: Invalid lqr period - min %d\n", 1544 long_val, MIN_LQRPERIOD); 1545 return 1; 1546 } else 1547 l->lcp.cfg.lqrperiod = long_val; 1548 break; 1549 1550 case VAR_LCPRETRY: | 1363SetVariable(struct cmdargs const *arg) 1364{ 1365 long long_val, param = (long)arg->cmd->args; 1366 int mode, dummyint; 1367 const char *argp; 1368 struct datalink *cx = arg->cx; /* LOCAL_CX uses this */ 1369 const char *err = NULL; 1370 struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */ --- 213 unchanged lines hidden (view full) --- 1584 log_Printf(LogWARN, "%ld: Invalid lqr period - min %d\n", 1585 long_val, MIN_LQRPERIOD); 1586 return 1; 1587 } else 1588 l->lcp.cfg.lqrperiod = long_val; 1589 break; 1590 1591 case VAR_LCPRETRY: |
1551 long_val = atol(argp); 1552 if (long_val < MIN_FSMRETRY) { 1553 log_Printf(LogWARN, "%ld: Invalid LCP FSM retry period - min %d\n", 1554 long_val, MIN_FSMRETRY); 1555 return 1; 1556 } else 1557 cx->physical->link.lcp.cfg.fsmretry = long_val; | 1592 return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, 1593 &cx->physical->link.lcp.cfg.fsm.timeout, 1594 &cx->physical->link.lcp.cfg.fsm.maxreq, 1595 &cx->physical->link.lcp.cfg.fsm.maxtrm, DEF_FSMTRIES); |
1558 break; 1559 1560 case VAR_CHAPRETRY: | 1596 break; 1597 1598 case VAR_CHAPRETRY: |
1561 long_val = atol(argp); 1562 if (long_val < MIN_FSMRETRY) { 1563 log_Printf(LogWARN, "%ld: Invalid CHAP FSM retry period - min %d\n", 1564 long_val, MIN_FSMRETRY); 1565 return 1; 1566 } else 1567 cx->chap.auth.cfg.fsmretry = long_val; | 1599 return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, 1600 &cx->chap.auth.cfg.fsm.timeout, 1601 &cx->chap.auth.cfg.fsm.maxreq, NULL, DEF_FSMAUTHTRIES); |
1568 break; 1569 1570 case VAR_PAPRETRY: | 1602 break; 1603 1604 case VAR_PAPRETRY: |
1571 long_val = atol(argp); 1572 if (long_val < MIN_FSMRETRY) { 1573 log_Printf(LogWARN, "%ld: Invalid PAP FSM retry period - min %d\n", 1574 long_val, MIN_FSMRETRY); 1575 return 1; 1576 } else 1577 cx->pap.cfg.fsmretry = long_val; | 1605 return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, 1606 &cx->pap.cfg.fsm.timeout, &cx->pap.cfg.fsm.maxreq, 1607 NULL, DEF_FSMAUTHTRIES); |
1578 break; 1579 1580 case VAR_CCPRETRY: | 1608 break; 1609 1610 case VAR_CCPRETRY: |
1581 long_val = atol(argp); 1582 if (long_val < MIN_FSMRETRY) { 1583 log_Printf(LogWARN, "%ld: Invalid CCP FSM retry period - min %d\n", 1584 long_val, MIN_FSMRETRY); 1585 return 1; 1586 } else 1587 l->ccp.cfg.fsmretry = long_val; | 1611 return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, 1612 &l->ccp.cfg.fsm.timeout, &l->ccp.cfg.fsm.maxreq, 1613 &l->ccp.cfg.fsm.maxtrm, DEF_FSMTRIES); |
1588 break; 1589 1590 case VAR_IPCPRETRY: | 1614 break; 1615 1616 case VAR_IPCPRETRY: |
1591 long_val = atol(argp); 1592 if (long_val < MIN_FSMRETRY) { 1593 log_Printf(LogWARN, "%ld: Invalid IPCP FSM retry period - min %d\n", 1594 long_val, MIN_FSMRETRY); 1595 return 1; 1596 } else 1597 arg->bundle->ncp.ipcp.cfg.fsmretry = long_val; | 1617 return SetRetry(arg->argc - arg->argn, arg->argv + arg->argn, 1618 &arg->bundle->ncp.ipcp.cfg.fsm.timeout, 1619 &arg->bundle->ncp.ipcp.cfg.fsm.maxreq, 1620 &arg->bundle->ncp.ipcp.cfg.fsm.maxtrm, DEF_FSMTRIES); |
1598 break; 1599 1600 case VAR_NBNS: 1601 case VAR_DNS: 1602 if (param == VAR_DNS) 1603 addr = arg->bundle->ncp.ipcp.cfg.ns.dns; 1604 else 1605 addr = arg->bundle->ncp.ipcp.cfg.ns.nbns; --- 136 unchanged lines hidden (view full) --- 1742 "auto link [de]activation", "set autoload maxtime maxload mintime minload", 1743 (const void *)VAR_AUTOLOAD}, 1744 {"callback", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1745 "callback control", "set callback [none|auth|cbcp|" 1746 "E.164 *|number[,number]...]...", (const void *)VAR_CALLBACK}, 1747 {"cbcp", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1748 "CBCP control", "set cbcp [*|phone[,phone...] [delay [timeout]]]", 1749 (const void *)VAR_CBCP}, | 1621 break; 1622 1623 case VAR_NBNS: 1624 case VAR_DNS: 1625 if (param == VAR_DNS) 1626 addr = arg->bundle->ncp.ipcp.cfg.ns.dns; 1627 else 1628 addr = arg->bundle->ncp.ipcp.cfg.ns.nbns; --- 136 unchanged lines hidden (view full) --- 1765 "auto link [de]activation", "set autoload maxtime maxload mintime minload", 1766 (const void *)VAR_AUTOLOAD}, 1767 {"callback", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1768 "callback control", "set callback [none|auth|cbcp|" 1769 "E.164 *|number[,number]...]...", (const void *)VAR_CALLBACK}, 1770 {"cbcp", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1771 "CBCP control", "set cbcp [*|phone[,phone...] [delay [timeout]]]", 1772 (const void *)VAR_CBCP}, |
1750 {"ccpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1751 "FSM retry period", "set ccpretry value", (const void *)VAR_CCPRETRY}, | 1773 {"ccpretry", "ccpretries", SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1774 "CCP retries", "set ccpretry value [attempts]", (const void *)VAR_CCPRETRY}, |
1752 {"cd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Carrier delay requirement", 1753 "set cd value[!]", (const void *)VAR_CD}, | 1775 {"cd", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Carrier delay requirement", 1776 "set cd value[!]", (const void *)VAR_CD}, |
1754 {"chapretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1755 "CHAP retry period", "set chapretry value", (const void *)VAR_CHAPRETRY}, | 1777 {"chapretry", "chapretries", SetVariable, LOCAL_AUTH | LOCAL_CX, 1778 "CHAP retries", "set chapretry value [attempts]", 1779 (const void *)VAR_CHAPRETRY}, |
1756 {"choked", NULL, SetVariable, LOCAL_AUTH, 1757 "choked timeout", "set choked [secs]", (const void *)VAR_CHOKED}, 1758 {"ctsrts", "crtscts", SetCtsRts, LOCAL_AUTH | LOCAL_CX, 1759 "Use hardware flow control", "set ctsrts [on|off]"}, 1760 {"deflate", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1761 "deflate window sizes", "set deflate out-winsize in-winsize", 1762 (const void *) VAR_WINSIZE}, 1763 {"device", "line", SetVariable, LOCAL_AUTH | LOCAL_CX, --- 10 unchanged lines hidden (view full) --- 1774 {"filter", NULL, filter_Set, LOCAL_AUTH, 1775 "packet filters", "set filter alive|dial|in|out rule-no permit|deny " 1776 "[src_addr[/width]] [dst_addr[/width]] [tcp|udp|icmp [src [lt|eq|gt port]] " 1777 "[dst [lt|eq|gt port]] [estab] [syn] [finrst]]"}, 1778 {"hangup", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1779 "hangup script", "set hangup chat-script", (const void *) VAR_HANGUP}, 1780 {"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "destination address", 1781 "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"}, | 1780 {"choked", NULL, SetVariable, LOCAL_AUTH, 1781 "choked timeout", "set choked [secs]", (const void *)VAR_CHOKED}, 1782 {"ctsrts", "crtscts", SetCtsRts, LOCAL_AUTH | LOCAL_CX, 1783 "Use hardware flow control", "set ctsrts [on|off]"}, 1784 {"deflate", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1785 "deflate window sizes", "set deflate out-winsize in-winsize", 1786 (const void *) VAR_WINSIZE}, 1787 {"device", "line", SetVariable, LOCAL_AUTH | LOCAL_CX, --- 10 unchanged lines hidden (view full) --- 1798 {"filter", NULL, filter_Set, LOCAL_AUTH, 1799 "packet filters", "set filter alive|dial|in|out rule-no permit|deny " 1800 "[src_addr[/width]] [dst_addr[/width]] [tcp|udp|icmp [src [lt|eq|gt port]] " 1801 "[dst [lt|eq|gt port]] [estab] [syn] [finrst]]"}, 1802 {"hangup", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1803 "hangup script", "set hangup chat-script", (const void *) VAR_HANGUP}, 1804 {"ifaddr", NULL, SetInterfaceAddr, LOCAL_AUTH, "destination address", 1805 "set ifaddr [src-addr [dst-addr [netmask [trg-addr]]]]"}, |
1782 {"ipcpretry", NULL, SetVariable, LOCAL_AUTH, 1783 "FSM retry period", "set ipcpretry value", (const void *)VAR_IPCPRETRY}, 1784 {"lcpretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1785 "FSM retry period", "set lcpretry value", (const void *)VAR_LCPRETRY}, | 1806 {"ipcpretry", "ipcpretries", SetVariable, LOCAL_AUTH, "IPCP retries", 1807 "set ipcpretry value [attempts]", (const void *)VAR_IPCPRETRY}, 1808 {"lcpretry", "lcpretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "LCP retries", 1809 "set lcpretry value [attempts]", (const void *)VAR_LCPRETRY}, |
1786 {"log", NULL, log_SetLevel, LOCAL_AUTH, "log level", 1787 "set log [local] [+|-]async|cbcp|ccp|chat|command|connect|debug|hdlc|id0|" 1788 "ipcp|lcp|lqm|phase|tcp/ip|timer|tun..."}, 1789 {"login", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1790 "login script", "set login chat-script", (const void *) VAR_LOGIN}, 1791 {"lqrperiod", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1792 "LQR period", "set lqrperiod value", (const void *)VAR_LQRPERIOD}, 1793 {"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "mode value", 1794 "set mode interactive|auto|ddial|background", (const void *)VAR_MODE}, 1795 {"mrru", NULL, SetVariable, LOCAL_AUTH, "MRRU value", 1796 "set mrru value", (const void *)VAR_MRRU}, 1797 {"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1798 "MRU value", "set mru value", (const void *)VAR_MRU}, 1799 {"mtu", NULL, SetVariable, LOCAL_AUTH, 1800 "interface MTU value", "set mtu value", (const void *)VAR_MTU}, 1801 {"nbns", NULL, SetVariable, LOCAL_AUTH, "NetBIOS Name Server", 1802 "set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS}, 1803 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode", 1804 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE}, | 1810 {"log", NULL, log_SetLevel, LOCAL_AUTH, "log level", 1811 "set log [local] [+|-]async|cbcp|ccp|chat|command|connect|debug|hdlc|id0|" 1812 "ipcp|lcp|lqm|phase|tcp/ip|timer|tun..."}, 1813 {"login", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1814 "login script", "set login chat-script", (const void *) VAR_LOGIN}, 1815 {"lqrperiod", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1816 "LQR period", "set lqrperiod value", (const void *)VAR_LQRPERIOD}, 1817 {"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "mode value", 1818 "set mode interactive|auto|ddial|background", (const void *)VAR_MODE}, 1819 {"mrru", NULL, SetVariable, LOCAL_AUTH, "MRRU value", 1820 "set mrru value", (const void *)VAR_MRRU}, 1821 {"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 1822 "MRU value", "set mru value", (const void *)VAR_MRU}, 1823 {"mtu", NULL, SetVariable, LOCAL_AUTH, 1824 "interface MTU value", "set mtu value", (const void *)VAR_MTU}, 1825 {"nbns", NULL, SetVariable, LOCAL_AUTH, "NetBIOS Name Server", 1826 "set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS}, 1827 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode", 1828 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE}, |
1805 {"papretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 1806 "PAP retry period", "set papretry value", (const void *)VAR_PAPRETRY}, | 1829 {"papretry", "papretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "PAP retries", 1830 "set papretry value [attempts]", (const void *)VAR_PAPRETRY}, |
1807 {"parity", NULL, SetModemParity, LOCAL_AUTH | LOCAL_CX, 1808 "modem parity", "set parity [odd|even|none]"}, 1809 {"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "telephone number(s)", 1810 "set phone phone1[:phone2[...]]", (const void *)VAR_PHONE}, 1811 {"proctitle", "title", SetProcTitle, LOCAL_AUTH, 1812 "Process title", "set proctitle [value]"}, 1813#ifndef NORADIUS 1814 {"radius", NULL, SetVariable, LOCAL_AUTH, --- 705 unchanged lines hidden --- | 1831 {"parity", NULL, SetModemParity, LOCAL_AUTH | LOCAL_CX, 1832 "modem parity", "set parity [odd|even|none]"}, 1833 {"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "telephone number(s)", 1834 "set phone phone1[:phone2[...]]", (const void *)VAR_PHONE}, 1835 {"proctitle", "title", SetProcTitle, LOCAL_AUTH, 1836 "Process title", "set proctitle [value]"}, 1837#ifndef NORADIUS 1838 {"radius", NULL, SetVariable, LOCAL_AUTH, --- 705 unchanged lines hidden --- |