msg.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
20 #include <stdint.h>
21 #include <stdlib.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
35 #ifndef CONFIG_DNS_MSG_LEN
36 #define CONFIG_DNS_MSG_LEN (128U)
37 #endif /* CONFIG_DNS_MSG_LEN */
45 typedef struct __attribute__((packed)) {
46  uint16_t id;
65  uint16_t flags;
66  uint16_t qdcount;
67  uint16_t ancount;
68  uint16_t nscount;
69  uint16_t arcount;
70  uint8_t payload[];
71 } dns_hdr_t;
72 
93 size_t dns_msg_compose_query(void *dns_buf, const char *domain_name,
94  uint16_t id, int family);
95 
110 int dns_msg_parse_reply(const uint8_t *buf, size_t len, int family,
111  void *addr_out, uint32_t *ttl);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
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:45
uint16_t arcount
number of additional records
Definition: msg.h:69
uint16_t id
identifier
Definition: msg.h:46
uint16_t flags
flags
Definition: msg.h:65
uint16_t nscount
number of name server resource records
Definition: msg.h:68
uint16_t qdcount
number of question entries
Definition: msg.h:66
uint16_t ancount
number of answer resource records
Definition: msg.h:67