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 |
#ifndef RR_H |
24 |
#define RR_H |
25 |
|
26 |
#ifndef MOD_DNS_H |
27 |
#include "mod_dns.h" |
28 |
#endif |
29 |
|
30 |
#ifdef __cplusplus |
31 |
extern "C" { |
32 |
#endif |
33 |
|
34 |
#define DNS_RDATA_SERIALIZE(type) apr_status_t dns_rdata_##type##_serialize\ |
35 |
(void *rdata, char *data, int *dlen) |
36 |
#define DNS_RDATA_UNSERIALIZE(type) apr_status_t dns_rdata_##type##_unserialize\ |
37 |
(apr_pool_t *pool, const char *data, void **rdata) |
38 |
#define DNS_RDATA_PSERIALIZE(type) \ |
39 |
apr_status_t dns_rdata_##type##_pserialize(void *rdata, apr_pool_t *pool,\ |
40 |
char **data, int *dlen)\ |
41 |
{\ |
42 |
apr_status_t rv;\ |
43 |
*dlen = 0;\ |
44 |
if ((rv = dns_rdata_##type##_serialize(rdata, NULL, dlen)) != APR_SUCCESS)\ |
45 |
return rv;\ |
46 |
*data = apr_palloc(pool, *dlen);\ |
47 |
return dns_rdata_##type##_serialize(rdata, *data, dlen);\ |
48 |
} |
49 |
|
50 |
#define dns_init_rdata_const(type,var) \ |
51 |
var->serialize = dns_rdata_##type.serialize;\ |
52 |
var->pserialize = dns_rdata_##type.pserialize;\ |
53 |
var->unserialize = dns_rdata_##type.unserialize |
54 |
|
55 |
#define dns_init_rdata(type,var) \ |
56 |
var->serialize = type->serialize;\ |
57 |
var->pserialize = type->pserialize;\ |
58 |
var->unserialize = type->unserialize |
59 |
|
60 |
#define dns_null_rdata {NULL,NULL,NULL} |
61 |
|
62 |
#define DNS_RDATA_DECLARE(type) DNS_DECLARE_DATA extern const dns_rdata_t dns_rdata_##type |
63 |
#define DNS_RDATA_IMPLEMENT(type) DNS_DECLARE_DATA const dns_rdata_t dns_rdata_##type = {\ |
64 |
NULL,\ |
65 |
dns_rdata_##type##_serialize,\ |
66 |
dns_rdata_##type##_pserialize,\ |
67 |
dns_rdata_##type##_unserialize\ |
68 |
} |
69 |
|
70 |
DNS_RDATA_DECLARE(a); |
71 |
DNS_RDATA_DECLARE(cname); |
72 |
DNS_RDATA_DECLARE(mx); |
73 |
|
74 |
#ifdef __cplusplus |
75 |
} |
76 |
#endif |
77 |
|
78 |
#endif |