}
void
-cache_dump_records(struct blob_buf *buf, const char *name)
+cache_dump_records(struct blob_buf *buf, const char *name, int txt_array)
{
struct cache_record *r, *last, *next;
const char *txt;
switch (r->type) {
case TYPE_TXT:
if (r->txt && strlen(r->txt)) {
+ void *c = NULL;
+
+ if (txt_array)
+ c = blobmsg_open_array(buf, "txt");
+
txt = r->txt;
do {
blobmsg_add_string(buf, "txt", txt);
txt = &txt[strlen(txt) + 1];
} while (*txt);
+ if (c)
+ blobmsg_close_array(buf, c);
}
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);
+void cache_dump_records(struct blob_buf *buf, const char *name, int txt_array);
void cache_dump_recursive(struct blob_buf *b, const char *name, uint16_t type, struct interface *iface);
#endif
enum {
BROWSE_SERVICE,
+ BROWSE_TXT_ARRAY,
BROWSE_MAX
};
static const struct blobmsg_policy browse_policy[] = {
[BROWSE_SERVICE] = { "service", BLOBMSG_TYPE_STRING },
+ [BROWSE_TXT_ARRAY] = { "txt_array", BLOBMSG_TYPE_BOOL },
};
static int
struct blob_attr *data[BROWSE_MAX];
void *c1 = NULL, *c2;
char *service = NULL;
+ int txt_array = 0;
blobmsg_parse(browse_policy, BROWSE_MAX, data, blob_data(msg), blob_len(msg));
if (data[BROWSE_SERVICE])
service = blobmsg_get_string(data[BROWSE_SERVICE]);
+ if (data[BROWSE_TXT_ARRAY])
+ txt_array = blobmsg_get_u8(data[BROWSE_TXT_ARRAY]);
blob_buf_init(&b, 0);
avl_for_each_element(&services, s, avl) {
*local = '\0';
c2 = blobmsg_open_table(&b, buffer);
strncat(buffer, ".local", MAX_NAME_LEN);
- cache_dump_records(&b, buffer);
- cache_dump_records(&b, s->entry);
+ cache_dump_records(&b, buffer, txt_array);
+ cache_dump_records(&b, s->entry, txt_array);
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);
+ cache_dump_records(&b, r->record, false);
blobmsg_close_table(&b, c);
}
prev = r;