• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/mdnsd/dns.h

  1 /*
  2  * Copyright (C) 2014 John Crispin <blogic@openwrt.org>
  3  *
  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
  7  *
  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.
 12  */
 13 
 14 #ifndef _DNS_H__
 15 #define _DNS_H__
 16 
 17 #include <stdint.h>
 18 #include <arpa/inet.h>
 19 
 20 #define FLAG_RESPONSE           0x8000
 21 #define FLAG_AUTHORATIVE        0x0400
 22 
 23 #define TYPE_A                  0x0001
 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
 29 
 30 #define IS_COMPRESSED(x)        ((x & 0xc0) == 0xc0)
 31 
 32 #define MCAST_ADDR              "224.0.0.251"
 33 #define MCAST_ADDR6             "ff02::fb"
 34 #define MCAST_PORT              5353
 35 
 36 #define CLASS_FLUSH             0x8000
 37 #define CLASS_UNICAST           0x8000
 38 #define CLASS_IN                0x0001
 39 
 40 #define MAX_NAME_LEN            8096
 41 #define MAX_DATA_LEN            8096
 42 
 43 /* 4.3.2.1.in-addr.arpa */
 44 #define MIN_PTR_NAME_LEN        20
 45 /* 123.123.123.123.in-addr.arpa */
 46 #define MAX_PTR_NAME_LEN        28
 47 /* .e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.f.e.d.c.b.a.9.8.7.6.5.4.3.2.1.0.ip6.arpa */
 48 #define MAX_PTR6_NAME_LEN       72
 49 
 50 #define C_DNS_SD                "_services._dns-sd._udp.local"
 51 
 52 struct dns_header {
 53         uint16_t id;
 54         uint16_t flags;
 55         uint16_t questions;
 56         uint16_t answers;
 57         uint16_t authority;
 58         uint16_t additional;
 59 } __attribute__((packed));
 60 
 61 struct dns_srv_data {
 62         uint16_t priority;
 63         uint16_t weight;
 64         uint16_t port;
 65 } __attribute__((packed));
 66 
 67 struct dns_answer {
 68         uint16_t type;
 69         uint16_t class;
 70         uint32_t ttl;
 71         uint16_t rdlength;
 72 } __attribute__((packed));
 73 
 74 struct dns_question {
 75         uint16_t type;
 76         uint16_t class;
 77 } __attribute__((packed));
 78 
 79 struct interface;
 80 extern int cfg_proto;
 81 extern int cfg_no_subnet;
 82 
 83 void dns_packet_init(void);
 84 bool dns_packet_question(const char *name, int type);
 85 void dns_packet_answer(const char *name, int type, const uint8_t *rdata, uint16_t rdlength, int ttl);
 86 void dns_packet_send(struct interface *iface, struct sockaddr *to, bool query, int multicast);
 87 
 88 void dns_query(const char *name, uint16_t type);
 89 
 90 void dns_send_question(struct interface *iface, struct sockaddr *to,
 91                        const char *question, int type, int multicast);
 92 void dns_reply_a(struct interface *iface, struct sockaddr *to, int ttl, const char *hostname);
 93 void dns_reply_a_additional(struct interface *iface, struct sockaddr *to, int ttl);
 94 const char* dns_type_string(uint16_t type);
 95 void dns_handle_packet(struct interface *iface, struct sockaddr *s, uint16_t port, uint8_t *buf, int len);
 96 
 97 #endif
 98 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt