command.c (78189) | command.c (78410) |
---|---|
1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * | 1/*- 2 * Copyright (c) 1996 - 2001 Brian Somers <brian@Awfulhak.org> 3 * based on work by Toshiharu OHNO <tony-o@iij.ad.jp> 4 * Internet Initiative Japan, Inc (IIJ) 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 11 unchanged lines hidden (view full) --- 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * |
28 * $FreeBSD: head/usr.sbin/ppp/command.c 78189 2001-06-13 21:52:19Z brian $ | 28 * $FreeBSD: head/usr.sbin/ppp/command.c 78410 2001-06-18 14:59:36Z brian $ |
29 */ 30 31#include <sys/param.h> 32#include <netinet/in_systm.h> 33#include <netinet/in.h> 34#include <netinet/ip.h> 35#include <arpa/inet.h> 36#include <sys/socket.h> --- 117 unchanged lines hidden (view full) --- 154#define NEG_PPPDDEFLATE 49 155#define NEG_PRED1 50 156#define NEG_PROTOCOMP 51 157#define NEG_SHORTSEQ 52 158#define NEG_VJCOMP 53 159#define NEG_MPPE 54 160#define NEG_CHAP81 55 161 | 29 */ 30 31#include <sys/param.h> 32#include <netinet/in_systm.h> 33#include <netinet/in.h> 34#include <netinet/ip.h> 35#include <arpa/inet.h> 36#include <sys/socket.h> --- 117 unchanged lines hidden (view full) --- 154#define NEG_PPPDDEFLATE 49 155#define NEG_PRED1 50 156#define NEG_PROTOCOMP 51 157#define NEG_SHORTSEQ 52 158#define NEG_VJCOMP 53 159#define NEG_MPPE 54 160#define NEG_CHAP81 55 161 |
162const char Version[] = "2.3.1"; | 162const char Version[] = "2.3.2"; |
163 164static int ShowCommand(struct cmdargs const *); 165static int TerminalCommand(struct cmdargs const *); 166static int QuitCommand(struct cmdargs const *); 167static int OpenCommand(struct cmdargs const *); 168static int CloseCommand(struct cmdargs const *); 169static int DownCommand(struct cmdargs const *); 170static int SetCommand(struct cmdargs const *); --- 1313 unchanged lines hidden (view full) --- 1484 return 0; 1485} 1486 1487static int 1488SetVariable(struct cmdargs const *arg) 1489{ 1490 long long_val, param = (long)arg->cmd->args; 1491 int mode, dummyint, f, first; | 163 164static int ShowCommand(struct cmdargs const *); 165static int TerminalCommand(struct cmdargs const *); 166static int QuitCommand(struct cmdargs const *); 167static int OpenCommand(struct cmdargs const *); 168static int CloseCommand(struct cmdargs const *); 169static int DownCommand(struct cmdargs const *); 170static int SetCommand(struct cmdargs const *); --- 1313 unchanged lines hidden (view full) --- 1484 return 0; 1485} 1486 1487static int 1488SetVariable(struct cmdargs const *arg) 1489{ 1490 long long_val, param = (long)arg->cmd->args; 1491 int mode, dummyint, f, first; |
1492 u_short *change; |
|
1492 const char *argp; 1493 struct datalink *cx = arg->cx; /* LOCAL_CX uses this */ 1494 const char *err = NULL; 1495 struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */ 1496 struct in_addr dummyaddr, *addr; 1497 1498 if (arg->argc > arg->argn) 1499 argp = arg->argv[arg->argn]; --- 173 unchanged lines hidden (view full) --- 1673 } else if (long_val > MAX_MRU) { 1674 log_Printf(LogWARN, "MRRU %ld: too big - max %d\n", long_val, MAX_MRU); 1675 return 1; 1676 } else 1677 arg->bundle->ncp.mp.cfg.mrru = long_val; 1678 break; 1679 1680 case VAR_MRU: | 1493 const char *argp; 1494 struct datalink *cx = arg->cx; /* LOCAL_CX uses this */ 1495 const char *err = NULL; 1496 struct link *l = command_ChooseLink(arg); /* LOCAL_CX_OPT uses this */ 1497 struct in_addr dummyaddr, *addr; 1498 1499 if (arg->argc > arg->argn) 1500 argp = arg->argv[arg->argn]; --- 173 unchanged lines hidden (view full) --- 1674 } else if (long_val > MAX_MRU) { 1675 log_Printf(LogWARN, "MRRU %ld: too big - max %d\n", long_val, MAX_MRU); 1676 return 1; 1677 } else 1678 arg->bundle->ncp.mp.cfg.mrru = long_val; 1679 break; 1680 1681 case VAR_MRU: |
1681 long_val = atol(argp); | 1682 switch(arg->argc - arg->argn) { 1683 case 1: 1684 if (argp[strspn(argp, "0123456789")] != '\0') 1685 return -1; 1686 case 0: 1687 long_val = atol(argp); 1688 change = &l->lcp.cfg.mru; 1689 if (long_val > l->lcp.cfg.max_mru) { 1690 log_Printf(LogWARN, "MRU %ld: too large - max set to %d\n", long_val, 1691 l->lcp.cfg.max_mru); 1692 return 1; 1693 } 1694 break; 1695 case 2: 1696 if (strcasecmp(argp, "max") && strcasecmp(argp, "maximum")) 1697 return -1; 1698 long_val = atol(arg->argv[arg->argn + 1]); 1699 change = &l->lcp.cfg.max_mru; 1700 if (long_val > MAX_MRU) { 1701 log_Printf(LogWARN, "MRU %ld: too large - maximum is %d\n", long_val, 1702 MAX_MRU); 1703 return 1; 1704 } 1705 break; 1706 default: 1707 return -1; 1708 } 1709 |
1682 if (long_val == 0) | 1710 if (long_val == 0) |
1683 l->lcp.cfg.mru = DEF_MRU; | 1711 *change = DEF_MRU; |
1684 else if (long_val < MIN_MRU) { 1685 log_Printf(LogWARN, "MRU %ld: too small - min %d\n", long_val, MIN_MRU); 1686 return 1; 1687 } else if (long_val > MAX_MRU) { 1688 log_Printf(LogWARN, "MRU %ld: too big - max %d\n", long_val, MAX_MRU); 1689 return 1; 1690 } else | 1712 else if (long_val < MIN_MRU) { 1713 log_Printf(LogWARN, "MRU %ld: too small - min %d\n", long_val, MIN_MRU); 1714 return 1; 1715 } else if (long_val > MAX_MRU) { 1716 log_Printf(LogWARN, "MRU %ld: too big - max %d\n", long_val, MAX_MRU); 1717 return 1; 1718 } else |
1691 l->lcp.cfg.mru = long_val; | 1719 *change = long_val; 1720 if (l->lcp.cfg.mru > *change) 1721 l->lcp.cfg.mru = *change; |
1692 break; 1693 1694 case VAR_MTU: | 1722 break; 1723 1724 case VAR_MTU: |
1695 long_val = atol(argp); | 1725 switch(arg->argc - arg->argn) { 1726 case 1: 1727 if (argp[strspn(argp, "0123456789")] != '\0') 1728 return -1; 1729 case 0: 1730 long_val = atol(argp); 1731 change = &l->lcp.cfg.mtu; 1732 if (long_val > l->lcp.cfg.max_mtu) { 1733 log_Printf(LogWARN, "MTU %ld: too large - max set to %d\n", long_val, 1734 l->lcp.cfg.max_mtu); 1735 return 1; 1736 } 1737 break; 1738 case 2: 1739 if (strcasecmp(argp, "max") && strcasecmp(argp, "maximum")) 1740 return -1; 1741 long_val = atol(arg->argv[arg->argn + 1]); 1742 change = &l->lcp.cfg.max_mtu; 1743 if (long_val > MAX_MTU) { 1744 log_Printf(LogWARN, "MTU %ld: too large - maximum is %d\n", long_val, 1745 MAX_MTU); 1746 return 1; 1747 } 1748 break; 1749 default: 1750 return -1; 1751 } 1752 |
1696 if (long_val && long_val < MIN_MTU) { 1697 log_Printf(LogWARN, "MTU %ld: too small - min %d\n", long_val, MIN_MTU); 1698 return 1; 1699 } else if (long_val > MAX_MTU) { 1700 log_Printf(LogWARN, "MTU %ld: too big - max %d\n", long_val, MAX_MTU); 1701 return 1; 1702 } else | 1753 if (long_val && long_val < MIN_MTU) { 1754 log_Printf(LogWARN, "MTU %ld: too small - min %d\n", long_val, MIN_MTU); 1755 return 1; 1756 } else if (long_val > MAX_MTU) { 1757 log_Printf(LogWARN, "MTU %ld: too big - max %d\n", long_val, MAX_MTU); 1758 return 1; 1759 } else |
1703 arg->bundle->cfg.mtu = long_val; | 1760 *change = long_val; 1761 if (l->lcp.cfg.mtu > *change) 1762 l->lcp.cfg.mtu = *change; |
1704 break; 1705 1706 case VAR_OPENMODE: 1707 if (strcasecmp(argp, "active") == 0) 1708 cx->physical->link.lcp.cfg.openmode = arg->argc > arg->argn+1 ? 1709 atoi(arg->argv[arg->argn+1]) : 1; 1710 else if (strcasecmp(argp, "passive") == 0) 1711 cx->physical->link.lcp.cfg.openmode = OPEN_PASSIVE; --- 347 unchanged lines hidden (view full) --- 2059 "logout script", "set logout chat-script", (const void *) VAR_LOGOUT}, 2060 {"lqrperiod", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 2061 "LQR period", "set lqrperiod value", (const void *)VAR_LQRPERIOD}, 2062 {"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "mode value", 2063 "set mode interactive|auto|ddial|background", (const void *)VAR_MODE}, 2064 {"mrru", NULL, SetVariable, LOCAL_AUTH, "MRRU value", 2065 "set mrru value", (const void *)VAR_MRRU}, 2066 {"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, | 1763 break; 1764 1765 case VAR_OPENMODE: 1766 if (strcasecmp(argp, "active") == 0) 1767 cx->physical->link.lcp.cfg.openmode = arg->argc > arg->argn+1 ? 1768 atoi(arg->argv[arg->argn+1]) : 1; 1769 else if (strcasecmp(argp, "passive") == 0) 1770 cx->physical->link.lcp.cfg.openmode = OPEN_PASSIVE; --- 347 unchanged lines hidden (view full) --- 2118 "logout script", "set logout chat-script", (const void *) VAR_LOGOUT}, 2119 {"lqrperiod", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, 2120 "LQR period", "set lqrperiod value", (const void *)VAR_LQRPERIOD}, 2121 {"mode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "mode value", 2122 "set mode interactive|auto|ddial|background", (const void *)VAR_MODE}, 2123 {"mrru", NULL, SetVariable, LOCAL_AUTH, "MRRU value", 2124 "set mrru value", (const void *)VAR_MRRU}, 2125 {"mru", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX_OPT, |
2067 "MRU value", "set mru value", (const void *)VAR_MRU}, 2068 {"mtu", NULL, SetVariable, LOCAL_AUTH, 2069 "interface MTU value", "set mtu value", (const void *)VAR_MTU}, | 2126 "MRU value", "set mru [max[imum]] [value]", (const void *)VAR_MRU}, 2127 {"mtu", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, 2128 "interface MTU value", "set mtu [max[imum]] [value]", (const void *)VAR_MTU}, |
2070 {"nbns", NULL, SetVariable, LOCAL_AUTH, "NetBIOS Name Server", 2071 "set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS}, 2072 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode", 2073 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE}, 2074 {"papretry", "papretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "PAP retries", 2075 "set papretry value [attempts]", (const void *)VAR_PAPRETRY}, 2076 {"parity", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "serial parity", 2077 "set parity [odd|even|none]", (const void *)VAR_PARITY}, --- 778 unchanged lines hidden --- | 2129 {"nbns", NULL, SetVariable, LOCAL_AUTH, "NetBIOS Name Server", 2130 "set nbns pri-addr [sec-addr]", (const void *)VAR_NBNS}, 2131 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "open mode", 2132 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE}, 2133 {"papretry", "papretries", SetVariable, LOCAL_AUTH | LOCAL_CX, "PAP retries", 2134 "set papretry value [attempts]", (const void *)VAR_PAPRETRY}, 2135 {"parity", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "serial parity", 2136 "set parity [odd|even|none]", (const void *)VAR_PARITY}, --- 778 unchanged lines hidden --- |