summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/datalink.c
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1999-08-06 20:04:08 +0000
committerBrian Somers <brian@FreeBSD.org>1999-08-06 20:04:08 +0000
commiteb6e5e05f99108605df1aab67c0985f869dd12e7 (patch)
tree144bd3b2299bb3f3ae244a50357d1c6be8290dfb /usr.sbin/ppp/datalink.c
parent2203dc00302283becdc4d18e2922fa2228132140 (diff)
downloadsrc-test2-eb6e5e05f99108605df1aab67c0985f869dd12e7.tar.gz
src-test2-eb6e5e05f99108605df1aab67c0985f869dd12e7.zip
Add ISDN support via isdnd & i4b. This requires version
0.81.1 of the i4b code - namely support of the I4B_VR_REQ ioctl via the i4brbchX device. Ppp controls the phone number, but idle timers and SYNC/RAW decisions are still made by isdnd (in isdnd.rc). This involves a new datalink state machine phase. The ``wait for carrier'' phase happens after dialing but before logging in. The whole dial state should really be abstracted so that each device type can deal with it in its own way (thinking about PPPoE) - but that'll have to wait. The ``set cd'' symantics remain the same for tty devices, but we now delay until we either get CD or timeout waiting (at which time we drop the link if we require CD). For i4b devices we always insist on carrier. Thanks to hm@ for his help, and especially for pointing out that I *don't* need to re-implement isdnd (that was a huge waste of time !) :-]
Notes
Notes: svn path=/head/; revision=49472
Diffstat (limited to 'usr.sbin/ppp/datalink.c')
-rw-r--r--usr.sbin/ppp/datalink.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/usr.sbin/ppp/datalink.c b/usr.sbin/ppp/datalink.c
index 4899b400d277..9e449e81fe16 100644
--- a/usr.sbin/ppp/datalink.c
+++ b/usr.sbin/ppp/datalink.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.c,v 1.41 1999/06/18 13:49:01 brian Exp $
+ * $Id: datalink.c,v 1.42 1999/08/05 10:32:10 brian Exp $
*/
#include <sys/param.h>
@@ -175,7 +175,7 @@ datalink_HangupDone(struct datalink *dl)
}
}
-static const char *
+const char *
datalink_ChoosePhoneNumber(struct datalink *dl)
{
char *phone;
@@ -269,7 +269,8 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
if (dl->script.run) {
datalink_NewState(dl, DATALINK_DIAL);
chat_Init(&dl->chat, dl->physical, dl->cfg.script.dial, 1,
- datalink_ChoosePhoneNumber(dl));
+ *dl->cfg.script.dial ?
+ datalink_ChoosePhoneNumber(dl) : "");
if (!(dl->physical->type & (PHYS_DDIAL|PHYS_DEDICATED)) &&
dl->cfg.dial.max)
log_Printf(LogCHAT, "%s: Dial attempt %u of %d\n",
@@ -307,6 +308,25 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
}
break;
+ case DATALINK_CARRIER:
+ /* Wait for carrier on the device */
+ switch (physical_AwaitCarrier(dl->physical)) {
+ case CARRIER_PENDING:
+ log_Printf(LogDEBUG, "Waiting for carrier\n");
+ return 0; /* A device timer is running to wake us up again */
+
+ case CARRIER_OK:
+ datalink_NewState(dl, DATALINK_LOGIN);
+ chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0, NULL);
+ return datalink_UpdateSet(d, r, w, e, n);
+
+ case CARRIER_LOST:
+ datalink_NewState(dl, DATALINK_HANGUP);
+ physical_Offline(dl->physical); /* Is this required ? */
+ chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
+ return datalink_UpdateSet(d, r, w, e, n);
+ }
+
case DATALINK_HANGUP:
case DATALINK_DIAL:
case DATALINK_LOGIN:
@@ -320,8 +340,7 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
datalink_HangupDone(dl);
break;
case DATALINK_DIAL:
- datalink_NewState(dl, DATALINK_LOGIN);
- chat_Init(&dl->chat, dl->physical, dl->cfg.script.login, 0, NULL);
+ datalink_NewState(dl, DATALINK_CARRIER);
return datalink_UpdateSet(d, r, w, e, n);
case DATALINK_LOGIN:
dl->phone.alt = NULL;
@@ -341,7 +360,8 @@ datalink_UpdateSet(struct descriptor *d, fd_set *r, fd_set *w, fd_set *e,
case DATALINK_LOGIN:
datalink_NewState(dl, DATALINK_HANGUP);
physical_Offline(dl->physical); /* Is this required ? */
- chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup, 1, NULL);
+ chat_Init(&dl->chat, dl->physical, dl->cfg.script.hangup,
+ 1, NULL);
return datalink_UpdateSet(d, r, w, e, n);
}
break;
@@ -1164,6 +1184,7 @@ static const char *states[] = {
"opening",
"hangup",
"dial",
+ "carrier",
"login",
"ready",
"lcp",