summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp/main.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-11-16 22:15:11 +0000
committerbrian <brian@FreeBSD.org>1997-11-16 22:15:11 +0000
commit5696a07f36cde36ef7955344c7b33fc5c7c57248 (patch)
tree766aa7f660926161982f1e79a01aa4827f8022d9 /usr.sbin/ppp/main.c
parent0f428e70f1f534b0936e0af7a36d1ad2f7e76775 (diff)
downloadFreeBSD-src-5696a07f36cde36ef7955344c7b33fc5c7c57248.zip
FreeBSD-src-5696a07f36cde36ef7955344c7b33fc5c7c57248.tar.gz
Abstract data read from and written to the tun device,
allowing for a possible header on the front of all packets. In OpenBSD, there's a structure containing the address family here. If we're building under OpenBSD, set up the ``flags'' part of struct tuninfo (not there under FreeBSD) so that we config the interface as POINTOPOINT. Prefix prototypes with ``extern'' in os.c for consistency. These changes are cosmetic under FreeBSD, but allow ppp to build & work under OpenBSD (bar the srandomdev() stuff, the inclusing of <net/if_var.h> and some Makefile symantecs).
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r--usr.sbin/ppp/main.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 1e6bec1..54a5ede 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,19 +17,24 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.97 1997/11/13 14:44:06 brian Exp $
+ * $Id: main.c,v 1.98 1997/11/13 15:35:06 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
* o Add signal handler for misc controls.
*/
#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/if_tun.h>
#include <errno.h>
#include <fcntl.h>
@@ -70,6 +75,7 @@
#include "vjcomp.h"
#include "async.h"
#include "pathnames.h"
+#include "tun.h"
#ifndef O_NONBLOCK
#ifdef O_NDELAY
@@ -728,11 +734,12 @@ DoLoop()
struct timeval timeout, *tp;
int ssize = sizeof(hisaddr);
u_char *cp;
- u_char rbuff[MAX_MRU];
int tries;
int qlen;
int res;
pid_t pgroup;
+ struct tun_data tun;
+#define rbuff tun.data
pgroup = getpgrp();
@@ -1004,11 +1011,18 @@ DoLoop()
}
if (tun_in >= 0 && FD_ISSET(tun_in, &rfds)) { /* something to read
* from tun */
- n = read(tun_in, rbuff, sizeof(rbuff));
+ n = read(tun_in, &tun, sizeof(tun));
if (n < 0) {
LogPrintf(LogERROR, "read from tun: %s\n", strerror(errno));
continue;
}
+ n -= sizeof(tun)-sizeof(tun.data);
+ if (n <= 0) {
+ LogPrintf(LogERROR, "read from tun: Only %d bytes read\n", n);
+ continue;
+ }
+ if (!tun_check_header(tun, AF_INET))
+ continue;
if (((struct ip *) rbuff)->ip_dst.s_addr == IpcpInfo.want_ipaddr.s_addr) {
/* we've been asked to send something addressed *to* us :( */
if (VarLoopback) {
OpenPOWER on IntegriCloud