X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmdnsd.git;a=blobdiff_plain;f=dns.h;h=7f3cbe176e6b6d492fa7e7b4303b8c0d9a131c94;hp=b29e297f37996566f9f7333fe1db581b04ffed5c;hb=c0c78c92d57c53276bb7f08468bcc716ba272497;hpb=788316ef66136e6a68d881e5b24ccf5a98fa4550 diff --git a/dns.h b/dns.h index b29e297..7f3cbe1 100644 --- a/dns.h +++ b/dns.h @@ -14,6 +14,9 @@ #ifndef _DNS_H__ #define _DNS_H__ +#include +#include + #define FLAG_RESPONSE 0x8000 #define FLAG_AUTHORATIVE 0x0400 @@ -27,9 +30,11 @@ #define IS_COMPRESSED(x) ((x & 0xc0) == 0xc0) #define MCAST_ADDR "224.0.0.251" +#define MCAST_ADDR6 "ff02::fb" #define MCAST_PORT 5353 #define CLASS_FLUSH 0x8000 +#define CLASS_UNICAST 0x8000 #define CLASS_IN 0x0001 #define MAX_NAME_LEN 8096 @@ -50,32 +55,30 @@ struct dns_srv_data { uint16_t priority; uint16_t weight; uint16_t port; -} __attribute__((packed, aligned(2))); +} __attribute__((packed)); struct dns_answer { uint16_t type; uint16_t class; uint32_t ttl; uint16_t rdlength; -} __attribute__((packed, aligned(2))); +} __attribute__((packed)); struct dns_question { uint16_t type; uint16_t class; -} __attribute__((packed, aligned(2))); - -extern char *rdata_buffer; - -extern int dns_init(void); -extern void dns_cleanup(void); -extern void dns_send_question(struct uloop_fd *u, char *question, int type); -extern void dns_init_answer(void); -extern void dns_add_answer(int type, uint8_t *rdata, uint16_t rdlength); -extern void dns_send_answer(struct uloop_fd *u, char *answer); -extern char* dns_consume_name(uint8_t *base, int blen, uint8_t **data, int *len); -extern struct dns_answer* dns_consume_answer(uint8_t **data, int *len); -extern struct dns_question* dns_consume_question(uint8_t **data, int *len); -extern struct dns_header* dns_consume_header(uint8_t **data, int *len); -extern const char* dns_type_string(uint16_t type); +} __attribute__((packed)); + +struct interface; +extern int cfg_proto; +extern int cfg_no_subnet; + +void dns_send_question(struct interface *iface, const char *question, int type, int multicast); +void dns_init_answer(void); +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); +void dns_reply_a(struct interface *iface, int ttl); +const char* dns_type_string(uint16_t type); +void dns_handle_packet(struct interface *iface, struct sockaddr *s, uint16_t port, uint8_t *buf, int len); #endif