2 * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #define FLAG_RESPONSE 0x8000
18 #define FLAG_AUTHORATIVE 0x0400
21 #define TYPE_PTR 0x000C
22 #define TYPE_TXT 0x0010
23 #define TYPE_AAAA 0x001c
24 #define TYPE_SRV 0x0021
25 #define TYPE_ANY 0x00ff
27 #define IS_COMPRESSED(x) ((x & 0xc0) == 0xc0)
29 #define MCAST_ADDR "224.0.0.251"
30 #define MCAST_PORT 5353
32 #define CLASS_FLUSH 0x8000
33 #define CLASS_IN 0x0001
35 #define MAX_NAME_LEN 8096
36 #define MAX_DATA_LEN 8096
38 #define C_DNS_SD "_services._dns-sd._udp.local"
53 } __attribute__((packed, aligned(2)));
60 } __attribute__((packed, aligned(2)));
65 } __attribute__((packed, aligned(2)));
67 extern char rdata_buffer[MAX_DATA_LEN + 1];
69 extern void dns_send_question(struct uloop_fd *u, const char *question, int type);
70 extern void dns_init_answer(void);
71 extern void dns_add_answer(int type, const uint8_t *rdata, uint16_t rdlength);
72 extern void dns_send_answer(struct uloop_fd *u, const char *answer);
73 extern char* dns_consume_name(const uint8_t *base, int blen, uint8_t **data, int *len);
74 extern struct dns_answer* dns_consume_answer(uint8_t **data, int *len);
75 extern struct dns_question* dns_consume_question(uint8_t **data, int *len);
76 extern struct dns_header* dns_consume_header(uint8_t **data, int *len);
77 extern const char* dns_type_string(uint16_t type);