}
void
-dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength)
+dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength, int ttl)
{
struct blob_attr *attr;
struct dns_answer *a;
a = blob_data(attr);
a->type = cpu_to_be16(type);
a->class = cpu_to_be16(1);
- a->ttl = cpu_to_be32(announce_ttl);
+ a->ttl = cpu_to_be32(ttl);
a->rdlength = cpu_to_be16(rdlength);
memcpy(a + 1, rdata, rdlength);
void dns_send_question(struct interface *iface, const char *question, int type);
void dns_init_answer(void);
-void dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength);
+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);
const char* dns_type_string(uint16_t type);
void dns_handle_packet(struct interface *iface, uint8_t *buf, int len);
#include "service.h"
#include "util.h"
#include "interface.h"
+#include "announce.h"
enum {
SERVICE_PORT,
if (len < 1)
return;
- dns_add_answer(TYPE_PTR, mdns_buf, len);
+ dns_add_answer(TYPE_PTR, mdns_buf, len, announce_ttl);
}
static void
return;
sd->port = cpu_to_be16(s->port);
- dns_add_answer(TYPE_SRV, mdns_buf, len);
+ dns_add_answer(TYPE_SRV, mdns_buf, len, announce_ttl);
}
#define TOUT_LOOKUP 60
sa = (struct sockaddr_in *) ifa->ifa_addr;
addr = inet_ntoa(sa->sin_addr);
printf("Interface: %s\tAddress4: %s\n", ifa->ifa_name, addr);
- dns_add_answer(TYPE_A, (uint8_t *) &sa->sin_addr, 4);
+ dns_add_answer(TYPE_A, (uint8_t *) &sa->sin_addr, 4, announce_ttl);
}
if (ifa->ifa_addr->sa_family==AF_INET6) {
uint8_t ll_prefix[] = {0xfe, 0x80 };
if (!memcmp(&sa6->sin6_addr, &ll_prefix, 2)) {
if (inet_ntop(AF_INET6, &sa6->sin6_addr, buf, 64))
printf("Interface: %s\tAddress6: %s\n", ifa->ifa_name, buf);
- dns_add_answer(TYPE_AAAA, (uint8_t *) &sa6->sin6_addr, 16);
+ dns_add_answer(TYPE_AAAA, (uint8_t *) &sa6->sin6_addr, 16, announce_ttl);
}
}
}
dns_init_answer();
service_add_srv(s);
if (s->txt && s->txt_len)
- dns_add_answer(TYPE_TXT, (uint8_t *) s->txt, s->txt_len);
+ dns_add_answer(TYPE_TXT, (uint8_t *) s->txt, s->txt_len, announce_ttl);
dns_send_answer(iface, host);
}