]>
Commit | Line | Data |
---|---|---|
7b724b86 | 1 | /* |
5c193dec | 2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
c5dd4956 | 3 | * |
5c193dec AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
7b724b86 | 7 | */ |
5c193dec | 8 | |
b5638623 | 9 | #ifndef SQUID_RFC1035_H |
10 | #define SQUID_RFC1035_H | |
7b724b86 | 11 | |
7b724b86 | 12 | #if HAVE_SYS_TYPES_H |
13 | #include <sys/types.h> | |
14 | #endif | |
15 | #if HAVE_NETINET_IN_H | |
16 | #include <netinet/in.h> | |
17 | #endif | |
18 | #if HAVE_ARPA_INET_H | |
19 | #include <arpa/inet.h> | |
20 | #endif | |
21 | ||
e1f7507e AJ |
22 | #include "rfc2181.h" |
23 | ||
24 | /** | |
25 | \par RFC 1035 Section 3.1: | |
26 | * To simplify implementations, the total length of a domain name (i.e., | |
27 | * label octets and label length octets) is restricted to 255 octets or | |
28 | * less. | |
29 | *\par | |
30 | * Clarified by RFC 2181 Section 11. (RFC2181_MAXHOSTNAMELEN) | |
31 | */ | |
32 | #define RFC1035_MAXHOSTNAMESZ RFC2181_MAXHOSTNAMELEN | |
33 | ||
e210930b | 34 | #define RFC1035_DEFAULT_PACKET_SZ 512 |
e1f7507e | 35 | |
7b724b86 | 36 | typedef struct _rfc1035_rr rfc1035_rr; |
37 | struct _rfc1035_rr { | |
38 | char name[RFC1035_MAXHOSTNAMESZ]; | |
39 | unsigned short type; | |
29b8d8d6 | 40 | unsigned short _class; |
7b724b86 | 41 | unsigned int ttl; |
42 | unsigned short rdlength; | |
43 | char *rdata; | |
44 | }; | |
e1f7507e | 45 | |
ec7bade0 | 46 | typedef struct _rfc1035_query rfc1035_query; |
47 | struct _rfc1035_query { | |
48 | char name[RFC1035_MAXHOSTNAMESZ]; | |
49 | unsigned short qtype; | |
50 | unsigned short qclass; | |
51 | }; | |
e1f7507e | 52 | |
ec7bade0 | 53 | typedef struct _rfc1035_message rfc1035_message; |
54 | struct _rfc1035_message { | |
55 | unsigned short id; | |
56 | unsigned int qr:1; | |
57 | unsigned int opcode:4; | |
58 | unsigned int aa:1; | |
59 | unsigned int tc:1; | |
60 | unsigned int rd:1; | |
61 | unsigned int ra:1; | |
62 | unsigned int rcode:4; | |
63 | unsigned short qdcount; | |
64 | unsigned short ancount; | |
65 | unsigned short nscount; | |
66 | unsigned short arcount; | |
67 | rfc1035_query *query; | |
68 | rfc1035_rr *answer; | |
69 | }; | |
70 | ||
108d67a0 | 71 | SQUIDCEXTERN ssize_t rfc1035BuildAQuery(const char *hostname, |
c5dd4956 AJ |
72 | char *buf, |
73 | size_t sz, | |
74 | unsigned short qid, | |
e210930b AJ |
75 | rfc1035_query * query, |
76 | ssize_t edns_sz); | |
7b6b4a98 | 77 | SQUIDCEXTERN ssize_t rfc1035BuildPTRQuery(const struct in_addr, |
c5dd4956 AJ |
78 | char *buf, |
79 | size_t sz, | |
80 | unsigned short qid, | |
e210930b | 81 | rfc1035_query * query, |
24520b1b | 82 | ssize_t edns_sz); |
108d67a0 | 83 | SQUIDCEXTERN void rfc1035SetQueryID(char *, unsigned short qid); |
ec7bade0 | 84 | SQUIDCEXTERN int rfc1035MessageUnpack(const char *buf, |
c5dd4956 AJ |
85 | size_t sz, |
86 | rfc1035_message ** answer); | |
9e1f210d | 87 | SQUIDCEXTERN int rfc1035QueryCompare(const rfc1035_query *, const rfc1035_query *); |
bae9832d | 88 | SQUIDCEXTERN void rfc1035RRDestroy(rfc1035_rr ** rr, int n); |
cc192b50 | 89 | SQUIDCEXTERN void rfc1035MessageDestroy(rfc1035_message ** message); |
42687bb2 | 90 | SQUIDCEXTERN const char * rfc1035ErrorMessage(int n); |
7b724b86 | 91 | |
92 | #define RFC1035_TYPE_A 1 | |
2d320a3a | 93 | #define RFC1035_TYPE_CNAME 5 |
34a46fef | 94 | #define RFC1035_TYPE_PTR 12 |
7b724b86 | 95 | #define RFC1035_CLASS_IN 1 |
96 | ||
c5dd4956 | 97 | /* Child Library RFC3596 Depends on some otherwise internal functions */ |
7b6b4a98 | 98 | SQUIDCEXTERN int rfc1035HeaderPack(char *buf, |
c5dd4956 AJ |
99 | size_t sz, |
100 | rfc1035_message * hdr); | |
7b6b4a98 | 101 | SQUIDCEXTERN int rfc1035HeaderUnpack(const char *buf, |
c5dd4956 AJ |
102 | size_t sz, |
103 | unsigned int *off, | |
104 | rfc1035_message * h); | |
7b6b4a98 | 105 | SQUIDCEXTERN int rfc1035QuestionPack(char *buf, |
c5dd4956 AJ |
106 | size_t sz, |
107 | const char *name, | |
108 | const unsigned short type, | |
109 | const unsigned short _class); | |
e210930b | 110 | SQUIDCEXTERN int rfc1035RRPack(char *buf, size_t sz, const rfc1035_rr * RR); |
7b6b4a98 | 111 | |
b5638623 | 112 | #endif /* SQUID_RFC1035_H */ |
f53969cc | 113 |