command.c (85602e5267f413a849370d3c6fe3d0a87cdd5b49) command.c (565e35e50e2cdac423588a3d18742544bde128b0)
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.131.2.55 1998/04/07 00:53:33 brian Exp $
20 * $Id: command.c,v 1.131.2.56 1998/04/07 23:45:45 brian Exp $
21 *
22 */
23#include <sys/types.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>
29#include <net/route.h>
30#include <netdb.h>
21 *
22 */
23#include <sys/types.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>
29#include <net/route.h>
30#include <netdb.h>
31#include <sys/un.h>
31
32#ifndef NOALIAS
33#include <alias.h>
34#endif
35#include <errno.h>
36#include <fcntl.h>
37#include <paths.h>
38#include <signal.h>

--- 138 unchanged lines hidden (view full) ---

177 LogPrintf(LogWARN, "remove: Cannot delete links that aren't closed\n");
178 return 2;
179 }
180
181 bundle_DatalinkRemove(arg->bundle, arg->cx);
182 return 0;
183}
184
32
33#ifndef NOALIAS
34#include <alias.h>
35#endif
36#include <errno.h>
37#include <fcntl.h>
38#include <paths.h>
39#include <signal.h>

--- 138 unchanged lines hidden (view full) ---

178 LogPrintf(LogWARN, "remove: Cannot delete links that aren't closed\n");
179 return 2;
180 }
181
182 bundle_DatalinkRemove(arg->bundle, arg->cx);
183 return 0;
184}
185
186int
187LoadCommand(struct cmdargs const *arg)
188{
189 const char *name;
190
191 if (arg->argc > 0)
192 name = *arg->argv;
193 else
194 name = "default";
195
196 if (!ValidSystem(name, arg->prompt, arg->bundle->phys_type)) {
197 LogPrintf(LogERROR, "%s: Label not allowed\n", name);
198 return 1;
199 } else if (SelectSystem(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
200 LogPrintf(LogWARN, "%s: label not found.\n", name);
201 return -1;
202 } else
203 SetLabel(arg->argc ? name : NULL);
204 return 0;
205}
206
207int
208SaveCommand(struct cmdargs const *arg)
209{
210 LogPrintf(LogWARN, "save command is not implemented (yet).\n");
211 return 1;
212}
213
185static int
186DialCommand(struct cmdargs const *arg)
187{
188 int res;
189
214static int
215DialCommand(struct cmdargs const *arg)
216{
217 int res;
218
190 if ((mode & MODE_DAEMON) && !(mode & MODE_AUTO)) {
219 if ((arg->cx && !(arg->cx->physical->type & (PHYS_MANUAL|PHYS_DEMAND)))
220 || (!arg->cx && (arg->bundle->phys_type & ~(PHYS_MANUAL|PHYS_DEMAND)))) {
191 LogPrintf(LogWARN,
192 "Manual dial is only available in auto and interactive mode\n");
193 return 1;
194 }
195
196 if (arg->argc > 0 && (res = LoadCommand(arg)) != 0)
197 return res;
198
221 LogPrintf(LogWARN,
222 "Manual dial is only available in auto and interactive mode\n");
223 return 1;
224 }
225
226 if (arg->argc > 0 && (res = LoadCommand(arg)) != 0)
227 return res;
228
199 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL);
229 bundle_Open(arg->bundle, arg->cx ? arg->cx->name : NULL, PHYS_ALL);
200
201 return 0;
202}
203
204static int
205ShellCommand(struct cmdargs const *arg, int bg)
206{
207 const char *shell;
208 pid_t shpid;
209 int argc;
210 char *argv[MAXARGS];
211
212#ifdef SHELL_ONLY_INTERACTIVELY
213 /* we're only allowed to shell when we run ppp interactively */
230
231 return 0;
232}
233
234static int
235ShellCommand(struct cmdargs const *arg, int bg)
236{
237 const char *shell;
238 pid_t shpid;
239 int argc;
240 char *argv[MAXARGS];
241
242#ifdef SHELL_ONLY_INTERACTIVELY
243 /* we're only allowed to shell when we run ppp interactively */
214 if (mode != MODE_INTER) {
215 LogPrintf(LogWARN, "Can only start a shell in interactive mode\n");
244 if (arg->prompt && arg->prompt->owner) {
245 LogPrintf(LogWARN, "Can't start a shell from a network connection\n");
216 return 1;
217 }
218#endif
246 return 1;
247 }
248#endif
219#ifdef NO_SHELL_IN_AUTO_INTERACTIVE
220
249
221 /*
222 * we want to stop shell commands when we've got a telnet connection to an
223 * auto mode ppp
224 */
225 if (arg->prompt && !(mode & MODE_INTER)) {
226 LogPrintf(LogWARN, "Shell is not allowed interactively in auto mode\n");
227 return 1;
228 }
229#endif
230
231 if (arg->argc == 0)
250 if (arg->argc == 0)
232 if (!(mode & MODE_INTER)) {
233 if (arg->prompt)
234 LogPrintf(LogWARN, "Can't start an interactive shell from"
235 " a telnet session\n");
236 else
237 LogPrintf(LogWARN, "Can only start an interactive shell in"
238 " interactive mode\n");
251 if (!arg->prompt) {
252 LogPrintf(LogWARN, "Can't start an interactive shell from"
253 " a config file\n");
239 return 1;
254 return 1;
255 } else if (arg->prompt->owner) {
256 LogPrintf(LogWARN, "Can't start an interactive shell from"
257 " a socket connection\n");
258 return 1;
240 } else if (bg) {
241 LogPrintf(LogWARN, "Can only start an interactive shell in"
242 " the foreground mode\n");
243 return 1;
244 }
259 } else if (bg) {
260 LogPrintf(LogWARN, "Can only start an interactive shell in"
261 " the foreground mode\n");
262 return 1;
263 }
245 if ((shell = getenv("SHELL")) == 0)
246 shell = _PATH_BSHELL;
247
248 if ((shpid = fork()) == 0) {
249 int dtablesize, i, fd;
250
264
265 if ((shpid = fork()) == 0) {
266 int dtablesize, i, fd;
267
268 if ((shell = getenv("SHELL")) == 0)
269 shell = _PATH_BSHELL;
270
251 TermTimerService();
252 signal(SIGINT, SIG_DFL);
253 signal(SIGQUIT, SIG_DFL);
254 signal(SIGTERM, SIG_DFL);
255 signal(SIGHUP, SIG_DFL);
256 signal(SIGALRM, SIG_DFL);
257
258 if (arg->prompt)
259 fd = arg->prompt->fd_out;
260 else if ((fd = open("/dev/null", O_RDWR)) == -1) {
261 LogPrintf(LogALERT, "Failed to open /dev/null: %s\n", strerror(errno));
262 exit(1);
263 }
264 for (i = 0; i < 3; i++)
265 dup2(fd, i);
266
267 for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
268 close(i);
269
271 TermTimerService();
272 signal(SIGINT, SIG_DFL);
273 signal(SIGQUIT, SIG_DFL);
274 signal(SIGTERM, SIG_DFL);
275 signal(SIGHUP, SIG_DFL);
276 signal(SIGALRM, SIG_DFL);
277
278 if (arg->prompt)
279 fd = arg->prompt->fd_out;
280 else if ((fd = open("/dev/null", O_RDWR)) == -1) {
281 LogPrintf(LogALERT, "Failed to open /dev/null: %s\n", strerror(errno));
282 exit(1);
283 }
284 for (i = 0; i < 3; i++)
285 dup2(fd, i);
286
287 for (dtablesize = getdtablesize(), i = 3; i < dtablesize; i++)
288 close(i);
289
270 prompt_TtyOldMode(arg->prompt);
271 setuid(geteuid());
272 if (arg->argc > 0) {
273 /* substitute pseudo args */
274 argv[0] = strdup(arg->argv[0]);
275 for (argc = 1; argc < arg->argc; argc++) {
276 if (strcasecmp(arg->argv[argc], "HISADDR") == 0)
277 argv[argc] = strdup(inet_ntoa(arg->bundle->ncp.ipcp.peer_ip));
278 else if (strcasecmp(arg->argv[argc], "INTERFACE") == 0)

--- 13 unchanged lines hidden (view full) ---

292 exit(1);
293 }
294 } else if (arg->prompt)
295 printf("ppp: Pausing until %s finishes\n", arg->argv[0]);
296 execvp(argv[0], argv);
297 } else {
298 if (arg->prompt)
299 printf("ppp: Pausing until %s finishes\n", shell);
290 setuid(geteuid());
291 if (arg->argc > 0) {
292 /* substitute pseudo args */
293 argv[0] = strdup(arg->argv[0]);
294 for (argc = 1; argc < arg->argc; argc++) {
295 if (strcasecmp(arg->argv[argc], "HISADDR") == 0)
296 argv[argc] = strdup(inet_ntoa(arg->bundle->ncp.ipcp.peer_ip));
297 else if (strcasecmp(arg->argv[argc], "INTERFACE") == 0)

--- 13 unchanged lines hidden (view full) ---

311 exit(1);
312 }
313 } else if (arg->prompt)
314 printf("ppp: Pausing until %s finishes\n", arg->argv[0]);
315 execvp(argv[0], argv);
316 } else {
317 if (arg->prompt)
318 printf("ppp: Pausing until %s finishes\n", shell);
319 prompt_TtyOldMode(arg->prompt);
300 execl(shell, shell, NULL);
301 }
302
303 LogPrintf(LogWARN, "exec() of %s failed\n",
304 arg->argc > 0 ? arg->argv[0] : shell);
305 exit(255);
306 }
320 execl(shell, shell, NULL);
321 }
322
323 LogPrintf(LogWARN, "exec() of %s failed\n",
324 arg->argc > 0 ? arg->argv[0] : shell);
325 exit(255);
326 }
307 if (shpid == (pid_t) - 1) {
327
328 if (shpid == (pid_t) - 1)
308 LogPrintf(LogERROR, "Fork failed: %s\n", strerror(errno));
329 LogPrintf(LogERROR, "Fork failed: %s\n", strerror(errno));
309 } else {
330 else {
310 int status;
331 int status;
311
312 waitpid(shpid, &status, 0);
313 }
314
332 waitpid(shpid, &status, 0);
333 }
334
315 if (arg->prompt)
335 if (arg->prompt && !arg->prompt->owner)
316 prompt_TtyCommandMode(arg->prompt);
317
336 prompt_TtyCommandMode(arg->prompt);
337
318 return (0);
338 return 0;
319}
320
321static int
322BgShellCommand(struct cmdargs const *arg)
323{
324 if (arg->argc == 0)
325 return -1;
326 return ShellCommand(arg, 1);

--- 35 unchanged lines hidden (view full) ---

362 {"disable", NULL, DisableCommand, LOCAL_AUTH,
363 "Disable option", "disable option .."},
364 {"display", NULL, DisplayCommand, LOCAL_AUTH,
365 "Display option configs", "display"},
366 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX,
367 "Generate a down event", "down"},
368 {"enable", NULL, EnableCommand, LOCAL_AUTH,
369 "Enable option", "enable option .."},
339}
340
341static int
342BgShellCommand(struct cmdargs const *arg)
343{
344 if (arg->argc == 0)
345 return -1;
346 return ShellCommand(arg, 1);

--- 35 unchanged lines hidden (view full) ---

382 {"disable", NULL, DisableCommand, LOCAL_AUTH,
383 "Disable option", "disable option .."},
384 {"display", NULL, DisplayCommand, LOCAL_AUTH,
385 "Display option configs", "display"},
386 {"down", NULL, DownCommand, LOCAL_AUTH | LOCAL_CX,
387 "Generate a down event", "down"},
388 {"enable", NULL, EnableCommand, LOCAL_AUTH,
389 "Enable option", "enable option .."},
370 {"link", NULL, LinkCommand, LOCAL_AUTH,
390 {"link", "datalink", LinkCommand, LOCAL_AUTH,
371 "Link specific commands", "link name command ..."},
372 {"load", NULL, LoadCommand, LOCAL_AUTH,
373 "Load settings", "load [remote]"},
374 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
375 "Password for manipulation", "passwd LocalPassword"},
376 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
377 "Quit PPP program", "quit|bye [all]"},
378 {"remove", NULL, RemoveCommand, LOCAL_AUTH | LOCAL_CX,

--- 82 unchanged lines hidden (view full) ---

461 prompt_Printf(arg->prompt, "AuthKey = %s\n", HIDDEN);
462 return 0;
463}
464
465static int
466ShowVersion(struct cmdargs const *arg)
467{
468 static char VarVersion[] = "PPP Version 2.0-beta";
391 "Link specific commands", "link name command ..."},
392 {"load", NULL, LoadCommand, LOCAL_AUTH,
393 "Load settings", "load [remote]"},
394 {"passwd", NULL, PasswdCommand, LOCAL_NO_AUTH,
395 "Password for manipulation", "passwd LocalPassword"},
396 {"quit", "bye", QuitCommand, LOCAL_AUTH | LOCAL_NO_AUTH,
397 "Quit PPP program", "quit|bye [all]"},
398 {"remove", NULL, RemoveCommand, LOCAL_AUTH | LOCAL_CX,

--- 82 unchanged lines hidden (view full) ---

481 prompt_Printf(arg->prompt, "AuthKey = %s\n", HIDDEN);
482 return 0;
483}
484
485static int
486ShowVersion(struct cmdargs const *arg)
487{
488 static char VarVersion[] = "PPP Version 2.0-beta";
469 static char VarLocalVersion[] = "$Date: 1998/04/07 00:53:33 $";
489 static char VarLocalVersion[] = "$Date: 1998/04/07 23:45:45 $";
470
471 prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
472 return 0;
473}
474
475int
476ShowProtocolStats(struct cmdargs const *arg)
477{
478 struct link *l = ChooseLink(arg);
479
480 prompt_Printf(arg->prompt, "%s:\n", l->name);
481 link_ReportProtocolStatus(l, arg->prompt);
482 return 0;
483}
484
485
490
491 prompt_Printf(arg->prompt, "%s - %s \n", VarVersion, VarLocalVersion);
492 return 0;
493}
494
495int
496ShowProtocolStats(struct cmdargs const *arg)
497{
498 struct link *l = ChooseLink(arg);
499
500 prompt_Printf(arg->prompt, "%s:\n", l->name);
501 link_ReportProtocolStatus(l, arg->prompt);
502 return 0;
503}
504
505
486static int
487ShowReconnect(struct cmdargs const *arg)
488{
489 prompt_Printf(arg->prompt, "%s: Reconnect Timer: %d, %d tries\n",
490 arg->cx->name, arg->cx->cfg.reconnect_timeout,
491 arg->cx->cfg.max_reconnect);
492 return 0;
493}
494
495static int
496ShowRedial(struct cmdargs const *arg)
497{
498 prompt_Printf(arg->prompt, " Redial Timer: ");
499
500 if (arg->cx->cfg.dial_timeout >= 0)
501 prompt_Printf(arg->prompt, " %d seconds, ", arg->cx->cfg.dial_timeout);
502 else
503 prompt_Printf(arg->prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
504
505 prompt_Printf(arg->prompt, " Redial Next Timer: ");
506
507 if (arg->cx->cfg.dial_next_timeout >= 0)
508 prompt_Printf(arg->prompt, " %d seconds, ", arg->cx->cfg.dial_next_timeout);
509 else
510 prompt_Printf(arg->prompt, " Random 0 - %d seconds, ", DIAL_TIMEOUT);
511
512 if (arg->cx->cfg.max_dial)
513 prompt_Printf(arg->prompt, "%d dial tries", arg->cx->cfg.max_dial);
514
515 prompt_Printf(arg->prompt, "\n");
516
517 return 0;
518}
519
520#ifndef NOMSEXT
521static int
522ShowMSExt(struct cmdargs const *arg)
523{
524 prompt_Printf(arg->prompt, " MS PPP extention values \n");
525 prompt_Printf(arg->prompt, " Primary NS : %s\n",
526 inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[0]));
527 prompt_Printf(arg->prompt, " Secondary NS : %s\n",

--- 34 unchanged lines hidden (view full) ---

562 {"modem", NULL, modem_ShowStatus, LOCAL_AUTH | LOCAL_CX,
563 "Show modem setups", "show modem"},
564#ifndef NOMSEXT
565 {"msext", NULL, ShowMSExt, LOCAL_AUTH,
566 "Show MS PPP extentions", "show msext"},
567#endif
568 {"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT,
569 "Show protocol summary", "show proto"},
506#ifndef NOMSEXT
507static int
508ShowMSExt(struct cmdargs const *arg)
509{
510 prompt_Printf(arg->prompt, " MS PPP extention values \n");
511 prompt_Printf(arg->prompt, " Primary NS : %s\n",
512 inet_ntoa(arg->bundle->ncp.ipcp.cfg.ns_entries[0]));
513 prompt_Printf(arg->prompt, " Secondary NS : %s\n",

--- 34 unchanged lines hidden (view full) ---

548 {"modem", NULL, modem_ShowStatus, LOCAL_AUTH | LOCAL_CX,
549 "Show modem setups", "show modem"},
550#ifndef NOMSEXT
551 {"msext", NULL, ShowMSExt, LOCAL_AUTH,
552 "Show MS PPP extentions", "show msext"},
553#endif
554 {"proto", NULL, ShowProtocolStats, LOCAL_AUTH | LOCAL_CX_OPT,
555 "Show protocol summary", "show proto"},
570 {"reconnect", NULL, ShowReconnect, LOCAL_AUTH | LOCAL_CX,
571 "Show reconnect timer", "show reconnect"},
572 {"redial", NULL, ShowRedial, LOCAL_AUTH | LOCAL_CX,
573 "Show Redial timeout", "show redial"},
574 {"route", NULL, ShowRoute, LOCAL_AUTH,
575 "Show routing table", "show route"},
576 {"stopped", NULL, ShowStopped, LOCAL_AUTH | LOCAL_CX,
577 "Show STOPPED timeout", "show stopped"},
578 {"timeout", NULL, ShowTimeout, LOCAL_AUTH,
579 "Show Idle timeout", "show timeout"},
580 {"timers", NULL, ShowTimerList, LOCAL_AUTH,
581 "Show alarm timers", "show timers"},

--- 247 unchanged lines hidden (view full) ---

829 LogPrintf(LogWARN, "%s: Invalid speed\n", *arg->argv);
830 } else
831 LogPrintf(LogWARN, "SetModemSpeed: No speed specified\n");
832
833 return -1;
834}
835
836static int
556 {"route", NULL, ShowRoute, LOCAL_AUTH,
557 "Show routing table", "show route"},
558 {"stopped", NULL, ShowStopped, LOCAL_AUTH | LOCAL_CX,
559 "Show STOPPED timeout", "show stopped"},
560 {"timeout", NULL, ShowTimeout, LOCAL_AUTH,
561 "Show Idle timeout", "show timeout"},
562 {"timers", NULL, ShowTimerList, LOCAL_AUTH,
563 "Show alarm timers", "show timers"},

--- 247 unchanged lines hidden (view full) ---

811 LogPrintf(LogWARN, "%s: Invalid speed\n", *arg->argv);
812 } else
813 LogPrintf(LogWARN, "SetModemSpeed: No speed specified\n");
814
815 return -1;
816}
817
818static int
837SetReconnect(struct cmdargs const *arg)
838{
839 if (arg->argc == 2) {
840 arg->cx->cfg.reconnect_timeout = atoi(arg->argv[0]);
841 arg->cx->cfg.max_reconnect = (mode & MODE_DIRECT) ? 0 : atoi(arg->argv[1]);
842 return 0;
843 }
844 return -1;
845}
846
847static int
848SetRedialTimeout(struct cmdargs const *arg)
849{
850 int timeout;
851 int tries;
852 char *dot;
853
854 if (arg->argc == 1 || arg->argc == 2) {
855 if (strncasecmp(arg->argv[0], "random", 6) == 0 &&
856 (arg->argv[0][6] == '\0' || arg->argv[0][6] == '.')) {
857 arg->cx->cfg.dial_timeout = -1;
858 randinit();
859 } else {
860 timeout = atoi(arg->argv[0]);
861
862 if (timeout >= 0)
863 arg->cx->cfg.dial_timeout = timeout;
864 else {
865 LogPrintf(LogWARN, "Invalid redial timeout\n");
866 return -1;
867 }
868 }
869
870 dot = strchr(arg->argv[0], '.');
871 if (dot) {
872 if (strcasecmp(++dot, "random") == 0) {
873 arg->cx->cfg.dial_next_timeout = -1;
874 randinit();
875 } else {
876 timeout = atoi(dot);
877 if (timeout >= 0)
878 arg->cx->cfg.dial_next_timeout = timeout;
879 else {
880 LogPrintf(LogWARN, "Invalid next redial timeout\n");
881 return -1;
882 }
883 }
884 } else
885 /* Default next timeout */
886 arg->cx->cfg.dial_next_timeout = DIAL_NEXT_TIMEOUT;
887
888 if (arg->argc == 2) {
889 tries = atoi(arg->argv[1]);
890
891 if (tries >= 0) {
892 arg->cx->cfg.max_dial = tries;
893 } else {
894 LogPrintf(LogWARN, "Invalid retry value\n");
895 return 1;
896 }
897 }
898 return 0;
899 }
900 return -1;
901}
902
903static int
904SetStoppedTimeout(struct cmdargs const *arg)
905{
906 struct link *l = &arg->cx->physical->link;
907
908 l->lcp.fsm.StoppedTimer.load = 0;
909 l->ccp.fsm.StoppedTimer.load = 0;
910 if (arg->argc <= 2) {
911 if (arg->argc > 0) {

--- 23 unchanged lines hidden (view full) ---

935 passwd = arg->argv[1];
936 mask = NULL;
937 } else if (arg->argc == 3) {
938 passwd = arg->argv[1];
939 mask = arg->argv[2];
940 if (!ismask(mask))
941 return -1;
942 } else if (strcasecmp(port, "none") == 0) {
819SetStoppedTimeout(struct cmdargs const *arg)
820{
821 struct link *l = &arg->cx->physical->link;
822
823 l->lcp.fsm.StoppedTimer.load = 0;
824 l->ccp.fsm.StoppedTimer.load = 0;
825 if (arg->argc <= 2) {
826 if (arg->argc > 0) {

--- 23 unchanged lines hidden (view full) ---

850 passwd = arg->argv[1];
851 mask = NULL;
852 } else if (arg->argc == 3) {
853 passwd = arg->argv[1];
854 mask = arg->argv[2];
855 if (!ismask(mask))
856 return -1;
857 } else if (strcasecmp(port, "none") == 0) {
943 if (mask != NULL || passwd != NULL)
944 return -1;
945
946 if (ServerClose(arg->bundle))
947 LogPrintf(LogPHASE, "Disabled server port.\n");
948 return 0;
949 } else
950 return -1;
951
952 strncpy(server.passwd, passwd, sizeof server.passwd - 1);
953 server.passwd[sizeof server.passwd - 1] = '\0';

--- 117 unchanged lines hidden (view full) ---

1071 }
1072 ipcp->my_ip.s_addr = ipcp->cfg.my_range.ipaddr.s_addr;
1073
1074 if (ipcp->cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
1075 ipcp->cfg.peer_range.mask.s_addr = INADDR_ANY;
1076 ipcp->cfg.peer_range.width = 0;
1077 }
1078
858 if (ServerClose(arg->bundle))
859 LogPrintf(LogPHASE, "Disabled server port.\n");
860 return 0;
861 } else
862 return -1;
863
864 strncpy(server.passwd, passwd, sizeof server.passwd - 1);
865 server.passwd[sizeof server.passwd - 1] = '\0';

--- 117 unchanged lines hidden (view full) ---

983 }
984 ipcp->my_ip.s_addr = ipcp->cfg.my_range.ipaddr.s_addr;
985
986 if (ipcp->cfg.peer_range.ipaddr.s_addr == INADDR_ANY) {
987 ipcp->cfg.peer_range.mask.s_addr = INADDR_ANY;
988 ipcp->cfg.peer_range.width = 0;
989 }
990
1079 if (hisaddr && !UseHisaddr(arg->bundle, hisaddr, mode & MODE_AUTO))
991 if (hisaddr &&
992 !UseHisaddr(arg->bundle, hisaddr, arg->bundle->phys_type & PHYS_DEMAND))
1080 return 4;
1081
1082 return 0;
1083}
1084
1085#ifndef NOMSEXT
1086
1087static void
1088SetMSEXT(struct ipcp *ipcp, struct in_addr * pri_addr,
1089 struct in_addr * sec_addr, int argc, char const *const *argv)
1090{
1091 int dummyint;
1092 struct in_addr dummyaddr;
1093
993 return 4;
994
995 return 0;
996}
997
998#ifndef NOMSEXT
999
1000static void
1001SetMSEXT(struct ipcp *ipcp, struct in_addr * pri_addr,
1002 struct in_addr * sec_addr, int argc, char const *const *argv)
1003{
1004 int dummyint;
1005 struct in_addr dummyaddr;
1006
1094 if (!(mode & MODE_DIRECT)) {
1095 LogPrintf(LogWARN, "set nbns|ns: Only available in direct mode\n");
1096 return;
1097 }
1098
1099 pri_addr->s_addr = sec_addr->s_addr = 0L;
1100
1101 if (argc > 0) {
1102 ParseAddr(ipcp, argc, argv++, pri_addr, &dummyaddr, &dummyint);
1103 if (--argc > 0)
1104 ParseAddr(ipcp, argc, argv++, sec_addr, &dummyaddr, &dummyint);
1105 else
1106 sec_addr->s_addr = pri_addr->s_addr;

--- 68 unchanged lines hidden (view full) ---

1175 sizeof arg->bundle->cfg.auth.name - 1);
1176 arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name - 1] = '\0';
1177 } else {
1178 err = "set authname: Only available at phase DEAD\n";
1179 LogPrintf(LogWARN, err);
1180 }
1181 break;
1182 case VAR_DIAL:
1007 pri_addr->s_addr = sec_addr->s_addr = 0L;
1008
1009 if (argc > 0) {
1010 ParseAddr(ipcp, argc, argv++, pri_addr, &dummyaddr, &dummyint);
1011 if (--argc > 0)
1012 ParseAddr(ipcp, argc, argv++, sec_addr, &dummyaddr, &dummyint);
1013 else
1014 sec_addr->s_addr = pri_addr->s_addr;

--- 68 unchanged lines hidden (view full) ---

1083 sizeof arg->bundle->cfg.auth.name - 1);
1084 arg->bundle->cfg.auth.name[sizeof arg->bundle->cfg.auth.name - 1] = '\0';
1085 } else {
1086 err = "set authname: Only available at phase DEAD\n";
1087 LogPrintf(LogWARN, err);
1088 }
1089 break;
1090 case VAR_DIAL:
1183 if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
1184 strncpy(cx->cfg.script.dial, argp, sizeof cx->cfg.script.dial - 1);
1185 cx->cfg.script.dial[sizeof cx->cfg.script.dial - 1] = '\0';
1186 }
1091 strncpy(cx->cfg.script.dial, argp, sizeof cx->cfg.script.dial - 1);
1092 cx->cfg.script.dial[sizeof cx->cfg.script.dial - 1] = '\0';
1187 break;
1188 case VAR_LOGIN:
1093 break;
1094 case VAR_LOGIN:
1189 if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
1190 strncpy(cx->cfg.script.login, argp, sizeof cx->cfg.script.login - 1);
1191 cx->cfg.script.login[sizeof cx->cfg.script.login - 1] = '\0';
1192 }
1095 strncpy(cx->cfg.script.login, argp, sizeof cx->cfg.script.login - 1);
1096 cx->cfg.script.login[sizeof cx->cfg.script.login - 1] = '\0';
1193 break;
1194 case VAR_WINSIZE:
1195 if (arg->argc > 0) {
1196 l->ccp.cfg.deflate.out.winsize = atoi(arg->argv[0]);
1197 if (l->ccp.cfg.deflate.out.winsize < 8 ||
1198 l->ccp.cfg.deflate.out.winsize > 15) {
1199 LogPrintf(LogWARN, "%d: Invalid outgoing window size\n",
1200 l->ccp.cfg.deflate.out.winsize);

--- 61 unchanged lines hidden (view full) ---

1262 LogPrintf(LogWARN, err, argp);
1263 }
1264 break;
1265 case VAR_PHONE:
1266 strncpy(cx->cfg.phone.list, argp, sizeof cx->cfg.phone.list - 1);
1267 cx->cfg.phone.list[sizeof cx->cfg.phone.list - 1] = '\0';
1268 break;
1269 case VAR_HANGUP:
1097 break;
1098 case VAR_WINSIZE:
1099 if (arg->argc > 0) {
1100 l->ccp.cfg.deflate.out.winsize = atoi(arg->argv[0]);
1101 if (l->ccp.cfg.deflate.out.winsize < 8 ||
1102 l->ccp.cfg.deflate.out.winsize > 15) {
1103 LogPrintf(LogWARN, "%d: Invalid outgoing window size\n",
1104 l->ccp.cfg.deflate.out.winsize);

--- 61 unchanged lines hidden (view full) ---

1166 LogPrintf(LogWARN, err, argp);
1167 }
1168 break;
1169 case VAR_PHONE:
1170 strncpy(cx->cfg.phone.list, argp, sizeof cx->cfg.phone.list - 1);
1171 cx->cfg.phone.list[sizeof cx->cfg.phone.list - 1] = '\0';
1172 break;
1173 case VAR_HANGUP:
1270 if (!(mode & (MODE_DIRECT|MODE_DEDICATED))) {
1271 strncpy(cx->cfg.script.hangup, argp, sizeof cx->cfg.script.hangup - 1);
1272 cx->cfg.script.hangup[sizeof cx->cfg.script.hangup - 1] = '\0';
1273 }
1174 strncpy(cx->cfg.script.hangup, argp, sizeof cx->cfg.script.hangup - 1);
1175 cx->cfg.script.hangup[sizeof cx->cfg.script.hangup - 1] = '\0';
1274 break;
1275 case VAR_IDLETIMEOUT:
1276 if (arg->argc > 1)
1277 err = "Too many idle timeout values\n";
1278 else if (arg->argc == 1)
1279 bundle_SetIdleTimer(arg->bundle, atoi(argp));
1280 if (err)
1281 LogPrintf(LogWARN, err);

--- 121 unchanged lines hidden (view full) ---

1403 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set open mode",
1404 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE},
1405 {"papretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
1406 "Set PAP retry period", "set papretry value", (const void *)VAR_PAPRETRY},
1407 {"parity", NULL, SetModemParity, LOCAL_AUTH | LOCAL_CX,
1408 "Set modem parity", "set parity [odd|even|none]"},
1409 {"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set telephone number(s)",
1410 "set phone phone1[:phone2[...]]", (const void *)VAR_PHONE},
1176 break;
1177 case VAR_IDLETIMEOUT:
1178 if (arg->argc > 1)
1179 err = "Too many idle timeout values\n";
1180 else if (arg->argc == 1)
1181 bundle_SetIdleTimer(arg->bundle, atoi(argp));
1182 if (err)
1183 LogPrintf(LogWARN, err);

--- 121 unchanged lines hidden (view full) ---

1305 {"openmode", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set open mode",
1306 "set openmode active|passive [secs]", (const void *)VAR_OPENMODE},
1307 {"papretry", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX,
1308 "Set PAP retry period", "set papretry value", (const void *)VAR_PAPRETRY},
1309 {"parity", NULL, SetModemParity, LOCAL_AUTH | LOCAL_CX,
1310 "Set modem parity", "set parity [odd|even|none]"},
1311 {"phone", NULL, SetVariable, LOCAL_AUTH | LOCAL_CX, "Set telephone number(s)",
1312 "set phone phone1[:phone2[...]]", (const void *)VAR_PHONE},
1411 {"reconnect", NULL, SetReconnect, LOCAL_AUTH | LOCAL_CX,
1313 {"reconnect", NULL, datalink_SetReconnect, LOCAL_AUTH | LOCAL_CX,
1412 "Set Reconnect timeout", "set reconnect value ntries"},
1314 "Set Reconnect timeout", "set reconnect value ntries"},
1413 {"redial", NULL, SetRedialTimeout, LOCAL_AUTH | LOCAL_CX,
1315 {"redial", NULL, datalink_SetRedial, LOCAL_AUTH | LOCAL_CX,
1414 "Set Redial timeout", "set redial value|random[.value|random] [attempts]"},
1415 {"server", "socket", SetServer, LOCAL_AUTH,
1416 "Set server port", "set server|socket TcpPort|LocalName|none [mask]"},
1417 {"speed", NULL, SetModemSpeed, LOCAL_AUTH | LOCAL_CX,
1418 "Set modem speed", "set speed value"},
1419 {"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH | LOCAL_CX,
1420 "Set STOPPED timeouts", "set stopped [LCPseconds [CCPseconds]]"},
1421 {"timeout", NULL, SetVariable, LOCAL_AUTH, "Set Idle timeout",

--- 231 unchanged lines hidden ---
1316 "Set Redial timeout", "set redial value|random[.value|random] [attempts]"},
1317 {"server", "socket", SetServer, LOCAL_AUTH,
1318 "Set server port", "set server|socket TcpPort|LocalName|none [mask]"},
1319 {"speed", NULL, SetModemSpeed, LOCAL_AUTH | LOCAL_CX,
1320 "Set modem speed", "set speed value"},
1321 {"stopped", NULL, SetStoppedTimeout, LOCAL_AUTH | LOCAL_CX,
1322 "Set STOPPED timeouts", "set stopped [LCPseconds [CCPseconds]]"},
1323 {"timeout", NULL, SetVariable, LOCAL_AUTH, "Set Idle timeout",

--- 231 unchanged lines hidden ---