dns.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Kaspar Schleiser <kaspar@schleiser.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef NET_SOCK_DNS_H
24 #define NET_SOCK_DNS_H
25 
26 #include <errno.h>
27 #include <stdint.h>
28 #include <unistd.h>
29 
30 #include "net/sock/udp.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 typedef struct {
40  uint16_t id;
41  uint16_t flags;
42  uint16_t qdcount;
43  uint16_t ancount;
44  uint16_t nscount;
45  uint16_t arcount;
46  uint8_t payload[];
48 
53 #define DNS_TYPE_A (1)
54 #define DNS_TYPE_AAAA (28)
55 #define DNS_CLASS_IN (1)
56 
57 #define SOCK_DNS_PORT (53)
58 #define SOCK_DNS_RETRIES (2)
59 
60 #define SOCK_DNS_BUF_LEN (128) /* we're in embedded context. */
61 #define SOCK_DNS_MAX_NAME_LEN (SOCK_DNS_BUF_LEN - sizeof(sock_dns_hdr_t) - 4)
62 
86 int sock_dns_query(const char *domain_name, void *addr_out, int family);
87 
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* NET_SOCK_DNS_H */
98 
sock_dns_hdr_t::ancount
uint16_t ancount
for
Definition: dns.h:43
sock_dns_hdr_t::arcount
uint16_t arcount
explanations
Definition: dns.h:45
udp.h
UDP sock definitions.
sock_dns_hdr_t::flags
uint16_t flags
DNS
Definition: dns.h:41
sock_dns_server
sock_udp_ep_t sock_dns_server
global DNS server endpoint
_sock_tl_ep
Common IP-based transport layer end point.
Definition: sock.h:213
sock_dns_hdr_t::qdcount
uint16_t qdcount
RFC
Definition: dns.h:42
sock_dns_hdr_t::id
uint16_t id
read
Definition: dns.h:40
sock_dns_hdr_t
DNS internal structure.
Definition: dns.h:39
sock_dns_query
int sock_dns_query(const char *domain_name, void *addr_out, int family)
Get IP address for DNS name.
sock_dns_hdr_t::nscount
uint16_t nscount
detailed
Definition: dns.h:44
errno.h