From 02fd1696e5b29c566309b4a3c8b963ddba306e01 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Mon, 3 Mar 2014 12:24:38 +0000
Subject: [PATCH] main/igmpproxy: fix building with musl

---
 ...-Use-standard-unsigned-integer-types.patch | 202 ++++++++++++++++++
 main/igmpproxy/APKBUILD                       |  19 +-
 2 files changed, 216 insertions(+), 5 deletions(-)
 create mode 100644 main/igmpproxy/0001-Use-standard-unsigned-integer-types.patch

diff --git a/main/igmpproxy/0001-Use-standard-unsigned-integer-types.patch b/main/igmpproxy/0001-Use-standard-unsigned-integer-types.patch
new file mode 100644
index 000000000000..40ada6f7ce38
--- /dev/null
+++ b/main/igmpproxy/0001-Use-standard-unsigned-integer-types.patch
@@ -0,0 +1,202 @@
+From ed3dff27f360239910310be6706fd54572398992 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Mon, 3 Mar 2014 12:11:26 +0000
+Subject: [PATCH] Use standard unsigned integer types
+
+Use the stanard unsigned integer types instead of the non-standard
+u_char, u_short and u_int.
+
+This fixes build with musl libc.
+
+(cherry picked from commit b914bcf882c6189be7a0ce6fceb34422372c3606)
+
+Conflicts:
+	src/igmp.c
+---
+ src/igmp.c         |  4 ++--
+ src/kern.c         |  4 ++--
+ src/lib.c          | 10 +++++-----
+ src/os-dragonfly.h |  4 ++--
+ src/os-freebsd.h   |  4 ++--
+ src/os-linux.h     |  4 ++--
+ src/os-netbsd.h    |  4 ++--
+ src/os-openbsd.h   |  4 ++--
+ 8 files changed, 19 insertions(+), 19 deletions(-)
+
+diff --git a/src/igmp.c b/src/igmp.c
+index a0cd27d..92f37e7 100644
+--- a/src/igmp.c
++++ b/src/igmp.c
+@@ -79,7 +79,7 @@ void initIgmp() {
+ /**
+ *   Finds the textual name of the supplied IGMP request.
+ */
+-char *igmpPacketKind(u_int type, u_int code) {
++char *igmpPacketKind(unsigned int type, unsigned int code) {
+     static char unknown[20];
+ 
+     switch (type) {
+@@ -226,7 +226,7 @@ void buildIgmp(uint32_t src, uint32_t dst, int type, int code, uint32_t group, i
+     igmp->igmp_code         = code;
+     igmp->igmp_group.s_addr = group;
+     igmp->igmp_cksum        = 0;
+-    igmp->igmp_cksum        = inetChksum((u_short *)igmp,
++    igmp->igmp_cksum        = inetChksum((unsigned short *)igmp,
+                                          IGMP_MINLEN + datalen);
+ }
+ 
+diff --git a/src/kern.c b/src/kern.c
+index 2055636..12c613f 100644
+--- a/src/kern.c
++++ b/src/kern.c
+@@ -82,7 +82,7 @@ void k_hdr_include(int hdrincl) {
+ 
+ void k_set_ttl(int t) {
+ #ifndef RAW_OUTPUT_IS_RAW
+-    u_char ttl;
++    unsigned char ttl;
+ 
+     ttl = t;
+     if (setsockopt(MRouterFD, IPPROTO_IP, IP_MULTICAST_TTL,
+@@ -94,7 +94,7 @@ void k_set_ttl(int t) {
+ 
+ 
+ void k_set_loop(int l) {
+-    u_char loop;
++    unsigned char loop;
+ 
+     loop = l;
+     if (setsockopt(MRouterFD, IPPROTO_IP, IP_MULTICAST_LOOP,
+diff --git a/src/lib.c b/src/lib.c
+index 70a730a..0eed9ce 100644
+--- a/src/lib.c
++++ b/src/lib.c
+@@ -61,9 +61,9 @@ char *fmtInAdr( char *St, struct in_addr InAdr ) {
+  * Convert an IP address in u_long (network) format into a printable string.
+  */
+ char *inetFmt(uint32_t addr, char *s) {
+-    register u_char *a;
++    register unsigned char *a;
+ 
+-    a = (u_char *)&addr;
++    a = (unsigned char *)&addr;
+     sprintf(s, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
+     return(s);
+ }
+@@ -74,15 +74,15 @@ char *inetFmt(uint32_t addr, char *s) {
+  * string including the netmask as a number of bits.
+  */
+ char *inetFmts(uint32_t addr, uint32_t mask, char *s) {
+-    register u_char *a, *m;
++    register unsigned char *a, *m;
+     int bits;
+ 
+     if ((addr == 0) && (mask == 0)) {
+         sprintf(s, "default");
+         return(s);
+     }
+-    a = (u_char *)&addr;
+-    m = (u_char *)&mask;
++    a = (unsigned char *)&addr;
++    m = (unsigned char *)&mask;
+     bits = 33 - ffs(ntohl(mask));
+ 
+     if (m[3] != 0) sprintf(s, "%u.%u.%u.%u/%d", a[0], a[1], a[2], a[3],
+diff --git a/src/os-dragonfly.h b/src/os-dragonfly.h
+index 735401c..189dfb2 100644
+--- a/src/os-dragonfly.h
++++ b/src/os-dragonfly.h
+@@ -3,12 +3,12 @@
+ #include <netinet/ip.h>
+ #include <netinet/igmp.h>
+ 
+-static inline u_short ip_data_len(const struct ip *ip)
++static inline unsigned short ip_data_len(const struct ip *ip)
+ {
+ 	return ip->ip_len;
+ }
+ 
+-static inline void ip_set_len(struct ip *ip, u_short len)
++static inline void ip_set_len(struct ip *ip, unsigned short len)
+ {
+ 	ip->ip_len = len;
+ }
+diff --git a/src/os-freebsd.h b/src/os-freebsd.h
+index ca01cc5..60b897c 100644
+--- a/src/os-freebsd.h
++++ b/src/os-freebsd.h
+@@ -12,12 +12,12 @@
+ #define IGMP_V2_LEAVE_GROUP IGMP_HOST_LEAVE_MESSAGE
+ #endif
+ 
+-static inline u_short ip_data_len(const struct ip *ip)
++static inline unsigned short ip_data_len(const struct ip *ip)
+ {
+ 	return ip->ip_len;
+ }
+ 
+-static inline void ip_set_len(struct ip *ip, u_short len)
++static inline void ip_set_len(struct ip *ip, unsigned short len)
+ {
+ 	ip->ip_len = len;
+ }
+diff --git a/src/os-linux.h b/src/os-linux.h
+index 7504b1f..6cdcdc7 100644
+--- a/src/os-linux.h
++++ b/src/os-linux.h
+@@ -4,12 +4,12 @@
+ #include <netinet/ip.h>
+ #include <netinet/igmp.h>
+ 
+-static inline u_short ip_data_len(const struct ip *ip)
++static inline unsigned short ip_data_len(const struct ip *ip)
+ {
+ 	return ntohs(ip->ip_len) - (ip->ip_hl << 2);
+ }
+ 
+-static inline void ip_set_len(struct ip *ip, u_short len)
++static inline void ip_set_len(struct ip *ip, unsigned short len)
+ {
+ 	ip->ip_len = htons(len);
+ }
+diff --git a/src/os-netbsd.h b/src/os-netbsd.h
+index 17bd5fa..22f74e5 100644
+--- a/src/os-netbsd.h
++++ b/src/os-netbsd.h
+@@ -8,12 +8,12 @@
+ #define IGMP_V2_MEMBERSHIP_REPORT IGMP_v2_HOST_MEMBERSHIP_REPORT
+ #define IGMP_V2_LEAVE_GROUP IGMP_HOST_LEAVE_MESSAGE
+ 
+-static inline u_short ip_data_len(const struct ip *ip)
++static inline unsigned short ip_data_len(const struct ip *ip)
+ {
+ 	return ip->ip_len;
+ }
+ 
+-static inline void ip_set_len(struct ip *ip, u_short len)
++static inline void ip_set_len(struct ip *ip, unsigned short len)
+ {
+ 	ip->ip_len = len;
+ }
+diff --git a/src/os-openbsd.h b/src/os-openbsd.h
+index 873e5fb..75ddf80 100644
+--- a/src/os-openbsd.h
++++ b/src/os-openbsd.h
+@@ -10,12 +10,12 @@
+ 
+ #define INADDR_ALLRTRS_GROUP INADDR_ALLROUTERS_GROUP
+ 
+-static inline u_short ip_data_len(const struct ip *ip)
++static inline unsigned short ip_data_len(const struct ip *ip)
+ {
+ 	return ntohs(ip->ip_len) - (ip->ip_hl << 2);
+ }
+ 
+-static inline void ip_set_len(struct ip *ip, u_short len)
++static inline void ip_set_len(struct ip *ip, unsigned short len)
+ {
+ 	ip->ip_len = htons(len);
+ }
+-- 
+1.9.0
+
diff --git a/main/igmpproxy/APKBUILD b/main/igmpproxy/APKBUILD
index 17895176a5f7..0dc2bcc3506a 100644
--- a/main/igmpproxy/APKBUILD
+++ b/main/igmpproxy/APKBUILD
@@ -2,7 +2,7 @@
 # Maintainer: Natanael Copa <ncopa@alpinelinux.org>
 pkgname=igmpproxy
 pkgver=0.1
-pkgrel=3
+pkgrel=4
 pkgdesc="A simple dynamic Multicast Routing Daemon using only IGMP signalling"
 url="http://sourceforge.net/projects/igmpproxy/"
 arch="all"
@@ -11,11 +11,17 @@ depends=""
 makedepends=""
 install=""
 subpackages="$pkgname-doc"
-source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz"
+source="http://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.gz
+	0001-Use-standard-unsigned-integer-types.patch"
 
 _builddir="$srcdir/$pkgname-$pkgver"
 prepare() {
 	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
 	update_config_sub || return 1
 }
 
@@ -42,6 +48,9 @@ package() {
 	make DESTDIR="$pkgdir" install || return 1
 }
 
-md5sums="c56f41ec195bc1fe016369bf74efc5a1  igmpproxy-0.1.tar.gz"
-sha256sums="ee18ff3d8c3ae3a29dccb7e5eedf332337330020168bd95a11cece8d7d7ee6ae  igmpproxy-0.1.tar.gz"
-sha512sums="1a569814d8984610402313d8c4adb78ff362f82ae28c968a8ba0fb411e12a704d1b51b387111b51517ab8fb2e86952bbd196f27eccd311c11ce288fc6fa25ad4  igmpproxy-0.1.tar.gz"
+md5sums="c56f41ec195bc1fe016369bf74efc5a1  igmpproxy-0.1.tar.gz
+5e5d698b45e28b77d77eb9243f10a6d1  0001-Use-standard-unsigned-integer-types.patch"
+sha256sums="ee18ff3d8c3ae3a29dccb7e5eedf332337330020168bd95a11cece8d7d7ee6ae  igmpproxy-0.1.tar.gz
+12b5c5458fe335fd7ec231887240367464fc69330038731425963051385ee6d0  0001-Use-standard-unsigned-integer-types.patch"
+sha512sums="1a569814d8984610402313d8c4adb78ff362f82ae28c968a8ba0fb411e12a704d1b51b387111b51517ab8fb2e86952bbd196f27eccd311c11ce288fc6fa25ad4  igmpproxy-0.1.tar.gz
+161bcc7f247131f74251b12095361a4883581986d25e84b9dc16f9330846f4be8d2913123cef27a46b790956b258b16fcd77bf8a037a680f79d9bacfa1e037ad  0001-Use-standard-unsigned-integer-types.patch"
-- 
GitLab