chiark / gitweb /
tripe-admin manpage: Generate a command and message summary.
[tripe] / tun-linux.c
index 8c7278cebd947dcc21fd7e087e3032acf4317a52..3cfa5d72d03778362fc59eef55163f606e7d8b04 100644 (file)
@@ -68,12 +68,12 @@ static void t_read(int fd, unsigned mode, void *v)
 
   n = read(fd, buf_i, sizeof(buf_i));
   if (n < 0) {
-    a_warn("TUN %s read-error -- %s", t->ifn, strerror(errno));
+    a_warn("TUN", "%s", t->ifn, "read-error", "?ERRNO", A_END);
     return;
   }
   IF_TRACING(T_TUNNEL, {
-    trace(T_TUNNEL, "tunnel: packet arrived");
-    trace_block(T_PACKET, "tunnel: packet contents", buf_i, n);
+    trace(T_TUNNEL, "tun-linux: packet arrived");
+    trace_block(T_PACKET, "tun-linux: packet contents", buf_i, n);
   })
   buf_init(&b, buf_i, n);
   p_tun(t->p, &b);
@@ -108,14 +108,17 @@ static tunnel *t_create(peer *p)
   tunnel *t;
 
   if ((fd = open("/dev/net/tun", O_RDWR)) < 0) {
-    a_warn("TUN - open-error /dev/net/tun -- %s", strerror(errno));
+    a_warn("TUN", "-", "linux",
+           "open-error", "/dev/net/tun", "?ERRNO",
+           A_END);
     return (0);
   }
   fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
+  memset(&iff, 0, sizeof(iff));
   iff.ifr_name[0] = 0;
   iff.ifr_flags = IFF_TUN | IFF_NO_PI;
   if ((f = ioctl(fd, TUNSETIFF, &iff)) < 0) {
-    a_warn("TUN - linux config-error -- %s", strerror(errno));
+    a_warn("TUN", "-", "linux", "config-error", "?ERRNO", A_END);
     close(fd);
     return (0);
   }
@@ -126,7 +129,7 @@ static tunnel *t_create(peer *p)
   sel_addfile(&t->f);
   iff.ifr_name[IFNAMSIZ - 1] = 0;
   strcpy(t->ifn, iff.ifr_name);
-  T( trace(T_TUNNEL, "tunnel: attached interface %s to peer `%s'",
+  T( trace(T_TUNNEL, "tun-linux: attached interface %s to peer `%s'",
           t->ifn, p_name(p)); )
   return (t);
 }
@@ -153,7 +156,7 @@ static const char *t_ifname(tunnel *t) { return (t->ifn); }
 static void t_inject(tunnel *t, buf *b)
 {
   IF_TRACING(T_TUNNEL, {
-    trace(T_TUNNEL, "tunnel: inject decrypted packet");
+    trace(T_TUNNEL, "tun-linux: inject decrypted packet");
     trace_block(T_PACKET, "tunnel: packet contents", BBASE(b), BLEN(b));
   })
   write(t->f.fd, BBASE(b), BLEN(b));