summaryrefslogtreecommitdiff
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@cvs.openbsd.org>1999-07-15 02:04:08 +0000
committerbrian <brian@cvs.openbsd.org>1999-07-15 02:04:08 +0000
commitcfbe55d5f1715d74b1107c714a5fbe33014a0390 (patch)
tree5c428a2e0c4ce6af35e935e55288140ee68156fd /usr.sbin/ppp
parent25a19388d55a4a90fa31d232488f7dd013a8a05c (diff)
Don't declare `end' if we aren't compiling radius support.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ppp/Makefile4
-rw-r--r--usr.sbin/ppp/ppp/README.changes2
-rw-r--r--usr.sbin/ppp/ppp/bundle.c6
-rw-r--r--usr.sbin/ppp/ppp/chap.c6
-rw-r--r--usr.sbin/ppp/ppp/datalink.c33
-rw-r--r--usr.sbin/ppp/ppp/datalink.h16
-rw-r--r--usr.sbin/ppp/ppp/deflate.c4
-rw-r--r--usr.sbin/ppp/ppp/exec.c29
-rw-r--r--usr.sbin/ppp/ppp/hdlc.c28
-rw-r--r--usr.sbin/ppp/ppp/ip.c6
-rw-r--r--usr.sbin/ppp/ppp/link.c4
-rw-r--r--usr.sbin/ppp/ppp/pap.c4
-rw-r--r--usr.sbin/ppp/ppp/physical.c25
-rw-r--r--usr.sbin/ppp/ppp/physical.h19
-rw-r--r--usr.sbin/ppp/ppp/ppp.851
-rw-r--r--usr.sbin/ppp/ppp/tcp.c4
-rw-r--r--usr.sbin/ppp/ppp/tty.c159
-rw-r--r--usr.sbin/ppp/ppp/udp.c4
-rw-r--r--usr.sbin/ppp/ppp/vjcomp.c4
19 files changed, 249 insertions, 159 deletions
diff --git a/usr.sbin/ppp/ppp/Makefile b/usr.sbin/ppp/ppp/Makefile
index 276cfb5bd46..5e685546eed 100644
--- a/usr.sbin/ppp/ppp/Makefile
+++ b/usr.sbin/ppp/ppp/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.9 1999/05/12 10:03:48 brian Exp $
+# $Id: Makefile,v 1.10 1999/07/15 02:04:06 brian Exp $
PROG= ppp
SRCS= alias.c alias_cmd.c alias_cuseeme.c alias_db.c alias_ftp.c \
@@ -9,7 +9,7 @@ SRCS= alias.c alias_cmd.c alias_cuseeme.c alias_db.c alias_ftp.c \
main.c mbuf.c mp.c pap.c physical.c pred.c probe.c prompt.c proto.c \
radius.c radlib.c route.c server.c sig.c slcompress.c systems.c \
sync.c tcp.c throughput.c timer.c tty.c tun.c udp.c vjcomp.c
-CFLAGS+=-Wall -DHAVE_DES -DNO_FW_PUNCH
+CFLAGS+=-Wall -DHAVE_DES -DNO_FW_PUNCH -DNOI4B
LDADD+= -ldes -lutil -lz
DPADD+= ${LIBDES} ${LIBUTIL} ${LIBZ}
BINMODE=4554
diff --git a/usr.sbin/ppp/ppp/README.changes b/usr.sbin/ppp/ppp/README.changes
index d70c0531cb3..9d32c72f4ad 100644
--- a/usr.sbin/ppp/ppp/README.changes
+++ b/usr.sbin/ppp/ppp/README.changes
@@ -85,3 +85,5 @@ o The ``set device'' command now expects each device to be specified as an
on commas and spaces.
o The ``show modem'' command is depricated and has been changed to
``show physical''.
+o Ppp now waits the full ``set cd'' time before running the login script,
+ and drops the connection at that point if CD is required and not present.
diff --git a/usr.sbin/ppp/ppp/bundle.c b/usr.sbin/ppp/ppp/bundle.c
index 29aefb0739b..1b526f768eb 100644
--- a/usr.sbin/ppp/ppp/bundle.c
+++ b/usr.sbin/ppp/ppp/bundle.c
@@ -23,14 +23,14 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: bundle.c,v 1.20 1999/06/22 11:32:44 brian Exp $
+ * $Id: bundle.c,v 1.21 1999/07/15 02:04:06 brian Exp $
*/
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <net/if.h>
-#include <net/if_tun.h>
+#include <net/if_tun.h> /* For TUNSIFMODE & TUNSLMODE */
#include <arpa/inet.h>
#include <net/route.h>
#include <netinet/in_systm.h>
@@ -43,7 +43,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/ioctl.h>
+/* #include <sys/ioctl.h> (auto-remove) */
#include <sys/uio.h>
#include <sys/wait.h>
#include <termios.h>
diff --git a/usr.sbin/ppp/ppp/chap.c b/usr.sbin/ppp/ppp/chap.c
index 090f3ad218c..3178fac8cf9 100644
--- a/usr.sbin/ppp/ppp/chap.c
+++ b/usr.sbin/ppp/ppp/chap.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: chap.c,v 1.14 1999/06/09 08:47:23 brian Exp $
+ * $Id: chap.c,v 1.15 1999/07/15 02:04:06 brian Exp $
*
* TODO:
*/
@@ -543,7 +543,7 @@ chap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
struct chap *chap = &p->dl->chap;
char *name, *key, *ans;
int len, nlen;
- u_char alen, end;
+ u_char alen;
#ifdef HAVE_DES
int lanman;
#endif
@@ -694,6 +694,8 @@ chap_Input(struct bundle *bundle, struct link *l, struct mbuf *bp)
nlen = strlen(name);
#ifndef NORADIUS
if (*bundle->radius.cfg.file) {
+ u_char end;
+
end = chap->challenge.local[*chap->challenge.local+1];
chap->challenge.local[*chap->challenge.local+1] = '\0';
radius_Authenticate(&bundle->radius, &chap->auth,
diff --git a/usr.sbin/ppp/ppp/datalink.c b/usr.sbin/ppp/ppp/datalink.c
index 27cb9e8e182..e77f91c6760 100644
--- a/usr.sbin/ppp/ppp/datalink.c
+++ b/usr.sbin/ppp/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.21 1999/06/18 13:49:19 brian Exp $
+ * $Id: datalink.c,v 1.22 1999/07/15 02:04:06 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;
@@ -1161,6 +1181,7 @@ static const char *states[] = {
"opening",
"hangup",
"dial",
+ "carrier",
"login",
"ready",
"lcp",
diff --git a/usr.sbin/ppp/ppp/datalink.h b/usr.sbin/ppp/ppp/datalink.h
index 8206275a045..c838ea85570 100644
--- a/usr.sbin/ppp/ppp/datalink.h
+++ b/usr.sbin/ppp/ppp/datalink.h
@@ -23,19 +23,20 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: datalink.h,v 1.3 1999/03/04 17:42:25 brian Exp $
+ * $Id: datalink.h,v 1.4 1999/07/15 02:04:06 brian Exp $
*/
#define DATALINK_CLOSED (0)
#define DATALINK_OPENING (1)
#define DATALINK_HANGUP (2)
#define DATALINK_DIAL (3)
-#define DATALINK_LOGIN (4)
-#define DATALINK_READY (5)
-#define DATALINK_LCP (6)
-#define DATALINK_AUTH (7)
-#define DATALINK_CBCP (8)
-#define DATALINK_OPEN (9)
+#define DATALINK_CARRIER (4)
+#define DATALINK_LOGIN (5)
+#define DATALINK_READY (6)
+#define DATALINK_LCP (7)
+#define DATALINK_AUTH (8)
+#define DATALINK_CBCP (9)
+#define DATALINK_OPEN (10)
#define DATALINK_MAXNAME (20) /* Maximum datalink::name length */
@@ -149,3 +150,4 @@ extern int datalink_RemoveFromSet(struct datalink *, fd_set *, fd_set *,
fd_set *);
extern int datalink_SetMode(struct datalink *, int);
extern int datalink_GetDialTimeout(struct datalink *);
+extern const char *datalink_ChoosePhoneNumber(struct datalink *);
diff --git a/usr.sbin/ppp/ppp/deflate.c b/usr.sbin/ppp/ppp/deflate.c
index 84ac739afd9..314f67f5519 100644
--- a/usr.sbin/ppp/ppp/deflate.c
+++ b/usr.sbin/ppp/ppp/deflate.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: deflate.c,v 1.5 1999/06/02 15:58:40 brian Exp $
+ * $Id: deflate.c,v 1.6 1999/07/15 02:04:06 brian Exp $
*/
#include <sys/types.h>
@@ -37,8 +37,6 @@
#include "mbuf.h"
#include "log.h"
#include "timer.h"
-#include "lqr.h"
-#include "hdlc.h"
#include "fsm.h"
#include "lcp.h"
#include "ccp.h"
diff --git a/usr.sbin/ppp/ppp/exec.c b/usr.sbin/ppp/ppp/exec.c
index daef54e7415..4e302102820 100644
--- a/usr.sbin/ppp/ppp/exec.c
+++ b/usr.sbin/ppp/ppp/exec.c
@@ -23,16 +23,16 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: exec.c,v 1.6 1999/06/09 08:47:23 brian Exp $
+ * $Id: exec.c,v 1.7 1999/07/15 02:04:06 brian Exp $
*/
#include <sys/param.h>
#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
+/* #include <netinet/in.h> (auto-remove) */
+/* #include <arpa/inet.h> (auto-remove) */
+/* #include <netdb.h> (auto-remove) */
+/* #include <netinet/in_systm.h> (auto-remove) */
+/* #include <netinet/ip.h> (auto-remove) */
#include <sys/un.h>
#include <errno.h>
@@ -49,7 +49,7 @@
#include "defs.h"
#include "mbuf.h"
#include "log.h"
-#include "sync.h"
+/* #include "sync.h" (auto-remove) */
#include "timer.h"
#include "lqr.h"
#include "hdlc.h"
@@ -59,20 +59,20 @@
#include "ccp.h"
#include "link.h"
#include "async.h"
-#include "slcompress.h"
-#include "iplist.h"
-#include "ipcp.h"
-#include "filter.h"
+/* #include "slcompress.h" (auto-remove) */
+/* #include "iplist.h" (auto-remove) */
+/* #include "ipcp.h" (auto-remove) */
+/* #include "filter.h" (auto-remove) */
#include "descriptor.h"
#include "physical.h"
#include "mp.h"
#ifndef NORADIUS
-#include "radius.h"
+/* #include "radius.h" (auto-remove) */
#endif
#include "chat.h"
#include "command.h"
-#include "bundle.h"
-#include "prompt.h"
+/* #include "bundle.h" (auto-remove) */
+/* #include "prompt.h" (auto-remove) */
#include "auth.h"
#include "chap.h"
#include "cbcp.h"
@@ -91,6 +91,7 @@ static struct device execdevice = {
NULL,
NULL,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/ppp/hdlc.c b/usr.sbin/ppp/ppp/hdlc.c
index 6beb6c9167a..6eb3fd52469 100644
--- a/usr.sbin/ppp/ppp/hdlc.c
+++ b/usr.sbin/ppp/ppp/hdlc.c
@@ -17,14 +17,14 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: hdlc.c,v 1.7 1999/06/02 15:58:40 brian Exp $
+ * $Id: hdlc.c,v 1.8 1999/07/15 02:04:06 brian Exp $
*
* TODO:
*/
#include <sys/param.h>
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
+/* #include <netinet/in.h> (auto-remove) */
+/* #include <netinet/in_systm.h> (auto-remove) */
+/* #include <netinet/ip.h> (auto-remove) */
#include <sys/un.h>
#include <stdio.h>
@@ -40,15 +40,15 @@
#include "fsm.h"
#include "lqr.h"
#include "hdlc.h"
-#include "proto.h"
-#include "iplist.h"
+/* #include "proto.h" (auto-remove) */
+/* #include "iplist.h" (auto-remove) */
#include "throughput.h"
-#include "slcompress.h"
-#include "ipcp.h"
-#include "ip.h"
-#include "vjcomp.h"
+/* #include "slcompress.h" (auto-remove) */
+/* #include "ipcp.h" (auto-remove) */
+/* #include "ip.h" (auto-remove) */
+/* #include "vjcomp.h" (auto-remove) */
#include "auth.h"
-#include "pap.h"
+/* #include "pap.h" (auto-remove) */
#include "lcp.h"
#include "async.h"
#include "ccp.h"
@@ -61,11 +61,11 @@
#include "mp.h"
#include "cbcp.h"
#include "datalink.h"
-#include "filter.h"
+/* #include "filter.h" (auto-remove) */
#ifndef NORADIUS
-#include "radius.h"
+/* #include "radius.h" (auto-remove) */
#endif
-#include "bundle.h"
+/* #include "bundle.h" (auto-remove) */
static u_int16_t const fcstab[256] = {
/* 00 */ 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
diff --git a/usr.sbin/ppp/ppp/ip.c b/usr.sbin/ppp/ppp/ip.c
index 53c73df90a4..114f3ea6c3b 100644
--- a/usr.sbin/ppp/ppp/ip.c
+++ b/usr.sbin/ppp/ppp/ip.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ip.c,v 1.13 1999/06/23 16:49:04 brian Exp $
+ * $Id: ip.c,v 1.14 1999/07/15 02:04:06 brian Exp $
*
* TODO:
* o Return ICMP message for filterd packet
@@ -38,7 +38,7 @@
#include <errno.h>
#include <stdio.h>
-#include <stdlib.h>
+/* #include <stdlib.h> (auto-remove) */
#include <string.h>
#include <termios.h>
#include <unistd.h>
@@ -66,7 +66,7 @@
#include "radius.h"
#endif
#include "bundle.h"
-#include "vjcomp.h"
+/* #include "vjcomp.h" (auto-remove) */
#include "tun.h"
#include "ip.h"
diff --git a/usr.sbin/ppp/ppp/link.c b/usr.sbin/ppp/ppp/link.c
index fa812d7fcb0..7f95190024d 100644
--- a/usr.sbin/ppp/ppp/link.c
+++ b/usr.sbin/ppp/ppp/link.c
@@ -23,13 +23,13 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: link.c,v 1.7 1999/06/02 15:58:41 brian Exp $
+ * $Id: link.c,v 1.8 1999/07/15 02:04:06 brian Exp $
*
*/
#include <sys/types.h>
#include <netinet/in_systm.h>
-#include <netdb.h>
+/* #include <netdb.h> (auto-remove) */
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/ip.h>
diff --git a/usr.sbin/ppp/ppp/pap.c b/usr.sbin/ppp/ppp/pap.c
index 9031315cd9d..31e694b7bfe 100644
--- a/usr.sbin/ppp/ppp/pap.c
+++ b/usr.sbin/ppp/ppp/pap.c
@@ -18,7 +18,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: pap.c,v 1.9 1999/06/02 15:58:41 brian Exp $
+ * $Id: pap.c,v 1.10 1999/07/15 02:04:06 brian Exp $
*
* TODO:
*/
@@ -29,7 +29,7 @@
#include <sys/un.h>
#include <stdlib.h>
-#include <string.h>
+/* #include <string.h> (auto-remove) */
#include <termios.h>
#include "layer.h"
diff --git a/usr.sbin/ppp/ppp/physical.c b/usr.sbin/ppp/ppp/physical.c
index 91ef8cfd53e..da463860033 100644
--- a/usr.sbin/ppp/ppp/physical.c
+++ b/usr.sbin/ppp/ppp/physical.c
@@ -16,15 +16,15 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.c,v 1.14 1999/06/11 13:29:29 brian Exp $
+ * $Id: physical.c,v 1.15 1999/07/15 02:04:06 brian Exp $
*
*/
#include <sys/param.h>
-#include <sys/socket.h>
+/* #include <sys/socket.h> (auto-remove) */
#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
+/* #include <arpa/inet.h> (auto-remove) */
+/* #include <netdb.h> (auto-remove) */
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <sys/un.h>
@@ -37,7 +37,7 @@
#include <string.h>
#include <sys/tty.h> /* TIOCOUTQ */
#include <sys/uio.h>
-#include <sys/wait.h>
+/* #include <sys/wait.h> (auto-remove) */
#include <time.h>
#include <unistd.h>
#include <utmp.h>
@@ -91,6 +91,9 @@
#include "udp.h"
#include "exec.h"
#include "tty.h"
+#ifndef NOI4B
+#include "i4b.h"
+#endif
static int physical_DescriptorWrite(struct descriptor *, struct bundle *,
@@ -110,6 +113,9 @@ struct {
int *niov, int maxiov);
int (*DeviceSize)(void);
} devices[] = {
+#ifndef NOI4B
+ { i4b_Create, i4b_iov2device, i4b_DeviceSize },
+#endif
{ tty_Create, tty_iov2device, tty_DeviceSize },
{ tcp_Create, tcp_iov2device, tcp_DeviceSize },
{ udp_Create, udp_iov2device, udp_DeviceSize },
@@ -993,3 +999,12 @@ physical_StopDeviceTimer(struct physical *p)
if (p->handler && p->handler->stoptimer)
(*p->handler->stoptimer)(p);
}
+
+int
+physical_AwaitCarrier(struct physical *p)
+{
+ if (p->handler && p->handler->awaitcarrier)
+ return (*p->handler->awaitcarrier)(p);
+
+ return CARRIER_OK;
+}
diff --git a/usr.sbin/ppp/ppp/physical.h b/usr.sbin/ppp/ppp/physical.h
index d008164198e..422da2d13d5 100644
--- a/usr.sbin/ppp/ppp/physical.h
+++ b/usr.sbin/ppp/ppp/physical.h
@@ -16,7 +16,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: physical.h,v 1.11 1999/06/05 21:36:01 brian Exp $
+ * $Id: physical.h,v 1.12 1999/07/15 02:04:06 brian Exp $
*
*/
@@ -28,15 +28,23 @@ struct bundle;
struct ccp;
struct cmdargs;
-#define TTY_DEVICE 1
-#define TCP_DEVICE 2
-#define UDP_DEVICE 3
-#define EXEC_DEVICE 4
+/* Device types */
+#define I4B_DEVICE 1
+#define TTY_DEVICE 2
+#define TCP_DEVICE 3
+#define UDP_DEVICE 4
+#define EXEC_DEVICE 5
+
+/* Returns from awaitcarrier() */
+#define CARRIER_PENDING 1
+#define CARRIER_OK 2
+#define CARRIER_LOST 3
struct device {
int type;
const char *name;
+ int (*awaitcarrier)(struct physical *);
int (*raw)(struct physical *);
void (*offline)(struct physical *);
void (*cooked)(struct physical *);
@@ -137,3 +145,4 @@ extern void physical_DeleteQueue(struct physical *);
extern void physical_SetupStack(struct physical *, const char *, int);
extern void physical_StopDeviceTimer(struct physical *);
extern int physical_MaxDeviceSize(void);
+extern int physical_AwaitCarrier(struct physical *);
diff --git a/usr.sbin/ppp/ppp/ppp.8 b/usr.sbin/ppp/ppp/ppp.8
index 2edd49dc463..252e7d48620 100644
--- a/usr.sbin/ppp/ppp/ppp.8
+++ b/usr.sbin/ppp/ppp/ppp.8
@@ -1,4 +1,4 @@
-.\" $Id: ppp.8,v 1.55 1999/07/07 10:50:14 aaron Exp $
+.\" $Id: ppp.8,v 1.56 1999/07/15 02:04:07 brian Exp $
.Dd 20 September 1995
.nr XX \w'\fC00'
.Dt PPP 8
@@ -157,6 +157,13 @@ will open a TCP or UDP connection for transporting data rather than using a
conventional serial device. UDP connections force
.Nm
into synchronous mode.
+.It Supports PPP over ISDN
+If
+.Nm
+is given a raw B-channel i4b device to open as a link, it's able to talk
+to the
+.Xr isdnd 8
+daemon to establish an ISDN connection.
.It "Supports IETF draft Predictor-1 (rfc 1978) and DEFLATE (rfc 1979) compression."
.Nm
supports not only VJ-compression but also Predictor-1 and DEFLATE compression.
@@ -3510,16 +3517,24 @@ checks for the existence of carrier one second after the login script is
complete. If it's not set,
.Nm
assumes that this is because the device doesn't support carrier (which
-is true for most NULL-modem cables), logs the fact and stops checking
+is true for most
+.Dq laplink
+NULL-modem cables), logs the fact and stops checking
for carrier. However, some modems take some time to assert the carrier
signal, resulting in
.Nm ppp Ns No s
inability to detect when the link is dropped.
-.Ar Seconds
+.Ar seconds
specifies the number of seconds that
.Nm
-should wait after the login script has finished before first checking for
-carrier.
+should wait after the dial script has finished before deciding if
+carrier is available or not.
+.Pp
+.Nm
+will not proceed to the login script until either carrier is detected
+or until
+.Ar seconds
+has elapsed.
.Pp
If
.Ar seconds
@@ -3528,12 +3543,21 @@ is followed immediately by an exclaimation mark
.Nm
will
.Em require
-carrier. If carrier is not detected at the first check, the link will
-be considered disconnected.
+carrier. If carrier is not detected after
+.Ar seconds
+seconds, the link will be disconnected.
+.Pp
+For ISDN devices,
+.Nm
+will always insist on carrier. Carrier is raised by the i4brbchX device
+driver only after the call has connected. It is therefore wise to set
+a reasonable value such as
+.Ar 6
+seconds.
.Pp
Carrier
.Em require Ns No ment
-is ignored when the link is not a tty device.
+is ignored for all other device types.
.It set choked Op Ar timeout
This sets the number of seconds that
.Nm
@@ -3599,8 +3623,14 @@ This sets the device(s) to which
.Nm
will talk to the given
.Dq value .
-All serial device names are expected to begin with
+.Pp
+All ISDN and serial device names are expected to begin with
.Pa /dev/ .
+ISDN devices are usually called
+.Pa i4brbchX
+and serial devices are usually called
+.Pa cuaaX .
+.Pp
If
.Dq value
does not begin with
@@ -3608,7 +3638,7 @@ does not begin with
it must either begin with an exclamation mark
.Pq Dq \&!
or be of the format
-.Dq host:port .
+.Dq host:port Ns Op Ns /proto .
.Pp
If it begins with an exclamation mark, the rest of the device name is
treated as a program name, and that program is executed when the device
@@ -4616,6 +4646,7 @@ This socket is used to pass links between different instances of
.Xr getty 8 ,
.Xr inetd 8 ,
.Xr init 8 ,
+.Xr isdn 8 ,
.Xr named 8 ,
.Xr ping 8 ,
.Xr pppctl 8 ,
diff --git a/usr.sbin/ppp/ppp/tcp.c b/usr.sbin/ppp/ppp/tcp.c
index 631c5a1135a..5be9f41dbab 100644
--- a/usr.sbin/ppp/ppp/tcp.c
+++ b/usr.sbin/ppp/ppp/tcp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tcp.c,v 1.4 1999/06/05 21:36:01 brian Exp $
+ * $Id: tcp.c,v 1.5 1999/07/15 02:04:07 brian Exp $
*/
#include <sys/types.h>
@@ -44,7 +44,6 @@
#include "defs.h"
#include "mbuf.h"
#include "log.h"
-#include "sync.h"
#include "timer.h"
#include "lqr.h"
#include "hdlc.h"
@@ -109,6 +108,7 @@ static struct device tcpdevice = {
NULL,
NULL,
NULL,
+ NULL,
NULL
};
diff --git a/usr.sbin/ppp/ppp/tty.c b/usr.sbin/ppp/ppp/tty.c
index c9b83d789f4..881b384648c 100644
--- a/usr.sbin/ppp/ppp/tty.c
+++ b/usr.sbin/ppp/ppp/tty.c
@@ -23,32 +23,32 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: tty.c,v 1.9 1999/06/05 21:36:03 brian Exp $
+ * $Id: tty.c,v 1.10 1999/07/15 02:04:07 brian Exp $
*/
#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
+/* #include <sys/socket.h> (auto-remove) */
+/* #include <netinet/in.h> (auto-remove) */
+/* #include <arpa/inet.h> (auto-remove) */
+/* #include <netdb.h> (auto-remove) */
+/* #include <netinet/in_systm.h> (auto-remove) */
+/* #include <netinet/ip.h> (auto-remove) */
#include <sys/un.h>
#if defined(__OpenBSD__) || defined(__NetBSD__)
#include <sys/ioctl.h>
-#include <util.h>
+/* #include <util.h> (auto-remove) */
#else
-#include <libutil.h>
+/* #include <libutil.h> (auto-remove) */
#endif
#include <errno.h>
#include <fcntl.h>
-#include <paths.h>
-#include <stdio.h>
+/* #include <paths.h> (auto-remove) */
+/* #include <stdio.h> (auto-remove) */
#include <stdlib.h>
#include <string.h>
#include <sysexits.h>
-#include <sys/wait.h>
+/* #include <sys/wait.h> (auto-remove) */
#include <sys/uio.h>
#include <termios.h>
#include <unistd.h>
@@ -57,8 +57,8 @@
#include "defs.h"
#include "mbuf.h"
#include "log.h"
-#include "id.h"
-#include "sync.h"
+/* #include "id.h" (auto-remove) */
+/* #include "sync.h" (auto-remove) */
#include "timer.h"
#include "lqr.h"
#include "hdlc.h"
@@ -68,20 +68,20 @@
#include "ccp.h"
#include "link.h"
#include "async.h"
-#include "slcompress.h"
-#include "iplist.h"
-#include "ipcp.h"
-#include "filter.h"
+/* #include "slcompress.h" (auto-remove) */
+/* #include "iplist.h" (auto-remove) */
+/* #include "ipcp.h" (auto-remove) */
+/* #include "filter.h" (auto-remove) */
#include "descriptor.h"
#include "physical.h"
#include "mp.h"
#ifndef NORADIUS
-#include "radius.h"
+/* #include "radius.h" (auto-remove) */
#endif
#include "chat.h"
-#include "command.h"
-#include "bundle.h"
-#include "prompt.h"
+/* #include "command.h" (auto-remove) */
+/* #include "bundle.h" (auto-remove) */
+/* #include "prompt.h" (auto-remove) */
#include "auth.h"
#include "chap.h"
#include "cbcp.h"
@@ -95,6 +95,7 @@ struct ttydevice {
struct device dev; /* What struct physical knows about */
struct pppTimer Timer; /* CD checks */
int mbits; /* Current DCD status */
+ int carrier_seconds; /* seconds before CD is *required* */
struct termios ios; /* To be able to reset from raw mode */
};
@@ -124,29 +125,35 @@ tty_Timeout(void *data)
if (p->fd >= 0) {
if (ioctl(p->fd, TIOCMGET, &dev->mbits) < 0) {
- log_Printf(LogPHASE, "%s: ioctl error (%s)!\n", p->link.name,
+ /* we must be a pty ? */
+ log_Printf(LogDEBUG, "%s: ioctl error (%s)!\n", p->link.name,
strerror(errno));
- datalink_Down(p->dl, CLOSE_NORMAL);
timer_Stop(&dev->Timer);
return;
}
- } else
+ } else {
+log_Printf(LogPHASE, "timeout ?\n");
dev->mbits = 0;
+}
if (ombits == -1) {
/* First time looking for carrier */
if (Online(dev))
- log_Printf(LogDEBUG, "%s: %s: CD detected\n", p->link.name, p->name.full);
- else if (p->cfg.cd.required) {
- log_Printf(LogPHASE, "%s: %s: Required CD not detected\n",
- p->link.name, p->name.full);
- datalink_Down(p->dl, CLOSE_NORMAL);
- } else {
- log_Printf(LogPHASE, "%s: %s doesn't support CD\n",
- p->link.name, p->name.full);
+ log_Printf(LogPHASE, "%s: %s: CD detected\n", p->link.name, p->name.full);
+ else if (++dev->carrier_seconds >= p->cfg.cd.delay) {
+ if (p->cfg.cd.required)
+ log_Printf(LogPHASE, "%s: %s: Required CD not detected\n",
+ p->link.name, p->name.full);
+ else {
+ log_Printf(LogPHASE, "%s: %s doesn't support CD\n",
+ p->link.name, p->name.full);
+ dev->mbits = TIOCM_CD; /* Dodgy null-modem cable ? */
+ }
timer_Stop(&dev->Timer);
- dev->mbits = TIOCM_CD;
- }
+ /* tty_AwaitCarrier() will notice */
+ } else
+ /* Keep waiting */
+ dev->mbits = -1;
} else {
change = ombits ^ dev->mbits;
if (change & TIOCM_CD) {
@@ -170,52 +177,66 @@ tty_StartTimer(struct physical *p)
struct ttydevice *dev = device2tty(p->handler);
timer_Stop(&dev->Timer);
- dev->Timer.load = SECTICKS * p->cfg.cd.delay;
+ dev->Timer.load = SECTICKS;
dev->Timer.func = tty_Timeout;
dev->Timer.name = "tty CD";
dev->Timer.arg = p;
log_Printf(LogDEBUG, "%s: Using tty_Timeout [%p]\n",
p->link.name, tty_Timeout);
- dev->mbits = -1; /* So we know it's the first time */
timer_Start(&dev->Timer);
}
static int
+tty_AwaitCarrier(struct physical *p)
+{
+ struct ttydevice *dev = device2tty(p->handler);
+
+ if (physical_IsSync(p))
+ return CARRIER_OK;
+
+ if (dev->mbits == -1) {
+ if (dev->Timer.state == TIMER_STOPPED) {
+ dev->carrier_seconds = 0;
+ tty_StartTimer(p);
+ }
+ return CARRIER_PENDING; /* Not yet ! */
+ }
+
+ return Online(dev) || !p->cfg.cd.required ? CARRIER_OK : CARRIER_LOST;
+}
+
+static int
tty_Raw(struct physical *p)
{
struct ttydevice *dev = device2tty(p->handler);
struct termios ios;
int oldflag;
- if (physical_IsSync(p))
- return 1;
-
- log_Printf(LogDEBUG, "%s: Entering physical_Raw\n", p->link.name);
+ log_Printf(LogDEBUG, "%s: Entering tty_Raw\n", p->link.name);
if (p->type != PHYS_DIRECT && p->fd >= 0 && !Online(dev))
log_Printf(LogDEBUG, "%s: Raw: descriptor = %d, mbits = %x\n",
p->link.name, p->fd, dev->mbits);
- tcgetattr(p->fd, &ios);
- cfmakeraw(&ios);
- if (p->cfg.rts_cts)
- ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW;
- else
- ios.c_cflag |= CLOCAL;
+ if (!physical_IsSync(p)) {
+ tcgetattr(p->fd, &ios);
+ cfmakeraw(&ios);
+ if (p->cfg.rts_cts)
+ ios.c_cflag |= CLOCAL | CCTS_OFLOW | CRTS_IFLOW;
+ else
+ ios.c_cflag |= CLOCAL;
- if (p->type != PHYS_DEDICATED)
- ios.c_cflag |= HUPCL;
+ if (p->type != PHYS_DEDICATED)
+ ios.c_cflag |= HUPCL;
- tcsetattr(p->fd, TCSANOW, &ios);
+ tcsetattr(p->fd, TCSANOW, &ios);
+ }
oldflag = fcntl(p->fd, F_GETFL, 0);
if (oldflag < 0)
return 0;
fcntl(p->fd, F_SETFL, oldflag | O_NONBLOCK);
- if (ioctl(p->fd, TIOCMGET, &dev->mbits) == 0)
- tty_StartTimer(p);
-
return 1;
}
@@ -226,7 +247,7 @@ tty_Offline(struct physical *p)
if (p->fd >= 0) {
timer_Stop(&dev->Timer);
- dev->mbits &= ~TIOCM_DTR;
+ dev->mbits &= ~TIOCM_DTR; /* XXX: Hmm, what's this supposed to do ? */
if (Online(dev)) {
struct termios tio;
@@ -249,12 +270,12 @@ tty_Cooked(struct physical *p)
tty_Offline(p); /* In case of emergency close()s */
tcflush(p->fd, TCIOFLUSH);
- if (!physical_IsSync(p)) {
+
+ if (!physical_IsSync(p))
tcsetattr(p->fd, TCSAFLUSH, &dev->ios);
- oldflag = fcntl(p->fd, F_GETFL, 0);
- if (oldflag == 0)
- fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK);
- }
+
+ if ((oldflag = fcntl(p->fd, F_GETFL, 0)) != -1)
+ fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK);
}
static void
@@ -296,6 +317,7 @@ tty_OpenInfo(struct physical *p)
else
strcpy(buf, "no");
strcat(buf, " carrier");
+
return buf;
}
@@ -323,6 +345,7 @@ tty_device2iov(struct device *d, struct iovec *iov, int *niov,
static struct device basettydevice = {
TTY_DEVICE,
"tty",
+ tty_AwaitCarrier,
tty_Raw,
tty_Offline,
tty_Cooked,
@@ -393,6 +416,7 @@ tty_Create(struct physical *p)
memcpy(&dev->dev, &basettydevice, sizeof dev->dev);
memset(&dev->Timer, '\0', sizeof dev->Timer);
+ dev->mbits = -1;
tcgetattr(p->fd, &ios);
dev->ios = ios;
@@ -424,22 +448,6 @@ tty_Create(struct physical *p)
"cflag = %lx\n", p->link.name, (u_long)ios.c_iflag,
(u_long)ios.c_oflag, (u_long)ios.c_cflag);
- if (ioctl(p->fd, TIOCMGET, &dev->mbits) == -1) {
- if (p->type != PHYS_DIRECT) {
- /* Complete failure - parent doesn't continue trying to ``create'' */
-
- log_Printf(LogWARN, "%s: Open: Cannot get physical status: %s\n",
- p->link.name, strerror(errno));
- tty_Cooked(p);
- close(p->fd);
- p->fd = -1;
- return NULL;
- } else
- dev->mbits = TIOCM_CD;
- }
- log_Printf(LogDEBUG, "%s: Open: physical control = %o\n",
- p->link.name, dev->mbits);
-
oldflag = fcntl(p->fd, F_GETFL, 0);
if (oldflag < 0) {
/* Complete failure - parent doesn't continue trying to ``create'' */
@@ -449,6 +457,7 @@ tty_Create(struct physical *p)
tty_Cooked(p);
close(p->fd);
p->fd = -1;
+ free(dev);
return NULL;
} else
fcntl(p->fd, F_SETFL, oldflag & ~O_NONBLOCK);
diff --git a/usr.sbin/ppp/ppp/udp.c b/usr.sbin/ppp/ppp/udp.c
index f7d5541b9d6..73965230b2c 100644
--- a/usr.sbin/ppp/ppp/udp.c
+++ b/usr.sbin/ppp/ppp/udp.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: udp.c,v 1.3 1999/06/05 21:36:04 brian Exp $
+ * $Id: udp.c,v 1.4 1999/07/15 02:04:07 brian Exp $
*/
#include <sys/types.h>
@@ -45,7 +45,6 @@
#include "defs.h"
#include "mbuf.h"
#include "log.h"
-#include "sync.h"
#include "timer.h"
#include "lqr.h"
#include "hdlc.h"
@@ -137,6 +136,7 @@ static const struct device baseudpdevice = {
NULL,
NULL,
NULL,
+ NULL,
udp_Free,
udp_Recvfrom,
udp_Sendto,
diff --git a/usr.sbin/ppp/ppp/vjcomp.c b/usr.sbin/ppp/ppp/vjcomp.c
index 6296dcf2846..b64c2fc38e3 100644
--- a/usr.sbin/ppp/ppp/vjcomp.c
+++ b/usr.sbin/ppp/ppp/vjcomp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: vjcomp.c,v 1.8 1999/06/02 15:58:41 brian Exp $
+ * $Id: vjcomp.c,v 1.9 1999/07/15 02:04:07 brian Exp $
*
* TODO:
*/
@@ -28,7 +28,7 @@
#include <sys/un.h>
#include <stdio.h>
-#include <string.h>
+/* #include <string.h> (auto-remove) */
#include <termios.h>
#include "layer.h"