datalink.c (2764b86afdc99a30f4b1a4da2c04db8aa7aa785d) datalink.c (565e35e50e2cdac423588a3d18742544bde128b0)
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: datalink.c,v 1.1.2.34 1998/04/06 09:12:26 brian Exp $
26 * $Id: datalink.c,v 1.1.2.35 1998/04/07 00:53:35 brian Exp $
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33
34#include <stdio.h>

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

58#include "bundle.h"
59#include "chat.h"
60#include "auth.h"
61#include "modem.h"
62#include "prompt.h"
63#include "lcpproto.h"
64#include "pap.h"
65#include "chap.h"
27 */
28
29#include <sys/types.h>
30#include <netinet/in.h>
31#include <netinet/in_systm.h>
32#include <netinet/ip.h>
33
34#include <stdio.h>

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

58#include "bundle.h"
59#include "chat.h"
60#include "auth.h"
61#include "modem.h"
62#include "prompt.h"
63#include "lcpproto.h"
64#include "pap.h"
65#include "chap.h"
66#include "command.h"
66#include "datalink.h"
67
68static const char *datalink_State(struct datalink *);
69
70static void
71datalink_OpenTimeout(void *v)
72{
73 struct datalink *dl = (struct datalink *)v;

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

97 dl->name, Timeout);
98 }
99}
100
101static void
102datalink_HangupDone(struct datalink *dl)
103{
104 modem_Close(dl->physical);
67#include "datalink.h"
68
69static const char *datalink_State(struct datalink *);
70
71static void
72datalink_OpenTimeout(void *v)
73{
74 struct datalink *dl = (struct datalink *)v;

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

98 dl->name, Timeout);
99 }
100}
101
102static void
103datalink_HangupDone(struct datalink *dl)
104{
105 modem_Close(dl->physical);
105 dl->phone.chosen = "[N/A]";
106 dl->phone.chosen = "N/A";
106
107 if (dl->bundle->CleaningUp ||
107
108 if (dl->bundle->CleaningUp ||
108 (mode & MODE_DIRECT) ||
109 (dl->physical->type == PHYS_STDIN) ||
109 ((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) &&
110 ((!dl->dial_tries || (dl->dial_tries < 0 && !dl->reconnect_tries)) &&
110 !(mode & (MODE_DDIAL|MODE_DEDICATED)))) {
111 !(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)))) {
111 LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
112 dl->state = DATALINK_CLOSED;
113 dl->dial_tries = -1;
114 dl->reconnect_tries = 0;
115 bundle_LinkClosed(dl->bundle, dl);
116 if (!dl->bundle->CleaningUp)
112 LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
113 dl->state = DATALINK_CLOSED;
114 dl->dial_tries = -1;
115 dl->reconnect_tries = 0;
116 bundle_LinkClosed(dl->bundle, dl);
117 if (!dl->bundle->CleaningUp)
117 datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
118 datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
118 } else {
119 LogPrintf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name);
120 dl->state = DATALINK_OPENING;
121 if (dl->dial_tries < 0) {
119 } else {
120 LogPrintf(LogPHASE, "%s: Re-entering OPENING state\n", dl->name);
121 dl->state = DATALINK_OPENING;
122 if (dl->dial_tries < 0) {
122 datalink_StartDialTimer(dl, dl->cfg.reconnect_timeout);
123 dl->dial_tries = dl->cfg.max_dial;
123 datalink_StartDialTimer(dl, dl->cfg.reconnect.timeout);
124 dl->dial_tries = dl->cfg.dial.max;
124 dl->reconnect_tries--;
125 } else {
126 if (dl->phone.next == NULL)
125 dl->reconnect_tries--;
126 } else {
127 if (dl->phone.next == NULL)
127 datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
128 datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
128 else
129 else
129 datalink_StartDialTimer(dl, dl->cfg.dial_next_timeout);
130 datalink_StartDialTimer(dl, dl->cfg.dial.next_timeout);
130 }
131 }
132}
133
134static const char *
135datalink_ChoosePhoneNumber(struct datalink *dl)
136{
137 char *phone;

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

190 int *n)
191{
192 struct datalink *dl = descriptor2datalink(d);
193 int result;
194
195 result = 0;
196 switch (dl->state) {
197 case DATALINK_CLOSED:
131 }
132 }
133}
134
135static const char *
136datalink_ChoosePhoneNumber(struct datalink *dl)
137{
138 char *phone;

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

191 int *n)
192{
193 struct datalink *dl = descriptor2datalink(d);
194 int result;
195
196 result = 0;
197 switch (dl->state) {
198 case DATALINK_CLOSED:
198 break;
199 if ((dl->physical->type & (PHYS_STDIN|PHYS_DEDICATED|PHYS_1OFF)) &&
200 !bundle_IsDead(dl->bundle))
201 /*
202 * Our first time in - DEDICATED never comes down, and STDIN & 1OFF
203 * get deleted when they enter DATALINK_CLOSED. Go to
204 * DATALINK_OPENING via datalink_Up() and fall through.
205 */
206 datalink_Up(dl, 1, 1);
207 else
208 break;
209 /* fall through */
199
200 case DATALINK_OPENING:
201 if (dl->dial_timer.state != TIMER_RUNNING) {
202 if (--dl->dial_tries < 0)
203 dl->dial_tries = 0;
204 if (modem_Open(dl->physical, dl->bundle) >= 0) {
205 if (dl->script.run) {
206 LogPrintf(LogPHASE, "%s: Entering DIAL state\n", dl->name);
207 dl->state = DATALINK_DIAL;
208 chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
209 datalink_ChoosePhoneNumber(dl));
210
211 case DATALINK_OPENING:
212 if (dl->dial_timer.state != TIMER_RUNNING) {
213 if (--dl->dial_tries < 0)
214 dl->dial_tries = 0;
215 if (modem_Open(dl->physical, dl->bundle) >= 0) {
216 if (dl->script.run) {
217 LogPrintf(LogPHASE, "%s: Entering DIAL state\n", dl->name);
218 dl->state = DATALINK_DIAL;
219 chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
220 datalink_ChoosePhoneNumber(dl));
210 if (!(mode & MODE_DDIAL) && dl->cfg.max_dial)
221 if (!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
222 dl->cfg.dial.max)
211 LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n",
223 LogPrintf(LogCHAT, "%s: Dial attempt %u of %d\n",
212 dl->name, dl->cfg.max_dial - dl->dial_tries,
213 dl->cfg.max_dial);
224 dl->name, dl->cfg.dial.max - dl->dial_tries,
225 dl->cfg.dial.max);
214 } else
215 datalink_LoginDone(dl);
216 } else {
226 } else
227 datalink_LoginDone(dl);
228 } else {
217 if (!(mode & MODE_DDIAL) && dl->cfg.max_dial)
229 if (!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
230 dl->cfg.dial.max)
218 LogPrintf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
231 LogPrintf(LogCHAT, "Failed to open modem (attempt %u of %d)\n",
219 dl->cfg.max_dial - dl->dial_tries, dl->cfg.max_dial);
232 dl->cfg.dial.max - dl->dial_tries, dl->cfg.dial.max);
220 else
221 LogPrintf(LogCHAT, "Failed to open modem\n");
222
223 if (dl->bundle->CleaningUp ||
233 else
234 LogPrintf(LogCHAT, "Failed to open modem\n");
235
236 if (dl->bundle->CleaningUp ||
224 (!(mode & (MODE_DDIAL|MODE_DEDICATED)) &&
225 dl->cfg.max_dial && dl->dial_tries == 0)) {
237 (!(dl->physical->type & (PHYS_PERM|PHYS_DEDICATED)) &&
238 dl->cfg.dial.max && dl->dial_tries == 0)) {
226 LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
227 dl->state = DATALINK_CLOSED;
228 dl->reconnect_tries = 0;
229 dl->dial_tries = -1;
230 bundle_LinkClosed(dl->bundle, dl);
231 }
232 if (!dl->bundle->CleaningUp)
239 LogPrintf(LogPHASE, "%s: Entering CLOSED state\n", dl->name);
240 dl->state = DATALINK_CLOSED;
241 dl->reconnect_tries = 0;
242 dl->dial_tries = -1;
243 bundle_LinkClosed(dl->bundle, dl);
244 }
245 if (!dl->bundle->CleaningUp)
233 datalink_StartDialTimer(dl, dl->cfg.dial_timeout);
246 datalink_StartDialTimer(dl, dl->cfg.dial.timeout);
234 }
235 }
236 break;
237
238 case DATALINK_HANGUP:
239 case DATALINK_DIAL:
240 case DATALINK_LOGIN:
241 result = descriptor_UpdateSet(&dl->chat.desc, r, w, e, n);

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

463 FsmDown(fp); /* Bring us to INITIAL or STARTING */
464 (*dl->parent->LayerFinish)(dl->parent->object, fp);
465 datalink_ComeDown(dl, 0);
466 }
467}
468
469struct datalink *
470datalink_Create(const char *name, struct bundle *bundle,
247 }
248 }
249 break;
250
251 case DATALINK_HANGUP:
252 case DATALINK_DIAL:
253 case DATALINK_LOGIN:
254 result = descriptor_UpdateSet(&dl->chat.desc, r, w, e, n);

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

476 FsmDown(fp); /* Bring us to INITIAL or STARTING */
477 (*dl->parent->LayerFinish)(dl->parent->object, fp);
478 datalink_ComeDown(dl, 0);
479 }
480}
481
482struct datalink *
483datalink_Create(const char *name, struct bundle *bundle,
471 const struct fsm_parent *parent)
484 const struct fsm_parent *parent, int type)
472{
473 struct datalink *dl;
474
475 dl = (struct datalink *)malloc(sizeof(struct datalink));
476 if (dl == NULL)
477 return dl;
478
479 dl->desc.type = DATALINK_DESCRIPTOR;

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

498 mp_linkInit(&dl->mp);
499
500 dl->bundle = bundle;
501 dl->next = NULL;
502
503 memset(&dl->dial_timer, '\0', sizeof dl->dial_timer);
504
505 dl->dial_tries = 0;
485{
486 struct datalink *dl;
487
488 dl = (struct datalink *)malloc(sizeof(struct datalink));
489 if (dl == NULL)
490 return dl;
491
492 dl->desc.type = DATALINK_DESCRIPTOR;

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

511 mp_linkInit(&dl->mp);
512
513 dl->bundle = bundle;
514 dl->next = NULL;
515
516 memset(&dl->dial_timer, '\0', sizeof dl->dial_timer);
517
518 dl->dial_tries = 0;
506 dl->cfg.max_dial = 1;
507 dl->cfg.dial_timeout = DIAL_TIMEOUT;
508 dl->cfg.dial_next_timeout = DIAL_NEXT_TIMEOUT;
519 dl->cfg.dial.max = 1;
520 dl->cfg.dial.next_timeout = DIAL_NEXT_TIMEOUT;
521 dl->cfg.dial.timeout = DIAL_TIMEOUT;
509
510 dl->reconnect_tries = 0;
522
523 dl->reconnect_tries = 0;
511 dl->cfg.max_reconnect = 0;
512 dl->cfg.reconnect_timeout = RECONNECT_TIMEOUT;
524 dl->cfg.reconnect.max = 0;
525 dl->cfg.reconnect.timeout = RECONNECT_TIMEOUT;
513
514 dl->name = strdup(name);
515 dl->parent = parent;
516 dl->fsmp.LayerStart = datalink_LayerStart;
517 dl->fsmp.LayerUp = datalink_LayerUp;
518 dl->fsmp.LayerDown = datalink_LayerDown;
519 dl->fsmp.LayerFinish = datalink_LayerFinish;
520 dl->fsmp.object = dl;
521
522 authinfo_Init(&dl->pap);
523 authinfo_Init(&dl->chap.auth);
524
526
527 dl->name = strdup(name);
528 dl->parent = parent;
529 dl->fsmp.LayerStart = datalink_LayerStart;
530 dl->fsmp.LayerUp = datalink_LayerUp;
531 dl->fsmp.LayerDown = datalink_LayerDown;
532 dl->fsmp.LayerFinish = datalink_LayerFinish;
533 dl->fsmp.object = dl;
534
535 authinfo_Init(&dl->pap);
536 authinfo_Init(&dl->chap.auth);
537
525 if ((dl->physical = modem_Create(dl)) == NULL) {
538 if ((dl->physical = modem_Create(dl, type)) == NULL) {
526 free(dl->name);
527 free(dl);
528 return NULL;
529 }
530 chat_Init(&dl->chat, dl->physical, NULL, 1, NULL);
531
532 LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
533

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

564 dl->parent = odl->parent;
565 memcpy(&dl->fsmp, &odl->fsmp, sizeof dl->fsmp);
566 authinfo_Init(&dl->pap);
567 dl->pap.cfg.fsmretry = odl->pap.cfg.fsmretry;
568
569 authinfo_Init(&dl->chap.auth);
570 dl->chap.auth.cfg.fsmretry = odl->chap.auth.cfg.fsmretry;
571
539 free(dl->name);
540 free(dl);
541 return NULL;
542 }
543 chat_Init(&dl->chat, dl->physical, NULL, 1, NULL);
544
545 LogPrintf(LogPHASE, "%s: Created in CLOSED state\n", dl->name);
546

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

577 dl->parent = odl->parent;
578 memcpy(&dl->fsmp, &odl->fsmp, sizeof dl->fsmp);
579 authinfo_Init(&dl->pap);
580 dl->pap.cfg.fsmretry = odl->pap.cfg.fsmretry;
581
582 authinfo_Init(&dl->chap.auth);
583 dl->chap.auth.cfg.fsmretry = odl->chap.auth.cfg.fsmretry;
584
572 if ((dl->physical = modem_Create(dl)) == NULL) {
585 if ((dl->physical = modem_Create(dl, PHYS_MANUAL)) == NULL) {
573 free(dl->name);
574 free(dl);
575 return NULL;
576 }
577 memcpy(&dl->physical->cfg, &odl->physical->cfg, sizeof dl->physical->cfg);
578 memcpy(&dl->physical->link.lcp.cfg, &odl->physical->link.lcp.cfg,
579 sizeof dl->physical->link.lcp.cfg);
580 memcpy(&dl->physical->link.ccp.cfg, &odl->physical->link.ccp.cfg,

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

605 free(dl);
606
607 return result;
608}
609
610void
611datalink_Up(struct datalink *dl, int runscripts, int packetmode)
612{
586 free(dl->name);
587 free(dl);
588 return NULL;
589 }
590 memcpy(&dl->physical->cfg, &odl->physical->cfg, sizeof dl->physical->cfg);
591 memcpy(&dl->physical->link.lcp.cfg, &odl->physical->link.lcp.cfg,
592 sizeof dl->physical->link.lcp.cfg);
593 memcpy(&dl->physical->link.ccp.cfg, &odl->physical->link.ccp.cfg,

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

618 free(dl);
619
620 return result;
621}
622
623void
624datalink_Up(struct datalink *dl, int runscripts, int packetmode)
625{
626 if (dl->physical->type & (PHYS_STDIN|PHYS_DEDICATED))
627 /* Ignore scripts */
628 runscripts = 0;
629
613 switch (dl->state) {
614 case DATALINK_CLOSED:
615 LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
616 if (bundle_Phase(dl->bundle) == PHASE_DEAD ||
617 bundle_Phase(dl->bundle) == PHASE_TERMINATE)
618 bundle_NewPhase(dl->bundle, PHASE_ESTABLISH);
619 dl->state = DATALINK_OPENING;
630 switch (dl->state) {
631 case DATALINK_CLOSED:
632 LogPrintf(LogPHASE, "%s: Entering OPENING state\n", dl->name);
633 if (bundle_Phase(dl->bundle) == PHASE_DEAD ||
634 bundle_Phase(dl->bundle) == PHASE_TERMINATE)
635 bundle_NewPhase(dl->bundle, PHASE_ESTABLISH);
636 dl->state = DATALINK_OPENING;
620 dl->reconnect_tries = dl->cfg.max_reconnect;
621 dl->dial_tries = dl->cfg.max_dial;
637 dl->reconnect_tries =
638 dl->physical->type == PHYS_STDIN ? 0 : dl->cfg.reconnect.max;
639 dl->dial_tries = dl->cfg.dial.max;
622 dl->script.run = runscripts;
623 dl->script.packetmode = packetmode;
624 break;
625
626 case DATALINK_OPENING:
627 if (!dl->script.run && runscripts)
628 dl->script.run = 1;
629 /* fall through */

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

692datalink_StayDown(struct datalink *dl)
693{
694 dl->reconnect_tries = 0;
695}
696
697void
698datalink_Show(struct datalink *dl, struct prompt *prompt)
699{
640 dl->script.run = runscripts;
641 dl->script.packetmode = packetmode;
642 break;
643
644 case DATALINK_OPENING:
645 if (!dl->script.run && runscripts)
646 dl->script.run = 1;
647 /* fall through */

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

710datalink_StayDown(struct datalink *dl)
711{
712 dl->reconnect_tries = 0;
713}
714
715void
716datalink_Show(struct datalink *dl, struct prompt *prompt)
717{
700 prompt_Printf(prompt, "Link %s: State %s\n", dl->name, datalink_State(dl));
718 prompt_Printf(prompt, "Name: %s\n", dl->name);
719 prompt_Printf(prompt, " State: %s\n", datalink_State(dl));
701#ifdef HAVE_DES
702 prompt_Printf(arg->prompt, " Encryption = %s\n",
703 dl->chap.using_MSChap ? "MSChap" : "MD5" );
704#endif
720#ifdef HAVE_DES
721 prompt_Printf(arg->prompt, " Encryption = %s\n",
722 dl->chap.using_MSChap ? "MSChap" : "MD5" );
723#endif
724 prompt_Printf(prompt, "\nDefaults:\n");
725 prompt_Printf(prompt, " Phone List: %s\n", dl->cfg.phone.list);
726 if (dl->cfg.dial.max)
727 prompt_Printf(prompt, " Dial tries: %d, delay ", dl->cfg.dial.max);
728 else
729 prompt_Printf(prompt, " Dial tries: infinite, delay ");
730 if (dl->cfg.dial.next_timeout > 0)
731 prompt_Printf(prompt, "%ds/", dl->cfg.dial.next_timeout);
732 else
733 prompt_Printf(prompt, "random/");
734 if (dl->cfg.dial.timeout > 0)
735 prompt_Printf(prompt, "%ds\n", dl->cfg.dial.timeout);
736 else
737 prompt_Printf(prompt, "random\n");
738 prompt_Printf(prompt, " Reconnect tries: %d, delay ", dl->cfg.reconnect.max);
739 if (dl->cfg.reconnect.timeout > 0)
740 prompt_Printf(prompt, "%ds\n", dl->cfg.reconnect.timeout);
741 else
742 prompt_Printf(prompt, "random\n");
743 prompt_Printf(prompt, " Dial Script: %s\n", dl->cfg.script.dial);
744 prompt_Printf(prompt, " Login Script: %s\n", dl->cfg.script.login);
745 prompt_Printf(prompt, " Hangup Script: %s\n", dl->cfg.script.hangup);
705}
706
746}
747
748int
749datalink_SetReconnect(struct cmdargs const *arg)
750{
751 if (arg->argc == 2) {
752 arg->cx->cfg.reconnect.timeout = atoi(arg->argv[0]);
753 arg->cx->cfg.reconnect.max = atoi(arg->argv[1]);
754 return 0;
755 }
756 return -1;
757}
758
759int
760datalink_SetRedial(struct cmdargs const *arg)
761{
762 int timeout;
763 int tries;
764 char *dot;
765
766 if (arg->argc == 1 || arg->argc == 2) {
767 if (strncasecmp(arg->argv[0], "random", 6) == 0 &&
768 (arg->argv[0][6] == '\0' || arg->argv[0][6] == '.')) {
769 arg->cx->cfg.dial.timeout = -1;
770 randinit();
771 } else {
772 timeout = atoi(arg->argv[0]);
773
774 if (timeout >= 0)
775 arg->cx->cfg.dial.timeout = timeout;
776 else {
777 LogPrintf(LogWARN, "Invalid redial timeout\n");
778 return -1;
779 }
780 }
781
782 dot = strchr(arg->argv[0], '.');
783 if (dot) {
784 if (strcasecmp(++dot, "random") == 0) {
785 arg->cx->cfg.dial.next_timeout = -1;
786 randinit();
787 } else {
788 timeout = atoi(dot);
789 if (timeout >= 0)
790 arg->cx->cfg.dial.next_timeout = timeout;
791 else {
792 LogPrintf(LogWARN, "Invalid next redial timeout\n");
793 return -1;
794 }
795 }
796 } else
797 /* Default next timeout */
798 arg->cx->cfg.dial.next_timeout = DIAL_NEXT_TIMEOUT;
799
800 if (arg->argc == 2) {
801 tries = atoi(arg->argv[1]);
802
803 if (tries >= 0) {
804 arg->cx->cfg.dial.max = tries;
805 } else {
806 LogPrintf(LogWARN, "Invalid retry value\n");
807 return 1;
808 }
809 }
810 return 0;
811 }
812 return -1;
813}
814
707static char *states[] = {
815static char *states[] = {
708 "CLOSED",
709 "OPENING",
710 "HANGUP",
711 "DIAL",
712 "LOGIN",
713 "READY",
714 "LCP"
715 "AUTH"
716 "OPEN"
816 "closed",
817 "opening",
818 "hangup",
819 "dial",
820 "login",
821 "ready",
822 "lcp",
823 "auth",
824 "open"
717};
718
719static const char *
720datalink_State(struct datalink *dl)
721{
722 if (dl->state < 0 || dl->state >= sizeof states / sizeof states[0])
723 return "unknown";
724 return states[dl->state];
725}
825};
826
827static const char *
828datalink_State(struct datalink *dl)
829{
830 if (dl->state < 0 || dl->state >= sizeof states / sizeof states[0])
831 return "unknown";
832 return states[dl->state];
833}