1
/* dns.h - Declarations for dns handling and generic dns functions
2
Copyright (C) 2000, 2001 Thomas Moestl
4
This file is part of the pdnsd package.
6
pdnsd is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
pdnsd is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
16
You should have received a copy of the GNU General Public License
17
along with pdsnd; see the file COPYING. If not, write to
18
the Free Software Foundation, 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
21
/* $Id: dns.h,v 1.14 2002/01/01 23:54:49 tmm Exp $ */
27
#include <arpa/inet.h>
29
#include <sys/types.h>
34
/* Deal with byte orders */
36
# define LITTLE_ENDIAN __LITTLE_ENDIAN
37
# define BIG_ENDIAN __BIG_ENDIAN
39
# define BYTE_ORDER __BYTE_ORDER
41
# ifdef __LITTLE_ENDIAN
42
# define BYTE_ORDER __LITTLE_ENDIAN
45
# define BYTE_ORDER __LITTLE_ENDIAN
50
/* special rr type codes for queries */
69
/* special classes for queries */
81
* special internal retvals
83
#define RC_TCPREFUSED 254
96
/* rfc2181 details that the ttl is a 32-bit integer, where the most significant bit is always 0.
97
* for convenience and Unix compatablility we use a uint32_t, which satisfies these conditions if
98
* positive (which is ensured in the code) */
100
/* the name is the first field. It has variable length, so it can't be put in the struct */
101
uint16_t type __attribute__((packed));
102
uint16_t class __attribute__((packed));
103
uint32_t ttl __attribute__((packed));
104
uint16_t rdlength __attribute__((packed));
109
/* The server name and maintainer mailbox are the first two fields. It has variable length, */
110
/* so they can't be put in the struct */
111
uint32_t serial __attribute__((packed));
112
uint32_t refresh __attribute__((packed));
113
uint32_t retry __attribute__((packed));
114
uint32_t expire __attribute__((packed));
115
uint32_t minimum __attribute__((packed));
121
uint16_t qtype __attribute__((packed));
122
uint16_t qclass __attribute__((packed));
126
uint16_t id __attribute__((packed));
127
#if __BYTE_ORDER == __LITTLE_ENDIAN
131
unsigned int opcode:4;
133
unsigned int rcode:4;
138
#elif __BYTE_ORDER == __BIG_ENDIAN
140
unsigned int opcode:4;
148
unsigned int rcode:4;
150
# error "Please define __BYTE_ORDER to be __LITTLE_ENDIAN or __BIG_ENDIAN"
152
uint16_t qdcount __attribute__((packed));
153
uint16_t ancount __attribute__((packed));
154
uint16_t nscount __attribute__((packed));
155
uint16_t arcount __attribute__((packed));
158
/* Recursion depth. */
162
* Types for compression buffers.
166
unsigned char s[256];
169
int decompress_name(unsigned char *msg, unsigned char *tgt, unsigned char **src, long *sz, long msgsz, int *len, int *uscore);
170
int domain_match(int *o, unsigned char *ms, unsigned char *md, unsigned char *rest);
171
int compress_name(unsigned char *in, unsigned char *out, int offs, darray *cb);
173
int read_hosts(char *fn, unsigned char *rns, time_t ttl, int flags, int aliases, char *errbuf, int errsize);
176
char *get_cname(int id);
177
char *get_tname(int id);
178
char *get_ename(int id);