Loading...
Searching...
No Matches
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
24#ifndef NET_SOCK_DNS_H
25#define NET_SOCK_DNS_H
26
27#include <errno.h>
28#include <stdint.h>
29#include <unistd.h>
30
31#include "net/dns/msg.h"
32
33#include "net/sock/udp.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39#ifdef MODULE_AUTO_INIT_SOCK_DNS
43#ifndef CONFIG_AUTO_INIT_SOCK_DNS_IP_VERSION
44 /* IPv6 is preferred */
45 #if defined(SOCK_HAS_IPV6)
46 #define CONFIG_AUTO_INIT_SOCK_DNS_IP_VERSION 6
47 #elif defined(SOCK_HAS_IPV4)
48 #define CONFIG_AUTO_INIT_SOCK_DNS_IP_VERSION 4
49 #else
50 #error "Neither IPv4 nor IPv6 included in build"
51 #endif
52#endif
53
57#ifndef CONFIG_AUTO_INIT_SOCK_DNS_SERVER_ADDR
58 /* Default to Google Public DNS */
59 #if CONFIG_AUTO_INIT_SOCK_DNS_IP_VERSION == 6
60 #define CONFIG_AUTO_INIT_SOCK_DNS_SERVER_ADDR "2001:4860:4860::8888"
61 #elif CONFIG_AUTO_INIT_SOCK_DNS_IP_VERSION == 4
62 #define CONFIG_AUTO_INIT_SOCK_DNS_SERVER_ADDR "8.8.8.8"
63 #endif
64#endif
65
69#ifndef CONFIG_AUTO_INIT_SOCK_DNS_SERVER_PORT
70#define CONFIG_AUTO_INIT_SOCK_DNS_SERVER_PORT SOCK_DNS_PORT
71#endif
72#endif /* MODULE_AUTO_INIT_SOCK_DNS */
73
78#define SOCK_DNS_PORT (53)
79#define SOCK_DNS_RETRIES (2)
80
81#define SOCK_DNS_MAX_NAME_LEN (CONFIG_DNS_MSG_LEN - sizeof(dns_hdr_t) - 4)
106int sock_dns_query(const char *domain_name, void *addr_out, int family);
107
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif /* NET_SOCK_DNS_H */
int sock_dns_query(const char *domain_name, void *addr_out, int family)
Get IP address for DNS name.
sock_udp_ep_t sock_dns_server
global DNS server endpoint
UDP sock definitions.
Common IP-based transport layer end point.
Definition sock.h:215
Definitions for parsing and composition of DNS messages.