case STATE_PROBE1:
case STATE_PROBE2:
case STATE_PROBE3:
- dns_send_question(iface, mdns_hostname_local, TYPE_ANY);
+ dns_send_question(iface, mdns_hostname_local, TYPE_ANY, 0);
uloop_timeout_set(timeout, 250);
iface->announce_state++;
break;
vlist_for_each_element(&interfaces, iface, node)
avl_for_each_element(&entries, s, avl)
- dns_send_question(iface, s->entry, TYPE_PTR);
+ dns_send_question(iface, s->entry, TYPE_PTR, 1);
}
static struct cache_entry*
avl_insert(&entries, &s->avl);
if (!hlen)
- dns_send_question(iface, entry, TYPE_PTR);
+ dns_send_question(iface, entry, TYPE_PTR, !iface->multicast);
return s;
}
}
void
-dns_send_question(struct interface *iface, const char *question, int type)
+dns_send_question(struct interface *iface, const char *question, int type, int unicast)
{
static struct dns_header h;
static struct dns_question q;
int len;
h.questions = cpu_to_be16(1);
- q.class = cpu_to_be16(1);
+ q.class = cpu_to_be16(((unicast) ? (CLASS_UNICAST) : (0)) | 1);
q.type = cpu_to_be16(type);
len = dn_comp(question, (void *) name_buffer, sizeof(name_buffer), NULL, NULL);
iov[1].iov_len = len;
+ if (unicast == iface->multicast)
+ iface = iface->peer;
+
if (interface_send_packet(iface, iov, ARRAY_SIZE(iov)) < 0)
fprintf(stderr, "failed to send question\n");
else
{
char *host;
+ if ((q->class & CLASS_UNICAST) && iface->multicast)
+ iface = iface->peer;
+
DBG(1, "Q -> %s %s\n", dns_type_string(q->type), name);
switch (q->type) {
#define MCAST_ADDR6 "ff02::fb"
#define MCAST_PORT 5353
-#define CLASS_FLUSH 0x8000
+#define CLASS_UNICAST 0x8000
#define CLASS_IN 0x0001
#define MAX_NAME_LEN 8096
struct interface;
extern int cfg_proto;
-void dns_send_question(struct interface *iface, const char *question, int type);
+void dns_send_question(struct interface *iface, const char *question, int type, int unicast);
void dns_init_answer(void);
void dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
void dns_send_answer(struct interface *iface, const char *answer);
}
uloop_fd_add(&iface->fd, ULOOP_READ);
- dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR);
- announce_init(iface);
+ dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 1);
+ if (iface->multicast)
+ announce_init(iface);
return;
}
uloop_fd_add(&iface->fd, ULOOP_READ);
- dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR);
+ dns_send_question(iface, "_services._dns-sd._udp.local", TYPE_PTR, 1);
announce_init(iface);
return;
memcpy(&unicast->v4_addr, &sa->sin_addr, sizeof(unicast->v4_addr));
inet_ntop(AF_INET, &sa->sin_addr, unicast->v4_addrs, sizeof(unicast->v4_addrs));
+
+ v4->peer = unicast;
+ unicast->peer = v4;
}
if (ifa->ifa_addr->sa_family == AF_INET6 && !v6) {
memcpy(&unicast->v6_addr, &sa6->sin6_addr, sizeof(unicast->v6_addr));
inet_ntop(AF_INET6, &sa6->sin6_addr, unicast->v6_addrs, sizeof(unicast->v6_addrs));
+
+ v6->peer = unicast;
+ unicast->peer = v6;
}
}
struct interface {
struct vlist_node node;
+ struct interface *peer;
const char *name;
char *id;