resolved-dns-packet.h revision 8ba9fd9cee0eef572f7b3ed7a8c3ed31160e93d3
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#pragma once
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
typedef struct DnsPacketHeader DnsPacketHeader;
#include <inttypes.h>
#include "macro.h"
#include "sparse-endian.h"
#include "hashmap.h"
#include "resolved-dns-rr.h"
struct DnsPacketHeader {
};
#define DNS_PACKET_HEADER_SIZE sizeof(DnsPacketHeader)
/* The various DNS protocols deviate in how large a packet can grow,
but the TCP transport has a 16bit size field, hence that appears to
be the maximum. */
#define DNS_PACKET_SIZE_MAX 0xFFFF
#define DNS_PACKET_SIZE_START 512
struct DnsPacket {
int n_ref;
int ifindex;
void *data;
};
if (_unlikely_(!p))
return NULL;
if (p->data)
return p->data;
}
int dns_packet_validate(DnsPacket *p);
int dns_packet_validate_reply(DnsPacket *p);
int dns_packet_skip_question(DnsPacket *p);
enum {
DNS_RCODE_SUCCESS = 0,
DNS_RCODE_FORMERR = 1,
DNS_RCODE_SERVFAIL = 2,
DNS_RCODE_NXDOMAIN = 3,
DNS_RCODE_NOTIMP = 4,
DNS_RCODE_REFUSED = 5,
DNS_RCODE_YXDOMAIN = 6,
DNS_RCODE_YXRRSET = 7,
DNS_RCODE_NXRRSET = 8,
DNS_RCODE_NOTAUTH = 9,
DNS_RCODE_NOTZONE = 10,
DNS_RCODE_BADVERS = 16,
DNS_RCODE_BADKEY = 17,
DNS_RCODE_BADTIME = 18,
DNS_RCODE_BADMODE = 19,
DNS_RCODE_BADNAME = 20,
DNS_RCODE_BADALG = 21,
DNS_RCODE_BADTRUNC = 22,
};
const char* dns_rcode_to_string(int i) _const_;
int dns_rcode_from_string(const char *s) _pure_;