resolved-dns-packet.h revision f3abbe25403444688e1a1a23b9dbcc9aeefc0507
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering This file is part of systemd.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Copyright 2014 Lennart Poettering
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is free software; you can redistribute it and/or modify it
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering under the terms of the GNU Lesser General Public License as published by
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering (at your option) any later version.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering systemd is distributed in the hope that it will be useful, but
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering Lesser General Public License for more details.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering You should have received a copy of the GNU Lesser General Public License
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
1ee306e1248866617c96ed9f4263f375588ad838Lennart Poetteringtypedef struct DnsPacketHeader DnsPacketHeader;
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poettering#define DNS_PACKET_HEADER_SIZE sizeof(DnsPacketHeader)
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poettering#define UDP_PACKET_HEADER_SIZE (sizeof(struct iphdr) + sizeof(struct udphdr))
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poettering/* The various DNS protocols deviate in how large a packet can grow,
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poettering but the TCP transport has a 16bit size field, hence that appears to
adacb9575a09981fcf11279f2f661e3fc21e58ffLennart Poettering be the absolute maximum. */
d3152a09ac5804ec8603daee12f98cf03523cce0Lennart Poettering/* RFC 1035 say 512 is the maximum, for classic unicast DNS */
717603e391b52983ca1fd218e7333a1b9dfc5c05Lennart Poettering/* With EDNS0 we can use larger packets, default to 4096, which is what is commonly used */
e70bc43cdf75b36e7ad3d29e9a6f8ee1461e7d5eLennart Poettering#define DNS_PACKET_UNICAST_SIZE_LARGE_MAX 4096
int ifindex;
if (_unlikely_(!p))
return NULL;
if (p->_data)
return p->_data;
if (p->opt)
rcode = 0;
(unsigned) DNS_PACKET_ANCOUNT(p) +
(unsigned) DNS_PACKET_NSCOUNT(p) +
(unsigned) DNS_PACKET_ARCOUNT(p);
int dns_packet_new_query(DnsPacket **p, DnsProtocol protocol, size_t mtu, bool dnssec_checking_disabled);
int dns_packet_append_label(DnsPacket *p, const char *s, size_t l, bool canonical_candidate, size_t *start);
int dns_packet_append_name(DnsPacket *p, const char *name, bool allow_compression, bool canonical_candidate, size_t *start);
int dns_packet_append_rr(DnsPacket *p, const DnsResourceRecord *rr, size_t *start, size_t *rdata_start);
int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, bool *ret_cache_flush, size_t *start);
/* https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 */
DNS_RCODE_SUCCESS = 0,
#define LLMNR_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03 } })
#define MDNS_MULTICAST_IPV6_ADDRESS ((struct in6_addr) { .s6_addr = { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0xfb } })
static inline uint64_t SD_RESOLVED_FLAGS_MAKE(DnsProtocol protocol, int family, bool authenticated) {
uint64_t f;
switch (protocol) {
case DNS_PROTOCOL_DNS:
return f|SD_RESOLVED_DNS;
case DNS_PROTOCOL_LLMNR:
case DNS_PROTOCOL_MDNS: