From 507861592725c5abedd51342324eea3e412e4e60 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 29 Mar 2015 15:13:28 +0200 Subject: [PATCH] olsrd: fix build with musl Signed-off-by: Daniel Golle --- olsrd/patches/010-fix-musl-build.patch | 148 +++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 olsrd/patches/010-fix-musl-build.patch diff --git a/olsrd/patches/010-fix-musl-build.patch b/olsrd/patches/010-fix-musl-build.patch new file mode 100644 index 0000000..8531023 --- /dev/null +++ b/olsrd/patches/010-fix-musl-build.patch @@ -0,0 +1,148 @@ +Index: olsrd-0.6.8/lib/bmf/src/Address.c +=================================================================== +--- olsrd-0.6.8.orig/lib/bmf/src/Address.c ++++ olsrd-0.6.8/lib/bmf/src/Address.c +@@ -142,7 +142,11 @@ int IsOlsrOrBmfPacket(unsigned char* ipP + + /* Go into the UDP header and check port number */ + udpHeader = (struct udphdr*) ARM_NOWARN_ALIGN((ipPacket + ipHeaderLen)); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + + if (destPort == olsr_cnf->olsrport || destPort == BMF_ENCAP_PORT || destPort == 51698) + /* TODO: #define for 51698 */ +Index: olsrd-0.6.8/lib/bmf/src/Bmf.c +=================================================================== +--- olsrd-0.6.8.orig/lib/bmf/src/Bmf.c ++++ olsrd-0.6.8/lib/bmf/src/Bmf.c +@@ -1028,7 +1028,11 @@ BMF_handle_listeningFd(int skfd, void *d + } + + udpHeader = (struct udphdr*) ARM_NOWARN_ALIGN((rxBuffer + headerLength)); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + if (destPort != BMF_ENCAP_PORT) + { + /* Not BMF */ +Index: olsrd-0.6.8/lib/bmf/src/NetworkInterfaces.c +=================================================================== +--- olsrd-0.6.8.orig/lib/bmf/src/NetworkInterfaces.c ++++ olsrd-0.6.8/lib/bmf/src/NetworkInterfaces.c +@@ -50,6 +50,7 @@ + #include /* assert() */ + #include /* socket(), ifreq, if_indextoname(), if_nametoindex() */ + #include /* htons() */ ++#include /* struct udphdr */ + #include /* ETH_P_IP */ + #include /* packet_mreq, PACKET_MR_PROMISC, PACKET_ADD_MEMBERSHIP */ + #include /* IFF_TAP */ +@@ -1893,7 +1894,11 @@ void CheckAndUpdateLocalBroadcast(unsign + + /* RFC 1624, Eq. 3: HC' = ~(~HC - m + m') */ + ++#ifdef __UCLIBC__ + check = ntohs(udph->check); ++#else ++ check = ntohs(udph->uh_sum); ++#endif + + check = ~ (~ check - ((origDaddr >> 16) & 0xFFFF) + ((newDaddr >> 16) & 0xFFFF)); + check = ~ (~ check - (origDaddr & 0xFFFF) + (newDaddr & 0xFFFF)); +@@ -1901,7 +1906,11 @@ void CheckAndUpdateLocalBroadcast(unsign + /* Add carry */ + check = check + (check >> 16); + ++#ifdef __UCLIBC__ + udph->check = htons(check); ++#else ++ udph->uh_sum = htons(check); ++#endif + } /* if */ + } /* if */ + } /* CheckAndUpdateLocalBroadcast */ +Index: olsrd-0.6.8/lib/mdns/src/mdns.c +=================================================================== +--- olsrd-0.6.8.orig/lib/mdns/src/mdns.c ++++ olsrd-0.6.8/lib/mdns/src/mdns.c +@@ -462,7 +462,11 @@ BmfPacketCaptured( + return; /* for */ + } + udpHeader = (struct udphdr *)ARM_NOWARN_ALIGN(encapsulationUdpData + GetIpHeaderLength(encapsulationUdpData)); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + if (destPort != 5353) { + return; + } +@@ -498,7 +502,11 @@ BmfPacketCaptured( + return; /* for */ + } + udpHeader = (struct udphdr *)ARM_NOWARN_ALIGN(encapsulationUdpData + 40); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + if (destPort != 5353) { + return; + } +Index: olsrd-0.6.8/lib/p2pd/src/p2pd.c +=================================================================== +--- olsrd-0.6.8.orig/lib/p2pd/src/p2pd.c ++++ olsrd-0.6.8/lib/p2pd/src/p2pd.c +@@ -204,7 +204,11 @@ PacketReceivedFromOLSR(unsigned char *en + udpHeader = (struct udphdr*) ARM_NOWARN_ALIGN((encapsulationUdpData + + GetIpHeaderLength(encapsulationUdpData))); + destAddr.v4.s_addr = ipHeader->ip_dst.s_addr; ++#ifdef __UCLIBC__ + destPort = htons(udpHeader->dest); ++#else ++ destPort = htons(udpHeader->uh_dport); ++#endif + isInList = InUdpDestPortList(AF_INET, &destAddr, destPort); + #ifdef INCLUDE_DEBUG_OUTPUT + if (!isInList) { +@@ -223,7 +227,11 @@ PacketReceivedFromOLSR(unsigned char *en + if (ip6Header->ip6_nxt == SOL_UDP && !IsIpv6Fragment(ip6Header)) { + udpHeader = (struct udphdr*) ARM_NOWARN_ALIGN((encapsulationUdpData + 40)); + memcpy(&destAddr.v6, &ip6Header->ip6_dst, sizeof(struct in6_addr)); ++#ifdef __UCLIBC__ + destPort = htons(udpHeader->dest); ++#else ++ destPort = htons(udpHeader->uh_dport); ++#endif + isInList = InUdpDestPortList(AF_INET6, &destAddr, destPort); + #ifdef INCLUDE_DEBUG_OUTPUT + if (!isInList) { +@@ -695,7 +703,11 @@ P2pdPacketCaptured(unsigned char *encaps + + udpHeader = (struct udphdr *) ARM_NOWARN_ALIGN((encapsulationUdpData + + GetIpHeaderLength(encapsulationUdpData))); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + + if (!InUdpDestPortList(AF_INET, &dst, destPort)) { + #ifdef INCLUDE_DEBUG_OUTPUT +@@ -739,7 +751,11 @@ P2pdPacketCaptured(unsigned char *encaps + return; + + udpHeader = (struct udphdr *) ARM_NOWARN_ALIGN((encapsulationUdpData + 40)); ++#ifdef __UCLIBC__ + destPort = ntohs(udpHeader->dest); ++#else ++ destPort = ntohs(udpHeader->uh_dport); ++#endif + + if (!InUdpDestPortList(AF_INET6, &dst, destPort)) { + #ifdef INCLUDE_DEBUG_OUTPUT