summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/datalink.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-08-06 20:04:08 +0000
committerbrian <brian@FreeBSD.org>1999-08-06 20:04:08 +0000
commit8229df47c3e2374322058e43333045e6fe030427 (patch)
tree0dcd97a0d9e4b6f52cd1f2aa158c28fca4e9e808 /usr.sbin/ppp/datalink.c
parent82b15b21003b7e5df8e9a7bae9330508378a0ee8 (diff)
downloadFreeBSD-src-8229df47c3e2374322058e43333045e6fe030427.zip
FreeBSD-src-8229df47c3e2374322058e43333045e6fe030427.tar.gz
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 !) :-]
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 4899b40..9e449e8 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",
OpenPOWER on IntegriCloud