+ if (ioctl(t->f.fd, UNIOCGINFO, &uni)) {
+ a_warn("TUN", "-", "unet", "getinfo-error", "?ERRNO", A_END);
+ goto fail_1;
+ }
+ *ifn = xstrdup(uni.uni_ifname);
+ return (fd);
+
+fail_1:
+ close(fd);
+fail_0:
+ return (-1);
+}
+
+/* --- @t_create@ --- *
+ *
+ * Arguments: @peer *p@ = pointer to peer block
+ * @int fd@ = file descriptor of tunnel device
+ * @char **ifn@ = where to put the interface name
+ *
+ * Returns: A tunnel block if it worked, or null on failure.
+ *
+ * Use: Initializes a new tunnel.
+ */
+
+static tunnel *t_create(peer *p, int fd, char **ifn)
+{
+ tunnel *t;
+
+ fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);