gint flx_open_socket_ipv4(void) {
struct ip_mreqn mreq;
struct sockaddr_in sa, local;
- int fd = -1, ttl, yes, no;
+ int fd = -1, ttl, yes;
mdns_mcast_group_ipv4(&sa);
goto fail;
}
- no = 0;
- if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &no, sizeof(no)) < 0) {
+ yes = 1;
+ if (setsockopt(fd, SOL_IP, IP_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
g_warning("IP_MULTICAST_LOOP failed: %s\n", strerror(errno));
goto fail;
}
gint flx_open_socket_ipv6(void) {
struct ipv6_mreq mreq;
struct sockaddr_in6 sa, local;
- int fd = -1, ttl, yes, no;
+ int fd = -1, ttl, yes;
mdns_mcast_group_ipv6(&sa);
goto fail;
}
- no = 0;
- if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &no, sizeof(no)) < 0) {
+ yes = 1;
+ if (setsockopt(fd, SOL_IPV6, IPV6_MULTICAST_LOOP, &yes, sizeof(yes)) < 0) {
g_warning("IPV6_MULTICAST_LOOP failed: %s\n", strerror(errno));
goto fail;
}
mdns_mcast_group_ipv4(&sa);
memset(&io, 0, sizeof(io));
- io.iov_base = p->data;
+ io.iov_base = FLX_DNS_PACKET_DATA(p);
io.iov_len = p->size;
memset(cmsg_data, 0, sizeof(cmsg_data));
mdns_mcast_group_ipv6(&sa);
memset(&io, 0, sizeof(io));
- io.iov_base = p->data;
+ io.iov_base = FLX_DNS_PACKET_DATA(p);
io.iov_len = p->size;
memset(cmsg_data, 0, sizeof(cmsg_data));
g_assert(ret_iface);
g_assert(ret_ttl);
- p = flx_dns_packet_new();
+ p = flx_dns_packet_new(0);
- io.iov_base = p->data;
- io.iov_len = sizeof(p->data);
+ io.iov_base = FLX_DNS_PACKET_DATA(p);
+ io.iov_len = p->max_size;
memset(&msg, 0, sizeof(msg));
msg.msg_name = ret_sa;
}
flxDnsPacket* flx_recv_dns_packet_ipv6(gint fd, struct sockaddr_in6 *ret_sa, gint *ret_iface, guint8* ret_ttl) {
- flxDnsPacket *p= NULL;
+ flxDnsPacket *p = NULL;
struct msghdr msg;
struct iovec io;
uint8_t aux[64];
g_assert(ret_iface);
g_assert(ret_ttl);
- p = flx_dns_packet_new();
+ p = flx_dns_packet_new(0);
- io.iov_base = p->data;
- io.iov_len = sizeof(p->data);
+ io.iov_base = FLX_DNS_PACKET_DATA(p);
+ io.iov_len = p->max_size;
memset(&msg, 0, sizeof(msg));
msg.msg_name = ret_sa;
*ret_ttl = 0;
- g_message("pre");
-
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL; cmsg = CMSG_NXTHDR(&msg, cmsg)) {
if (cmsg->cmsg_level == SOL_IPV6 && cmsg->cmsg_type == IPV6_HOPLIMIT) {
*ret_ttl = *(uint8_t *) CMSG_DATA(cmsg);
*ret_iface = ((struct in6_pktinfo*) CMSG_DATA(cmsg))->ipi6_ifindex;
found_iface = TRUE;
}
-
- g_message("-- %u -- %u\n", cmsg->cmsg_level, cmsg->cmsg_type);
}
- g_message("post");
-
-
g_assert(found_iface);
g_assert(found_ttl);