From 6eb146d2a3d7224373f15e56ea9eee4aa1713b0f Mon Sep 17 00:00:00 2001
From: Piraty <piraty1@inbox.ru>
Date: Mon, 22 Jul 2019 00:37:23 +0200
Subject: [PATCH] New package: udptunnel-1.1

all patches from current ubuntu were picked
https://launchpad.net/ubuntu/+source/udptunnel/1.1-5
---
 srcpkgs/udptunnel/patches/01-multicast.diff   | 16 ++++++
 .../patches/02-strlen-prototype.diff          | 16 ++++++
 srcpkgs/udptunnel/patches/rpc.patch           | 54 +++++++++++++++++++
 srcpkgs/udptunnel/template                    | 20 +++++++
 4 files changed, 106 insertions(+)
 create mode 100644 srcpkgs/udptunnel/patches/01-multicast.diff
 create mode 100644 srcpkgs/udptunnel/patches/02-strlen-prototype.diff
 create mode 100644 srcpkgs/udptunnel/patches/rpc.patch
 create mode 100644 srcpkgs/udptunnel/template

diff --git a/srcpkgs/udptunnel/patches/01-multicast.diff b/srcpkgs/udptunnel/patches/01-multicast.diff
new file mode 100644
index 00000000000..034ddb44ed3
--- /dev/null
+++ b/srcpkgs/udptunnel/patches/01-multicast.diff
@@ -0,0 +1,16 @@
+# src: ubuntu
+
+Description: Fix issue where udptunnel was failing to receive packets sent to a multicast address. (See #254834).
+Author: singh_chinmay@extenprise.net
+
+--- udptunnel.c
++++ udptunnel.c
+@@ -217,7 +217,7 @@
+     (*relays)[i].udpaddr.sin_port = htons(udpport + i);
+     (*relays)[i].udpaddr.sin_family = AF_INET;
+     (*relays)[i].udp_ttl = udpttl;
+-    (*relays)[i].multicast_udp = IN_MULTICAST(htons(udpaddr.s_addr));
++    (*relays)[i].multicast_udp = IN_MULTICAST(htonl(udpaddr.s_addr));
+ 
+     (*relays)[i].tcpaddr.sin_addr = tcpaddr;
+     (*relays)[i].tcpaddr.sin_port = htons(tcpport + i);
diff --git a/srcpkgs/udptunnel/patches/02-strlen-prototype.diff b/srcpkgs/udptunnel/patches/02-strlen-prototype.diff
new file mode 100644
index 00000000000..b809f059986
--- /dev/null
+++ b/srcpkgs/udptunnel/patches/02-strlen-prototype.diff
@@ -0,0 +1,16 @@
+# src: ubuntu
+
+Description: Include string.h header for strlen prototype for GCC 4.4. compatibility.
+Author: Chris Lamb <chris@chris-lamb.co.uk>
+
+diff -urNad /tmp/bp-build/udptunnel-1.1.orig.orig/host2ip.c /tmp/bp-build/udptunnel-1.1.orig/host2ip.c
+--- host2ip.c	2008-08-28 07:50:41.000000000 +0100
++++ host2ip.c	2008-08-28 07:50:49.000000000 +0100
+@@ -6,6 +6,7 @@
+ #include <arpa/inet.h>       /* inet_addr() */
+ #include <rpcsvc/ypclnt.h>   /* YP */
+ #include <ctype.h>           /* isspace() */
++#include <string.h>          /* strlen() */
+ 
+ #include "host2ip.h"
+ 
diff --git a/srcpkgs/udptunnel/patches/rpc.patch b/srcpkgs/udptunnel/patches/rpc.patch
new file mode 100644
index 00000000000..98cda95c926
--- /dev/null
+++ b/srcpkgs/udptunnel/patches/rpc.patch
@@ -0,0 +1,54 @@
+# reason: rpcsvc/ypclnt.h is only present in glibc, so check for it
+
+--- configure.in
++++ configure.in
+@@ -19,6 +19,7 @@
+ dnl Checks for header files.
+ AC_HEADER_STDC
+ AC_CHECK_HEADERS(fcntl.h sys/time.h unistd.h)
++AC_CHECK_HEADERS(rpcsvc/ypclnt.h)
+ 
+ dnl Checks for typedefs, structures, and compiler characteristics.
+ AC_CHECK_SIZEOF(short)
+
+--- host2ip.c
++++ host2ip.c
+@@ -4,7 +4,9 @@
+ #include <netdb.h>           /* gethostbyname() */
+ #include <netinet/in.h>      /* sockaddr_in */
+ #include <arpa/inet.h>       /* inet_addr() */
++#ifdef HAVE_RPCSVC_YPCLNT_H
+ #include <rpcsvc/ypclnt.h>   /* YP */
++#endif
+ #include <ctype.h>           /* isspace() */
+ #include <string.h>          /* strlen() */
+ 
+@@ -27,6 +29,8 @@
+     while (*host && isspace((int)*host)) host++;  
+   }
+ 
++  /* pre-set */
++  in.s_addr = INADDR_ANY;
+   /* Check whether this is a dotted decimal. */
+   if (!host) {
+     in.s_addr = INADDR_ANY;
+@@ -38,6 +42,7 @@
+   else if ((hep = gethostbyname(host))) {
+     in = *(struct in_addr *)(hep->h_addr_list[0]);
+   }
++#ifdef HAVE_RPCSVC_YPCLNT_H && USE_NIS
+   /* As a last resort, try YP. */
+   else {
+     static char *domain = 0;  /* YP domain */
+@@ -47,10 +52,8 @@
+     if (!domain) yp_get_default_domain(&domain);
+     if (yp_match(domain, "hosts.byname", host, strlen(host), &value, &value_len) == 0) {
+       in.s_addr = inet_addr(value);
+-    } else {
+-      /* Everything failed */
+-      in.s_addr = INADDR_ANY;
+     }
+   }
++#endif
+   return in;
+ } /* host2ip */
diff --git a/srcpkgs/udptunnel/template b/srcpkgs/udptunnel/template
new file mode 100644
index 00000000000..dfc7ee1fe5e
--- /dev/null
+++ b/srcpkgs/udptunnel/template
@@ -0,0 +1,20 @@
+# Template file for 'udptunnel'
+pkgname=udptunnel
+version=1.1
+revision=1
+build_style=gnu-configure
+hostmakedepends="automake"
+short_desc="Tunnel UDP packets over a TCP connection"
+maintainer="Piraty <piraty1@inbox.ru>"
+license="BSD-3-Clause"
+homepage="http://www.cs.columbia.edu/~lennox/udptunnel/"
+distfiles="http://www.cs.columbia.edu/~lennox/udptunnel/udptunnel-${version}.tar.gz"
+checksum=45c0e12045735bc55734076ebbdc7622c746d1fe4e6f7267fa122e2421754670
+
+pre_configure() {
+	autoreconf -vfi
+}
+post_install() {
+	vlicense COPYRIGHT
+	vdoc udptunnel.html
+}
