1 /* 2 * Copyright (C) 2023 Joan Lled� <jlledom@member.fsf.org> 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * this list of conditions and the following disclaimer in the documentation 11 * and/or other materials provided with the distribution. 12 * 3. The name of the author may not be used to endorse or promote products 13 * derived from this software without specific prior written permission. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 18 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 23 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 24 * OF SUCH DAMAGE. 25 */ 26 27 #ifndef HURD_LWIP_POSIX_INET_H 28 #define HURD_LWIP_POSIX_INET_H 29 30 #include <arpa/inet.h> 31 #include <netinet/in.h> 32 #include <netinet/tcp.h> 33 #include <netinet/udp.h> 34 #include <sys/ioctl.h> 35 #include <fcntl.h> 36 #include <net/if.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 #if LWIP_IPV4 43 44 #define inet_addr_from_ip4addr(target_inaddr, source_ipaddr) ((target_inaddr)->s_addr = ip4_addr_get_u32(source_ipaddr)) 45 #define inet_addr_to_ip4addr(target_ipaddr, source_inaddr) (ip4_addr_set_u32(target_ipaddr, (source_inaddr)->s_addr)) 46 47 #ifdef LWIP_UNIX_HURD 48 #define IP_PKTINFO 8 49 50 struct in_pktinfo { 51 unsigned int ipi_ifindex; /* Interface index */ 52 struct in_addr ipi_addr; /* Destination (from header) address */ 53 }; 54 #endif /* LWIP_UNIX_HURD */ 55 56 #endif /* LWIP_IPV4 */ 57 58 #if LWIP_IPV6 59 #define inet6_addr_from_ip6addr(target_in6addr, source_ip6addr) {(target_in6addr)->s6_addr32[0] = (source_ip6addr)->addr[0]; \ 60 (target_in6addr)->s6_addr32[1] = (source_ip6addr)->addr[1]; \ 61 (target_in6addr)->s6_addr32[2] = (source_ip6addr)->addr[2]; \ 62 (target_in6addr)->s6_addr32[3] = (source_ip6addr)->addr[3];} 63 #define inet6_addr_to_ip6addr(target_ip6addr, source_in6addr) {(target_ip6addr)->addr[0] = (source_in6addr)->s6_addr32[0]; \ 64 (target_ip6addr)->addr[1] = (source_in6addr)->s6_addr32[1]; \ 65 (target_ip6addr)->addr[2] = (source_in6addr)->s6_addr32[2]; \ 66 (target_ip6addr)->addr[3] = (source_in6addr)->s6_addr32[3]; \ 67 ip6_addr_clear_zone(target_ip6addr);} 68 /* ATTENTION: the next define only works because both in6_addr and ip6_addr_t are an u32_t[4] effectively! */ 69 #define inet6_addr_to_ip6addr_p(target_ip6addr_p, source_in6addr) ((target_ip6addr_p) = (ip6_addr_t*)(source_in6addr)) 70 #endif /* LWIP_IPV6 */ 71 72 #ifdef __cplusplus 73 } 74 #endif 75 76 #endif /* HURD_LWIP_POSIX_INET_H */ 77