chiark / gitweb /
Support SLIP encapsulation as a tunnelling mechanism.
[tripe] / tun-unet.c
index 80cf73065183a98b77928caf6371480a76bfdd2b..1cbdf2beaa86130f51d5e08402a89dadecfb0674 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: tun-unet.c,v 1.5 2002/01/13 14:57:05 mdw Exp $
+ * $Id$
  *
  * Tunnel interface based on Linux Usernet
  *
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: tun-unet.c,v $
- * Revision 1.5  2002/01/13 14:57:05  mdw
- * Make @t_read@ be static, as it always should have been.
- *
- * Revision 1.4  2001/02/19 19:10:45  mdw
- * Set unet devices to be point-to-point.
- *
- * Revision 1.3  2001/02/05 19:55:00  mdw
- * Guard against inappropriate compilation.
- *
- * Revision 1.2  2001/02/04 17:10:58  mdw
- * Make file descriptors be nonblocking and close-on-exec.
- *
- * Revision 1.1  2001/02/03 20:26:37  mdw
- * Initial checkin.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include "tripe.h"
@@ -79,7 +59,7 @@ static void t_read(int fd, unsigned mode, void *v)
 
   n = read(fd, buf_i, sizeof(buf_i));
   if (n < 0) {
-    a_warn("tunnel read failed (%s): %s", tun_ifname(t), strerror(errno));
+    a_warn("TUN %s read-error -- %s", tun_ifname(t), strerror(errno));
     return;
   }
   IF_TRACING(T_TUNNEL, {
@@ -121,13 +101,13 @@ int tun_create(tunnel *t, peer *p)
   int f;
 
   if ((fd = open("/dev/unet", O_RDWR)) < 0) {
-    a_warn("open `/dev/unet' failed: %s", strerror(errno));
+    a_warn("TUN - open-error /dev/unet -- %s", strerror(errno));
     return (-1);
   }
   fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
   if ((f = ioctl(fd, UNIOCGIFFLAGS)) < 0 ||
       ioctl(fd, UNIOCSIFFLAGS, f | IFF_POINTOPOINT)) {
-    a_warn("couldn't set point-to-point flag: %s", strerror(errno));
+    a_warn("TUN - unet config-error -- %s", strerror(errno));
     close(fd);
     return (-1);
   }
@@ -151,11 +131,11 @@ const char *tun_ifname(tunnel *t)
   static char b[UNET_NAMEMAX];
   struct unet_info uni;
   if (ioctl(t->f.fd, UNIOCGINFO, &uni)) {
-    a_warn("ioctl(UNIOCGINFO) failed: %s", strerror(errno));
+    a_warn("TUN - unet getinfo-error -- %s", strerror(errno));
     return ("<error>");
   }
   if (strlen(uni.uni_ifname) + 1 > sizeof(b)) {
-    a_warn("interface name too long!");
+    a_warn("TUN - unet ifname-too-long");
     return ("<error>");
   }
   strcpy(b, uni.uni_ifname);