/[Apache-SVN]/httpd/sandbox/mod_domain/buckets.c
ViewVC logotype

Contents of /httpd/sandbox/mod_domain/buckets.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651222 - (show annotations) (download)
Thu Apr 24 11:44:55 2008 UTC (16 years, 3 months ago) by issac
File MIME type: text/plain
File size: 4930 byte(s)
Initial import of mod_dns (which will likely be renamed mod_domain)  This is the exact copy which was licensed by NetmaskIt! (the original copyright holder) to be donated to the ASF (see http://www.mail-archive.com/dev@httpd.apache.org/msg38687.html)

This version is fully functional in TCP mode.  Rudimentry UDP support can be enabled for httpd-prefork/apr/apr-util using the patchset at http://mail-archives.apache.org/mod_mbox/apr-dev/200709.mbox/%3C46DE8285.2010707@beamartyr.net%3E

1 /* Copyright 1999-2007 The Apache Software Foundation or its licensors, as
2 * applicable.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 /*
18 * Original Copyright (c) Netmask.IT!® 2006-2007
19 *
20 * DNS Protocol module for Apache 2.x
21 */
22
23 #include "mod_dns.h"
24
25 /** We need 4 bucket types: 3 for sending RRs (answer, authority, additional)
26 * which will just be pool buckets that can identify themselves later, and
27 * a 4th error type (we might steal normal apache error bucket for that)
28 */
29
30 /** TODO: Currently, we ensure that the rr is transported correctly, but don't
31 * consider sub-allocated memory, like rr->name, rr->rdata (and fields inside
32 * rr->rdata). We might want to serialize the rr in bucket_make and
33 * unserialize it in bucket_read to guarantee it never disappears */
34
35 static void dns_rr_bucket_destroy(void *data)
36 {
37 apr_bucket_type_pool.destroy(data);
38 }
39
40 static
41 /** This should read out rr->name, rr->rdata from some other form... */
42 apr_status_t dns_rr_bucket_read(apr_bucket *e, const char **str,
43 apr_size_t *len, apr_read_type_e block)
44 {
45 return apr_bucket_type_pool.read(e, str, len, block);
46 }
47
48 /** This needs to be improved to setaside subpools (rr->name, rr->rdata, etc) */
49 static
50 apr_status_t dns_rr_bucket_setaside(apr_bucket *data, apr_pool_t *reqpool)
51 {
52 return apr_bucket_type_pool.setaside(data, reqpool);
53 }
54
55 static
56 apr_status_t dns_rr_bucket_split(apr_bucket *a, apr_size_t point)
57 {
58 return apr_bucket_type_pool.split(a, point);
59 }
60
61 static
62 apr_status_t dns_rr_bucket_copy(apr_bucket *e, apr_bucket **c)
63 {
64 return apr_bucket_type_pool.copy(e, c);
65 }
66
67 DNS_DECLARE_DATA const apr_bucket_type_t dns_rr_answer_bucket_type = {
68 "DNS_RR_ANSWER", 5, APR_BUCKET_DATA,
69 dns_rr_bucket_destroy,
70 dns_rr_bucket_read,
71 dns_rr_bucket_setaside,
72 dns_rr_bucket_split,
73 dns_rr_bucket_copy,
74 };
75
76 DNS_DECLARE_DATA const apr_bucket_type_t dns_rr_authority_bucket_type = {
77 "DNS_RR_AUTHORITY", 5, APR_BUCKET_DATA,
78 dns_rr_bucket_destroy,
79 dns_rr_bucket_read,
80 dns_rr_bucket_setaside,
81 dns_rr_bucket_split,
82 dns_rr_bucket_copy,
83 };
84
85 DNS_DECLARE_DATA const apr_bucket_type_t dns_rr_additional_bucket_type = {
86 "DNS_RR_ADDITIONAL", 5, APR_BUCKET_DATA,
87 dns_rr_bucket_destroy,
88 dns_rr_bucket_read,
89 dns_rr_bucket_setaside,
90 dns_rr_bucket_split,
91 dns_rr_bucket_copy,
92 };
93
94 DNS_DECLARE(apr_bucket *) dns_bucket_rr_answer_create (
95 const char *buf, apr_size_t length,
96 apr_pool_t *pool, apr_bucket_alloc_t *list)
97 {
98 apr_bucket *e = apr_bucket_pool_create(buf, length, pool, list);
99 e->type = &dns_rr_answer_bucket_type;
100 return e;
101 }
102
103 DNS_DECLARE(apr_bucket *) dns_bucket_rr_answer_make (
104 apr_bucket *b, const char *buf,
105 apr_size_t length, apr_pool_t *pool)
106 {
107 apr_bucket *e = apr_bucket_pool_make(b, buf, length, pool);
108 e->type = &dns_rr_answer_bucket_type;
109 return e;
110 }
111
112 DNS_DECLARE(apr_bucket *) dns_bucket_rr_authority_create (
113 const char *buf, apr_size_t length,
114 apr_pool_t *pool, apr_bucket_alloc_t *list)
115 {
116 apr_bucket *e = apr_bucket_pool_create(buf, length, pool, list);
117 e->type = &dns_rr_authority_bucket_type;
118 return e;
119 }
120
121 DNS_DECLARE(apr_bucket *) dns_bucket_rr_authority_make (
122 apr_bucket *b, const char *buf,
123 apr_size_t length, apr_pool_t *pool)
124 {
125 apr_bucket *e = apr_bucket_pool_make(b, buf, length, pool);
126 e->type = &dns_rr_authority_bucket_type;
127 return e;
128 }
129
130 DNS_DECLARE(apr_bucket *) dns_bucket_rr_additional_create (
131 const char *buf, apr_size_t length,
132 apr_pool_t *pool, apr_bucket_alloc_t *list)
133 {
134 apr_bucket *e = apr_bucket_pool_create(buf, length, pool, list);
135 e->type = &dns_rr_additional_bucket_type;
136 return e;
137 }
138
139 DNS_DECLARE(apr_bucket *) dns_bucket_rr_additional_make (
140 apr_bucket *b, const char *buf,
141 apr_size_t length, apr_pool_t *pool)
142 {
143 apr_bucket *e = apr_bucket_pool_make(b, buf, length, pool);
144 e->type = &dns_rr_additional_bucket_type;
145 return e;
146 }

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26