}
void
-cache_dump_records(struct blob_buf *buf, const char *name, int array)
+cache_dump_records(struct blob_buf *buf, const char *name, int array,
+ const char **hostname)
{
struct cache_record *r, *last, *next;
const char *txt;
break;
case TYPE_SRV:
- if (r->rdata)
+ if (r->rdata) {
blobmsg_add_string(buf, "host", (char *)r->rdata + sizeof(struct dns_srv_data));
+ if (hostname)
+ *hostname = (char *)r->rdata + sizeof(struct dns_srv_data);
+ }
if (r->port)
blobmsg_add_u32(buf, "port", r->port);
break;
int blen, char *name, struct dns_answer *a, uint8_t *rdata,
int flush);
int cache_host_is_known(char *record);
-void cache_dump_records(struct blob_buf *buf, const char *name, int array);
+void cache_dump_records(struct blob_buf *buf, const char *name, int array,
+ const char **hostname);
void cache_dump_recursive(struct blob_buf *b, const char *name, uint16_t type, struct interface *iface);
#endif
blob_buf_init(&b, 0);
avl_for_each_element(&services, s, avl) {
+ const char *hostname = buffer;
char *local;
snprintf(buffer, MAX_NAME_LEN, "%s", (const char *) s->avl.key);
c2 = blobmsg_open_table(&b, buffer);
strncat(buffer, ".local", MAX_NAME_LEN);
blobmsg_add_string(&b, "iface", s->iface->name);
+ cache_dump_records(&b, s->entry, array, &hostname);
if (address)
- cache_dump_records(&b, buffer, array);
- cache_dump_records(&b, s->entry, array);
+ cache_dump_records(&b, hostname, array, NULL);
blobmsg_close_table(&b, c2);
q = avl_next_element(s, avl);
if (!q || avl_is_last(&services, &s->avl) || strcmp(s->avl.key, q->avl.key)) {
/* Query each domain just once */
if (!prev || strcmp(r->record, prev->record)) {
c = blobmsg_open_table(&b, r->record);
- cache_dump_records(&b, r->record, false);
+ cache_dump_records(&b, r->record, false, NULL);
blobmsg_close_table(&b, c);
}
prev = r;