]> git.ipfire.org Git - thirdparty/squid.git/blame - include/rfc1035.h
Boilerplate: update copyright on compat/ library sources
[thirdparty/squid.git] / include / rfc1035.h
CommitLineData
7b724b86 1/*
01efce4b 2 * AUTHOR: Duane Wessels
7b724b86 3 *
2b6662ba 4 * SQUID Web Proxy Cache http://www.squid-cache.org/
5 * ----------------------------------------------------------
7b724b86 6 *
2b6662ba 7 * Squid is the result of efforts by numerous individuals from
8 * the Internet community; see the CONTRIBUTORS file for full
9 * details. Many organizations have provided support for Squid's
10 * development; see the SPONSORS file for full details. Squid is
11 * Copyrighted (C) 2001 by the Regents of the University of
12 * California; see the COPYRIGHT file for full details. Squid
13 * incorporates software developed and/or copyrighted by other
14 * sources; see the CREDITS file for full details.
7b724b86 15 *
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
c5dd4956 20 *
7b724b86 21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
c5dd4956 25 *
7b724b86 26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
c5dd4956 29 *
7b724b86 30 */
b5638623 31#ifndef SQUID_RFC1035_H
32#define SQUID_RFC1035_H
7b724b86 33
7b724b86 34#if HAVE_SYS_TYPES_H
35#include <sys/types.h>
36#endif
37#if HAVE_NETINET_IN_H
38#include <netinet/in.h>
39#endif
40#if HAVE_ARPA_INET_H
41#include <arpa/inet.h>
42#endif
43
e1f7507e
AJ
44#include "rfc2181.h"
45
46/**
47 \par RFC 1035 Section 3.1:
48 * To simplify implementations, the total length of a domain name (i.e.,
49 * label octets and label length octets) is restricted to 255 octets or
50 * less.
51 *\par
52 * Clarified by RFC 2181 Section 11. (RFC2181_MAXHOSTNAMELEN)
53 */
54#define RFC1035_MAXHOSTNAMESZ RFC2181_MAXHOSTNAMELEN
55
e210930b 56#define RFC1035_DEFAULT_PACKET_SZ 512
e1f7507e 57
7b724b86 58typedef struct _rfc1035_rr rfc1035_rr;
59struct _rfc1035_rr {
60 char name[RFC1035_MAXHOSTNAMESZ];
61 unsigned short type;
29b8d8d6 62 unsigned short _class;
7b724b86 63 unsigned int ttl;
64 unsigned short rdlength;
65 char *rdata;
66};
e1f7507e 67
ec7bade0 68typedef struct _rfc1035_query rfc1035_query;
69struct _rfc1035_query {
70 char name[RFC1035_MAXHOSTNAMESZ];
71 unsigned short qtype;
72 unsigned short qclass;
73};
e1f7507e 74
ec7bade0 75typedef struct _rfc1035_message rfc1035_message;
76struct _rfc1035_message {
77 unsigned short id;
78 unsigned int qr:1;
79 unsigned int opcode:4;
80 unsigned int aa:1;
81 unsigned int tc:1;
82 unsigned int rd:1;
83 unsigned int ra:1;
84 unsigned int rcode:4;
85 unsigned short qdcount;
86 unsigned short ancount;
87 unsigned short nscount;
88 unsigned short arcount;
89 rfc1035_query *query;
90 rfc1035_rr *answer;
91};
92
108d67a0 93SQUIDCEXTERN ssize_t rfc1035BuildAQuery(const char *hostname,
c5dd4956
AJ
94 char *buf,
95 size_t sz,
96 unsigned short qid,
e210930b
AJ
97 rfc1035_query * query,
98 ssize_t edns_sz);
7b6b4a98 99SQUIDCEXTERN ssize_t rfc1035BuildPTRQuery(const struct in_addr,
c5dd4956
AJ
100 char *buf,
101 size_t sz,
102 unsigned short qid,
e210930b 103 rfc1035_query * query,
24520b1b 104 ssize_t edns_sz);
108d67a0 105SQUIDCEXTERN void rfc1035SetQueryID(char *, unsigned short qid);
ec7bade0 106SQUIDCEXTERN int rfc1035MessageUnpack(const char *buf,
c5dd4956
AJ
107 size_t sz,
108 rfc1035_message ** answer);
9e1f210d 109SQUIDCEXTERN int rfc1035QueryCompare(const rfc1035_query *, const rfc1035_query *);
bae9832d 110SQUIDCEXTERN void rfc1035RRDestroy(rfc1035_rr ** rr, int n);
cc192b50 111SQUIDCEXTERN void rfc1035MessageDestroy(rfc1035_message ** message);
42687bb2 112SQUIDCEXTERN const char * rfc1035ErrorMessage(int n);
7b724b86 113
114#define RFC1035_TYPE_A 1
2d320a3a 115#define RFC1035_TYPE_CNAME 5
34a46fef 116#define RFC1035_TYPE_PTR 12
7b724b86 117#define RFC1035_CLASS_IN 1
118
c5dd4956 119/* Child Library RFC3596 Depends on some otherwise internal functions */
7b6b4a98 120SQUIDCEXTERN int rfc1035HeaderPack(char *buf,
c5dd4956
AJ
121 size_t sz,
122 rfc1035_message * hdr);
7b6b4a98 123SQUIDCEXTERN int rfc1035HeaderUnpack(const char *buf,
c5dd4956
AJ
124 size_t sz,
125 unsigned int *off,
126 rfc1035_message * h);
7b6b4a98 127SQUIDCEXTERN int rfc1035QuestionPack(char *buf,
c5dd4956
AJ
128 size_t sz,
129 const char *name,
130 const unsigned short type,
131 const unsigned short _class);
e210930b 132SQUIDCEXTERN int rfc1035RRPack(char *buf, size_t sz, const rfc1035_rr * RR);
7b6b4a98 133
b5638623 134#endif /* SQUID_RFC1035_H */