1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377
|
/*
* Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#include <slirp.h>
#ifdef USE_PPP
#include "ppp/ppp.h"
#include "ppp/pppd.h"
#include "ppp/pathnames.h"
#include "ppp/patchlevel.h"
#include "ppp/fsm.h"
#include "ppp/lcp.h"
#include "ppp/ipcp.h"
#include "ppp/upap.h"
#include "ppp/chap.h"
#include "ppp/ccp.h"
#include "ppp/ppp-comp.h"
#define FALSE 0
#define TRUE 1
#ifndef GIDSET_TYPE
#define GIDSET_TYPE int
#endif
void readable _P((int fd));
/*
* Option variables
*/
int debug = 0; /* Debug flag */
int kdebugflag = 0; /* Tell kernel to print debug messages */
int default_device = 1; /* Using /dev/tty or equivalent */
char devnam[MAXPATHLEN] = "/dev/tty"; /* Device name */
int crtscts = 0; /* Use hardware flow control */
int modem = 1; /* Use modem control lines */
int inspeed = 0; /* Input/Output speed requested */
u_int32_t netmask = 0; /* IP netmask to set on interface */
int lockflag = 0; /* Create lock file to lock the serial dev */
int nodetach = 0; /* Don't detach from controlling tty */
char *connector = NULL; /* Script to establish physical link */
char *disconnector = NULL; /* Script to disestablish physical link */
char user[MAXNAMELEN]; /* Username for PAP */
char passwd[MAXSECRETLEN]; /* Password for PAP */
int auth_required = 0; /* Peer is required to authenticate */
int defaultroute = 0; /* assign default route through interface */
int proxyarp = 0; /* Set up proxy ARP entry for peer */
int persist = 0; /* Reopen link after it goes down */
int uselogin = 0; /* Use /etc/passwd for checking PAP */
int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
int usehostname = 0; /* Use hostname for our_name */
int disable_defaultip = 0; /* Don't use hostname for default IP adrs */
char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
int cryptpap; /* Passwords in pap-secrets are encrypted */
#ifndef IMPLEMENTATION
#define IMPLEMENTATION ""
#endif
#endif
int nozeros; /* If set, 5 0's will not terminate link...*/
/*
* Read the config file
*/
int (*lprint_print) _P((void *, const char *format, va_list));
char *lprint_ptr, *lprint_ptr2, **lprint_arg;
struct sbuf *lprint_sb;
int cfg_unit;
int ctl_password_ok;
char *ctl_password;
void
config(file, unit)
char *file;
int unit;
{
FILE *cfg;
char buff[256];
cfg = fopen(file, "r");
if (cfg == NULL)
return;
cfg_unit = unit;
lprint("Reading config file: %s\r\n", file);
while(fgets(buff, 256, cfg) != NULL)
do_config(buff, (struct socket *)0, PRN_STDERR);
fclose(cfg);
}
int
do_config(buff, inso, type)
char *buff;
struct socket *inso;
int type;
{
int str_len, i = 0, is_sprintf = 0;
switch (type) {
case PRN_STDERR:
lprint_print = (int (*) _P((void *, const char *, va_list)))vfprintf;
lprint_ptr2 = (char *)stderr;
lprint_arg = (char **)&lprint_ptr2;
break;
case PRN_SPRINTF:
lprint_print = (int (*) _P((void *, const char *, va_list)))vsprintf;
lprint_sb = &inso->so_snd;
lprint_ptr2 = lprint_sb->sb_wptr;
lprint_ptr = lprint_sb->sb_wptr;
lprint_arg = (char **)&lprint_ptr;
is_sprintf = 1;
break;
default:
return 0;
}
/* Remove any whitespace */
while (*buff == ' ' || *buff == '\t')
buff++;
/* Ignore if it's a comment, or it's an empty line */
if (*buff == '#' || *buff == '\r' || *buff == '\n' || *buff == 0)
return 0;
while (cfg[i].command) {
if ((((str_len = strlen(cfg[i].command)) && !strncmp(buff, cfg[i].command, str_len)) ||
(cfg[i].command_line && (str_len = strlen(cfg[i].command_line)) &&
!strncmp(buff, cfg[i].command_line, str_len))) &&
(buff[str_len] == ' ' || buff[str_len] == '\t' ||
buff[str_len] == '\n' || buff[str_len] == '\r' ||
buff[str_len] == 0)) {
while (buff[str_len] == ' ' || buff[str_len] == '\t')
str_len++;
if (buff[str_len] == '\n' || buff[str_len] == '\r')
buff[str_len] = 0;
if (cfg[i].type & type) {
if ((cfg[i].flags & CFG_NEEDARG) && buff[str_len] == 0) {
lprint("Error: Insufficient arguments to \"%s\".\r\n", buff);
goto done;
}
if ((*cfg[i].func)((buff[str_len]?buff+str_len:(char *)0), inso) == CFG_BADARGS)
lprint("Error: Usage: %s %s\r\n", cfg[i].command, cfg[i].usage_args);
goto done;
} else {
lprint("Error: Option unavailable from %s.\r\n",
(type == PRN_STDERR)?"config file/command line":
"telnet");
goto done;
}
}
i++;
}
/* Command failed */
lprint("Error: Bad command: %s", buff);
if (inso)
lprint("\r\n");
done:
if (do_echo)
lprint("\r");
if (is_sprintf)
lprint_print = 0;
if (lprint_sb) {
i = lprint_ptr - lprint_sb->sb_wptr;
lprint_sb = 0;
return i;
} else
return 0;
}
int
get_port(buff, proto_tcp)
char *buff;
int proto_tcp;
{
int x;
struct servent *servp;
if (!(x = atoi(buff))) {
/* Must be a service */
servp = getservbyname(buff, proto_tcp==1?"tcp":"udp");
if (!servp) {
lprint("Error: Unknown service: %s\r\n", buff);
return -1;
}
x = ntohs(servp->s_port);
}
return x;
}
int
cfg_redir_x(buff, inso)
char *buff;
struct socket *inso;
{
u_int32_t laddr = 0;
int display = 0;
int screen = 0;
int start_port = 0;
char *ptr = 0;
if (buff) {
if (strncmp(buff, "start", 5) == 0) {
buff += 5;
while (*buff == ' ' || *buff == '\t')
buff++;
start_port = strtol(buff, &ptr, 10);
if (buff == ptr)
return CFG_BADARGS;
buff = ptr;
while (*buff == ' ' || *buff == '\t')
buff++;
}
if ((ptr = strchr(buff, ':'))) {
*ptr++ = 0;
if (*ptr == 0)
return CFG_BADARGS;
}
if (buff[0]) {
laddr = inet_addr(buff);
if (laddr == 0xffffffff) {
lprint("Error: bad address\r\n");
return CFG_ERROR;
}
}
if (ptr) {
if (strchr(ptr, '.')) {
if (sscanf(ptr, "%d.%d", &display, &screen) != 2)
return CFG_BADARGS;
} else {
if (sscanf(ptr, "%d", &display) != 1)
return CFG_BADARGS;
}
}
}
if (!laddr) {
if (inso)
laddr = inso->so_laddr.s_addr;
else
laddr = inet_addr(CTL_LOCAL);
}
redir_x(laddr, start_port, display, screen);
return CFG_OK;
}
int
cfg_setunit(buff, inso)
char *buff;
struct socket *inso;
{
int x;
x = atoi(buff);
if (x < 0 || x >= MAX_INTERFACES) {
lprint("Error: unit out of range\r\n");
return CFG_ERROR;
}
if (!ttys_unit[x]) {
lprint("Error: no such unit\r\n");
return CFG_ERROR;
}
cfg_unit = x;
lprint("Configuring unit %d\r\n", cfg_unit);
return CFG_OK;
}
int
cfg_redir(buff, inso)
char *buff;
struct socket *inso;
{
u_int32_t laddr;
int port = 0, lport;
char str[256];
char str2[256];
int once_time = 0, proto_tcp = -1;
struct socket *so;
if (strncmp(buff, "once", 4) == 0) {
once_time = SS_FACCEPTONCE;
proto_tcp = 1;
buff += 4;
} else if (strncmp(buff, "time", 4) == 0) {
once_time = SS_FACCEPTONCE;
proto_tcp = 0;
buff += 4;
}
while (*buff == ' ' || *buff == '\t')
buff++;
if (strncmp(buff, "tcp", 3) == 0) {
if (proto_tcp == 0) {
lprint("Error: TCP redirections can't timeout (yet)\r\n");
return CFG_ERROR;
}
proto_tcp = 1;
buff += 3;
} else if (strncmp(buff, "udp", 3) == 0) {
if (proto_tcp == 1) {
lprint("Error: UDP redirections can't redirect only once (yet)\r\n");
return CFG_ERROR;
}
proto_tcp = 0;
buff += 3;
}
while (*buff == ' ' || *buff == '\t')
buff++;
/* If we can't infer the protocol, assume tcp */
if (proto_tcp == -1)
proto_tcp = 1;
if (sscanf(buff, "%d%*[to \t]%256[^:]:%256s", &port, str, str2) == 3) {
if ((laddr = inet_addr(str)) == -1) {
lprint("Error: Bad address: %s\r\n", buff);
return CFG_ERROR;
}
} else if (sscanf(buff, "%d%*[to \t]%256s", &port, str2) == 2) {
if (inso)
laddr = inso->so_laddr.s_addr;
else
laddr = inet_addr(CTL_LOCAL);
} else if (sscanf(buff, "%256[^:]:%256s", str, str2) == 2) {
if ((laddr = inet_addr(str)) == -1) {
lprint("Error: Bad address: %s\r\n", buff);
return CFG_ERROR;
}
} else if (sscanf(buff, "%256s", str2) == 1) {
if (inso)
laddr = inso->so_laddr.s_addr;
else
laddr = inet_addr(CTL_LOCAL);
} else {
return CFG_BADARGS;
}
lport = get_port(str2, proto_tcp);
if (lport < 0)
return CFG_ERROR;
/* Do the redirection */
if (proto_tcp) {
so = solisten(htons(port), laddr, htons(lport), once_time);
if (so)
lprint("Redirecting TCP port %d to %s:%d\r\n",
ntohs(so->so_fport), inet_ntoa(so->so_laddr), lport);
else
lprint("Redirection failed: %s\r\n", strerror(errno));
} else {
so = udp_listen(htons(port), laddr, htons(lport), once_time);
if (so)
lprint("Redirecting UDP port %d to %s:%d\r\n",
ntohs(so->so_fport), inet_ntoa(so->so_laddr), lport);
else
lprint("Redirection failed: %s\r\n", strerror(errno));
}
return CFG_OK;
}
#ifndef FULL_BOLT
int
cfg_baudrate(buff, inso)
char *buff;
struct socket *inso;
{
int x;
struct ttys *ttyp = ttys_unit[cfg_unit];
if (!ttyp) {
lprint("Error: Unit does not exist. Weird.\r\n");
return CFG_ERROR;
}
x = atoi(buff);
if (x < 300) {
lprint("Error: baudrate too low\r\n");
return CFG_ERROR;
}
ttyp->baud = x;
ttyp->bytesps = ttyp->baud / 10; /* XXX */
lprint("Setting baudrate to %d\r\n", ttyp->baud);
return CFG_OK;
}
#endif
int
cfg_wait(buff, inso)
char *buff;
struct socket *inso;
{
if (buff) {
int x = atoi(buff);
if (x < 0) {
lprint("Error: wait value must be non-negative\r\n");
return CFG_ERROR;
}
if (x > 24*60) {
lprint("Error: wait value too large (one day max)\r\n");
return CFG_ERROR;
}
detach_wait = x * 60 * 1000;
}
lprint("Wait time is %d minutes\r\n", detach_wait/1000/60);
return CFG_OK;
}
int
cfg_sp_addr(buff, inso)
char *buff;
struct socket *inso;
{
struct in_addr tmp_addr;
if (!inet_aton(buff, &tmp_addr)) {
lprint("Error: Bad special address: %s\r\n", buff);
return CFG_ERROR;
}
special_addr = tmp_addr;
lprint("Setting special address to %s\r\n", buff);
return CFG_OK;
}
int
cfg_ctl_addr(buff, inso)
char *buff;
struct socket *inso;
{
struct in_addr tmp_addr;
if (!inet_aton(buff, &tmp_addr)) {
lprint("Error: Bad control address: %s\r\n", buff);
return CFG_ERROR;
}
ctl_addr = tmp_addr;
lprint("Setting control address to %s\r\n", buff);
return CFG_OK;
}
int
cfg_compress(buff, inso)
char *buff;
struct socket *inso;
{
if_comp &= ~(IF_AUTOCOMP|IF_NOCOMPRESS);
if_comp |= IF_COMPRESS;
lprint("Setting VJ compression\r\n");
return CFG_OK;
}
int
cfg_host_addr(buff, inso)
char *buff;
struct socket *inso;
{
struct in_addr tmp_addr;
if (!inet_aton(buff, &tmp_addr)) {
lprint("Error: Bad host address: %s\r\n", buff);
return CFG_ERROR;
}
our_addr = tmp_addr;
lprint("Setting host address to %s\r\n", buff);
return CFG_OK;
}
int
cfg_add_exec(buff, inso)
char *buff;
struct socket *inso;
{
char str[256];
char str2[256];
char str3[256];
int x;
u_int32_t laddr;
if (sscanf(buff, "%256[^:]:%256[^:]:%256s", str, str2, str3) == 3) {
/* XXX should check if address == special address */
x = get_port(str3, 1);
if (x < 0)
return CFG_ERROR;
if (x > 65535) {
lprint("Error: Port out of range: %d\r\n", x);
return CFG_ERROR;
} else if ((laddr = inet_addr(str2)) == -1) {
lprint("Error: Invalid address: %s\r\n", str2);
return CFG_ERROR;
} else if (add_exec(&exec_list, 0, str, (ntohl(laddr) & 0xff), htons(x)) < 0) {
lprint("Error: Port already used: %s\r\n", buff);
return CFG_ERROR;
} else
lprint("Adding execution of %s to address %s, port %d\r\n", str, str2, x);
} else if (sscanf(buff, "%256[^:]:%256s", str, str3) == 2) {
x = get_port(str3, 1);
if (x < 0)
return CFG_ERROR;
if (x > 65535) {
lprint("Error: Port out of range: %d\r\n", x);
return CFG_ERROR;
} else if (add_exec(&exec_list, 0, str, CTL_EXEC, htons(x)) < 0) {
lprint("Error: Port already used: %s\r\n", buff);
return CFG_ERROR;
} else
lprint("Adding execution of %s to port %d\r\n", str, x);
} else
return CFG_BADARGS;
return CFG_OK;
}
int
cfg_add_ptyexec(buff, inso)
char *buff;
struct socket *inso;
{
char str[256];
char str2[256];
int x;
u_int32_t laddr;
if (sscanf(buff, "%256[^:]:%256[^:]:%d", str, str2, &x) == 3) {
/* XXX should check if address == special address */
if (x < 0 || x > 65535) {
lprint("Error: Port out of range: %d\r\n", x);
return CFG_ERROR;
} else if ((laddr = inet_addr(str2)) == -1) {
lprint("Error: Invalid address: %s\r\n", str2);
return CFG_ERROR;
} else if (add_exec(&exec_list, 1, str, (ntohl(laddr) & 0xff), htons(x)) < 0) {
lprint("Error: Port already used: %s\r\n", buff);
return CFG_ERROR;
} else
lprint("Adding %s to address %s, port %d\r\n", str, str2, x);
} else if (sscanf(buff, "%256[^:]:%d", str, &x) == 2) {
if (x < 0 || x > 65535) {
lprint("Error: Port out of range: %d\r\n", x);
return CFG_ERROR;
} else if (add_exec(&exec_list, 1, str, CTL_EXEC, htons(x)) < 0) {
lprint("Error: Port already used.\r\n");
return CFG_ERROR;
} else
lprint("Adding %s to port %d\r\n", str, x);
} else
return CFG_BADARGS;
return CFG_OK;
}
int
cfg_shell(buff, inso)
char *buff;
struct socket *inso;
{
char str[256];
if (exec_shell)
free(exec_shell);
sscanf(buff, "%256s", str);
exec_shell = (char *)strdup(str);
return CFG_OK;
}
int
cfg_debug(buff, inso)
char *buff;
struct socket *inso;
{
int x;
if (!buff)
x = DEBUG_DEFAULT;
else {
if ((x = atoi(buff)) == 0)
x = DEBUG_DEFAULT;
}
debug_init("slirp_debug", x);
return CFG_OK;
}
int
cfg_logstart(buff, inso)
char *buff;
struct socket *inso;
{
char buff1[256];
char *bptr;
if (!buff) {
buff1[0] = 0;
if ((bptr = (char *)getenv("HOME")) != NULL)
strncpy2(buff1, bptr, sizeof(buff1));
strncat(buff1, "/.slirp_start", sizeof(buff1));
lfd = fopen(buff1, "w");
bptr = buff1;
} else {
lfd = fopen(buff, "w");
bptr = buff;
}
if (!lfd) {
lprint("Error: could not open logstart file: %s\r\n", strerror(errno));
return CFG_ERROR;
}
lprint("Log started to %s\r\n", bptr);
return CFG_OK;
}
int
cfg_logstats(buff, inso)
char *buff;
struct socket *inso;
{
dostats = 1;
lprint("Logging statistics\r\n");
return CFG_OK;
}
int
cfg_config(buff, inso)
char *buff;
struct socket *inso;
{
config(buff, cfg_unit);
return CFG_OK;
}
int
cfg_help(buff, inso)
char *buff;
struct socket *inso;
{
int i = 0;
int str_len;
int count = 0;
char str[256];
char *str2;
char *sptr;
if (!buff) {
lprint("Valid commands:\r\n");
while (cfg[i].command) {
if (count >= 2) {
snprintf(str, sizeof(str), "\r\n");
count = 0;
} else {
count++;
sptr = str;
str_len = strlen(cfg[i].command);
str_len = 20 - str_len;
while (str_len-- >= 0)
*sptr++ = ' ';
*sptr = 0;
}
lprint("%s%s", cfg[i].command, str);
i++;
}
if (count != 0)
lprint("\r\n");
lprint("For more help type \"help COMMAND\" where command is either\r\n");
lprint("one of the above commands or a portion of a command.\r\n");
} else {
str_len = strlen(buff);
while (cfg[i].command) {
if (!strncmp(cfg[i].command, buff, str_len) ||
(cfg[i].command_line && !strncmp(cfg[i].command_line, buff, str_len))) {
/* Found a match, print the help */
count++;
if (cfg[i].command_line)
snprintf(str, sizeof(str), "Command-line: %s\r\n", cfg[i].command_line);
else
str[0] = 0;
if (cfg[i].type == CFG_TELNET)
str2 = "telnet";
else if (cfg[i].type == CFG_CMD_FILE)
str2 = "command-line, config-file";
else if (cfg[i].type == (CFG_ANY))
str2 = "command-line, config-file, telnet";
else
str2 = "[none]";
lprint(
"Command: \"%s\"\r\nUsage: %s %s\r\n%sAvailable: %s\r\n %s\r\n\r\n",
cfg[i].command, cfg[i].command, cfg[i].usage_args, str, str2, cfg[i].help);
}
i++;
}
lprint("%d match(es) found\r\n", count);
}
/* If it was called from the command-line, exit */
if (!inso)
slirp_exit(0);
return CFG_OK;
}
int
cfg_stats(buff, inso)
char *buff;
struct socket *inso;
{
if (!strncmp(buff, "ip", 2))
ipstats();
else if (!strncmp(buff, "socket", 6))
sockstats();
else if (!strncmp(buff, "tcp", 3))
tcpstats();
else if (!strncmp(buff, "udp", 3))
udpstats();
else if (!strncmp(buff, "icmp", 4))
icmpstats();
else if (!strncmp(buff, "mbuf", 4))
mbufstats();
else if (!strncmp(buff, "vj", 2))
vjstats();
else if (!strncmp(buff, "alltty", 6))
allttystats();
else if (!strncmp(buff, "tty", 3))
ttystats(ttys_unit[cfg_unit]);
else
return CFG_BADARGS;
return CFG_OK;
}
int
cfg_echo(buff, inso)
char *buff;
struct socket *inso;
{
if (!buff) {
lprint("Echo is %s\r\n", do_echo?"on":"off");
} else {
if (strncmp(buff, "on", 2) == 0) {
do_echo = 1;
lprint("Echo is on.\r\n");
} else if (strncmp(buff, "off", 3) == 0) {
do_echo = 0;
lprint("Echo is off\r\n");
} else
return CFG_BADARGS;
}
return CFG_OK;
}
int
cfg_kill_close(x, type)
int x, type;
{
struct socket *so;
for (so = tcb.so_next; so != &tcb; so = so->so_next) {
if (so->s == x) {
/* Found it */
if (type == 1) {
tcp_close(sototcpcb(so));
lprint(
"Session removed.\r\n");
} else {
tcp_sockclosed(sototcpcb(so));
shutdown(so->s, 0); /* XXX */
shutdown(so->s, 1); /* XXX */
so->so_state = SS_NOFDREF; /* XXX */
lprint("Session closed.\r\n");
}
return CFG_OK;
}
}
/*
* Not TCP, maybe UDP
*/
for (so = udb.so_next; so != &tcb; so = so->so_next) {
if (so->s == x) {
udp_detach(so);
lprint("Session closed.\r\n");
return CFG_OK;
}
}
/*
* Nup, cant find it
*/
lprint(" Error: session not found.\r\n");
return CFG_ERROR;
}
int cfg_quitting;
int
cfg_quit(buff, inso)
char *buff;
struct socket *inso;
{
lprint("Goodbye\r\n");
tcp_sockclosed(sototcpcb(inso));
cfg_quitting = 1;
return CFG_OK;
}
int
cfg_pass(buff, inso)
char *buff;
struct socket *inso;
{
char *ptr = buff;
if (ctl_password)
free(ctl_password);
while (*ptr) {
if (*ptr == '\n' || *ptr == '\r')
*ptr = 0;
else
ptr++;
}
ctl_password = strdup(buff);
return CFG_OK;
}
int
cfg_tty(buff, inso)
char *buff;
struct socket *inso;
{
/* TTY actually set up earlier prior to main options processing
(Only usable on command line)
*/
return CFG_OK;
}
int
cfg_nozeros(buff, inso)
char *buff;
struct socket *inso;
{
/* Disable special zero processing
*/
nozeros++;
return CFG_OK;
}
int
cfg_kill(buff, inso)
char *buff;
struct socket *inso;
{
cfg_kill_close(atoi(buff), 1);
return CFG_OK;
}
int
cfg_close(buff, inso)
char *buff;
struct socket *inso;
{
cfg_kill_close(atoi(buff), 0);
return CFG_OK;
}
int
cfg_exec(buff, inso)
char *buff;
struct socket *inso;
{
fork_exec(inso, buff, 0);
soisfconnected(inso);
inso->so_emu = 0;
return CFG_OK;
}
int
cfg_ptyexec(buff, inso)
char *buff;
struct socket *inso;
{
fork_exec(inso, buff, 1);
soisfconnected(inso);
inso->so_emu = 0;
return CFG_OK;
}
int
cfg_add_emu(buff, inso)
char *buff;
struct socket *inso;
{
add_emu(buff);
return CFG_OK;
}
int
cfg_socket(buff, inso)
char *buff;
struct socket *inso;
{
struct sockaddr_in addr;
char pwd[256];
int s, port;
if (!buff) {
/* Want unix domain socket */
#ifndef NO_UNIX_SOCKETS
struct sockaddr_un sock_un;
if (slirp_socket >= 0) {
/* Close the old socket */
close(slirp_socket);
slirp_socket = -1;
}
if (slirp_socket_passwd) {
free(slirp_socket_passwd);
slirp_socket_passwd = 0;
}
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
lprint("Error: socket() failed\r\n");
return CFG_ERROR;
}
/* Remove the old socket */
(void) unlink(socket_path);
/* Create a new one */
sock_un.sun_family = AF_UNIX;
strncpy2(sock_un.sun_path, socket_path, sizeof(sock_un.sun_path));
if ((bind(s, (struct sockaddr *)&sock_un,
sizeof(sock_un.sun_family) + sizeof(sock_un.sun_path)) < 0) ||
(listen(s, 1) < 0)) {
close(s);
lprint("Error: %s: %s\r\n", socket_path, strerror(errno));
return CFG_ERROR;
}
slirp_socket = s;
return CFG_OK;
#else
lprint("Sorry, your system does not support unix-domain sockets.\r\n");
return CFG_OK;
#endif
} else {
/* Want internet domain socket */
if (slirp_socket >= 0) {
/* Close the old socket */
close(slirp_socket);
slirp_socket = -1;
}
if (sscanf(buff, "%d,%s", &port, pwd) != 2) {
lprint("Error: bad arguments to \"socket\"\r\n");
return CFG_ERROR;
}
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0) {
lprint("Error: socket() failed: %s\r\n", strerror(errno));
close(s);
return CFG_ERROR;
}
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
lprint("Error: bind() failed: %s\r\n", strerror(errno));
close(s);
return CFG_ERROR;
}
listen(s, 1);
slirp_socket = s;
if (slirp_socket_passwd) {
/* Free old password */
free(slirp_socket_passwd);
}
slirp_socket_passwd = strdup(pwd);
return CFG_OK;
}
}
int
cfg_dns(buff, inso)
char *buff;
struct socket *inso;
{
struct in_addr tmp_addr;
if (!inet_aton(buff, &tmp_addr)) {
lprint("Error: Bad IP\r\n");
return CFG_ERROR;
}
if(dns_addr.s_addr) {
dns2_addr = tmp_addr;
lprint("Setting DNS2 to %s\r\n", buff);
}
else {
dns_addr = tmp_addr;
lprint("Setting DNS to %s\r\n", buff);
}
return CFG_OK;
}
int
cfg_keepalive(buff, inso)
char *buff;
struct socket *inso;
{
int tmp;
if (buff) {
tmp = atoi(buff);
if (tmp < 5*PR_SLOWHZ || tmp > tcp_keepidle) {
lprint("Error: TCP keepalive interval must be between 5 and %d\r\n", tcp_keepidle);
return CFG_ERROR;
}
tcp_keepintvl = tmp*PR_SLOWHZ;
}
so_options = 1;
lprint("Setting keepalive to %d seconds\r\n", tcp_keepintvl/PR_SLOWHZ);
return CFG_OK;
}
int
cfg_version(buff, inso)
char *buff;
struct socket *inso;
{
#ifndef FULL_BOLT
lprint("Slirp v%s (%s)\r\n", SLIRP_VERSION, SLIRP_STATUS);
#else
lprint("Slirp v%s (%s) FULL_BOLT\r\n", SLIRP_VERSION, SLIRP_STATUS);
#endif
return CFG_OK;
}
int
cfg_towrite_max(buff, inso)
char *buff;
struct socket *inso;
{
int tmp;
tmp = atoi(buff);
if (tmp < 0) {
lprint("Error: towrite_max must be positive\r\n");
return CFG_ERROR;
}
towrite_max = tmp;
lprint("Setting towrite_max to %d\r\n", towrite_max);
return CFG_OK;
}
#ifdef USE_PPP
int
cfg_ppp_exit(buff, inso)
char *buff;
struct socket *inso;
{
ppp_exit = 1;
lprint("Slirp will exit when PPP goes down\r\n");
return CFG_OK;
}
void
setipdefault(unit)
int unit;
{
struct hostent *hp;
u_int32_t local;
ipcp_options *wo = &ipcp_wantoptions[unit];
/*
* If local IP address already given, don't bother.
*/
if (wo->ouraddr != 0 || disable_defaultip)
return;
/*
* Look up our hostname (possibly with domain name appended)
* and take the first IP address as our local IP address.
* If there isn't an IP address for our hostname, too bad.
*/
wo->accept_local = 1; /* don't insist on this default value */
if ((hp = gethostbyname(hostname)) == NULL)
return;
local = *(u_int32_t *)hp->h_addr;
if (local != 0 && !bad_ip_adrs(local))
wo->ouraddr = local;
return;
}
/*
* Read a word from a file.
* Words are delimited by white-space or by quotes (").
* Quotes, white-space and \ may be escaped with \.
* \<newline> is ignored.
*/
int
getword(f, word, newlinep, filename)
FILE *f;
char *word;
int *newlinep;
char *filename;
{
int c, len, escape;
int quoted;
*newlinep = 0;
len = 0;
escape = 0;
quoted = 0;
/*
* First skip white-space and comments
*/
while ((c = getc(f)) != EOF) {
if (c == '\\') {
/*
* \<newline> is ignored; \ followed by anything else
* starts a word.
*/
if ((c = getc(f)) == '\n')
continue;
word[len++] = '\\';
escape = 1;
break;
}
if (c == '\n')
*newlinep = 1; /* next word starts a line */
else if (c == '#') {
/* comment - ignore until EOF or \r\n */
while ((c = getc(f)) != EOF && c != '\n')
;
if (c == EOF)
break;
*newlinep = 1;
} else if (!isspace(c))
break;
}
/*
* End of file or error - fail
*/
if (c == EOF) {
if (ferror(f)) {
perror(filename);
die(1);
}
return 0;
}
for (;;) {
/*
* Is this character escaped by \ ?
*/
if (escape) {
if (c == '\n')
--len; /* ignore \<newline> */
else if (c == '"' || isspace(c) || c == '\\')
word[len-1] = c; /* put special char in word */
else {
if (len < MAXWORDLEN-1)
word[len] = c;
++len;
}
escape = 0;
} else if (c == '"') {
quoted = !quoted;
} else if (!quoted && (isspace(c) || c == '#')) {
ungetc(c, f);
break;
} else {
if (len < MAXWORDLEN-1)
word[len] = c;
++len;
if (c == '\\')
escape = 1;
}
if ((c = getc(f)) == EOF)
break;
}
if (ferror(f)) {
perror(filename);
die(1);
}
if (len >= MAXWORDLEN) {
word[MAXWORDLEN-1] = 0;
lprint("Warning: word in file %s too long (%.20s...)\r\n",
filename, word);
} else
word[len] = 0;
return 1;
}
u_int32_t
GetMask(addr)
u_int32_t addr;
{
return(netmask);
}
/*
* number_option - parse a numeric parameter for an option
*/
u_int
number_option(str, valp, base)
char *str;
u_int32_t *valp;
int base;
{
char *bptr;
*valp = strtoul(str, &bptr, base);
if (bptr == str) {
lprint("invalid number: %s\r\n", str);
return CFG_ERROR;
}
return CFG_OK;
}
/*
* int_option - like number_option, but valp is int *,
* the base is assumed to be 0, and *valp is not changed
* if there is an error.
*/
u_int
int_option(str, valp)
char *str;
int *valp;
{
u_int32_t v;
if (number_option(str, &v, 0) == CFG_ERROR)
return CFG_ERROR;
*valp = (u_int) v;
return CFG_OK;
}
#endif
int
cfg_ppp(buff, inso)
char *buff;
struct socket *inso;
{
#ifdef USE_PPP
struct ttys *ttyp = ttys_unit[cfg_unit];
if (!ttyp) {
lprint("Error: Unit does not exists. Weird.\r\n");
return CFG_ERROR;
}
ppp_init(ttyp);
return CFG_OK;
#else
lprint("Error: PPP not compiled into this slirp executable\r\n");
return CFG_OK;
#endif
}
#ifdef USE_PPP
/*
* The following procedures execute commands.
*/
/*
* setdebug - Set debug (command line argument).
*/
int
setdebug(buff, inso)
char *buff;
struct socket *inso;
{
if (logfile)
fclose(logfile);
logfile = fopen("slirp_pppdebug", "w");
if (!logfile) {
lprint("Error: can't open logfile\r\n");
return CFG_ERROR;
}
debug = 1;
return CFG_OK;
}
/*
* noopt - Disable all options.
*/
int
noopt(buff, inso)
char *buff;
struct socket *inso;
{
BZERO((char *) &lcp_wantoptions[cfg_unit], sizeof (struct lcp_options));
BZERO((char *) &lcp_allowoptions[cfg_unit], sizeof (struct lcp_options));
BZERO((char *) &ipcp_wantoptions[cfg_unit], sizeof (struct ipcp_options));
BZERO((char *) &ipcp_allowoptions[cfg_unit], sizeof (struct ipcp_options));
return CFG_OK;
}
/*
* noaccomp - Disable Address/Control field compression negotiation.
*/
int
noaccomp(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_accompression = 0;
lcp_allowoptions[cfg_unit].neg_accompression = 0;
return CFG_OK;
}
/*
* noasyncmap - Disable async map negotiation.
*/
int
noasyncmap(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_asyncmap = 0;
lcp_allowoptions[cfg_unit].neg_asyncmap = 0;
return CFG_OK;
}
/*
* noipaddr - Disable IP address negotiation.
*/
int
noipaddr(buff, inso)
char *buff;
struct socket *inso;
{
ipcp_wantoptions[cfg_unit].neg_addr = 0;
ipcp_allowoptions[cfg_unit].neg_addr = 0;
return CFG_OK;
}
/*
* nomagicnumber - Disable magic number negotiation.
*/
int
nomagicnumber(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_magicnumber = 0;
lcp_allowoptions[cfg_unit].neg_magicnumber = 0;
return CFG_OK;
}
/*
* nomru - Disable mru negotiation.
*/
int
nomru(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_mru = 0;
lcp_allowoptions[cfg_unit].neg_mru = 0;
return CFG_OK;
}
#endif
/*
* setmru - Set MRU for negotiation.
*/
int
setmru(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
long mru;
/* PPP */
mru = atoi(opt_arg);
#ifdef USE_PPP
lcp_wantoptions[cfg_unit].mru = mru;
lcp_wantoptions[cfg_unit].neg_mru = 1;
#endif
/* SLIP */
if_mru = mru;
return CFG_OK;
}
/*
* setmtu - Set the largest MTU we'll use.
*/
int
setmtu(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
long mtu;
/* PPP */
mtu = atoi(opt_arg);
if (mtu < MIN_MRU || mtu > MAX_MRU) {
lprint("mtu option value of %ld is too %s\r\n", mtu,
(mtu < MIN_MRU? "small": "large"));
return CFG_ERROR;;
}
#ifdef USE_PPP
lcp_allowoptions[cfg_unit].mru = mtu;
#endif
/* SLIP XXXXX */
if_mtu = mtu;
return CFG_OK;
}
#ifdef USE_PPP
/*
* nopcomp - Disable Protocol field compression negotiation.
*/
int
nopcomp(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_pcompression = 0;
lcp_allowoptions[cfg_unit].neg_pcompression = 0;
return CFG_OK;
}
/*
* setsilent - Set silent mode (don't start sending LCP configure-requests
* until we get one from the peer).
*/
int
setinitopt(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].silent = 0;
return CFG_OK;
}
/*
* nopap - Disable PAP authentication with peer.
*/
int
nopap(buff, inso)
char *buff;
struct socket *inso;
{
lcp_allowoptions[cfg_unit].neg_upap = 0;
return CFG_OK;
}
/*
* reqpap - Require PAP authentication from peer.
*/
int
reqpap(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_upap = 1;
auth_required = 1;
return CFG_OK;
}
/*
* setupapfile - specifies UPAP info for authenticating with peer.
*/
int
setupapfile(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
FILE * ufile;
int l;
lcp_allowoptions[cfg_unit].neg_upap = 1;
/* open user info file */
if ((ufile = fopen(opt_arg, "r")) == NULL) {
lprint("unable to open user login data file %s\r\n", opt_arg);
return CFG_ERROR;
}
check_access(ufile, opt_arg);
/* get username */
if (fgets(user, MAXNAMELEN - 1, ufile) == NULL
|| fgets(passwd, MAXSECRETLEN - 1, ufile) == NULL){
lprint("Unable to read user login data file %s.\r\n", opt_arg);
return CFG_ERROR;
}
fclose(ufile);
/* get rid of newlines */
l = strlen(user);
if (l > 0 && user[l-1] == '\n')
user[l-1] = 0;
l = strlen(passwd);
if (l > 0 && passwd[l-1] == '\n')
passwd[l-1] = 0;
return CFG_OK;
}
/*
* nochap - Disable CHAP authentication with peer.
*/
int
nochap(buff, inso)
char *buff;
struct socket *inso;
{
lcp_allowoptions[cfg_unit].neg_chap = 0;
return CFG_OK;
}
/*
* reqchap - Require CHAP authentication from peer.
*/
int
reqchap(buff, inso)
char *buff;
struct socket *inso;
{
lcp_wantoptions[cfg_unit].neg_chap = 1;
auth_required = 1;
return CFG_OK;
}
/*
* setnovj - disable vj compression
*/
int
setnovj(buff, inso)
char *buff;
struct socket *inso;
{
if_comp &= ~(IF_AUTOCOMP|IF_COMPRESS);
if_comp |= IF_NOCOMPRESS;
ipcp_wantoptions[cfg_unit].neg_vj = 0;
ipcp_allowoptions[cfg_unit].neg_vj = 0;
return CFG_OK;
}
/*
* setnovjccomp - disable VJ connection-ID compression
*/
int
setnovjccomp(buff, inso)
char *buff;
struct socket *inso;
{
ipcp_wantoptions[cfg_unit].cflag = 0;
ipcp_allowoptions[cfg_unit].cflag = 0;
return CFG_OK;
}
/*
* setvjslots - set maximum number of connection slots for VJ compression
*/
int
setvjslots(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
int value;
if (int_option(opt_arg, &value) == CFG_ERROR)
return CFG_ERROR;
if (value < 2 || value > 16) {
lprint("pppd: vj-max-slots value must be between 2 and 16\r\n");
return CFG_ERROR;
}
ipcp_wantoptions[cfg_unit].maxslotindex =
ipcp_allowoptions[cfg_unit].maxslotindex = value - 1;
return CFG_OK;
}
/*
* setdomain - Set domain name to append to hostname
*/
int
setdomain(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
strncat(hostname, opt_arg, MAXNAMELEN - strlen(hostname));
hostname[MAXNAMELEN-1] = 0;
return CFG_OK;
}
/*
* setasyncmap - add bits to asyncmap (what we request peer to escape).
*/
int
setasyncmap(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
u_int32_t asyncmap;
if (number_option(opt_arg, &asyncmap, 16) == CFG_ERROR)
return CFG_ERROR;
lcp_wantoptions[cfg_unit].asyncmap |= asyncmap;
lcp_wantoptions[cfg_unit].neg_asyncmap = 1;
return CFG_OK;
}
/*
* setescape - add chars to the set we escape on transmission.
*/
int
setescape(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
int n, n2, ret, num = 0;
char *p, *endp;
p = opt_arg;
ret = CFG_OK;
lprint("Escaping: ");
while (*p) {
n = strtoul(p, &endp, 16);
if (p == endp) {
lprint("\r\nError: invalid hex number: %s\r\n", p);
return CFG_ERROR;
}
p = endp;
if (*p == '-') {
p++;
n2 = strtoul(p, &endp, 16);
if (p == endp) {
lprint("\r\nError: invalid hex number: %s\r\n", p);
return CFG_ERROR;
}
p = endp;
if (n2 < n || n2 > 0xff) {
lprint("\r\nError: bad second number in range\r\n");
return CFG_ERROR;
}
} else
n2 = n;
while (n <= n2) {
if (n < 0 || (0x20 <= n && n <= 0x3F) || n == 0x5E || n > 0xFF) {
lprint("\r\nError: can't escape character 0x%x\r\n", n);
ret = CFG_ERROR;
} else {
if (num)
lprint(", ");
lprint("0x%x", n);
num++;
xmit_accm[cfg_unit][n >> 5] |= 1 << (n & 0x1F);
}
n++;
}
while (*p == ',' || *p == ' ' || *p == '\n' || *p == '\r')
++p;
}
lprint("\r\n");
if (!num)
return CFG_BADARGS;
else
return ret;
}
/*
* setipcpaccl - accept peer's idea of our address
*/
int
setipcpaccl(buff, inso)
char *buff;
struct socket *inso;
{
ipcp_wantoptions[cfg_unit].accept_local = 1;
return CFG_OK;
}
/*
* setipcpaccr - accept peer's idea of its address
*/
int
setipcpaccr(buff, inso)
char *buff;
struct socket *inso;
{
ipcp_wantoptions[cfg_unit].accept_remote = 1;
return CFG_OK;
}
int
setusehostname(buff, inso)
char *buff;
struct socket *inso;
{
usehostname = 1;
return CFG_OK;
}
int
setname(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
if (our_name[cfg_unit] == 0) {
strncpy(our_name, opt_arg, MAXNAMELEN);
our_name[MAXNAMELEN-1] = 0;
}
return CFG_OK;
}
int
set_user(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
strncpy(user, opt_arg, MAXNAMELEN);
user[MAXNAMELEN-1] = 0;
return CFG_OK;
}
int
setremote(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
strncpy(remote_name, opt_arg, MAXNAMELEN);
remote_name[MAXNAMELEN-1] = 0;
return CFG_OK;
}
int
setauth(buff, inso)
char *buff;
struct socket *inso;
{
auth_required = 1;
return CFG_OK;
}
int
setproxyarp(buff, inso)
char *buff;
struct socket *inso;
{
ipcp_wantoptions[cfg_unit].proxy_arp = 1;
return CFG_OK;
}
int
setdologin(buff, inso)
char *buff;
struct socket *inso;
{
uselogin = 1;
return CFG_OK;
}
/*
* Functions to set the echo interval for modem-less monitors
*/
int
setlcpechointv(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_echo_interval);
}
int
setlcpechofails(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_echo_fails);
}
/*
* Functions to set timeouts, max transmits, etc.
*/
int
setlcptimeout(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_fsm[cfg_unit].timeouttime);
}
int
setlcpterm(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_fsm[cfg_unit].maxtermtransmits);
}
int
setlcpconf(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_fsm[cfg_unit].maxconfreqtransmits);
}
int
setlcpfails(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_fsm[cfg_unit].maxnakloops);
}
int
setipcptimeout(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &ipcp_fsm[cfg_unit].timeouttime);
}
int
setipcpterm(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &ipcp_fsm[cfg_unit].maxtermtransmits);
}
int
setipcpconf(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &ipcp_fsm[cfg_unit].maxconfreqtransmits);
}
int
setipcpfails(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &lcp_fsm[cfg_unit].maxnakloops);
}
int
setpaptimeout(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &upap[cfg_unit].us_timeouttime);
}
int
setpapreqs(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &upap[cfg_unit].us_maxtransmits);
}
int
setchaptimeout(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &chap[cfg_unit].timeouttime);
}
int
setchapchal(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &chap[cfg_unit].max_transmits);
}
int
setchapintv(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &chap[cfg_unit].chal_interval);
}
int
setpapreqtime(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
return int_option(opt_arg, &upap[cfg_unit].us_reqtimeout);
}
int
setbsdcomp(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
int rbits, abits;
char *str, *endp;
str = opt_arg;
abits = rbits = strtol(str, &endp, 0);
if (endp != str && *endp == ',') {
str = endp + 1;
abits = strtol(str, &endp, 0);
}
if ((*endp != 0 && *endp != '\n' && *endp != '\r') || endp == str) {
lprint("Error: invalid argument format for bsdcomp option\n");
return CFG_ERROR;
}
if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS))
|| (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) {
lprint("Error: bsdcomp option values must be 0 or %d .. %d\n",
BSD_MIN_BITS, BSD_MAX_BITS);
return CFG_ERROR;
}
if (rbits > 0) {
ccp_wantoptions[cfg_unit].bsd_compress = 1;
ccp_wantoptions[cfg_unit].bsd_bits = rbits;
} else
ccp_wantoptions[cfg_unit].bsd_compress = 0;
if (abits > 0) {
ccp_allowoptions[cfg_unit].bsd_compress = 1;
ccp_allowoptions[cfg_unit].bsd_bits = abits;
} else
ccp_allowoptions[cfg_unit].bsd_compress = 0;
return CFG_OK;
}
int
setnobsdcomp(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
ccp_wantoptions[cfg_unit].bsd_compress = 0;
ccp_allowoptions[cfg_unit].bsd_compress = 0;
return CFG_OK;
}
int
setpapcrypt(opt_arg, inso)
char *opt_arg;
struct socket *inso;
{
cryptpap = 1;
return CFG_OK;
}
#endif
struct cfgtab cfg[] = {
{ "redir X", 0, cfg_redir_x, CFG_ANY, 0,
"[start RDISP] [ADDR][:DISPLAY[.SCREEN]]",
"redirect a port for X" },
{ "show X", 0, show_x, CFG_TELNET, 0,
"",
"show a previous redirection" },
{ "redir", 0, cfg_redir, CFG_ANY, CFG_NEEDARG,
"[once|time] [udp|tcp] PORT [to] [ADDR:]LPORT",
"redirect a port" },
#ifndef FULL_BOLT
{ "baudrate", "-b", cfg_baudrate, CFG_ANY, CFG_NEEDARG,
"BAUDRATE",
"change the baudrate" },
#endif
{ "special addr", 0, cfg_sp_addr, CFG_ANY, CFG_NEEDARG,
"ADDR",
"set slirp's special address" },
{ "control addr", 0, cfg_ctl_addr, CFG_ANY, CFG_NEEDARG,
"ADDR",
"set slirp's control address" },
{ "compress", 0, cfg_compress, CFG_CMD_FILE, 0,
"",
"use VJ compression" },
{ "host addr", 0, cfg_host_addr, CFG_ANY, CFG_NEEDARG,
"ADDR",
"set slirp's host address" },
{ "add exec", 0, cfg_add_exec, CFG_ANY, CFG_NEEDARG,
"| ptyexec PROGRAM:[ADDRESS:]PORT",
"make slirp execute a program on connection to a specific host/port" },
{ "add ptyexec", 0, cfg_add_ptyexec, CFG_ANY, CFG_NEEDARG,
"| exec PROGRAM:[ADDRESS:]PORT",
"make slirp execute a program on connection to a specific host/port" },
{ "add emu", 0, cfg_add_emu, CFG_ANY, CFG_NEEDARG,
"ftp|irc|none[:lowdelay|throughput] [LPORT:]FPORT",
"add emulation to specific service/port" },
{ "shell", 0, cfg_shell, CFG_CMD_FILE, CFG_NEEDARG,
"PATH_TO_SHELL",
"set your shell (same as add ptyexec PATH_TO_SHELL:23)" },
{ "debug", "-d", cfg_debug, CFG_ANY, CFG_NEEDARG,
"LEVEL",
"start debugging to file slirp_debug" },
{ "socket", "-s", cfg_socket, CFG_ANY, 0,
"[PORT,PASSWORD]",
"bind a socket and listen for other unit connections" },
{ "log stats", "-S", cfg_logstats, CFG_CMD_FILE, 0,
"",
"log statistics to file slirp_stats upon exit" },
{ "config", "-f", cfg_config, CFG_CMD_FILE, CFG_NEEDARG,
"FILE",
"read a configuration file" },
{ "log start", 0, cfg_logstart, CFG_CMD_FILE, 0,
"",
"log startup info to ~/.slirp_start" },
{ "dns", 0, cfg_dns, CFG_ANY, CFG_NEEDARG,
"ADDR",
"set dns address, for 10.0.2.3 as an alias for the real dns" },
{ "help", 0, cfg_help, CFG_ANY, 0,
"[COMMAND|START_OF_COMMAND]",
"show help on given command" },
{ "-h", 0, cfg_help, CFG_ANY, CFG_NEEDARG,
"[COMMAND|START_OF_COMMAND]",
"show help on given command" },
{ "echo", 0, cfg_echo, CFG_TELNET, 0,
"[on|off]",
"set echo on or off, or show current state" },
{ "kill", 0, cfg_kill, CFG_TELNET, CFG_NEEDARG,
"SOCKET",
"kill a socket" },
{ "close", 0, cfg_close, CFG_TELNET, CFG_NEEDARG,
"SOCKET",
"close a socket" },
{ "stats", 0, cfg_stats, CFG_TELNET, CFG_NEEDARG,
"ip|socket|tcp|udp|icmp|mbuf|tty|alltty|vj",
"show statistics" },
{ "exec", 0, cfg_exec, CFG_TELNET, CFG_NEEDARG,
"PATH_TO_PROGRAM",
"execute a program" },
{ "ptyexec", 0, cfg_ptyexec, CFG_TELNET, CFG_NEEDARG,
"PATH_TO_PROGRAM",
"execute a program in a pty" },
{ "unit", 0, cfg_setunit, CFG_TELNET, CFG_NEEDARG,
"N",
"configure a different unit" },
{ "wait", 0, cfg_wait, CFG_ANY, 0,
"[MINUTES]",
"set or show number of minutes slirp will linger after a disconnect" },
{ "quit", 0, cfg_quit, CFG_TELNET, 0,
"",
"quit the command-line" },
{ "password", 0, cfg_pass, CFG_CMD_FILE, CFG_NEEDARG,
"PASSWORD",
"make PASSWORD a password for telnet 10.0.2.0" },
{ "keepalive", 0, cfg_keepalive, CFG_CMD_FILE, 0,
"[SECONDS]",
"make Slirp probe each TCP connection [every SECONDS seconds]" },
{ "version", "-v", cfg_version, CFG_ANY, 0,
"",
"print Slirp's version" },
{ "towrite_max", 0, cfg_towrite_max, CFG_ANY, CFG_NEEDARG,
"NUM",
"set the maximum towrite per tty (see slirp.doc for details)" },
{ "tty", 0, cfg_tty, CFG_CMD_FILE, CFG_NEEDARG, "TTY",
"Configure alternate TTY for slirp to use (Overrides SLIRP_TTY)" },
{ "nozeros", 0, cfg_nozeros, CFG_CMD_FILE, 0, "",
"Disable 5 0's to exit, 5 1's to detach" },
/* PPP options */
#ifndef USE_PPP
{ "ppp", "-P", cfg_ppp, CFG_CMD_FILE, 0,
"",
"PPP not compiled into this slirp executable" },
#else
{ "ppp", "-P", cfg_ppp, CFG_CMD_FILE, 0,
"",
"set unit to use PPP instead of SLIP" },
#endif
#ifdef USE_PPP
{ "ppp_exit", 0, cfg_ppp_exit, CFG_ANY, 0,
"",
"make Slirp exit when PPP goes down" },
{ "-all", 0, noopt, CFG_CMD_FILE, 0,
"",
"ppp: don't request/allow any options" },
{ "-ac", 0, noaccomp, CFG_CMD_FILE, 0,
"",
"ppp: disable address/control compress" },
{ "-am", 0, noasyncmap, CFG_CMD_FILE, 0,
"",
"ppp: disable asyncmap negotiation" },
{ "asyncmap", "-as", setasyncmap, CFG_CMD_FILE, CFG_NEEDARG,
"ASYNCMAP",
"ppp: set the desired async map" },
{ "debugppp", "-dppp", setdebug, CFG_ANY, 0,
"FILE",
"ppp: increase debugging level" },
{ "-ip", 0, noipaddr, CFG_CMD_FILE, 0,
"",
"ppp: disable IP address negotiation" },
{ "-mn", 0, nomagicnumber, CFG_CMD_FILE, 0,
"",
"ppp: disable magic number negotiation" },
{ "-mru", 0, nomru, CFG_CMD_FILE, 0,
"",
"ppp: disable mru negotiation" },
{ "-pc", 0, nopcomp, CFG_CMD_FILE, 0,
"",
"ppp: disable protocol field compress" },
{ "+ua", 0, setupapfile, CFG_CMD_FILE, CFG_NEEDARG,
"FILE",
"ppp: get PAP user and password from file" },
{ "+pap", 0, reqpap, CFG_CMD_FILE, 0,
"",
"ppp: require PAP auth from peer" },
{ "-pap", 0, nopap, CFG_CMD_FILE, 0,
"",
"ppp: don't allow UPAP authentication with peer" },
{ "+chap", 0, reqchap, CFG_CMD_FILE, 0,
"",
"ppp: require CHAP authentication from peer" },
{ "-chap", 0, nochap, CFG_CMD_FILE, 0,
"",
"ppp: don't allow CHAP authentication with peer" },
{ "-vj", 0, setnovj, CFG_CMD_FILE, 0,
"",
"ppp: disable VJ compression" },
{ "-vjccomp", 0, setnovjccomp, CFG_CMD_FILE, 0,
"",
"ppp: disable VJ connection-ID compression" },
{ "vj-max-slots", 0, setvjslots, CFG_CMD_FILE, CFG_NEEDARG,
"SLOTS",
"ppp: set maximum VJ header slots" },
{ "escape", 0, setescape, CFG_CMD_FILE, CFG_NEEDARG,
"NUM[,NUM|-NUM][...]",
"ppp: set chars to escape on transmission" },
{ "domain", 0, setdomain, CFG_CMD_FILE, CFG_NEEDARG,
"ADDR",
"ppp: add given domain name to hostname" },
#endif
{ "mru", 0, setmru, CFG_CMD_FILE, CFG_NEEDARG,
"MRU",
"set MRU" },
{ "mtu", 0, setmtu, CFG_CMD_FILE, CFG_NEEDARG,
"MTU",
"set MTU" },
#ifdef USE_PPP
{ "initiate-options", 0, setinitopt, CFG_CMD_FILE, 0,
"",
"ppp: initiate the sending of options" },
{ "name", 0, setname, CFG_CMD_FILE, CFG_NEEDARG,
"NAME",
"ppp: set local name for authentication" },
{ "user", 0, set_user, CFG_CMD_FILE, CFG_NEEDARG,
"USERNAME",
"ppp: set username for PAP auth with peer" },
{ "usehostname", 0, setusehostname, CFG_CMD_FILE, 0,
"",
"ppp: must use hostname for auth" },
{ "remotename", 0, setremote, CFG_CMD_FILE, CFG_NEEDARG,
"HOSTNAME",
"ppp: set remote name for authentication" },
{ "auth", 0, setauth, CFG_CMD_FILE, 0,
"",
"ppp: require authentication from peer" },
{ "proxyarp", 0, setproxyarp, CFG_CMD_FILE, 0,
"",
"ppp: add proxy ARP entry" },
{ "login", 0, setdologin, CFG_CMD_FILE, 0,
"",
"ppp: use system password database for UPAP" },
{ "lcp-echo-failure", 0, setlcpechofails, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max number consecutive echo failures" },
{ "lcp-echo-interval", 0, setlcpechointv, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: time for lcp echo events" },
{ "lcp-restart", 0, setlcptimeout, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set timeout for LCP" },
{ "lcp-max-terminate", 0, setlcpterm, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for term-reqs" },
{ "lcp-max-configure", 0, setlcpconf, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for conf-reqs" },
{ "lcp-max-failure", 0, setlcpfails, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #conf-naks for LCP" },
{ "ipcp-restart", 0, setipcptimeout, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set timeout for IPCP" },
{ "ipcp-max-terminate", 0, setipcpterm, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for term-reqs" },
{ "ipcp-max-configure", 0, setipcpconf, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for conf-reqs" },
{ "ipcp-max-failure", 0, setipcpfails, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #conf-naks for IPCP" },
{ "pap-restart", 0, setpaptimeout, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set timeout for UPAP" },
{ "pap-max-authreq", 0, setpapreqs, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for auth-reqs" },
{ "pap-timeout", 0, setpapreqtime, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set PAP timeout" },
{ "chap-restart", 0, setchaptimeout, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set timeout for CHAP" },
{ "chap-max-challenge", 0, setchapchal, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set max #xmits for challenge" },
{ "chap-interval", 0, setchapintv, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set interval for rechallenge" },
{ "ipcp-accept-local", 0, setipcpaccl, CFG_CMD_FILE, 0,
"",
"ppp: accept peer's address for us" },
{ "ipcp-accept-remote", 0, setipcpaccr, CFG_CMD_FILE, 0,
"",
"ppp: accept peer's address for it" },
{ "bsdcomp", 0, setbsdcomp, CFG_CMD_FILE, CFG_NEEDARG,
"N",
"ppp: set bsdcomp" },
{ "-bsdcomp", 0, setnobsdcomp, CFG_CMD_FILE, 0,
"",
"ppp: don't use bsdcomp" },
{ "papcrypt", 0, setpapcrypt, CFG_CMD_FILE, 0,
"",
"ppp: crypt PAP authentication" },
#endif
{ NULL, NULL, NULL, 0, 0, NULL, NULL }
};
|