6210e0e52868d83892202714b1be2917762b3326
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.
18 #include <arpa/inet.h>
20 #define FLAG_RESPONSE 0x8000
21 #define FLAG_AUTHORATIVE 0x0400
24 #define TYPE_PTR 0x000C
25 #define TYPE_TXT 0x0010
26 #define TYPE_AAAA 0x001c
27 #define TYPE_SRV 0x0021
28 #define TYPE_ANY 0x00ff
30 #define IS_COMPRESSED(x) ((x & 0xc0) == 0xc0)
32 #define MCAST_ADDR "224.0.0.251"
33 #define MCAST_ADDR6 "ff02::fb"
34 #define MCAST_PORT 5353
36 #define CLASS_FLUSH 0x8000
37 #define CLASS_UNICAST 0x8000
38 #define CLASS_IN 0x0001
40 #define MAX_NAME_LEN 8096
41 #define MAX_DATA_LEN 8096
43 #define C_DNS_SD "_services._dns-sd._udp.local"
58 } __attribute__((packed
));
65 } __attribute__((packed
));
70 } __attribute__((packed
));
74 extern int cfg_no_subnet
;
76 void dns_send_question(struct interface
*iface
, const char *question
, int type
, int multicast
);
77 void dns_init_answer(void);
78 void dns_add_answer(int type
, const uint8_t *rdata
, uint16_t rdlength
, int ttl
);
79 void dns_send_answer(struct interface
*iface
, const char *answer
);
80 const char* dns_type_string(uint16_t type
);
81 void dns_handle_packet(struct interface
*iface
, struct sockaddr
*s
, uint16_t port
, uint8_t *buf
, int len
);