-
-
-/*
- * setconnector - Set a program to connect to a serial line
- */
-static int
-setconnector(argv)
- char **argv;
-{
- connector = strdup(*argv);
- if (connector == NULL)
- novm("connect script");
- connector_info.priv = privileged_option;
- connector_info.source = option_source;
-
- return (1);
-}
-
-/*
- * setdisconnector - Set a program to disconnect from the serial line
- */
-static int
-setdisconnector(argv)
- char **argv;
-{
- disconnector = strdup(*argv);
- if (disconnector == NULL)
- novm("disconnect script");
- disconnector_info.priv = privileged_option;
- disconnector_info.source = option_source;
-
- return (1);
-}
-
-/*
- * setwelcomer - Set a program to welcome a client after connection
- */
-static int
-setwelcomer(argv)
- char **argv;
-{
- welcomer = strdup(*argv);
- if (welcomer == NULL)
- novm("welcome script");
- welcomer_info.priv = privileged_option;
- welcomer_info.source = option_source;
-
- return (1);
-}
-
-/*
- * setmaxconnect - Set the maximum connect time
- */
-static int
-setmaxconnect(argv)
- char **argv;
-{
- int value;
-
- if (!int_option(*argv, &value))
- return 0;
- if (value < 0) {
- option_error("maxconnect time must be positive");
- return 0;
- }
- if (maxconnect > 0 && (value == 0 || value > maxconnect)) {
- option_error("maxconnect time cannot be increased");
- return 0;
- }
- maxconnect = value;
- return 1;
-}
-
-/*
- * setdomain - Set domain name to append to hostname
- */
-static int
-setdomain(argv)
- char **argv;
-{
- if (!privileged_option) {
- option_error("using the domain option requires root privilege");
- return 0;
- }
- gethostname(hostname, MAXNAMELEN);
- if (**argv != 0) {
- if (**argv != '.')
- strncat(hostname, ".", MAXNAMELEN - strlen(hostname));
- strncat(hostname, *argv, MAXNAMELEN - strlen(hostname));
- }
- hostname[MAXNAMELEN-1] = 0;
- return (1);
-}
-
-
-/*
- * setasyncmap - add bits to asyncmap (what we request peer to escape).
- */
-static int
-setasyncmap(argv)
- char **argv;
-{
- u_int32_t asyncmap;
-
- if (!number_option(*argv, &asyncmap, 16))
- return 0;
- lcp_wantoptions[0].asyncmap |= asyncmap;
- lcp_wantoptions[0].neg_asyncmap = 1;
- return(1);
-}
-
-
-/*
- * setescape - add chars to the set we escape on transmission.
- */
-static int
-setescape(argv)
- char **argv;
-{
- int n, ret;
- char *p, *endp;
-
- p = *argv;
- ret = 1;
- while (*p) {
- n = strtol(p, &endp, 16);
- if (p == endp) {
- option_error("escape parameter contains invalid hex number '%s'",
- p);
- return 0;
- }
- p = endp;
- if (n < 0 || (0x20 <= n && n <= 0x3F) || n == 0x5E || n > 0xFF) {
- option_error("can't escape character 0x%x", n);
- ret = 0;
- } else
- xmit_accm[0][n >> 5] |= 1 << (n & 0x1F);
- while (*p == ',' || *p == ' ')
- ++p;
- }
- return ret;
-}
-
-
-/*
- * setspeed - Set the speed.
- */
-static int
-setspeed(arg)
- char *arg;
-{
- char *ptr;
- int spd;
-
- spd = strtol(arg, &ptr, 0);
- if (ptr == arg || *ptr != 0 || spd == 0)
- return 0;
- inspeed = spd;
- return 1;
-}
-
-
-/*
- * setdevname - Set the device name.
- */
-static int
-setdevname(cp, quiet)
- char *cp;
- int quiet;
-{
- struct stat statbuf;
- char dev[MAXPATHLEN];
-
- if (*cp == 0)
- return 0;
-
- if (strncmp("/dev/", cp, 5) != 0) {
- strcpy(dev, "/dev/");
- strncat(dev, cp, MAXPATHLEN - 5);
- dev[MAXPATHLEN-1] = 0;
- cp = dev;
- }
-
- /*
- * Check if there is a device by this name.
- */
- if (stat(cp, &statbuf) < 0) {
- if (errno == ENOENT || quiet)
- return 0;
- option_error("Couldn't stat %s: %m", cp);
- return -1;
- }
-
- (void) strncpy(devnam, cp, MAXPATHLEN);
- devnam[MAXPATHLEN-1] = 0;
- default_device = FALSE;
- devnam_info.priv = privileged_option;
- devnam_info.source = option_source;
-
- return 1;
-}
-
-
-/*
- * setipaddr - Set the IP address
- */
-static int
-setipaddr(arg)
- char *arg;
-{
- struct hostent *hp;
- char *colon;
- u_int32_t local, remote;
- ipcp_options *wo = &ipcp_wantoptions[0];
-
- /*
- * IP address pair separated by ":".
- */
- if ((colon = strchr(arg, ':')) == NULL)
- return 0;
-
- /*
- * If colon first character, then no local addr.
- */
- if (colon != arg) {
- *colon = '\0';
- if ((local = inet_addr(arg)) == -1) {
- if ((hp = gethostbyname(arg)) == NULL) {
- option_error("unknown host: %s", arg);
- return -1;
- } else {
- local = *(u_int32_t *)hp->h_addr;
- }
- }
- if (bad_ip_adrs(local)) {
- option_error("bad local IP address %s", ip_ntoa(local));
- return -1;
- }
- if (local != 0)
- wo->ouraddr = local;
- *colon = ':';
- }
-
- /*
- * If colon last character, then no remote addr.
- */
- if (*++colon != '\0') {
- if ((remote = inet_addr(colon)) == -1) {
- if ((hp = gethostbyname(colon)) == NULL) {
- option_error("unknown host: %s", colon);
- return -1;
- } else {
- remote = *(u_int32_t *)hp->h_addr;
- if (remote_name[0] == 0) {
- strncpy(remote_name, colon, MAXNAMELEN);
- remote_name[MAXNAMELEN-1] = 0;
- }
- }
- }
- if (bad_ip_adrs(remote)) {
- option_error("bad remote IP address %s", ip_ntoa(remote));
- return -1;
- }
- if (remote != 0)
- wo->hisaddr = remote;
- }
-
- return 1;
-}
-
-
-/*
- * setnoipdflt - disable setipdefault()
- */
-static int
-setnoipdflt(argv)
- char **argv;
-{
- disable_defaultip = 1;
- return 1;
-}
-
-
-/*
- * setipcpaccl - accept peer's idea of our address
- */
-static int
-setipcpaccl(argv)
- char **argv;
-{
- ipcp_wantoptions[0].accept_local = 1;
- return 1;
-}
-
-
-/*
- * setipcpaccr - accept peer's idea of its address
- */
-static int
-setipcpaccr(argv)
- char **argv;
-{
- ipcp_wantoptions[0].accept_remote = 1;
- return 1;
-}
-
-
-/*
- * setnetmask - set the netmask to be used on the interface.
- */
-static int
-setnetmask(argv)
- char **argv;
-{
- u_int32_t mask, b;
- int n, ok;
- char *p, *endp;
-
- /*
- * Unfortunately, if we use inet_addr, we can't tell whether
- * a result of all 1s is an error or a valid 255.255.255.255.
- */
- p = *argv;
- ok = 0;
- mask = 0;
- for (n = 3;; --n) {
- b = strtoul(p, &endp, 0);
- if (endp == p)
- break;
- if (b < 0 || b > 255) {
- if (n == 3) {
- /* accept e.g. 0xffffff00 */
- p = endp;
- mask = b;
- }
- break;
- }
- mask |= b << (n * 8);
- p = endp;
- if (*p != '.' || n == 0)
- break;
- ++p;
- }
-
- mask = htonl(mask);
-
- if (*p != 0 || (netmask & ~mask) != 0) {
- option_error("invalid netmask value '%s'", *argv);
- return 0;
- }
-
- netmask = mask;
- return (1);
-}
-
-static int
-setcrtscts(argv)
- char **argv;
-{
- crtscts = 1;
- return (1);
-}
-
-static int
-setnocrtscts(argv)
- char **argv;
-{
- crtscts = -1;
- return (1);
-}
-
-static int
-setxonxoff(argv)
- char **argv;
-{
- lcp_wantoptions[0].asyncmap |= 0x000A0000; /* escape ^S and ^Q */
- lcp_wantoptions[0].neg_asyncmap = 1;
-
- crtscts = -2;
- return (1);
-}
-
-static int
-setnodetach(argv)
- char **argv;
-{
- nodetach = 1;
- return (1);
-}
-
-static int
-setdemand(argv)
- char **argv;
-{
- demand = 1;
- persist = 1;
- return 1;
-}
-
-static int
-setmodem(argv)
- char **argv;
-{
- modem = 1;
- return 1;
-}
-
-static int
-setlocal(argv)
- char **argv;
-{
- modem = 0;
- return 1;
-}
-
-static int
-setlock(argv)
- char **argv;
-{
- lockflag = 1;
- return 1;
-}
-
-static int
-setusehostname(argv)
- char **argv;
-{
- usehostname = 1;
- return 1;
-}
-
-static int
-setname(argv)
- char **argv;
-{
- if (!privileged_option) {
- option_error("using the name option requires root privilege");
- return 0;
- }
- strncpy(our_name, argv[0], MAXNAMELEN);
- our_name[MAXNAMELEN-1] = 0;
- return 1;
-}
-
-static int
-setuser(argv)
- char **argv;
-{
- strncpy(user, argv[0], MAXNAMELEN);
- user[MAXNAMELEN-1] = 0;
- return 1;
-}
-
-static int
-setremote(argv)
- char **argv;
-{
- strncpy(remote_name, argv[0], MAXNAMELEN);
- remote_name[MAXNAMELEN-1] = 0;
- return 1;
-}
-
-static int
-setauth(argv)
- char **argv;
-{
- auth_required = 1;
- if (privileged_option > auth_req_info.priv) {
- auth_req_info.priv = privileged_option;
- auth_req_info.source = option_source;
- }
- return 1;
-}
-
-static int
-setnoauth(argv)
- char **argv;
-{
- if (auth_required && privileged_option < auth_req_info.priv) {
- option_error("cannot override auth option set by %s",
- auth_req_info.source);
- return 0;
- }
- auth_required = 0;
- return 1;
-}
-
-static int
-setdefaultroute(argv)
- char **argv;
-{
- if (!ipcp_allowoptions[0].default_route) {
- option_error("defaultroute option is disabled");
- return 0;
- }
- ipcp_wantoptions[0].default_route = 1;
- return 1;
-}
-
-static int
-setnodefaultroute(argv)
- char **argv;
-{
- ipcp_allowoptions[0].default_route = 0;
- ipcp_wantoptions[0].default_route = 0;
- return 1;
-}
-
-static int
-setproxyarp(argv)
- char **argv;
-{
- if (!ipcp_allowoptions[0].proxy_arp) {
- option_error("proxyarp option is disabled");
- return 0;
- }
- ipcp_wantoptions[0].proxy_arp = 1;
- return 1;
-}
-
-static int
-setnoproxyarp(argv)
- char **argv;
-{
- ipcp_wantoptions[0].proxy_arp = 0;
- ipcp_allowoptions[0].proxy_arp = 0;
- return 1;
-}
-
-static int
-setpersist(argv)
- char **argv;
-{
- persist = 1;
- return 1;
-}
-
-static int
-setnopersist(argv)
- char **argv;
-{
- persist = 0;
- return 1;
-}
-
-static int
-setdologin(argv)
- char **argv;
-{
- uselogin = 1;
- return 1;
-}
-
-/*
- * Functions to set the echo interval for modem-less monitors
- */
-
-static int
-setlcpechointv(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_echo_interval);
-}
-
-static int
-setlcpechofails(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_echo_fails);
-}
-
-/*
- * Functions to set timeouts, max transmits, etc.
- */
-static int
-setlcptimeout(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_fsm[0].timeouttime);
-}
-
-static int
-setlcpterm(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_fsm[0].maxtermtransmits);
-}
-
-static int
-setlcpconf(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_fsm[0].maxconfreqtransmits);
-}
-
-static int
-setlcpfails(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_fsm[0].maxnakloops);
-}
-
-static int
-setipcptimeout(argv)
- char **argv;
-{
- return int_option(*argv, &ipcp_fsm[0].timeouttime);
-}
-
-static int
-setipcpterm(argv)
- char **argv;
-{
- return int_option(*argv, &ipcp_fsm[0].maxtermtransmits);
-}
-
-static int
-setipcpconf(argv)
- char **argv;
-{
- return int_option(*argv, &ipcp_fsm[0].maxconfreqtransmits);
-}
-
-static int
-setipcpfails(argv)
- char **argv;
-{
- return int_option(*argv, &lcp_fsm[0].maxnakloops);
-}
-
-static int
-setpaptimeout(argv)
- char **argv;
-{
- return int_option(*argv, &upap[0].us_timeouttime);
-}
-
-static int
-setpapreqtime(argv)
- char **argv;
-{
- return int_option(*argv, &upap[0].us_reqtimeout);
-}
-
-static int
-setpapreqs(argv)
- char **argv;
-{
- return int_option(*argv, &upap[0].us_maxtransmits);
-}
-
-static int
-setchaptimeout(argv)
- char **argv;
-{
- return int_option(*argv, &chap[0].timeouttime);
-}
-
-static int
-setchapchal(argv)
- char **argv;
-{
- return int_option(*argv, &chap[0].max_transmits);
-}
-
-static int
-setchapintv(argv)
- char **argv;
-{
- return int_option(*argv, &chap[0].chal_interval);
-}
-
-static int
-noccp(argv)
- char **argv;
-{
- ccp_protent.enabled_flag = 0;
- return 1;
-}
-
-static int
-setbsdcomp(argv)
- char **argv;
-{
- int rbits, abits;
- char *str, *endp;
-
- str = *argv;
- abits = rbits = strtol(str, &endp, 0);
- if (endp != str && *endp == ',') {
- str = endp + 1;
- abits = strtol(str, &endp, 0);
- }
- if (*endp != 0 || endp == str) {
- option_error("invalid parameter '%s' for bsdcomp option", *argv);
- return 0;
- }
- if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS))
- || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) {
- option_error("bsdcomp option values must be 0 or %d .. %d",
- BSD_MIN_BITS, BSD_MAX_BITS);
- return 0;
- }
- if (rbits > 0) {
- ccp_wantoptions[0].bsd_compress = 1;
- ccp_wantoptions[0].bsd_bits = rbits;
- } else
- ccp_wantoptions[0].bsd_compress = 0;
- if (abits > 0) {
- ccp_allowoptions[0].bsd_compress = 1;
- ccp_allowoptions[0].bsd_bits = abits;
- } else
- ccp_allowoptions[0].bsd_compress = 0;
- return 1;
-}
-
-static int
-setnobsdcomp(argv)
- char **argv;
-{
- ccp_wantoptions[0].bsd_compress = 0;
- ccp_allowoptions[0].bsd_compress = 0;
- return 1;
-}
-
-static int
-setdeflate(argv)
- char **argv;
-{
- int rbits, abits;
- char *str, *endp;
-
- str = *argv;
- abits = rbits = strtol(str, &endp, 0);
- if (endp != str && *endp == ',') {
- str = endp + 1;
- abits = strtol(str, &endp, 0);
- }
- if (*endp != 0 || endp == str) {
- option_error("invalid parameter '%s' for deflate option", *argv);
- return 0;
- }
- if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE))
- || (abits != 0 && (abits < DEFLATE_MIN_SIZE
- || abits > DEFLATE_MAX_SIZE))) {
- option_error("deflate option values must be 0 or %d .. %d",
- DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE);
- return 0;
- }
- if (rbits > 0) {
- ccp_wantoptions[0].deflate = 1;
- ccp_wantoptions[0].deflate_size = rbits;
- } else
- ccp_wantoptions[0].deflate = 0;
- if (abits > 0) {
- ccp_allowoptions[0].deflate = 1;
- ccp_allowoptions[0].deflate_size = abits;
- } else
- ccp_allowoptions[0].deflate = 0;
- return 1;
-}
-
-static int
-setnodeflate(argv)
- char **argv;
-{
- ccp_wantoptions[0].deflate = 0;
- ccp_allowoptions[0].deflate = 0;
- return 1;
-}
-
-static int
-setpred1comp(argv)
- char **argv;
-{
- ccp_wantoptions[0].predictor_1 = 1;
- ccp_allowoptions[0].predictor_1 = 1;
- return 1;
-}
-
-static int
-setnopred1comp(argv)
- char **argv;
-{
- ccp_wantoptions[0].predictor_1 = 0;
- ccp_allowoptions[0].predictor_1 = 0;
- return 1;
-}
-
-static int
-setipparam(argv)
- char **argv;
-{
- ipparam = strdup(*argv);
- if (ipparam == NULL)
- novm("ipparam string");
-
- return 1;
-}
-
-static int
-setpapcrypt(argv)
- char **argv;
-{
- cryptpap = 1;
- return 1;
-}
-
-static int
-setidle(argv)
- char **argv;
-{
- return int_option(*argv, &idle_time_limit);
-}
-
-static int
-setholdoff(argv)
- char **argv;
-{
- return int_option(*argv, &holdoff);
-}
-
-/*
- * setdnsaddr - set the dns address(es)
- */
-static int
-setdnsaddr(argv)
- char **argv;
-{
- u_int32_t dns;
- struct hostent *hp;
-
- dns = inet_addr(*argv);
- if (dns == -1) {
- if ((hp = gethostbyname(*argv)) == NULL) {
- option_error("invalid address parameter '%s' for ms-dns option",
- *argv);
- return 0;
- }
- dns = *(u_int32_t *)hp->h_addr;
- }
-
- if (ipcp_allowoptions[0].dnsaddr[0] == 0) {
- ipcp_allowoptions[0].dnsaddr[0] = dns;
- } else {
- ipcp_allowoptions[0].dnsaddr[1] = dns;
- }
-
- return (1);
-}
-
-/*
- * setwinsaddr - set the wins address(es)
- * This is primrarly used with the Samba package under UNIX or for pointing
- * the caller to the existing WINS server on a Windows NT platform.
- */
-static int
-setwinsaddr(argv)
- char **argv;
-{
- u_int32_t wins;
- struct hostent *hp;
-
- wins = inet_addr(*argv);
- if (wins == -1) {
- if ((hp = gethostbyname(*argv)) == NULL) {
- option_error("invalid address parameter '%s' for ms-wins option",
- *argv);
- return 0;
- }
- wins = *(u_int32_t *)hp->h_addr;
- }
-
- if (ipcp_allowoptions[0].winsaddr[0] == 0) {
- ipcp_allowoptions[0].winsaddr[0] = wins;
- } else {
- ipcp_allowoptions[0].winsaddr[1] = wins;
- }
-
- return (1);
-}
-
-#ifdef IPX_CHANGE
-static int
-setipxrouter (argv)
- char **argv;
-{
- ipxcp_wantoptions[0].neg_router = 1;
- ipxcp_allowoptions[0].neg_router = 1;
- return int_option(*argv, &ipxcp_wantoptions[0].router);
-}
-
-static int
-setipxname (argv)
- char **argv;
-{
- char *dest = ipxcp_wantoptions[0].name;
- char *src = *argv;
- int count;
- char ch;
-
- ipxcp_wantoptions[0].neg_name = 1;
- ipxcp_allowoptions[0].neg_name = 1;
- memset (dest, '\0', sizeof (ipxcp_wantoptions[0].name));
-
- count = 0;
- while (*src) {
- ch = *src++;
- if (! isalnum (ch) && ch != '_') {
- option_error("IPX router name must be alphanumeric or _");
- return 0;
- }
-
- if (count >= sizeof (ipxcp_wantoptions[0].name)) {
- option_error("IPX router name is limited to %d characters",
- sizeof (ipxcp_wantoptions[0].name) - 1);
- return 0;
- }
-
- dest[count++] = toupper (ch);
- }
-
- return 1;
-}
-
-static int
-setipxcptimeout (argv)
- char **argv;
-{
- return int_option(*argv, &ipxcp_fsm[0].timeouttime);
-}
-
-static int
-setipxcpterm (argv)
- char **argv;
-{
- return int_option(*argv, &ipxcp_fsm[0].maxtermtransmits);
-}
-
-static int
-setipxcpconf (argv)
- char **argv;
-{
- return int_option(*argv, &ipxcp_fsm[0].maxconfreqtransmits);
-}
-
-static int
-setipxcpfails (argv)
- char **argv;
-{
- return int_option(*argv, &ipxcp_fsm[0].maxnakloops);
-}
-
-static int
-setipxnetwork(argv)
- char **argv;
-{
- u_int32_t v;
-
- if (!number_option(*argv, &v, 16))
- return 0;
-
- ipxcp_wantoptions[0].our_network = (int) v;
- ipxcp_wantoptions[0].neg_nn = 1;
- return 1;
-}
-
-static int
-setipxanet(argv)
- char **argv;
-{
- ipxcp_wantoptions[0].accept_network = 1;
- ipxcp_allowoptions[0].accept_network = 1;
-}
-
-static int
-setipxalcl(argv)
- char **argv;
-{
- ipxcp_wantoptions[0].accept_local = 1;
- ipxcp_allowoptions[0].accept_local = 1;
-}
-
-static int
-setipxarmt(argv)
- char **argv;
-{
- ipxcp_wantoptions[0].accept_remote = 1;
- ipxcp_allowoptions[0].accept_remote = 1;
-}
-
-static u_char *
-setipxnodevalue(src,dst)
-u_char *src, *dst;
-{
- int indx;
- int item;
-
- for (;;) {
- if (!isxdigit (*src))
- break;
-
- for (indx = 0; indx < 5; ++indx) {
- dst[indx] <<= 4;
- dst[indx] |= (dst[indx + 1] >> 4) & 0x0F;
- }
-
- item = toupper (*src) - '0';
- if (item > 9)
- item -= 7;
-
- dst[5] = (dst[5] << 4) | item;
- ++src;
- }
- return src;
-}
-
-static int
-setipxnode(argv)
- char **argv;
-{
- char *end;
-
- memset (&ipxcp_wantoptions[0].our_node[0], 0, 6);
- memset (&ipxcp_wantoptions[0].his_node[0], 0, 6);
-
- end = setipxnodevalue (*argv, &ipxcp_wantoptions[0].our_node[0]);
- if (*end == ':')
- end = setipxnodevalue (++end, &ipxcp_wantoptions[0].his_node[0]);
-
- if (*end == '\0') {
- ipxcp_wantoptions[0].neg_node = 1;
- return 1;
- }
-
- option_error("invalid parameter '%s' for ipx-node option", *argv);
- return 0;
-}
-
-static int
-setipxproto(argv)
- char **argv;
-{
- ipxcp_protent.enabled_flag = 1;
- return 1;
-}
-
-static int
-resetipxproto(argv)
- char **argv;
-{
- ipxcp_protent.enabled_flag = 0;
- return 1;
-}
-#else
-
-static int
-resetipxproto(argv)
- char **argv;
-{
- return 1;
-}
-#endif /* IPX_CHANGE */
-
-#ifdef MSLANMAN
-static int
-setmslanman(argv)
- char **argv;
-{
- ms_lanman = 1;
- return (1);
-}
-#endif