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_MAX_NAME_LEN (64U) /* we're in embedded context. */
61 #define SOCK_DNS_QUERYBUF_LEN (sizeof(sock_dns_hdr_t) + 4 + SOCK_DNS_MAX_NAME_LEN)
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 
uint16_t nscount
detailed
Definition: dns.h:44
uint16_t ancount
for
Definition: dns.h:43
DNS internal structure.
Definition: dns.h:39
UDP sock definitions.
sock_udp_ep_t sock_dns_server
global DNS server endpoint
Common IP-based transport layer end point.
Definition: sock.h:195
uint16_t id
read
Definition: dns.h:40
uint16_t flags
DNS.
Definition: dns.h:41
uint16_t qdcount
RFC.
Definition: dns.h:42
int sock_dns_query(const char *domain_name, void *addr_out, int family)
Get IP address for DNS name.
uint16_t arcount
explanations
Definition: dns.h:45