msg.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Freie Universität Berlin
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 
20 #ifndef NET_DNS_MSG_H
21 #define NET_DNS_MSG_H
22 
23 #include <stdint.h>
24 #include <stdlib.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
38 #ifndef CONFIG_DNS_MSG_LEN
39 #define CONFIG_DNS_MSG_LEN (128U)
40 #endif /* CONFIG_DNS_MSG_LEN */
48 typedef struct __attribute__((packed)) {
49  uint16_t id;
68  uint16_t flags;
69  uint16_t qdcount;
70  uint16_t ancount;
71  uint16_t nscount;
72  uint16_t arcount;
73  uint8_t payload[];
74 } dns_hdr_t;
75 
96 size_t dns_msg_compose_query(void *dns_buf, const char *domain_name,
97  uint16_t id, int family);
98 
113 int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
114  void *addr_out, uint32_t *ttl);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* NET_DNS_MSG_H */
size_t dns_msg_compose_query(void *dns_buf, const char *domain_name, uint16_t id, int family)
Composes a DNS query message.
int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family, void *addr_out, uint32_t *ttl)
Parses a DNS response message.
DNS internal structure.
Definition: msg.h:48
uint16_t arcount
number of additional records
Definition: msg.h:72
uint16_t id
identifier
Definition: msg.h:49
uint16_t flags
flags
Definition: msg.h:68
uint16_t nscount
number of name server resource records
Definition: msg.h:71
uint16_t qdcount
number of question entries
Definition: msg.h:69
uint16_t ancount
number of answer resource records
Definition: msg.h:70