[package] fix libtorrent build failure (#6981)
[openwrt/svn-archive/archive.git] / libs / libtorrent / patches / 120-fix-ipv6_socket_datagram.diff
1 --- a/src/net/socket_datagram.cc
2 +++ b/src/net/socket_datagram.cc
3 @@ -73,6 +73,23 @@ SocketDatagram::write_datagram(const voi
4 int r;
5
6 if (sa != NULL) {
7 +#ifdef RAK_USE_INET6
8 + if (m_ipv6_socket && sa->family() == rak::socket_address::pf_inet) {
9 + uint32_t addr32[4];
10 + sockaddr_in6 mapped_addr;
11 + memset(&mapped_addr, 0, sizeof(mapped_addr));
12 + mapped_addr.sin6_family = AF_INET6;
13 + addr32[0] = 0;
14 + addr32[1] = 0;
15 + addr32[2] = htonl(0xffff);
16 + addr32[3] = sa->sa_inet()->address_n();
17 + memcpy(mapped_addr.sin6_addr.s6_addr, addr32, sizeof(uint32_t) * 4);
18 + mapped_addr.sin6_port = sa->sa_inet()->port_n();
19 + r = ::sendto(m_fileDesc, buffer, length, 0, (sockaddr*)&mapped_addr, sizeof(mapped_addr));
20 + } else if (m_ipv6_socket && sa->family() == rak::socket_address::pf_inet6) {
21 + r = ::sendto(m_fileDesc, buffer, length, 0, sa->sa_inet6()->c_sockaddr(), sizeof(rak::socket_address_inet6));
22 + } else
23 +#endif
24 r = ::sendto(m_fileDesc, buffer, length, 0, sa->sa_inet()->c_sockaddr(), sizeof(rak::socket_address_inet));
25 } else {
26 r = ::send(m_fileDesc, buffer, length, 0);