]> git.meshlink.io Git - catta/blobdiff - src/socket.c
set the include flag for windows compat headers in configure
[catta] / src / socket.c
index a6dd588c7052416f06d391b910c6c454f48a2b66..1914316716861442ae149dcac1e6a2866ced1632 100644 (file)
@@ -364,7 +364,7 @@ int catta_open_socket_ipv4(int no_reuse) {
 
 fail:
     if (fd >= 0)
-        close(fd);
+        closesocket(fd);
 
     return -1;
 }
@@ -434,7 +434,7 @@ int catta_open_socket_ipv6(int no_reuse) {
 
 fail:
     if (fd >= 0)
-        close(fd);
+        closesocket(fd);
 
     return -1;
 }
@@ -469,7 +469,7 @@ static int sendmsg_loop(int fd, struct msghdr *msg, int flags) {
 
 int catta_send_dns_packet_ipv4(
         int fd,
-        CattaIfIndex interface,
+        CattaIfIndex iface,
         CattaDnsPacket *p,
         const CattaIPv4Address *src_address,
         const CattaIPv4Address *dst_address,
@@ -510,7 +510,7 @@ int catta_send_dns_packet_ipv4(
     msg.msg_controllen = 0;
 
 #ifdef IP_PKTINFO
-    if (interface > 0 || src_address) {
+    if (iface > 0 || src_address) {
         struct in_pktinfo *pkti;
 
         memset(cmsg_data, 0, sizeof(cmsg_data));
@@ -524,11 +524,13 @@ int catta_send_dns_packet_ipv4(
 
         pkti = (struct in_pktinfo*) CMSG_DATA(cmsg);
 
-        if (interface > 0)
-            pkti->ipi_ifindex = interface;
+        if (iface > 0)
+            pkti->ipi_ifindex = iface;
 
+#ifdef HAVE_IPI_SPEC_DST
         if (src_address)
             pkti->ipi_spec_dst.s_addr = src_address->address;
+#endif
     }
 #elif defined(IP_MULTICAST_IF)
     if (src_address) {
@@ -563,7 +565,7 @@ int catta_send_dns_packet_ipv4(
 
 int catta_send_dns_packet_ipv6(
         int fd,
-        CattaIfIndex interface,
+        CattaIfIndex iface,
         CattaDnsPacket *p,
         const CattaIPv6Address *src_address,
         const CattaIPv6Address *dst_address,
@@ -596,7 +598,7 @@ int catta_send_dns_packet_ipv6(
     msg.msg_iovlen = 1;
     msg.msg_flags = 0;
 
-    if (interface > 0 || src_address) {
+    if (iface > 0 || src_address) {
         struct in6_pktinfo *pkti;
 
         memset(cmsg_data, 0, sizeof(cmsg_data));
@@ -610,8 +612,8 @@ int catta_send_dns_packet_ipv6(
 
         pkti = (struct in6_pktinfo*) CMSG_DATA(cmsg);
 
-        if (interface > 0)
-            pkti->ipi6_ifindex = interface;
+        if (iface > 0)
+            pkti->ipi6_ifindex = iface;
 
         if (src_address)
             memcpy(&pkti->ipi6_addr, src_address->address, sizeof(src_address->address));
@@ -942,7 +944,7 @@ int catta_open_unicast_socket_ipv4(void) {
 
 fail:
     if (fd >= 0)
-        close(fd);
+        closesocket(fd);
 
     return -1;
 }
@@ -987,7 +989,7 @@ int catta_open_unicast_socket_ipv6(void) {
 
 fail:
     if (fd >= 0)
-        close(fd);
+        closesocket(fd);
 
     return -1;
 }