Blame
Date:
Thu Sep 10 14:45:56 2020 UTC
Message:
I want to stick with ldns-verify-zone
001
2017-06-26
pjp
/*
002
2017-06-26
pjp
* Copyright (c) 2017 Peter J. Philipp
003
2017-06-26
pjp
* All rights reserved.
004
2017-06-26
pjp
*
005
2017-06-26
pjp
* Redistribution and use in source and binary forms, with or without
006
2017-06-26
pjp
* modification, are permitted provided that the following conditions
007
2017-06-26
pjp
* are met:
008
2017-06-26
pjp
* 1. Redistributions of source code must retain the above copyright
009
2017-06-26
pjp
* notice, this list of conditions and the following disclaimer.
010
2017-06-26
pjp
* 2. Redistributions in binary form must reproduce the above copyright
011
2017-06-26
pjp
* notice, this list of conditions and the following disclaimer in the
012
2017-06-26
pjp
* documentation and/or other materials provided with the distribution.
013
2017-06-26
pjp
* 3. The name of the author may not be used to endorse or promote products
014
2017-06-26
pjp
* derived from this software without specific prior written permission
015
2017-06-26
pjp
*
016
2017-06-26
pjp
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
017
2017-06-26
pjp
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
018
2017-06-26
pjp
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
019
2017-06-26
pjp
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
020
2017-06-26
pjp
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
021
2017-06-26
pjp
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
022
2017-06-26
pjp
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
023
2017-06-26
pjp
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
024
2017-06-26
pjp
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
025
2017-06-26
pjp
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
026
2017-06-26
pjp
*
027
2017-06-26
pjp
*/
028
2017-06-26
pjp
029
2017-10-26
pjp
/*
030
2020-07-27
pjp
* $Id: db.c,v 1.24 2020/07/27 08:21:08 pjp Exp $
031
2017-10-26
pjp
*/
032
2017-10-26
pjp
033
2019-06-06
pjp
#include <sys/types.h>
034
2019-06-06
pjp
#include <sys/socket.h>
035
2019-06-06
pjp
036
2019-06-06
pjp
#include <netinet/in.h>
037
2019-06-06
pjp
#include <arpa/inet.h>
038
2019-06-06
pjp
#include <netdb.h>
039
2019-06-06
pjp
040
2019-06-06
pjp
#include <stdio.h>
041
2019-06-06
pjp
#include <stdlib.h>
042
2019-06-06
pjp
#include <string.h>
043
2019-06-06
pjp
#include <errno.h>
044
2019-06-06
pjp
#include <time.h>
045
2020-07-06
pjp
#include <syslog.h>
046
2019-06-06
pjp
047
2019-06-06
pjp
#ifdef __linux__
048
2019-06-06
pjp
#include <grp.h>
049
2019-06-06
pjp
#define __USE_BSD 1
050
2019-06-06
pjp
#include <endian.h>
051
2019-06-06
pjp
#include <bsd/stdlib.h>
052
2019-06-06
pjp
#include <bsd/string.h>
053
2019-06-06
pjp
#include <bsd/sys/queue.h>
054
2019-06-06
pjp
#define __unused
055
2019-06-06
pjp
#include <bsd/sys/tree.h>
056
2019-06-06
pjp
#include <bsd/sys/endian.h>
057
2019-06-06
pjp
#else /* not linux */
058
2019-06-06
pjp
#include <sys/queue.h>
059
2019-06-06
pjp
#include <sys/tree.h>
060
2019-06-06
pjp
#endif /* __linux__ */
061
2019-06-06
pjp
062
2019-06-06
pjp
063
2017-06-26
pjp
#include "ddd-dns.h"
064
2017-06-26
pjp
#include "ddd-db.h"
065
2017-06-26
pjp
066
2020-07-15
pjp
struct rbtree * create_rr(ddDB *, char *, int, int, void *, uint32_t, uint16_t);
067
2019-02-15
pjp
struct rbtree * find_rrset(ddDB *db, char *name, int len);
068
2019-02-15
pjp
struct rrset * find_rr(struct rbtree *rbt, u_int16_t rrtype);
069
2019-02-15
pjp
int add_rr(struct rbtree *rbt, char *name, int len, u_int16_t rrtype, void *rdata);
070
2019-02-15
pjp
int display_rr(struct rrset *rrset);
071
2019-02-15
pjp
int rotate_rr(struct rrset *rrset);
072
2019-04-07
pjp
void flag_rr(struct rbtree *rbt);
073
2020-07-08
pjp
int expire_rr(ddDB *, char *, int, u_int16_t, time_t);
074
2020-07-08
pjp
int expire_db(ddDB *, int);
075
2017-06-26
pjp
076
2019-02-18
pjp
extern void dolog(int, char *, ...);
077
2019-02-18
pjp
078
2019-02-15
pjp
extern char * convert_name(char *, int);
079
2019-02-19
pjp
int domaincmp(struct node *e1, struct node *e2);
080
2019-02-15
pjp
081
2019-02-19
pjp
082
2019-02-19
pjp
083
2017-06-26
pjp
int
084
2017-06-26
pjp
domaincmp(struct node *e1, struct node *e2)
085
2017-06-26
pjp
{
086
2017-06-26
pjp
if (e1->len < e2->len)
087
2017-06-26
pjp
return -1;
088
2017-06-26
pjp
else if (e1->len > e2->len)
089
2017-06-26
pjp
return 1;
090
2017-06-26
pjp
else {
091
2017-06-26
pjp
return (memcmp(e1->domainname, e2->domainname, e1->len));
092
2017-06-26
pjp
}
093
2017-06-26
pjp
}
094
2017-06-26
pjp
095
2017-06-26
pjp
096
2017-06-26
pjp
ddDB *
097
2017-06-26
pjp
dddbopen(void)
098
2017-06-26
pjp
{
099
2017-06-26
pjp
ddDB *db;
100
2017-06-26
pjp
101
2017-06-26
pjp
db = calloc(1, sizeof(ddDB));
102
2017-06-26
pjp
if (db == NULL) {
103
2017-06-26
pjp
errno = ENOMEM;
104
2017-06-26
pjp
return NULL;
105
2017-06-26
pjp
}
106
2017-06-26
pjp
107
2017-06-26
pjp
db->put = dddbput;
108
2017-06-26
pjp
db->get = dddbget;
109
2017-06-26
pjp
db->close = dddbclose;
110
2017-06-26
pjp
db->offset = 0;
111
2019-02-19
pjp
112
2019-02-19
pjp
RB_INIT(&db->head);
113
2017-06-26
pjp
114
2017-06-26
pjp
return (db);
115
2017-06-26
pjp
}
116
2017-06-26
pjp
117
2017-06-26
pjp
int
118
2017-06-26
pjp
dddbput(ddDB *db, ddDBT *key, ddDBT *data)
119
2017-06-26
pjp
{
120
2017-06-26
pjp
struct node find, *n, *res;
121
2017-06-26
pjp
122
2017-06-26
pjp
strlcpy(find.domainname, key->data, sizeof(find.domainname));
123
2017-06-26
pjp
find.len = key->size;
124
2017-06-26
pjp
125
2019-02-19
pjp
res = RB_FIND(domaintree, &db->head, &find);
126
2017-06-26
pjp
if (res == NULL) {
127
2017-06-26
pjp
/* does not exist, create it */
128
2017-06-26
pjp
n = calloc(sizeof(struct node), 1);
129
2017-06-26
pjp
if (n == NULL) {
130
2017-06-26
pjp
return -1;
131
2017-06-26
pjp
}
132
2017-06-26
pjp
n->len = key->size;
133
2017-06-26
pjp
memcpy(n->domainname, key->data, n->len);
134
2020-07-08
pjp
n->data = data->data;
135
2017-06-26
pjp
n->datalen = data->size;
136
2017-06-26
pjp
137
2019-02-19
pjp
RB_INSERT(domaintree, &db->head, n);
138
2017-06-26
pjp
} else {
139
2019-02-15
pjp
if (res->datalen != data->size)
140
2019-02-15
pjp
return -1;
141
2019-02-15
pjp
142
2020-07-08
pjp
if (res->data != data->data)
143
2020-07-08
pjp
free(res->data);
144
2020-07-08
pjp
145
2020-07-08
pjp
res->data = data->data;
146
2020-07-08
pjp
RB_REMOVE(domaintree, &db->head, res);
147
2020-07-08
pjp
RB_INSERT(domaintree, &db->head, res);
148
2017-06-26
pjp
}
149
2017-06-26
pjp
150
2017-06-26
pjp
return 0;
151
2017-06-26
pjp
}
152
2017-06-26
pjp
153
2017-06-26
pjp
int
154
2017-06-26
pjp
dddbget(ddDB *db, ddDBT *key, ddDBT *data)
155
2017-06-26
pjp
{
156
2017-06-26
pjp
struct node find, *res;
157
2017-06-26
pjp
158
2019-02-18
pjp
memset(&find, 0, sizeof(struct node));
159
2017-06-26
pjp
strlcpy(find.domainname, key->data, sizeof(find.domainname));
160
2017-06-26
pjp
find.len = key->size;
161
2017-06-26
pjp
162
2019-02-19
pjp
res = RB_FIND(domaintree, &db->head, &find);
163
2017-06-26
pjp
if (res == NULL) {
164
2017-06-26
pjp
return -1;
165
2017-06-26
pjp
}
166
2017-06-26
pjp
167
2017-06-26
pjp
data->size = res->datalen;
168
2017-06-26
pjp
data->data = res->data;
169
2017-06-26
pjp
170
2017-06-26
pjp
return 0;
171
2017-06-26
pjp
}
172
2017-06-26
pjp
173
2017-06-26
pjp
int
174
2017-06-26
pjp
dddbclose(ddDB *db)
175
2017-06-26
pjp
{
176
2020-07-27
pjp
free (db);
177
2019-02-15
pjp
return 0;
178
2019-02-15
pjp
}
179
2019-02-15
pjp
180
2019-02-15
pjp
struct rbtree *
181
2020-07-15
pjp
create_rr(ddDB *db, char *name, int len, int type, void *rdata, uint32_t ttl, uint16_t rdlen)
182
2019-02-15
pjp
{
183
2020-07-08
pjp
ddDBT key, data;
184
2019-02-15
pjp
struct rbtree *rbt = NULL;
185
2019-02-15
pjp
struct rrset *rrset = NULL;
186
2019-02-15
pjp
struct rr *myrr = NULL;
187
2019-02-15
pjp
char *humanname = NULL;
188
2019-02-15
pjp
189
2019-02-15
pjp
190
2019-02-15
pjp
rbt = find_rrset(db, name, len);
191
2019-02-15
pjp
if (rbt == NULL) {
192
2019-02-15
pjp
rbt = (struct rbtree *) calloc(1, sizeof(struct rbtree));
193
2019-02-15
pjp
if (! rbt) {
194
2019-02-15
pjp
perror("calloc");
195
2019-02-15
pjp
return NULL;
196
2019-02-15
pjp
}
197
2019-02-15
pjp
198
2019-02-15
pjp
strlcpy(rbt->zone, name, sizeof(rbt->zone));
199
2019-02-15
pjp
rbt->zonelen = len;
200
2019-02-15
pjp
humanname = convert_name(name, len);
201
2019-02-15
pjp
strlcpy(rbt->humanname, humanname, sizeof(rbt->humanname));
202
2019-11-11
pjp
rbt->flags &= ~RBT_DNSSEC; /* by default not dnssec'ed */
203
2020-07-06
pjp
204
2019-02-15
pjp
TAILQ_INIT(&rbt->rrset_head);
205
2020-07-08
pjp
206
2020-07-08
pjp
/* rb insert too */
207
2020-07-08
pjp
memset(&key, 0, sizeof(key));
208
2020-07-08
pjp
memset(&data, 0, sizeof(data));
209
2020-07-08
pjp
210
2020-07-08
pjp
key.data = (char *)name;
211
2020-07-08
pjp
key.size = len;
212
2020-07-08
pjp
213
2020-07-08
pjp
data.data = (void *)rbt;
214
2020-07-08
pjp
data.size = sizeof(struct rbtree);
215
2020-07-08
pjp
216
2020-07-08
pjp
db->put(db, &key, &data);
217
2019-02-15
pjp
}
218
2019-02-15
pjp
219
2019-02-15
pjp
rrset = find_rr(rbt, type);
220
2019-02-15
pjp
if (rrset == NULL) {
221
2019-02-15
pjp
rrset = (struct rrset *)calloc(1, sizeof(struct rrset));
222
2019-02-15
pjp
if (! rrset){
223
2019-02-15
pjp
perror("calloc");
224
2019-02-15
pjp
return NULL;
225
2019-02-15
pjp
}
226
2019-02-15
pjp
227
2019-02-15
pjp
rrset->rrtype = type;
228
2020-05-07
pjp
if (type != DNS_TYPE_RRSIG)
229
2020-05-07
pjp
rrset->ttl = ttl;
230
2020-05-07
pjp
else
231
2020-05-07
pjp
rrset->ttl = 0; /* fill in later */
232
2020-05-07
pjp
233
2020-07-06
pjp
rrset->created = time(NULL);
234
2020-07-06
pjp
235
2019-02-15
pjp
TAILQ_INIT(&rrset->rr_head);
236
2019-02-15
pjp
237
2019-02-15
pjp
TAILQ_INSERT_TAIL(&rbt->rrset_head, rrset, entries);
238
2020-07-06
pjp
} else
239
2020-07-06
pjp
rrset->created = time(NULL);
240
2019-02-15
pjp
241
2019-02-19
pjp
/* this sets up the RR */
242
2019-02-15
pjp
243
2019-02-15
pjp
myrr = (struct rr *)calloc(1, sizeof(struct rr));
244
2019-02-15
pjp
if (! myrr) {
245
2019-02-15
pjp
perror("calloc");
246
2019-02-15
pjp
return NULL;
247
2019-02-15
pjp
}
248
2019-02-15
pjp
249
2020-07-08
pjp
switch (type) {
250
2020-07-08
pjp
case DNS_TYPE_A:
251
2020-07-08
pjp
myrr->rdata = (struct a *)rdata;
252
2020-07-08
pjp
break;
253
2020-07-08
pjp
default:
254
2020-07-08
pjp
myrr->rdata = rdata;
255
2020-07-08
pjp
break;
256
2020-07-08
pjp
}
257
2019-02-15
pjp
myrr->changed = time(NULL);
258
2020-07-15
pjp
myrr->rdlen = rdlen;
259
2019-02-15
pjp
260
2020-07-06
pjp
rrset->ttl = ttl;
261
2020-07-06
pjp
262
2020-05-07
pjp
if (type == DNS_TYPE_RRSIG) {
263
2020-05-07
pjp
struct rrsig *rrsig = (struct rrsig *)rdata;
264
2020-05-07
pjp
rrsig->ttl = ttl;
265
2020-07-06
pjp
rrsig->created = time(NULL);
266
2020-05-07
pjp
}
267
2020-05-07
pjp
268
2019-02-19
pjp
TAILQ_INSERT_TAIL(&rrset->rr_head, myrr, entries);
269
2019-02-19
pjp
270
2019-02-15
pjp
return (rbt);
271
2019-02-15
pjp
}
272
2019-02-15
pjp
273
2019-02-15
pjp
274
2019-02-15
pjp
struct rbtree *
275
2019-02-15
pjp
find_rrset(ddDB *db, char *name, int len)
276
2019-02-15
pjp
{
277
2019-02-15
pjp
ddDBT key, data;
278
2019-02-15
pjp
279
2019-02-18
pjp
if (name == NULL || len == 0)
280
2019-02-18
pjp
return NULL;
281
2019-02-18
pjp
282
2019-02-15
pjp
memset(&key, 0, sizeof(key));
283
2019-02-15
pjp
memset(&data, 0, sizeof(data));
284
2019-02-15
pjp
285
2019-02-15
pjp
key.data = (char *)name;
286
2019-02-15
pjp
key.size = len;
287
2019-02-15
pjp
288
2019-02-15
pjp
if (db->get(db, &key, &data) != 0) {
289
2019-02-15
pjp
return (NULL);
290
2019-02-15
pjp
}
291
2019-02-15
pjp
292
2020-07-08
pjp
return ((struct rbtree *)data.data);
293
2019-02-15
pjp
}
294
2019-02-15
pjp
295
2019-02-15
pjp
296
2019-02-15
pjp
int
297
2019-02-15
pjp
add_rr(struct rbtree *rbt, char *name, int len, u_int16_t rrtype, void *rdata)
298
2019-02-15
pjp
{
299
2019-02-15
pjp
struct rrset *rp0, *rp;
300
2019-02-15
pjp
struct rr *rt;
301
2019-02-15
pjp
302
2019-02-15
pjp
TAILQ_FOREACH_SAFE(rp, &rbt->rrset_head, entries, rp0) {
303
2019-02-15
pjp
if (rrtype == rp->rrtype)
304
2019-02-15
pjp
break;
305
2019-02-15
pjp
}
306
2019-02-15
pjp
307
2019-02-15
pjp
if (rp == NULL) {
308
2019-02-15
pjp
/* the rrset doesn't exist, create it */
309
2019-02-15
pjp
rp = (struct rrset *)calloc(1, sizeof(struct rrset));
310
2019-02-15
pjp
if (! rp) {
311
2019-02-15
pjp
perror("calloc");
312
2019-02-15
pjp
return -1;
313
2019-02-15
pjp
}
314
2019-02-15
pjp
315
2019-02-15
pjp
rp->rrtype = rrtype;
316
2020-05-07
pjp
rp->ttl = 86400;
317
2019-02-15
pjp
TAILQ_INIT(&rp->rr_head);
318
2019-02-15
pjp
319
2019-02-15
pjp
TAILQ_INSERT_TAIL(&rbt->rrset_head, rp, entries);
320
2019-02-15
pjp
}
321
2019-02-15
pjp
322
2019-02-15
pjp
rt = calloc(1, sizeof(struct rr));
323
2019-02-15
pjp
if (rt == NULL) {
324
2019-02-15
pjp
perror("calloc");
325
2019-02-15
pjp
return -1;
326
2019-02-15
pjp
}
327
2019-02-15
pjp
328
2019-02-15
pjp
rt->changed = time(NULL);
329
2019-02-15
pjp
rt->rdata = rdata;
330
2019-02-15
pjp
331
2019-02-15
pjp
TAILQ_INSERT_HEAD(&rp->rr_head, rt, entries);
332
2019-02-15
pjp
333
2019-02-15
pjp
return 0;
334
2019-02-15
pjp
}
335
2019-02-15
pjp
336
2020-07-06
pjp
int
337
2020-07-08
pjp
expire_rr(ddDB *db, char *name, int len, u_int16_t rrtype, time_t now)
338
2020-07-06
pjp
{
339
2020-07-06
pjp
struct rbtree *rbt = NULL;
340
2020-07-06
pjp
struct rrset *rp;
341
2020-07-08
pjp
struct rr *rt1 = NULL, *rt2 = NULL;
342
2020-07-06
pjp
int count = 0;
343
2020-07-06
pjp
344
2020-07-06
pjp
rbt = find_rrset(db, name, len);
345
2020-07-06
pjp
if (rbt == NULL) {
346
2020-07-06
pjp
return 0;
347
2020-07-06
pjp
}
348
2020-07-06
pjp
349
2020-07-06
pjp
rp = find_rr(rbt, rrtype);
350
2020-07-06
pjp
if (rp == NULL) {
351
2020-07-06
pjp
return 0;
352
2020-07-06
pjp
}
353
2020-07-06
pjp
354
2020-07-08
pjp
#if 0
355
2020-07-06
pjp
rt = TAILQ_FIRST(&rp->rr_head);
356
2020-07-06
pjp
if (rt == NULL)
357
2020-07-06
pjp
return 0;
358
2020-07-08
pjp
#endif
359
2020-07-06
pjp
360
2020-07-06
pjp
/* expire these */
361
2020-07-06
pjp
if (rrtype != DNS_TYPE_RRSIG) {
362
2020-07-10
pjp
if (difftime(now, rp->created) >= (double)rp->ttl) {
363
2020-07-06
pjp
count = 0;
364
2020-07-08
pjp
365
2020-07-06
pjp
TAILQ_FOREACH_SAFE(rt1, &rp->rr_head, entries, rt2) {
366
2020-07-06
pjp
TAILQ_REMOVE(&rp->rr_head, rt1, entries);
367
2020-07-06
pjp
free(rt1->rdata);
368
2020-07-06
pjp
free(rt1);
369
2020-07-06
pjp
count++;
370
2020-07-06
pjp
}
371
2020-07-06
pjp
372
2020-07-08
pjp
TAILQ_REMOVE(&rbt->rrset_head, rp, entries);
373
2020-07-08
pjp
free(rp);
374
2020-07-08
pjp
375
2020-07-06
pjp
return (count);
376
2020-07-06
pjp
}
377
2020-07-06
pjp
} else {
378
2020-07-08
pjp
count = 0;
379
2020-07-08
pjp
TAILQ_FOREACH_SAFE(rt1, &rp->rr_head, entries, rt2) {
380
2020-07-08
pjp
struct rrsig *rrsig = (struct rrsig *)rt1->rdata;
381
2020-07-10
pjp
if (difftime(now, rrsig->created) >= (double)rrsig->ttl) {
382
2020-07-06
pjp
TAILQ_REMOVE(&rp->rr_head, rt1, entries);
383
2020-07-06
pjp
free(rt1->rdata);
384
2020-07-06
pjp
free(rt1);
385
2020-07-06
pjp
count++;
386
2020-07-06
pjp
}
387
2020-07-06
pjp
}
388
2020-07-08
pjp
389
2020-07-08
pjp
if (TAILQ_EMPTY(&rp->rr_head)) {
390
2020-07-08
pjp
TAILQ_REMOVE(&rbt->rrset_head, rp, entries);
391
2020-07-08
pjp
free(rp);
392
2020-07-08
pjp
}
393
2020-07-08
pjp
394
2020-07-08
pjp
return (count);
395
2020-07-06
pjp
}
396
2020-07-06
pjp
397
2020-07-06
pjp
return 0;
398
2020-07-08
pjp
}
399
2020-07-08
pjp
400
2020-07-08
pjp
int
401
2020-07-08
pjp
expire_db(ddDB *db, int all)
402
2020-07-08
pjp
{
403
2020-07-08
pjp
struct node *walk, *walk0;
404
2020-07-08
pjp
struct rbtree *rbt = NULL;
405
2020-07-08
pjp
struct rrset *rp, *rp0;
406
2020-07-08
pjp
int totalcount = 0, count = 0;
407
2020-07-08
pjp
time_t now;
408
2020-07-08
pjp
409
2020-07-08
pjp
if (all == 0)
410
2020-07-08
pjp
now = time(NULL);
411
2020-07-08
pjp
else
412
2020-07-08
pjp
#if __OpenBSD__
413
2020-07-10
pjp
now = 4000000000; /* Tue Oct 2 09:06:40 CEST 2096 hbdM */
414
2020-07-10
pjp
415
2020-07-08
pjp
#else
416
2020-07-08
pjp
now = 2147483647;
417
2020-07-08
pjp
#endif
418
2020-07-08
pjp
419
2020-07-08
pjp
RB_FOREACH_SAFE(walk, domaintree, &db->head, walk0) {
420
2020-07-08
pjp
rbt = (struct rbtree *)walk->data;
421
2020-07-08
pjp
if (rbt == NULL)
422
2020-07-08
pjp
continue;
423
2020-07-08
pjp
424
2020-07-08
pjp
TAILQ_FOREACH_SAFE(rp, &rbt->rrset_head, entries, rp0) {
425
2020-07-08
pjp
count = expire_rr(db, rbt->zone, rbt->zonelen, \
426
2020-07-08
pjp
rp->rrtype, now);
427
2020-07-08
pjp
428
2020-07-08
pjp
totalcount += count;
429
2020-07-08
pjp
}
430
2020-07-27
pjp
431
2020-07-27
pjp
RB_REMOVE(domaintree, &db->head, walk);
432
2020-07-27
pjp
free(walk);
433
2020-07-08
pjp
}
434
2020-07-08
pjp
435
2020-07-08
pjp
return (totalcount);
436
2020-07-06
pjp
}
437
2020-07-06
pjp
438
2019-11-02
pjp
struct rrset *
439
2019-11-02
pjp
find_rr(struct rbtree *rbt, u_int16_t rrtype)
440
2019-11-02
pjp
{
441
2019-11-02
pjp
struct rrset *rp = NULL, *rp0 = NULL;
442
2020-07-06
pjp
443
2020-07-06
pjp
if (TAILQ_EMPTY(&rbt->rrset_head))
444
2020-07-06
pjp
return NULL;
445
2020-05-07
pjp
446
2019-11-02
pjp
TAILQ_FOREACH_SAFE(rp, &rbt->rrset_head, entries, rp0) {
447
2019-02-15
pjp
if (rrtype == rp->rrtype)
448
2019-02-15
pjp
break;
449
2019-02-15
pjp
}
450
2019-02-15
pjp
451
2019-02-15
pjp
return (rp);
452
2019-02-15
pjp
}
453
2019-02-15
pjp
454
2019-04-07
pjp
void
455
2019-04-07
pjp
flag_rr(struct rbtree *rbt)
456
2019-04-07
pjp
{
457
2019-11-11
pjp
rbt->flags |= RBT_DNSSEC;
458
2019-04-07
pjp
}
459
2019-04-07
pjp
460
2019-02-15
pjp
int
461
2019-02-15
pjp
display_rr(struct rrset *rrset)
462
2019-02-15
pjp
{
463
2019-02-15
pjp
struct rr *rrp, *rrp0;
464
2019-02-15
pjp
465
2019-02-15
pjp
TAILQ_FOREACH_SAFE(rrp, &rrset->rr_head, entries, rrp0) {
466
2020-01-14
pjp
#if __linux__
467
2020-05-07
pjp
printf("%ld:%u:%s\n", rrp->changed, rrset->ttl, (char *)rrp->rdata);
468
2020-01-14
pjp
#else
469
2020-05-07
pjp
printf("%lld:%u:%s\n", rrp->changed, rrset->ttl, (char *)rrp->rdata);
470
2019-04-25
pjp
#endif
471
2019-02-15
pjp
}
472
2019-02-15
pjp
473
2019-02-15
pjp
return 0;
474
2019-02-15
pjp
}
475
2019-02-15
pjp
476
2019-02-15
pjp
int
477
2019-02-15
pjp
rotate_rr(struct rrset *rrset)
478
2019-02-15
pjp
{
479
2019-02-15
pjp
struct rr *rrp;
480
2019-02-15
pjp
481
2019-02-15
pjp
rrp = TAILQ_LAST(&rrset->rr_head, rrh);
482
2019-02-15
pjp
if (rrp == NULL)
483
2019-02-15
pjp
return -1;
484
2019-02-15
pjp
485
2019-02-15
pjp
TAILQ_REMOVE(&rrset->rr_head, rrp, entries);
486
2019-02-15
pjp
TAILQ_INSERT_HEAD(&rrset->rr_head, rrp, entries);
487
2019-02-15
pjp
488
2017-06-26
pjp
return 0;
489
2017-06-26
pjp
}
repomaster@centroid.eu