]>
Commit | Line | Data |
---|---|---|
7b724b86 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 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 | |
ff9d9458 FC |
9 | #ifndef SQUID_SRC_DNS_RFC1035_H |
10 | #define SQUID_SRC_DNS_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 | |
4a3b98d7 AJ |
36 | class rfc1035_rr |
37 | { | |
38 | public: | |
7b724b86 | 39 | char name[RFC1035_MAXHOSTNAMESZ]; |
40 | unsigned short type; | |
29b8d8d6 | 41 | unsigned short _class; |
7b724b86 | 42 | unsigned int ttl; |
43 | unsigned short rdlength; | |
44 | char *rdata; | |
45 | }; | |
e1f7507e | 46 | |
ec7bade0 | 47 | typedef struct _rfc1035_query rfc1035_query; |
48 | struct _rfc1035_query { | |
49 | char name[RFC1035_MAXHOSTNAMESZ]; | |
50 | unsigned short qtype; | |
51 | unsigned short qclass; | |
52 | }; | |
e1f7507e | 53 | |
ec7bade0 | 54 | typedef struct _rfc1035_message rfc1035_message; |
55 | struct _rfc1035_message { | |
56 | unsigned short id; | |
57 | unsigned int qr:1; | |
58 | unsigned int opcode:4; | |
59 | unsigned int aa:1; | |
60 | unsigned int tc:1; | |
61 | unsigned int rd:1; | |
62 | unsigned int ra:1; | |
63 | unsigned int rcode:4; | |
64 | unsigned short qdcount; | |
65 | unsigned short ancount; | |
66 | unsigned short nscount; | |
67 | unsigned short arcount; | |
68 | rfc1035_query *query; | |
69 | rfc1035_rr *answer; | |
70 | }; | |
71 | ||
ca919500 | 72 | ssize_t rfc1035BuildAQuery(const char *hostname, |
01be1532 AR |
73 | char *buf, |
74 | size_t sz, | |
75 | unsigned short qid, | |
76 | rfc1035_query * query, | |
77 | ssize_t edns_sz); | |
ca919500 | 78 | ssize_t rfc1035BuildPTRQuery(const struct in_addr, |
01be1532 AR |
79 | char *buf, |
80 | size_t sz, | |
81 | unsigned short qid, | |
82 | rfc1035_query * query, | |
83 | ssize_t edns_sz); | |
ca919500 FC |
84 | void rfc1035SetQueryID(char *, unsigned short qid); |
85 | int rfc1035MessageUnpack(const char *buf, | |
01be1532 AR |
86 | size_t sz, |
87 | rfc1035_message ** answer); | |
ca919500 FC |
88 | int rfc1035QueryCompare(const rfc1035_query *, const rfc1035_query *); |
89 | void rfc1035RRDestroy(rfc1035_rr ** rr, int n); | |
90 | void rfc1035MessageDestroy(rfc1035_message ** message); | |
91 | const char * rfc1035ErrorMessage(int n); | |
7b724b86 | 92 | |
93 | #define RFC1035_TYPE_A 1 | |
2d320a3a | 94 | #define RFC1035_TYPE_CNAME 5 |
34a46fef | 95 | #define RFC1035_TYPE_PTR 12 |
7b724b86 | 96 | #define RFC1035_CLASS_IN 1 |
97 | ||
c5dd4956 | 98 | /* Child Library RFC3596 Depends on some otherwise internal functions */ |
ca919500 | 99 | int rfc1035HeaderPack(char *buf, |
01be1532 AR |
100 | size_t sz, |
101 | rfc1035_message * hdr); | |
ca919500 | 102 | int rfc1035HeaderUnpack(const char *buf, |
01be1532 AR |
103 | size_t sz, |
104 | unsigned int *off, | |
105 | rfc1035_message * h); | |
ca919500 | 106 | int rfc1035QuestionPack(char *buf, |
01be1532 AR |
107 | size_t sz, |
108 | const char *name, | |
109 | const unsigned short type, | |
110 | const unsigned short _class); | |
ca919500 | 111 | int rfc1035RRPack(char *buf, size_t sz, const rfc1035_rr * RR); |
7b6b4a98 | 112 | |
ff9d9458 | 113 | #endif /* SQUID_SRC_DNS_RFC1035_H */ |
f53969cc | 114 |