X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fsocket.c;h=c6b670bc0c15401ac76acda1b20a693af0e4294d;hb=ba51d86d35c7686fe64e861e14177bec0a993e42;hp=dc989d8ac466f1647a5aa278b5ee980b667aae77;hpb=4ac8d5e93bf09c86e8352cdc2099b35ec89ba3a9;p=catta diff --git a/src/socket.c b/src/socket.c index dc989d8..c6b670b 100644 --- a/src/socket.c +++ b/src/socket.c @@ -105,7 +105,7 @@ static void ipv6_address_to_sockaddr(struct sockaddr_in6 *ret_sa, const CattaIPv memcpy(&ret_sa->sin6_addr, a, sizeof(CattaIPv6Address)); } -int catta_mdns_mcast_join_ipv4(int fd, const CattaIPv4Address *a, int idx, int join) { +int catta_mdns_mcast_join_ipv4(int fd, const CattaIPv4Address *a, CattaIfIndex idx, int join) { #ifdef HAVE_STRUCT_IP_MREQN struct ip_mreqn mreq; #else @@ -141,7 +141,7 @@ int catta_mdns_mcast_join_ipv4(int fd, const CattaIPv4Address *a, int idx, int j return 0; } -int catta_mdns_mcast_join_ipv6(int fd, const CattaIPv6Address *a, int idx, int join) { +int catta_mdns_mcast_join_ipv6(int fd, const CattaIPv6Address *a, CattaIfIndex idx, int join) { struct ipv6_mreq mreq6; struct sockaddr_in6 sa6; @@ -464,9 +464,12 @@ static int sendmsg_loop(int fd, struct msghdr *msg, int flags) { if (errno != EAGAIN && errno != EWOULDBLOCK) { char where[64]; - struct sockaddr_in *sin = msg->msg_name; + struct sockaddr *sa = msg->msg_name; - inet_ntop(sin->sin_family, &sin->sin_addr, where, sizeof(where)); + if(sa->sa_family == AF_INET) + inet_ntop(sa->sa_family, &((struct sockaddr_in *)sa)->sin_addr, where, sizeof(where)); + else + inet_ntop(sa->sa_family, &((struct sockaddr_in6 *)sa)->sin6_addr, where, sizeof(where)); catta_log_debug("sendmsg() to %s failed: %s", where, errnostrsocket()); return -1; } @@ -541,6 +544,9 @@ int catta_send_dns_packet_ipv4( #ifdef HAVE_IPI_SPEC_DST if (src_address) pkti->ipi_spec_dst.s_addr = src_address->address; +#else + if (src_address) + pkti->ipi_addr.s_addr = src_address->address; #endif } #elif defined(IP_MULTICAST_IF)