- if (len < 1)
- return;
-
- dns_add_answer(TYPE_PTR, buffer, len);
-}
-
-static void
-service_send_a(struct uloop_fd *u)
-{
- unsigned char buffer[MAX_NAME_LEN];
- char *host = service_name("local");
- int len = dn_comp(host, buffer, MAX_NAME_LEN, NULL, NULL);
- struct in_addr in;
-
- if (!inet_aton(iface_ip, &in)) {
- fprintf(stderr, "%s is not valid\n", iface_ip);
- return;
- }
-
- if (len < 1)
- return;
-
- dns_add_answer(TYPE_A, (uint8_t *) &in.s_addr, 4);
-}
-
-static void
-service_send_srv(struct uloop_fd *u, struct service *s)
-{
- unsigned char buffer[MAX_NAME_LEN];
- struct dns_srv_data *sd;
- char *host = service_name("local");
- int len = dn_comp(host, buffer, MAX_NAME_LEN, NULL, NULL);
-
- if (len < 1)
- return;
-
- sd = calloc(1, len + sizeof(struct dns_srv_data));
- if (!sd)
+ len += dn_comp(mdns_hostname_local, mdns_buf + len, sizeof(mdns_buf) - len, NULL, NULL);
+ if (len <= sizeof(*sd))