Blame socat-1.7.1.3-support-ipless-tuntap.patch

Paul Wouters 47404f
diff -up socat-1.7.1.3/xio-tun.c.orig socat-1.7.1.3/xio-tun.c
Paul Wouters 47404f
--- socat-1.7.1.3/xio-tun.c.orig	2011-05-19 20:25:38.654799000 +0200
Paul Wouters 47404f
+++ socat-1.7.1.3/xio-tun.c	2011-05-19 20:37:48.675627004 +0200
Paul Wouters 47404f
@@ -78,8 +78,8 @@ static int xioopen_tun(int argc, const c
Paul Wouters 47404f
    char *ifaddr;
Paul Wouters 47404f
    int result;
Paul Wouters 47404f
 
Paul Wouters 47404f
-   if (argc != 2) {
Paul Wouters 47404f
-      Error2("%s: wrong number of parameters (%d instead of 1)",
Paul Wouters 47404f
+   if (argc > 2 || argc < 0) {
Paul Wouters 47404f
+      Error2("%s: wrong number of parameters (%d instead of 0 or 1)",
Paul Wouters 47404f
 	     argv[0], argc-1);
Paul Wouters 47404f
    }
Paul Wouters 47404f
 
Paul Wouters 47404f
@@ -146,30 +146,31 @@ static int xioopen_tun(int argc, const c
Paul Wouters 47404f
    }
Paul Wouters 47404f
 
Paul Wouters 47404f
    /*--------------------- setting interface address and netmask ------------*/
Paul Wouters 47404f
-   if ((ifaddr = strdup(argv[1])) == NULL) {
Paul Wouters 47404f
-      Error1("strdup(\"%s\"): out of memory", argv[1]);
Paul Wouters 47404f
-      return STAT_RETRYLATER;
Paul Wouters 47404f
+   if (argc == 2) {
Paul Wouters 47404f
+       if ((ifaddr = strdup(argv[1])) == NULL) {
Paul Wouters 47404f
+          Error1("strdup(\"%s\"): out of memory", argv[1]);
Paul Wouters 47404f
+          return STAT_RETRYLATER;
Paul Wouters 47404f
+       }
Paul Wouters 47404f
+       if ((result = xioparsenetwork(ifaddr, pf, &network)) != STAT_OK) {
Paul Wouters 47404f
+          /*! recover */
Paul Wouters 47404f
+          return result;
Paul Wouters 47404f
+       }
Paul Wouters 47404f
+       socket_init(pf, (union sockaddr_union *)&ifr.ifr_addr);
Paul Wouters 47404f
+       ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr =
Paul Wouters 47404f
+          network.netaddr.ip4.sin_addr;
Paul Wouters 47404f
+       if (Ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
Paul Wouters 47404f
+          Error4("ioctl(%d, SIOCSIFADDR, {\"%s\", \"%s\"}: %s",
Paul Wouters 47404f
+             sockfd, ifr.ifr_name, ifaddr, strerror(errno));
Paul Wouters 47404f
+       }
Paul Wouters 47404f
+       ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr =
Paul Wouters 47404f
+          network.netmask.ip4.sin_addr;
Paul Wouters 47404f
+       if (Ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
Paul Wouters 47404f
+          Error4("ioctl(%d, SIOCSIFNETMASK, {\"0x%08u\", \"%s\"}, %s",
Paul Wouters 47404f
+             sockfd, ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
Paul Wouters 47404f
+             ifaddr, strerror(errno));
Paul Wouters 47404f
+       }
Paul Wouters 47404f
+       free(ifaddr);
Paul Wouters 47404f
    }
Paul Wouters 47404f
-   if ((result = xioparsenetwork(ifaddr, pf, &network)) != STAT_OK) {
Paul Wouters 47404f
-      /*! recover */
Paul Wouters 47404f
-      return result;
Paul Wouters 47404f
-   }
Paul Wouters 47404f
-   socket_init(pf, (union sockaddr_union *)&ifr.ifr_addr);
Paul Wouters 47404f
-   ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr =
Paul Wouters 47404f
-      network.netaddr.ip4.sin_addr;
Paul Wouters 47404f
-   if (Ioctl(sockfd, SIOCSIFADDR, &ifr) < 0) {
Paul Wouters 47404f
-      Error4("ioctl(%d, SIOCSIFADDR, {\"%s\", \"%s\"}: %s",
Paul Wouters 47404f
-	     sockfd, ifr.ifr_name, ifaddr, strerror(errno));
Paul Wouters 47404f
-   }
Paul Wouters 47404f
-   ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr =
Paul Wouters 47404f
-      network.netmask.ip4.sin_addr;
Paul Wouters 47404f
-   if (Ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) {
Paul Wouters 47404f
-      Error4("ioctl(%d, SIOCSIFNETMASK, {\"0x%08u\", \"%s\"}, %s",
Paul Wouters 47404f
-	     sockfd, ((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
Paul Wouters 47404f
-	     ifaddr, strerror(errno));
Paul Wouters 47404f
-   }
Paul Wouters 47404f
-   free(ifaddr);
Paul Wouters 47404f
-
Paul Wouters 47404f
    /*--------------------- setting interface flags --------------------------*/
Paul Wouters 47404f
    applyopts_single(&xfd->stream, opts, PH_FD);
Paul Wouters 47404f