OpenDNSSEC-enforcer 2.1.12
zone_db.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Jerry Lundström <lundstrom.jerry@gmail.com>
3 * Copyright (c) 2014 .SE (The Internet Infrastructure Foundation).
4 * Copyright (c) 2014 OpenDNSSEC AB (svb)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 */
29
30#include "zone_db.h"
31#include "db_error.h"
32
33
34#include <string.h>
35
41static db_object_t* __zone_db_new_object(const db_connection_t* connection) {
42 db_object_field_list_t* object_field_list;
43 db_object_field_t* object_field;
44 db_object_t* object;
45
46 if (!(object = db_object_new())
47 || db_object_set_connection(object, connection)
48 || db_object_set_table(object, "zone")
49 || db_object_set_primary_key_name(object, "id")
50 || !(object_field_list = db_object_field_list_new()))
51 {
52 db_object_free(object);
53 return NULL;
54 }
55
56 if (!(object_field = db_object_field_new())
57 || db_object_field_set_name(object_field, "id")
59 || db_object_field_list_add(object_field_list, object_field))
60 {
61 db_object_field_free(object_field);
62 db_object_field_list_free(object_field_list);
63 db_object_free(object);
64 return NULL;
65 }
66
67 if (!(object_field = db_object_field_new())
68 || db_object_field_set_name(object_field, "rev")
70 || db_object_field_list_add(object_field_list, object_field))
71 {
72 db_object_field_free(object_field);
73 db_object_field_list_free(object_field_list);
74 db_object_free(object);
75 return NULL;
76 }
77
78 if (!(object_field = db_object_field_new())
79 || db_object_field_set_name(object_field, "policyId")
81 || db_object_field_list_add(object_field_list, object_field))
82 {
83 db_object_field_free(object_field);
84 db_object_field_list_free(object_field_list);
85 db_object_free(object);
86 return NULL;
87 }
88
89 if (!(object_field = db_object_field_new())
90 || db_object_field_set_name(object_field, "name")
92 || db_object_field_list_add(object_field_list, object_field))
93 {
94 db_object_field_free(object_field);
95 db_object_field_list_free(object_field_list);
96 db_object_free(object);
97 return NULL;
98 }
99
100 if (!(object_field = db_object_field_new())
101 || db_object_field_set_name(object_field, "signconfNeedsWriting")
103 || db_object_field_list_add(object_field_list, object_field))
104 {
105 db_object_field_free(object_field);
106 db_object_field_list_free(object_field_list);
107 db_object_free(object);
108 return NULL;
109 }
110
111 if (!(object_field = db_object_field_new())
112 || db_object_field_set_name(object_field, "signconfPath")
113 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
114 || db_object_field_list_add(object_field_list, object_field))
115 {
116 db_object_field_free(object_field);
117 db_object_field_list_free(object_field_list);
118 db_object_free(object);
119 return NULL;
120 }
121
122 if (!(object_field = db_object_field_new())
123 || db_object_field_set_name(object_field, "nextChange")
125 || db_object_field_list_add(object_field_list, object_field))
126 {
127 db_object_field_free(object_field);
128 db_object_field_list_free(object_field_list);
129 db_object_free(object);
130 return NULL;
131 }
132
133 if (!(object_field = db_object_field_new())
134 || db_object_field_set_name(object_field, "ttlEndDs")
136 || db_object_field_list_add(object_field_list, object_field))
137 {
138 db_object_field_free(object_field);
139 db_object_field_list_free(object_field_list);
140 db_object_free(object);
141 return NULL;
142 }
143
144 if (!(object_field = db_object_field_new())
145 || db_object_field_set_name(object_field, "ttlEndDk")
147 || db_object_field_list_add(object_field_list, object_field))
148 {
149 db_object_field_free(object_field);
150 db_object_field_list_free(object_field_list);
151 db_object_free(object);
152 return NULL;
153 }
154
155 if (!(object_field = db_object_field_new())
156 || db_object_field_set_name(object_field, "ttlEndRs")
158 || db_object_field_list_add(object_field_list, object_field))
159 {
160 db_object_field_free(object_field);
161 db_object_field_list_free(object_field_list);
162 db_object_free(object);
163 return NULL;
164 }
165
166 if (!(object_field = db_object_field_new())
167 || db_object_field_set_name(object_field, "rollKskNow")
169 || db_object_field_list_add(object_field_list, object_field))
170 {
171 db_object_field_free(object_field);
172 db_object_field_list_free(object_field_list);
173 db_object_free(object);
174 return NULL;
175 }
176
177 if (!(object_field = db_object_field_new())
178 || db_object_field_set_name(object_field, "rollZskNow")
180 || db_object_field_list_add(object_field_list, object_field))
181 {
182 db_object_field_free(object_field);
183 db_object_field_list_free(object_field_list);
184 db_object_free(object);
185 return NULL;
186 }
187
188 if (!(object_field = db_object_field_new())
189 || db_object_field_set_name(object_field, "rollCskNow")
191 || db_object_field_list_add(object_field_list, object_field))
192 {
193 db_object_field_free(object_field);
194 db_object_field_list_free(object_field_list);
195 db_object_free(object);
196 return NULL;
197 }
198
199 if (!(object_field = db_object_field_new())
200 || db_object_field_set_name(object_field, "inputAdapterType")
201 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
202 || db_object_field_list_add(object_field_list, object_field))
203 {
204 db_object_field_free(object_field);
205 db_object_field_list_free(object_field_list);
206 db_object_free(object);
207 return NULL;
208 }
209
210 if (!(object_field = db_object_field_new())
211 || db_object_field_set_name(object_field, "inputAdapterUri")
212 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
213 || db_object_field_list_add(object_field_list, object_field))
214 {
215 db_object_field_free(object_field);
216 db_object_field_list_free(object_field_list);
217 db_object_free(object);
218 return NULL;
219 }
220
221 if (!(object_field = db_object_field_new())
222 || db_object_field_set_name(object_field, "outputAdapterType")
223 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
224 || db_object_field_list_add(object_field_list, object_field))
225 {
226 db_object_field_free(object_field);
227 db_object_field_list_free(object_field_list);
228 db_object_free(object);
229 return NULL;
230 }
231
232 if (!(object_field = db_object_field_new())
233 || db_object_field_set_name(object_field, "outputAdapterUri")
234 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
235 || db_object_field_list_add(object_field_list, object_field))
236 {
237 db_object_field_free(object_field);
238 db_object_field_list_free(object_field_list);
239 db_object_free(object);
240 return NULL;
241 }
242
243 if (!(object_field = db_object_field_new())
244 || db_object_field_set_name(object_field, "nextKskRoll")
246 || db_object_field_list_add(object_field_list, object_field))
247 {
248 db_object_field_free(object_field);
249 db_object_field_list_free(object_field_list);
250 db_object_free(object);
251 return NULL;
252 }
253
254 if (!(object_field = db_object_field_new())
255 || db_object_field_set_name(object_field, "nextZskRoll")
257 || db_object_field_list_add(object_field_list, object_field))
258 {
259 db_object_field_free(object_field);
260 db_object_field_list_free(object_field_list);
261 db_object_free(object);
262 return NULL;
263 }
264
265 if (!(object_field = db_object_field_new())
266 || db_object_field_set_name(object_field, "nextCskRoll")
268 || db_object_field_list_add(object_field_list, object_field))
269 {
270 db_object_field_free(object_field);
271 db_object_field_list_free(object_field_list);
272 db_object_free(object);
273 return NULL;
274 }
275
276 if (db_object_set_object_field_list(object, object_field_list)) {
277 db_object_field_list_free(object_field_list);
278 db_object_free(object);
279 return NULL;
280 }
281
282 return object;
283}
284
285/* ZONE */
286
288 zone_db_t* zone =
289 (zone_db_t*)calloc(1, sizeof(zone_db_t));
290
291 if (zone) {
292 if (!(zone->dbo = __zone_db_new_object(connection))) {
293 free(zone);
294 return NULL;
295 }
296 db_value_reset(&(zone->id));
297 db_value_reset(&(zone->rev));
298 db_value_reset(&(zone->policy_id));
299 zone->input_adapter_type = strdup("File");
300 zone->output_adapter_type = strdup("File");
301 }
302
303 return zone;
304}
305
307 zone_db_t* new_zone;
308
309 if (!zone) {
310 return NULL;
311 }
312 if (!zone->dbo) {
313 return NULL;
314 }
315
316 if (!(new_zone = zone_db_new(db_object_connection(zone->dbo)))
317 || zone_db_copy(new_zone, zone))
318 {
319 zone_db_free(new_zone);
320 return NULL;
321 }
322 return new_zone;
323}
324
326 if (zone) {
327 if (zone->dbo) {
328 db_object_free(zone->dbo);
329 }
330 db_value_reset(&(zone->id));
331 db_value_reset(&(zone->rev));
332 db_value_reset(&(zone->policy_id));
333 if (zone->private_policy_id) {
335 }
336 if (zone->name) {
337 free(zone->name);
338 }
339 if (zone->signconf_path) {
340 free(zone->signconf_path);
341 }
342 if (zone->input_adapter_type) {
343 free(zone->input_adapter_type);
344 }
345 if (zone->input_adapter_uri) {
346 free(zone->input_adapter_uri);
347 }
348 if (zone->output_adapter_type) {
349 free(zone->output_adapter_type);
350 }
351 if (zone->output_adapter_uri) {
352 free(zone->output_adapter_uri);
353 }
354 if (zone->key_data_list) {
356 }
357 if (zone->key_dependency_list) {
359 }
360 free(zone);
361 }
362}
363
364
365int zone_db_copy(zone_db_t* zone, const zone_db_t* zone_copy) {
366 char* name_text = NULL;
367 char* signconf_path_text = NULL;
368 char* input_adapter_type_text = NULL;
369 char* input_adapter_uri_text = NULL;
370 char* output_adapter_type_text = NULL;
371 char* output_adapter_uri_text = NULL;
372
373 if (!zone) {
374 return DB_ERROR_UNKNOWN;
375 }
376 if (!zone_copy) {
377 return DB_ERROR_UNKNOWN;
378 }
379
380 if (zone_copy->name) {
381 if (!(name_text = strdup(zone_copy->name))) {
382 return DB_ERROR_UNKNOWN;
383 }
384 }
385 if (zone_copy->signconf_path) {
386 if (!(signconf_path_text = strdup(zone_copy->signconf_path))) {
387 if (name_text) {
388 free(name_text);
389 }
390 return DB_ERROR_UNKNOWN;
391 }
392 }
393 if (zone_copy->input_adapter_type) {
394 if (!(input_adapter_type_text = strdup(zone_copy->input_adapter_type))) {
395 if (name_text) {
396 free(name_text);
397 }
398 if (signconf_path_text) {
399 free(signconf_path_text);
400 }
401 return DB_ERROR_UNKNOWN;
402 }
403 }
404 if (zone_copy->input_adapter_uri) {
405 if (!(input_adapter_uri_text = strdup(zone_copy->input_adapter_uri))) {
406 if (name_text) {
407 free(name_text);
408 }
409 if (signconf_path_text) {
410 free(signconf_path_text);
411 }
412 if (input_adapter_type_text) {
413 free(input_adapter_type_text);
414 }
415 return DB_ERROR_UNKNOWN;
416 }
417 }
418 if (zone_copy->output_adapter_type) {
419 if (!(output_adapter_type_text = strdup(zone_copy->output_adapter_type))) {
420 if (name_text) {
421 free(name_text);
422 }
423 if (signconf_path_text) {
424 free(signconf_path_text);
425 }
426 if (input_adapter_type_text) {
427 free(input_adapter_type_text);
428 }
429 if (input_adapter_uri_text) {
430 free(input_adapter_uri_text);
431 }
432 return DB_ERROR_UNKNOWN;
433 }
434 }
435 if (zone_copy->output_adapter_uri) {
436 if (!(output_adapter_uri_text = strdup(zone_copy->output_adapter_uri))) {
437 if (name_text) {
438 free(name_text);
439 }
440 if (signconf_path_text) {
441 free(signconf_path_text);
442 }
443 if (input_adapter_type_text) {
444 free(input_adapter_type_text);
445 }
446 if (input_adapter_uri_text) {
447 free(input_adapter_uri_text);
448 }
449 if (output_adapter_type_text) {
450 free(output_adapter_type_text);
451 }
452 return DB_ERROR_UNKNOWN;
453 }
454 }
455 if (db_value_copy(&(zone->id), &(zone_copy->id))) {
456 if (name_text) {
457 free(name_text);
458 }
459 if (signconf_path_text) {
460 free(signconf_path_text);
461 }
462 if (input_adapter_type_text) {
463 free(input_adapter_type_text);
464 }
465 if (input_adapter_uri_text) {
466 free(input_adapter_uri_text);
467 }
468 if (output_adapter_type_text) {
469 free(output_adapter_type_text);
470 }
471 if (output_adapter_uri_text) {
472 free(output_adapter_uri_text);
473 }
474 return DB_ERROR_UNKNOWN;
475 }
476 if (db_value_copy(&(zone->rev), &(zone_copy->rev))) {
477 if (name_text) {
478 free(name_text);
479 }
480 if (signconf_path_text) {
481 free(signconf_path_text);
482 }
483 if (input_adapter_type_text) {
484 free(input_adapter_type_text);
485 }
486 if (input_adapter_uri_text) {
487 free(input_adapter_uri_text);
488 }
489 if (output_adapter_type_text) {
490 free(output_adapter_type_text);
491 }
492 if (output_adapter_uri_text) {
493 free(output_adapter_uri_text);
494 }
495 return DB_ERROR_UNKNOWN;
496 }
497 if (db_value_copy(&(zone->policy_id), &(zone_copy->policy_id))) {
498 if (name_text) {
499 free(name_text);
500 }
501 if (signconf_path_text) {
502 free(signconf_path_text);
503 }
504 if (input_adapter_type_text) {
505 free(input_adapter_type_text);
506 }
507 if (input_adapter_uri_text) {
508 free(input_adapter_uri_text);
509 }
510 if (output_adapter_type_text) {
511 free(output_adapter_type_text);
512 }
513 if (output_adapter_uri_text) {
514 free(output_adapter_uri_text);
515 }
516 return DB_ERROR_UNKNOWN;
517 }
518 if (zone->private_policy_id) {
520 zone->private_policy_id = NULL;
521 }
522 if (zone_copy->private_policy_id
523 && !(zone->private_policy_id = policy_new_copy(zone_copy->private_policy_id)))
524 {
525 if (name_text) {
526 free(name_text);
527 }
528 if (signconf_path_text) {
529 free(signconf_path_text);
530 }
531 if (input_adapter_type_text) {
532 free(input_adapter_type_text);
533 }
534 if (input_adapter_uri_text) {
535 free(input_adapter_uri_text);
536 }
537 if (output_adapter_type_text) {
538 free(output_adapter_type_text);
539 }
540 if (output_adapter_uri_text) {
541 free(output_adapter_uri_text);
542 }
543 return DB_ERROR_UNKNOWN;
544 }
545 zone->associated_policy_id = NULL;
546 if (!zone_copy->private_policy_id
547 && zone_copy->associated_policy_id
549 {
550 if (name_text) {
551 free(name_text);
552 }
553 if (signconf_path_text) {
554 free(signconf_path_text);
555 }
556 if (input_adapter_type_text) {
557 free(input_adapter_type_text);
558 }
559 if (input_adapter_uri_text) {
560 free(input_adapter_uri_text);
561 }
562 if (output_adapter_type_text) {
563 free(output_adapter_type_text);
564 }
565 if (output_adapter_uri_text) {
566 free(output_adapter_uri_text);
567 }
568 return DB_ERROR_UNKNOWN;
569 }
570 if (zone->key_data_list) {
572 zone->key_data_list = NULL;
573 }
574 if (zone_copy->key_data_list
575 && !(zone->key_data_list = key_data_list_new_copy(zone_copy->key_data_list)))
576 {
577 if (name_text) {
578 free(name_text);
579 }
580 if (signconf_path_text) {
581 free(signconf_path_text);
582 }
583 if (input_adapter_type_text) {
584 free(input_adapter_type_text);
585 }
586 if (input_adapter_uri_text) {
587 free(input_adapter_uri_text);
588 }
589 if (output_adapter_type_text) {
590 free(output_adapter_type_text);
591 }
592 if (output_adapter_uri_text) {
593 free(output_adapter_uri_text);
594 }
595 return DB_ERROR_UNKNOWN;
596 }
597 if (zone->key_dependency_list) {
599 zone->key_dependency_list = NULL;
600 }
601 if (zone_copy->key_dependency_list
603 {
604 if (name_text) {
605 free(name_text);
606 }
607 if (signconf_path_text) {
608 free(signconf_path_text);
609 }
610 if (input_adapter_type_text) {
611 free(input_adapter_type_text);
612 }
613 if (input_adapter_uri_text) {
614 free(input_adapter_uri_text);
615 }
616 if (output_adapter_type_text) {
617 free(output_adapter_type_text);
618 }
619 if (output_adapter_uri_text) {
620 free(output_adapter_uri_text);
621 }
622 return DB_ERROR_UNKNOWN;
623 }
624 if (zone->name) {
625 free(zone->name);
626 }
627 zone->name = name_text;
629 if (zone->signconf_path) {
630 free(zone->signconf_path);
631 }
632 zone->signconf_path = signconf_path_text;
633 zone->next_change = zone_copy->next_change;
634 zone->ttl_end_ds = zone_copy->ttl_end_ds;
635 zone->ttl_end_dk = zone_copy->ttl_end_dk;
636 zone->ttl_end_rs = zone_copy->ttl_end_rs;
637 zone->roll_ksk_now = zone_copy->roll_ksk_now;
638 zone->roll_zsk_now = zone_copy->roll_zsk_now;
639 zone->roll_csk_now = zone_copy->roll_csk_now;
640 if (zone->input_adapter_type) {
641 free(zone->input_adapter_type);
642 }
643 zone->input_adapter_type = input_adapter_type_text;
644 if (zone->input_adapter_uri) {
645 free(zone->input_adapter_uri);
646 }
647 zone->input_adapter_uri = input_adapter_uri_text;
648 if (zone->output_adapter_type) {
649 free(zone->output_adapter_type);
650 }
651 zone->output_adapter_type = output_adapter_type_text;
652 if (zone->output_adapter_uri) {
653 free(zone->output_adapter_uri);
654 }
655 zone->output_adapter_uri = output_adapter_uri_text;
656 zone->next_ksk_roll = zone_copy->next_ksk_roll;
657 zone->next_zsk_roll = zone_copy->next_zsk_roll;
658 zone->next_csk_roll = zone_copy->next_csk_roll;
659 return DB_OK;
660}
661
662int zone_db_from_result(zone_db_t* zone, const db_result_t* result) {
663 const db_value_set_t* value_set;
664
665 if (!zone) {
666 return DB_ERROR_UNKNOWN;
667 }
668 if (!result) {
669 return DB_ERROR_UNKNOWN;
670 }
671
672 db_value_reset(&(zone->id));
673 db_value_reset(&(zone->rev));
674 db_value_reset(&(zone->policy_id));
675 if (zone->name) {
676 free(zone->name);
677 }
678 zone->name = NULL;
679 if (zone->signconf_path) {
680 free(zone->signconf_path);
681 }
682 zone->signconf_path = NULL;
683 if (zone->input_adapter_type) {
684 free(zone->input_adapter_type);
685 }
686 zone->input_adapter_type = NULL;
687 if (zone->input_adapter_uri) {
688 free(zone->input_adapter_uri);
689 }
690 zone->input_adapter_uri = NULL;
691 if (zone->output_adapter_type) {
692 free(zone->output_adapter_type);
693 }
694 zone->output_adapter_type = NULL;
695 if (zone->output_adapter_uri) {
696 free(zone->output_adapter_uri);
697 }
698 zone->output_adapter_uri = NULL;
699 if (!(value_set = db_result_value_set(result))
700 || db_value_set_size(value_set) != 20
701 || db_value_copy(&(zone->id), db_value_set_at(value_set, 0))
702 || db_value_copy(&(zone->rev), db_value_set_at(value_set, 1))
703 || db_value_copy(&(zone->policy_id), db_value_set_at(value_set, 2))
704 || db_value_to_text(db_value_set_at(value_set, 3), &(zone->name))
706 || db_value_to_text(db_value_set_at(value_set, 5), &(zone->signconf_path))
707 || db_value_to_int32(db_value_set_at(value_set, 6), &(zone->next_change))
708 || db_value_to_uint32(db_value_set_at(value_set, 7), &(zone->ttl_end_ds))
709 || db_value_to_uint32(db_value_set_at(value_set, 8), &(zone->ttl_end_dk))
710 || db_value_to_uint32(db_value_set_at(value_set, 9), &(zone->ttl_end_rs))
711 || db_value_to_uint32(db_value_set_at(value_set, 10), &(zone->roll_ksk_now))
712 || db_value_to_uint32(db_value_set_at(value_set, 11), &(zone->roll_zsk_now))
713 || db_value_to_uint32(db_value_set_at(value_set, 12), &(zone->roll_csk_now))
714 || db_value_to_text(db_value_set_at(value_set, 13), &(zone->input_adapter_type))
715 || db_value_to_text(db_value_set_at(value_set, 14), &(zone->input_adapter_uri))
716 || db_value_to_text(db_value_set_at(value_set, 15), &(zone->output_adapter_type))
717 || db_value_to_text(db_value_set_at(value_set, 16), &(zone->output_adapter_uri))
718 || db_value_to_uint32(db_value_set_at(value_set, 17), &(zone->next_ksk_roll))
719 || db_value_to_uint32(db_value_set_at(value_set, 18), &(zone->next_zsk_roll))
720 || db_value_to_uint32(db_value_set_at(value_set, 19), &(zone->next_csk_roll)))
721 {
722 return DB_ERROR_UNKNOWN;
723 }
724
725 return DB_OK;
726}
727
728const db_value_t* zone_db_id(const zone_db_t* zone) {
729 if (!zone) {
730 return NULL;
731 }
732
733 return &(zone->id);
734}
735
737 if (!zone) {
738 return NULL;
739 }
740
741 return &(zone->policy_id);
742}
743
745 policy_t* policy_id = NULL;
746
747 if (!zone) {
748 return NULL;
749 }
750 if (!zone->dbo) {
751 return NULL;
752 }
753 if (db_value_not_empty(&(zone->policy_id))) {
754 return NULL;
755 }
756
757 if (!(policy_id = policy_new(db_object_connection(zone->dbo)))) {
758 return NULL;
759 }
760 if (zone->private_policy_id) {
763 return NULL;
764 }
765 }
766 else if (zone->associated_policy_id) {
769 return NULL;
770 }
771 }
772 else {
773 if (policy_get_by_id(policy_id, &(zone->policy_id))) {
775 return NULL;
776 }
777 }
778
779 return policy_id;
780}
781
782const char* zone_db_name(const zone_db_t* zone) {
783 if (!zone) {
784 return NULL;
785 }
786
787 return zone->name;
788}
789
790unsigned int zone_db_signconf_needs_writing(const zone_db_t* zone) {
791 if (!zone) {
792 return 0;
793 }
794
795 return zone->signconf_needs_writing;
796}
797
798const char* zone_db_signconf_path(const zone_db_t* zone) {
799 if (!zone) {
800 return NULL;
801 }
802
803 return zone->signconf_path;
804}
805
807 if (!zone) {
808 return 0;
809 }
810
811 return zone->next_change;
812}
813
814unsigned int zone_db_ttl_end_ds(const zone_db_t* zone) {
815 if (!zone) {
816 return 0;
817 }
818
819 return zone->ttl_end_ds;
820}
821
822unsigned int zone_db_ttl_end_dk(const zone_db_t* zone) {
823 if (!zone) {
824 return 0;
825 }
826
827 return zone->ttl_end_dk;
828}
829
830unsigned int zone_db_ttl_end_rs(const zone_db_t* zone) {
831 if (!zone) {
832 return 0;
833 }
834
835 return zone->ttl_end_rs;
836}
837
838unsigned int zone_db_roll_ksk_now(const zone_db_t* zone) {
839 if (!zone) {
840 return 0;
841 }
842
843 return zone->roll_ksk_now;
844}
845
846unsigned int zone_db_roll_zsk_now(const zone_db_t* zone) {
847 if (!zone) {
848 return 0;
849 }
850
851 return zone->roll_zsk_now;
852}
853
854unsigned int zone_db_roll_csk_now(const zone_db_t* zone) {
855 if (!zone) {
856 return 0;
857 }
858
859 return zone->roll_csk_now;
860}
861
862const char* zone_db_input_adapter_type(const zone_db_t* zone) {
863 if (!zone) {
864 return NULL;
865 }
866
867 return zone->input_adapter_type;
868}
869
870const char* zone_db_input_adapter_uri(const zone_db_t* zone) {
871 if (!zone) {
872 return NULL;
873 }
874
875 return zone->input_adapter_uri;
876}
877
878const char* zone_db_output_adapter_type(const zone_db_t* zone) {
879 if (!zone) {
880 return NULL;
881 }
882
883 return zone->output_adapter_type;
884}
885
886const char* zone_db_output_adapter_uri(const zone_db_t* zone) {
887 if (!zone) {
888 return NULL;
889 }
890
891 return zone->output_adapter_uri;
892}
893
894unsigned int zone_db_next_ksk_roll(const zone_db_t* zone) {
895 if (!zone) {
896 return 0;
897 }
898
899 return zone->next_ksk_roll;
900}
901
902unsigned int zone_db_next_zsk_roll(const zone_db_t* zone) {
903 if (!zone) {
904 return 0;
905 }
906
907 return zone->next_zsk_roll;
908}
909
910unsigned int zone_db_next_csk_roll(const zone_db_t* zone) {
911 if (!zone) {
912 return 0;
913 }
914
915 return zone->next_csk_roll;
916}
917
919 if (!zone) {
920 return DB_ERROR_UNKNOWN;
921 }
922 if (!policy_id) {
923 return DB_ERROR_UNKNOWN;
924 }
926 return DB_ERROR_UNKNOWN;
927 }
928
929 db_value_reset(&(zone->policy_id));
930 if (db_value_copy(&(zone->policy_id), policy_id)) {
931 return DB_ERROR_UNKNOWN;
932 }
933
934 return DB_OK;
935}
936
937int zone_db_set_name(zone_db_t* zone, const char* name_text) {
938 char* new_name;
939
940 if (!zone) {
941 return DB_ERROR_UNKNOWN;
942 }
943 if (!name_text) {
944 return DB_ERROR_UNKNOWN;
945 }
946
947 if (!(new_name = strdup(name_text))) {
948 return DB_ERROR_UNKNOWN;
949 }
950
951 if (zone->name) {
952 free(zone->name);
953 }
954 zone->name = new_name;
955
956 return DB_OK;
957}
958
959int zone_db_set_signconf_needs_writing(zone_db_t* zone, unsigned int signconf_needs_writing) {
960 if (!zone) {
961 return DB_ERROR_UNKNOWN;
962 }
963
964 zone->signconf_needs_writing = signconf_needs_writing;
965
966 return DB_OK;
967}
968
969int zone_db_set_signconf_path(zone_db_t* zone, const char* signconf_path_text) {
970 char* new_signconf_path;
971
972 if (!zone) {
973 return DB_ERROR_UNKNOWN;
974 }
975 if (!signconf_path_text) {
976 return DB_ERROR_UNKNOWN;
977 }
978
979 if (!(new_signconf_path = strdup(signconf_path_text))) {
980 return DB_ERROR_UNKNOWN;
981 }
982
983 if (zone->signconf_path) {
984 free(zone->signconf_path);
985 }
986 zone->signconf_path = new_signconf_path;
987
988 return DB_OK;
989}
990
991int zone_db_set_next_change(zone_db_t* zone, int next_change) {
992 if (!zone) {
993 return DB_ERROR_UNKNOWN;
994 }
995
996 zone->next_change = next_change;
997
998 return DB_OK;
999}
1000
1001int zone_db_set_ttl_end_ds(zone_db_t* zone, unsigned int ttl_end_ds) {
1002 if (!zone) {
1003 return DB_ERROR_UNKNOWN;
1004 }
1005
1006 zone->ttl_end_ds = ttl_end_ds;
1007
1008 return DB_OK;
1009}
1010
1011int zone_db_set_ttl_end_dk(zone_db_t* zone, unsigned int ttl_end_dk) {
1012 if (!zone) {
1013 return DB_ERROR_UNKNOWN;
1014 }
1015
1016 zone->ttl_end_dk = ttl_end_dk;
1017
1018 return DB_OK;
1019}
1020
1021int zone_db_set_ttl_end_rs(zone_db_t* zone, unsigned int ttl_end_rs) {
1022 if (!zone) {
1023 return DB_ERROR_UNKNOWN;
1024 }
1025
1026 zone->ttl_end_rs = ttl_end_rs;
1027
1028 return DB_OK;
1029}
1030
1031int zone_db_set_roll_ksk_now(zone_db_t* zone, unsigned int roll_ksk_now) {
1032 if (!zone) {
1033 return DB_ERROR_UNKNOWN;
1034 }
1035
1036 zone->roll_ksk_now = roll_ksk_now;
1037
1038 return DB_OK;
1039}
1040
1041int zone_db_set_roll_zsk_now(zone_db_t* zone, unsigned int roll_zsk_now) {
1042 if (!zone) {
1043 return DB_ERROR_UNKNOWN;
1044 }
1045
1046 zone->roll_zsk_now = roll_zsk_now;
1047
1048 return DB_OK;
1049}
1050
1051int zone_db_set_roll_csk_now(zone_db_t* zone, unsigned int roll_csk_now) {
1052 if (!zone) {
1053 return DB_ERROR_UNKNOWN;
1054 }
1055
1056 zone->roll_csk_now = roll_csk_now;
1057
1058 return DB_OK;
1059}
1060
1061int zone_db_set_input_adapter_type(zone_db_t* zone, const char* input_adapter_type_text) {
1062 char* new_input_adapter_type;
1063
1064 if (!zone) {
1065 return DB_ERROR_UNKNOWN;
1066 }
1067 if (!input_adapter_type_text) {
1068 return DB_ERROR_UNKNOWN;
1069 }
1070
1071 if (!(new_input_adapter_type = strdup(input_adapter_type_text))) {
1072 return DB_ERROR_UNKNOWN;
1073 }
1074
1075 if (zone->input_adapter_type) {
1076 free(zone->input_adapter_type);
1077 }
1078 zone->input_adapter_type = new_input_adapter_type;
1079
1080 return DB_OK;
1081}
1082
1083int zone_db_set_input_adapter_uri(zone_db_t* zone, const char* input_adapter_uri_text) {
1084 char* new_input_adapter_uri;
1085
1086 if (!zone) {
1087 return DB_ERROR_UNKNOWN;
1088 }
1089 if (!input_adapter_uri_text) {
1090 return DB_ERROR_UNKNOWN;
1091 }
1092
1093 if (!(new_input_adapter_uri = strdup(input_adapter_uri_text))) {
1094 return DB_ERROR_UNKNOWN;
1095 }
1096
1097 if (zone->input_adapter_uri) {
1098 free(zone->input_adapter_uri);
1099 }
1100 zone->input_adapter_uri = new_input_adapter_uri;
1101
1102 return DB_OK;
1103}
1104
1105int zone_db_set_output_adapter_type(zone_db_t* zone, const char* output_adapter_type_text) {
1106 char* new_output_adapter_type;
1107
1108 if (!zone) {
1109 return DB_ERROR_UNKNOWN;
1110 }
1111 if (!output_adapter_type_text) {
1112 return DB_ERROR_UNKNOWN;
1113 }
1114
1115 if (!(new_output_adapter_type = strdup(output_adapter_type_text))) {
1116 return DB_ERROR_UNKNOWN;
1117 }
1118
1119 if (zone->output_adapter_type) {
1120 free(zone->output_adapter_type);
1121 }
1122 zone->output_adapter_type = new_output_adapter_type;
1123
1124 return DB_OK;
1125}
1126
1127int zone_db_set_output_adapter_uri(zone_db_t* zone, const char* output_adapter_uri_text) {
1128 char* new_output_adapter_uri;
1129
1130 if (!zone) {
1131 return DB_ERROR_UNKNOWN;
1132 }
1133 if (!output_adapter_uri_text) {
1134 return DB_ERROR_UNKNOWN;
1135 }
1136
1137 if (!(new_output_adapter_uri = strdup(output_adapter_uri_text))) {
1138 return DB_ERROR_UNKNOWN;
1139 }
1140
1141 if (zone->output_adapter_uri) {
1142 free(zone->output_adapter_uri);
1143 }
1144 zone->output_adapter_uri = new_output_adapter_uri;
1145
1146 return DB_OK;
1147}
1148
1149int zone_db_set_next_ksk_roll(zone_db_t* zone, unsigned int next_ksk_roll) {
1150 if (!zone) {
1151 return DB_ERROR_UNKNOWN;
1152 }
1153
1154 zone->next_ksk_roll = next_ksk_roll;
1155
1156 return DB_OK;
1157}
1158
1159int zone_db_set_next_zsk_roll(zone_db_t* zone, unsigned int next_zsk_roll) {
1160 if (!zone) {
1161 return DB_ERROR_UNKNOWN;
1162 }
1163
1164 zone->next_zsk_roll = next_zsk_roll;
1165
1166 return DB_OK;
1167}
1168
1169int zone_db_set_next_csk_roll(zone_db_t* zone, unsigned int next_csk_roll) {
1170 if (!zone) {
1171 return DB_ERROR_UNKNOWN;
1172 }
1173
1174 zone->next_csk_roll = next_csk_roll;
1175
1176 return DB_OK;
1177}
1178
1180 db_clause_t* clause;
1181
1182 if (!clause_list) {
1183 return NULL;
1184 }
1185 if (!policy_id) {
1186 return NULL;
1187 }
1189 return NULL;
1190 }
1191
1192 if (!(clause = db_clause_new())
1193 || db_clause_set_field(clause, "policyId")
1197 || db_clause_list_add(clause_list, clause))
1198 {
1199 db_clause_free(clause);
1200 return NULL;
1201 }
1202
1203 return clause;
1204}
1205
1207 db_object_field_list_t* object_field_list;
1208 db_object_field_t* object_field;
1209 db_value_set_t* value_set;
1210 int ret;
1211
1212 if (!zone) {
1213 return DB_ERROR_UNKNOWN;
1214 }
1215 if (!zone->dbo) {
1216 return DB_ERROR_UNKNOWN;
1217 }
1218 if (!db_value_not_empty(&(zone->id))) {
1219 return DB_ERROR_UNKNOWN;
1220 }
1221 if (!db_value_not_empty(&(zone->rev))) {
1222 return DB_ERROR_UNKNOWN;
1223 }
1224 if (db_value_not_empty(&(zone->policy_id))) {
1225 return DB_ERROR_UNKNOWN;
1226 }
1227 if (!zone->name) {
1228 return DB_ERROR_UNKNOWN;
1229 }
1230 if (!zone->signconf_path) {
1231 return DB_ERROR_UNKNOWN;
1232 }
1233 if (!zone->input_adapter_type) {
1234 return DB_ERROR_UNKNOWN;
1235 }
1236 if (!zone->input_adapter_uri) {
1237 return DB_ERROR_UNKNOWN;
1238 }
1239 if (!zone->output_adapter_type) {
1240 return DB_ERROR_UNKNOWN;
1241 }
1242 if (!zone->output_adapter_uri) {
1243 return DB_ERROR_UNKNOWN;
1244 }
1245 /* TODO: validate content more */
1246
1247 if (!(object_field_list = db_object_field_list_new())) {
1248 return DB_ERROR_UNKNOWN;
1249 }
1250
1251 if (!(object_field = db_object_field_new())
1252 || db_object_field_set_name(object_field, "policyId")
1253 || db_object_field_set_type(object_field, DB_TYPE_ANY)
1254 || db_object_field_list_add(object_field_list, object_field))
1255 {
1256 db_object_field_free(object_field);
1257 db_object_field_list_free(object_field_list);
1258 return DB_ERROR_UNKNOWN;
1259 }
1260
1261 if (!(object_field = db_object_field_new())
1262 || db_object_field_set_name(object_field, "name")
1263 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1264 || db_object_field_list_add(object_field_list, object_field))
1265 {
1266 db_object_field_free(object_field);
1267 db_object_field_list_free(object_field_list);
1268 return DB_ERROR_UNKNOWN;
1269 }
1270
1271 if (!(object_field = db_object_field_new())
1272 || db_object_field_set_name(object_field, "signconfNeedsWriting")
1274 || db_object_field_list_add(object_field_list, object_field))
1275 {
1276 db_object_field_free(object_field);
1277 db_object_field_list_free(object_field_list);
1278 return DB_ERROR_UNKNOWN;
1279 }
1280
1281 if (!(object_field = db_object_field_new())
1282 || db_object_field_set_name(object_field, "signconfPath")
1283 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1284 || db_object_field_list_add(object_field_list, object_field))
1285 {
1286 db_object_field_free(object_field);
1287 db_object_field_list_free(object_field_list);
1288 return DB_ERROR_UNKNOWN;
1289 }
1290
1291 if (!(object_field = db_object_field_new())
1292 || db_object_field_set_name(object_field, "nextChange")
1293 || db_object_field_set_type(object_field, DB_TYPE_INT32)
1294 || db_object_field_list_add(object_field_list, object_field))
1295 {
1296 db_object_field_free(object_field);
1297 db_object_field_list_free(object_field_list);
1298 return DB_ERROR_UNKNOWN;
1299 }
1300
1301 if (!(object_field = db_object_field_new())
1302 || db_object_field_set_name(object_field, "ttlEndDs")
1304 || db_object_field_list_add(object_field_list, object_field))
1305 {
1306 db_object_field_free(object_field);
1307 db_object_field_list_free(object_field_list);
1308 return DB_ERROR_UNKNOWN;
1309 }
1310
1311 if (!(object_field = db_object_field_new())
1312 || db_object_field_set_name(object_field, "ttlEndDk")
1314 || db_object_field_list_add(object_field_list, object_field))
1315 {
1316 db_object_field_free(object_field);
1317 db_object_field_list_free(object_field_list);
1318 return DB_ERROR_UNKNOWN;
1319 }
1320
1321 if (!(object_field = db_object_field_new())
1322 || db_object_field_set_name(object_field, "ttlEndRs")
1324 || db_object_field_list_add(object_field_list, object_field))
1325 {
1326 db_object_field_free(object_field);
1327 db_object_field_list_free(object_field_list);
1328 return DB_ERROR_UNKNOWN;
1329 }
1330
1331 if (!(object_field = db_object_field_new())
1332 || db_object_field_set_name(object_field, "rollKskNow")
1334 || db_object_field_list_add(object_field_list, object_field))
1335 {
1336 db_object_field_free(object_field);
1337 db_object_field_list_free(object_field_list);
1338 return DB_ERROR_UNKNOWN;
1339 }
1340
1341 if (!(object_field = db_object_field_new())
1342 || db_object_field_set_name(object_field, "rollZskNow")
1344 || db_object_field_list_add(object_field_list, object_field))
1345 {
1346 db_object_field_free(object_field);
1347 db_object_field_list_free(object_field_list);
1348 return DB_ERROR_UNKNOWN;
1349 }
1350
1351 if (!(object_field = db_object_field_new())
1352 || db_object_field_set_name(object_field, "rollCskNow")
1354 || db_object_field_list_add(object_field_list, object_field))
1355 {
1356 db_object_field_free(object_field);
1357 db_object_field_list_free(object_field_list);
1358 return DB_ERROR_UNKNOWN;
1359 }
1360
1361 if (!(object_field = db_object_field_new())
1362 || db_object_field_set_name(object_field, "inputAdapterType")
1363 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1364 || db_object_field_list_add(object_field_list, object_field))
1365 {
1366 db_object_field_free(object_field);
1367 db_object_field_list_free(object_field_list);
1368 return DB_ERROR_UNKNOWN;
1369 }
1370
1371 if (!(object_field = db_object_field_new())
1372 || db_object_field_set_name(object_field, "inputAdapterUri")
1373 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1374 || db_object_field_list_add(object_field_list, object_field))
1375 {
1376 db_object_field_free(object_field);
1377 db_object_field_list_free(object_field_list);
1378 return DB_ERROR_UNKNOWN;
1379 }
1380
1381 if (!(object_field = db_object_field_new())
1382 || db_object_field_set_name(object_field, "outputAdapterType")
1383 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1384 || db_object_field_list_add(object_field_list, object_field))
1385 {
1386 db_object_field_free(object_field);
1387 db_object_field_list_free(object_field_list);
1388 return DB_ERROR_UNKNOWN;
1389 }
1390
1391 if (!(object_field = db_object_field_new())
1392 || db_object_field_set_name(object_field, "outputAdapterUri")
1393 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1394 || db_object_field_list_add(object_field_list, object_field))
1395 {
1396 db_object_field_free(object_field);
1397 db_object_field_list_free(object_field_list);
1398 return DB_ERROR_UNKNOWN;
1399 }
1400
1401 if (!(object_field = db_object_field_new())
1402 || db_object_field_set_name(object_field, "nextKskRoll")
1404 || db_object_field_list_add(object_field_list, object_field))
1405 {
1406 db_object_field_free(object_field);
1407 db_object_field_list_free(object_field_list);
1408 return DB_ERROR_UNKNOWN;
1409 }
1410
1411 if (!(object_field = db_object_field_new())
1412 || db_object_field_set_name(object_field, "nextZskRoll")
1414 || db_object_field_list_add(object_field_list, object_field))
1415 {
1416 db_object_field_free(object_field);
1417 db_object_field_list_free(object_field_list);
1418 return DB_ERROR_UNKNOWN;
1419 }
1420
1421 if (!(object_field = db_object_field_new())
1422 || db_object_field_set_name(object_field, "nextCskRoll")
1424 || db_object_field_list_add(object_field_list, object_field))
1425 {
1426 db_object_field_free(object_field);
1427 db_object_field_list_free(object_field_list);
1428 return DB_ERROR_UNKNOWN;
1429 }
1430
1431 if (!(value_set = db_value_set_new(18))) {
1432 db_object_field_list_free(object_field_list);
1433 return DB_ERROR_UNKNOWN;
1434 }
1435
1436 if (db_value_copy(db_value_set_get(value_set, 0), &(zone->policy_id))
1437 || db_value_from_text(db_value_set_get(value_set, 1), zone->name)
1439 || db_value_from_text(db_value_set_get(value_set, 3), zone->signconf_path)
1440 || db_value_from_int32(db_value_set_get(value_set, 4), zone->next_change)
1441 || db_value_from_uint32(db_value_set_get(value_set, 5), zone->ttl_end_ds)
1442 || db_value_from_uint32(db_value_set_get(value_set, 6), zone->ttl_end_dk)
1443 || db_value_from_uint32(db_value_set_get(value_set, 7), zone->ttl_end_rs)
1444 || db_value_from_uint32(db_value_set_get(value_set, 8), zone->roll_ksk_now)
1445 || db_value_from_uint32(db_value_set_get(value_set, 9), zone->roll_zsk_now)
1446 || db_value_from_uint32(db_value_set_get(value_set, 10), zone->roll_csk_now)
1448 || db_value_from_text(db_value_set_get(value_set, 12), zone->input_adapter_uri)
1451 || db_value_from_uint32(db_value_set_get(value_set, 15), zone->next_ksk_roll)
1452 || db_value_from_uint32(db_value_set_get(value_set, 16), zone->next_zsk_roll)
1453 || db_value_from_uint32(db_value_set_get(value_set, 17), zone->next_csk_roll))
1454 {
1455 db_value_set_free(value_set);
1456 db_object_field_list_free(object_field_list);
1457 return DB_ERROR_UNKNOWN;
1458 }
1459
1460 ret = db_object_create(zone->dbo, object_field_list, value_set);
1461 db_value_set_free(value_set);
1462 db_object_field_list_free(object_field_list);
1463 return ret;
1464}
1465
1467 db_clause_list_t* clause_list;
1468 db_clause_t* clause;
1469 db_result_list_t* result_list;
1470 const db_result_t* result;
1471
1472 if (!zone) {
1473 return DB_ERROR_UNKNOWN;
1474 }
1475 if (!zone->dbo) {
1476 return DB_ERROR_UNKNOWN;
1477 }
1478 if (!id) {
1479 return DB_ERROR_UNKNOWN;
1480 }
1481 if (db_value_not_empty(id)) {
1482 return DB_ERROR_UNKNOWN;
1483 }
1484
1485 if (!(clause_list = db_clause_list_new())) {
1486 return DB_ERROR_UNKNOWN;
1487 }
1488 if (!(clause = db_clause_new())
1489 || db_clause_set_field(clause, "id")
1491 || db_value_copy(db_clause_get_value(clause), id)
1492 || db_clause_list_add(clause_list, clause))
1493 {
1494 db_clause_free(clause);
1495 db_clause_list_free(clause_list);
1496 return DB_ERROR_UNKNOWN;
1497 }
1498
1499 result_list = db_object_read(zone->dbo, NULL, clause_list);
1500 db_clause_list_free(clause_list);
1501
1502 if (result_list) {
1503 result = db_result_list_next(result_list);
1504 if (result) {
1505 if (zone_db_from_result(zone, result)) {
1506 db_result_list_free(result_list);
1507 return DB_ERROR_UNKNOWN;
1508 }
1509
1510 db_result_list_free(result_list);
1511 return DB_OK;
1512 }
1513 }
1514
1515 db_result_list_free(result_list);
1516 return DB_ERROR_UNKNOWN;
1517}
1518
1519int zone_db_get_by_name(zone_db_t* zone, const char* name) {
1520 db_clause_list_t* clause_list;
1521 db_clause_t* clause;
1522 db_result_list_t* result_list;
1523 const db_result_t* result;
1524
1525 if (!zone) {
1526 return DB_ERROR_UNKNOWN;
1527 }
1528 if (!zone->dbo) {
1529 return DB_ERROR_UNKNOWN;
1530 }
1531 if (!name) {
1532 return DB_ERROR_UNKNOWN;
1533 }
1534
1535 if (!(clause_list = db_clause_list_new())) {
1536 return DB_ERROR_UNKNOWN;
1537 }
1538 if (!(clause = db_clause_new())
1539 || db_clause_set_field(clause, "name")
1541 || db_value_from_text(db_clause_get_value(clause), name)
1542 || db_clause_list_add(clause_list, clause))
1543 {
1544 db_clause_free(clause);
1545 db_clause_list_free(clause_list);
1546 return DB_ERROR_UNKNOWN;
1547 }
1548
1549 result_list = db_object_read(zone->dbo, NULL, clause_list);
1550 db_clause_list_free(clause_list);
1551
1552 if (result_list) {
1553 result = db_result_list_next(result_list);
1554 if (result) {
1555 if (zone_db_from_result(zone, result)) {
1556 db_result_list_free(result_list);
1557 return DB_ERROR_UNKNOWN;
1558 }
1559
1560 db_result_list_free(result_list);
1561 return DB_OK;
1562 }
1563 }
1564
1565 db_result_list_free(result_list);
1566 return DB_ERROR_UNKNOWN;
1567}
1568
1569zone_db_t* zone_db_new_get_by_name(const db_connection_t* connection, const char* name) {
1570 zone_db_t* zone;
1571
1572 if (!connection) {
1573 return NULL;
1574 }
1575 if (!name) {
1576 return NULL;
1577 }
1578
1579 if (!(zone = zone_db_new(connection))
1580 || zone_db_get_by_name(zone, name))
1581 {
1582 zone_db_free(zone);
1583 return NULL;
1584 }
1585
1586 return zone;
1587}
1588
1590 db_object_field_list_t* object_field_list;
1591 db_object_field_t* object_field;
1592 db_value_set_t* value_set;
1593 db_clause_list_t* clause_list;
1594 db_clause_t* clause;
1595 int ret;
1596
1597 if (!zone) {
1598 return DB_ERROR_UNKNOWN;
1599 }
1600 if (!zone->dbo) {
1601 return DB_ERROR_UNKNOWN;
1602 }
1603 if (db_value_not_empty(&(zone->id))) {
1604 return DB_ERROR_UNKNOWN;
1605 }
1606 if (db_value_not_empty(&(zone->rev))) {
1607 return DB_ERROR_UNKNOWN;
1608 }
1609 if (db_value_not_empty(&(zone->policy_id))) {
1610 return DB_ERROR_UNKNOWN;
1611 }
1612 if (!zone->name) {
1613 return DB_ERROR_UNKNOWN;
1614 }
1615 if (!zone->signconf_path) {
1616 return DB_ERROR_UNKNOWN;
1617 }
1618 if (!zone->input_adapter_type) {
1619 return DB_ERROR_UNKNOWN;
1620 }
1621 if (!zone->input_adapter_uri) {
1622 return DB_ERROR_UNKNOWN;
1623 }
1624 if (!zone->output_adapter_type) {
1625 return DB_ERROR_UNKNOWN;
1626 }
1627 if (!zone->output_adapter_uri) {
1628 return DB_ERROR_UNKNOWN;
1629 }
1630 /* TODO: validate content more */
1631
1632 if (!(object_field_list = db_object_field_list_new())) {
1633 return DB_ERROR_UNKNOWN;
1634 }
1635
1636 if (!(object_field = db_object_field_new())
1637 || db_object_field_set_name(object_field, "policyId")
1638 || db_object_field_set_type(object_field, DB_TYPE_ANY)
1639 || db_object_field_list_add(object_field_list, object_field))
1640 {
1641 db_object_field_free(object_field);
1642 db_object_field_list_free(object_field_list);
1643 return DB_ERROR_UNKNOWN;
1644 }
1645
1646 if (!(object_field = db_object_field_new())
1647 || db_object_field_set_name(object_field, "name")
1648 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1649 || db_object_field_list_add(object_field_list, object_field))
1650 {
1651 db_object_field_free(object_field);
1652 db_object_field_list_free(object_field_list);
1653 return DB_ERROR_UNKNOWN;
1654 }
1655
1656 if (!(object_field = db_object_field_new())
1657 || db_object_field_set_name(object_field, "signconfNeedsWriting")
1659 || db_object_field_list_add(object_field_list, object_field))
1660 {
1661 db_object_field_free(object_field);
1662 db_object_field_list_free(object_field_list);
1663 return DB_ERROR_UNKNOWN;
1664 }
1665
1666 if (!(object_field = db_object_field_new())
1667 || db_object_field_set_name(object_field, "signconfPath")
1668 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1669 || db_object_field_list_add(object_field_list, object_field))
1670 {
1671 db_object_field_free(object_field);
1672 db_object_field_list_free(object_field_list);
1673 return DB_ERROR_UNKNOWN;
1674 }
1675
1676 if (!(object_field = db_object_field_new())
1677 || db_object_field_set_name(object_field, "nextChange")
1678 || db_object_field_set_type(object_field, DB_TYPE_INT32)
1679 || db_object_field_list_add(object_field_list, object_field))
1680 {
1681 db_object_field_free(object_field);
1682 db_object_field_list_free(object_field_list);
1683 return DB_ERROR_UNKNOWN;
1684 }
1685
1686 if (!(object_field = db_object_field_new())
1687 || db_object_field_set_name(object_field, "ttlEndDs")
1689 || db_object_field_list_add(object_field_list, object_field))
1690 {
1691 db_object_field_free(object_field);
1692 db_object_field_list_free(object_field_list);
1693 return DB_ERROR_UNKNOWN;
1694 }
1695
1696 if (!(object_field = db_object_field_new())
1697 || db_object_field_set_name(object_field, "ttlEndDk")
1699 || db_object_field_list_add(object_field_list, object_field))
1700 {
1701 db_object_field_free(object_field);
1702 db_object_field_list_free(object_field_list);
1703 return DB_ERROR_UNKNOWN;
1704 }
1705
1706 if (!(object_field = db_object_field_new())
1707 || db_object_field_set_name(object_field, "ttlEndRs")
1709 || db_object_field_list_add(object_field_list, object_field))
1710 {
1711 db_object_field_free(object_field);
1712 db_object_field_list_free(object_field_list);
1713 return DB_ERROR_UNKNOWN;
1714 }
1715
1716 if (!(object_field = db_object_field_new())
1717 || db_object_field_set_name(object_field, "rollKskNow")
1719 || db_object_field_list_add(object_field_list, object_field))
1720 {
1721 db_object_field_free(object_field);
1722 db_object_field_list_free(object_field_list);
1723 return DB_ERROR_UNKNOWN;
1724 }
1725
1726 if (!(object_field = db_object_field_new())
1727 || db_object_field_set_name(object_field, "rollZskNow")
1729 || db_object_field_list_add(object_field_list, object_field))
1730 {
1731 db_object_field_free(object_field);
1732 db_object_field_list_free(object_field_list);
1733 return DB_ERROR_UNKNOWN;
1734 }
1735
1736 if (!(object_field = db_object_field_new())
1737 || db_object_field_set_name(object_field, "rollCskNow")
1739 || db_object_field_list_add(object_field_list, object_field))
1740 {
1741 db_object_field_free(object_field);
1742 db_object_field_list_free(object_field_list);
1743 return DB_ERROR_UNKNOWN;
1744 }
1745
1746 if (!(object_field = db_object_field_new())
1747 || db_object_field_set_name(object_field, "inputAdapterType")
1748 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1749 || db_object_field_list_add(object_field_list, object_field))
1750 {
1751 db_object_field_free(object_field);
1752 db_object_field_list_free(object_field_list);
1753 return DB_ERROR_UNKNOWN;
1754 }
1755
1756 if (!(object_field = db_object_field_new())
1757 || db_object_field_set_name(object_field, "inputAdapterUri")
1758 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1759 || db_object_field_list_add(object_field_list, object_field))
1760 {
1761 db_object_field_free(object_field);
1762 db_object_field_list_free(object_field_list);
1763 return DB_ERROR_UNKNOWN;
1764 }
1765
1766 if (!(object_field = db_object_field_new())
1767 || db_object_field_set_name(object_field, "outputAdapterType")
1768 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1769 || db_object_field_list_add(object_field_list, object_field))
1770 {
1771 db_object_field_free(object_field);
1772 db_object_field_list_free(object_field_list);
1773 return DB_ERROR_UNKNOWN;
1774 }
1775
1776 if (!(object_field = db_object_field_new())
1777 || db_object_field_set_name(object_field, "outputAdapterUri")
1778 || db_object_field_set_type(object_field, DB_TYPE_TEXT)
1779 || db_object_field_list_add(object_field_list, object_field))
1780 {
1781 db_object_field_free(object_field);
1782 db_object_field_list_free(object_field_list);
1783 return DB_ERROR_UNKNOWN;
1784 }
1785
1786 if (!(object_field = db_object_field_new())
1787 || db_object_field_set_name(object_field, "nextKskRoll")
1789 || db_object_field_list_add(object_field_list, object_field))
1790 {
1791 db_object_field_free(object_field);
1792 db_object_field_list_free(object_field_list);
1793 return DB_ERROR_UNKNOWN;
1794 }
1795
1796 if (!(object_field = db_object_field_new())
1797 || db_object_field_set_name(object_field, "nextZskRoll")
1799 || db_object_field_list_add(object_field_list, object_field))
1800 {
1801 db_object_field_free(object_field);
1802 db_object_field_list_free(object_field_list);
1803 return DB_ERROR_UNKNOWN;
1804 }
1805
1806 if (!(object_field = db_object_field_new())
1807 || db_object_field_set_name(object_field, "nextCskRoll")
1809 || db_object_field_list_add(object_field_list, object_field))
1810 {
1811 db_object_field_free(object_field);
1812 db_object_field_list_free(object_field_list);
1813 return DB_ERROR_UNKNOWN;
1814 }
1815
1816 if (!(value_set = db_value_set_new(18))) {
1817 db_object_field_list_free(object_field_list);
1818 return DB_ERROR_UNKNOWN;
1819 }
1820
1821 if (db_value_copy(db_value_set_get(value_set, 0), &(zone->policy_id))
1822 || db_value_from_text(db_value_set_get(value_set, 1), zone->name)
1824 || db_value_from_text(db_value_set_get(value_set, 3), zone->signconf_path)
1825 || db_value_from_int32(db_value_set_get(value_set, 4), zone->next_change)
1826 || db_value_from_uint32(db_value_set_get(value_set, 5), zone->ttl_end_ds)
1827 || db_value_from_uint32(db_value_set_get(value_set, 6), zone->ttl_end_dk)
1828 || db_value_from_uint32(db_value_set_get(value_set, 7), zone->ttl_end_rs)
1829 || db_value_from_uint32(db_value_set_get(value_set, 8), zone->roll_ksk_now)
1830 || db_value_from_uint32(db_value_set_get(value_set, 9), zone->roll_zsk_now)
1831 || db_value_from_uint32(db_value_set_get(value_set, 10), zone->roll_csk_now)
1833 || db_value_from_text(db_value_set_get(value_set, 12), zone->input_adapter_uri)
1836 || db_value_from_uint32(db_value_set_get(value_set, 15), zone->next_ksk_roll)
1837 || db_value_from_uint32(db_value_set_get(value_set, 16), zone->next_zsk_roll)
1838 || db_value_from_uint32(db_value_set_get(value_set, 17), zone->next_csk_roll))
1839 {
1840 db_value_set_free(value_set);
1841 db_object_field_list_free(object_field_list);
1842 return DB_ERROR_UNKNOWN;
1843 }
1844
1845 if (!(clause_list = db_clause_list_new())) {
1846 db_value_set_free(value_set);
1847 db_object_field_list_free(object_field_list);
1848 return DB_ERROR_UNKNOWN;
1849 }
1850
1851 if (!(clause = db_clause_new())
1852 || db_clause_set_field(clause, "id")
1854 || db_value_copy(db_clause_get_value(clause), &(zone->id))
1855 || db_clause_list_add(clause_list, clause))
1856 {
1857 db_clause_free(clause);
1858 db_clause_list_free(clause_list);
1859 db_value_set_free(value_set);
1860 db_object_field_list_free(object_field_list);
1861 return DB_ERROR_UNKNOWN;
1862 }
1863
1864 if (!(clause = db_clause_new())
1865 || db_clause_set_field(clause, "rev")
1867 || db_value_copy(db_clause_get_value(clause), &(zone->rev))
1868 || db_clause_list_add(clause_list, clause))
1869 {
1870 db_clause_free(clause);
1871 db_clause_list_free(clause_list);
1872 db_value_set_free(value_set);
1873 db_object_field_list_free(object_field_list);
1874 return DB_ERROR_UNKNOWN;
1875 }
1876
1877 ret = db_object_update(zone->dbo, object_field_list, value_set, clause_list);
1878 db_value_set_free(value_set);
1879 db_object_field_list_free(object_field_list);
1880 db_clause_list_free(clause_list);
1881 return ret;
1882}
1883
1885 db_clause_list_t* clause_list;
1886 db_clause_t* clause;
1887 int ret;
1888
1889 if (!zone) {
1890 return DB_ERROR_UNKNOWN;
1891 }
1892 if (!zone->dbo) {
1893 return DB_ERROR_UNKNOWN;
1894 }
1895 if (db_value_not_empty(&(zone->id))) {
1896 return DB_ERROR_UNKNOWN;
1897 }
1898
1899 if (!(clause_list = db_clause_list_new())) {
1900 return DB_ERROR_UNKNOWN;
1901 }
1902
1903 if (!(clause = db_clause_new())
1904 || db_clause_set_field(clause, "id")
1906 || db_value_copy(db_clause_get_value(clause), &(zone->id))
1907 || db_clause_list_add(clause_list, clause))
1908 {
1909 db_clause_free(clause);
1910 db_clause_list_free(clause_list);
1911 return DB_ERROR_UNKNOWN;
1912 }
1913
1914 if (!(clause = db_clause_new())
1915 || db_clause_set_field(clause, "rev")
1917 || db_value_copy(db_clause_get_value(clause), &(zone->rev))
1918 || db_clause_list_add(clause_list, clause))
1919 {
1920 db_clause_free(clause);
1921 db_clause_list_free(clause_list);
1922 return DB_ERROR_UNKNOWN;
1923 }
1924
1925 ret = db_object_delete(zone->dbo, clause_list);
1926 db_clause_list_free(clause_list);
1927 return ret;
1928}
1929
1930int zone_db_count(zone_db_t* zone, db_clause_list_t* clause_list, size_t* count) {
1931 if (!zone) {
1932 return DB_ERROR_UNKNOWN;
1933 }
1934 if (!zone->dbo) {
1935 return DB_ERROR_UNKNOWN;
1936 }
1937 if (!count) {
1938 return DB_ERROR_UNKNOWN;
1939 }
1940
1941 return db_object_count(zone->dbo, NULL, clause_list, count);
1942}
1943
1944/* ZONE LIST */
1945
1947 zone_list_db_t* zone_list =
1948 (zone_list_db_t*)calloc(1, sizeof(zone_list_db_t));
1949
1950 if (zone_list) {
1951 if (!(zone_list->dbo = __zone_db_new_object(connection))) {
1952 free(zone_list);
1953 return NULL;
1954 }
1955 }
1956
1957 return zone_list;
1958}
1959
1961 zone_list_db_t* zone_list;
1962
1963 if (!from_zone_list) {
1964 return NULL;
1965 }
1966 if (!from_zone_list->dbo) {
1967 return NULL;
1968 }
1969
1970 if (!(zone_list = zone_list_db_new(db_object_connection(from_zone_list->dbo)))
1971 || zone_list_db_copy(zone_list, from_zone_list))
1972 {
1973 zone_list_db_free(zone_list);
1974 return NULL;
1975 }
1976 return zone_list;
1977}
1978
1980 if (!zone_list) {
1981 return DB_ERROR_UNKNOWN;
1982 }
1983
1984 zone_list->object_store = 1;
1985
1986 return DB_OK;
1987}
1988
1990 size_t i;
1991
1992 if (zone_list) {
1993 if (zone_list->dbo) {
1994 db_object_free(zone_list->dbo);
1995 }
1996 if (zone_list->result_list) {
1997 db_result_list_free(zone_list->result_list);
1998 }
1999 if (zone_list->zone) {
2000 zone_db_free(zone_list->zone);
2001 }
2002 for (i = 0; i < zone_list->object_list_size; i++) {
2003 if (zone_list->object_list[i]) {
2004 zone_db_free(zone_list->object_list[i]);
2005 }
2006 }
2007 if (zone_list->object_list) {
2008 free(zone_list->object_list);
2009 }
2010 if (zone_list->policy_id_list) {
2011 policy_list_free(zone_list->policy_id_list);
2012 }
2013 free(zone_list);
2014 }
2015}
2016
2017int zone_list_db_copy(zone_list_db_t* zone_list, const zone_list_db_t* from_zone_list) {
2018 size_t i;
2019
2020 if (!zone_list) {
2021 return DB_ERROR_UNKNOWN;
2022 }
2023 if (!from_zone_list) {
2024 return DB_ERROR_UNKNOWN;
2025 }
2026 if (from_zone_list->object_list && !from_zone_list->object_list_size) {
2027 return DB_ERROR_UNKNOWN;
2028 }
2029
2030 if (zone_list->result_list) {
2031 db_result_list_free(zone_list->result_list);
2032 zone_list->result_list = NULL;
2033 }
2034 if (from_zone_list->result_list
2035 && !(zone_list->result_list = db_result_list_new_copy(from_zone_list->result_list)))
2036 {
2037 return DB_ERROR_UNKNOWN;
2038 }
2039
2040 zone_list->object_store = from_zone_list->object_store;
2041 for (i = 0; i < zone_list->object_list_size; i++) {
2042 if (zone_list->object_list[i]) {
2043 zone_db_free(zone_list->object_list[i]);
2044 }
2045 }
2046 zone_list->object_list_size = 0;
2047 if (zone_list->object_list) {
2048 free(zone_list->object_list);
2049 zone_list->object_list = NULL;
2050 }
2051 if (from_zone_list->object_list) {
2052 if (!(zone_list->object_list = (zone_db_t**)calloc(from_zone_list->object_list_size, sizeof(zone_db_t*)))) {
2053 return DB_ERROR_UNKNOWN;
2054 }
2055 zone_list->object_list_size = from_zone_list->object_list_size;
2056 for (i = 0; i < from_zone_list->object_list_size; i++) {
2057 if (!from_zone_list->object_list[i]) {
2058 continue;
2059 }
2060 if (!(zone_list->object_list[i] = zone_db_new_copy(from_zone_list->object_list[i]))) {
2061 return DB_ERROR_UNKNOWN;
2062 }
2063 }
2064 }
2065 zone_list->object_list_position = 0;;
2066 zone_list->object_list_first = 1;
2067 zone_list->associated_fetch = from_zone_list->associated_fetch;
2068
2069 if (from_zone_list->policy_id_list
2070 && !(zone_list->policy_id_list = policy_list_new_copy(from_zone_list->policy_id_list)))
2071 {
2072 return DB_ERROR_UNKNOWN;
2073 }
2074
2075 return DB_OK;
2076}
2077
2078static int zone_list_db_get_associated(zone_list_db_t* zone_list) {
2079 const db_clause_t* clause_walk;
2080 const policy_t* policy_policy_id;
2081 size_t j, count;
2082 int cmp;
2083 size_t i;
2084 db_clause_list_t* clause_list;
2085 db_clause_t* clause;
2086 const zone_db_t* zone;
2088 const key_data_t* key_data;
2091
2092 if (!zone_list) {
2093 return DB_ERROR_UNKNOWN;
2094 }
2095 if (!zone_list->dbo) {
2096 return DB_ERROR_UNKNOWN;
2097 }
2098 if (!zone_list->associated_fetch) {
2099 return DB_ERROR_UNKNOWN;
2100 }
2101 if (!zone_list->result_list) {
2102 return DB_ERROR_UNKNOWN;
2103 }
2104 if (zone_list->object_list) {
2105 return DB_ERROR_UNKNOWN;
2106 }
2107
2108 if (zone_list->policy_id_list) {
2109 policy_list_free(zone_list->policy_id_list);
2110 zone_list->policy_id_list = NULL;
2111 }
2112
2113 if (!(clause_list = db_clause_list_new())) {
2114 return DB_ERROR_UNKNOWN;
2115 }
2116 zone = zone_list_db_begin(zone_list);
2117 while (zone) {
2118 cmp = 1;
2119 clause_walk = db_clause_list_begin(clause_list);
2120 while (clause_walk) {
2121 if (db_value_cmp(db_clause_value(clause_walk), zone_db_policy_id(zone), &cmp)) {
2122 db_clause_list_free(clause_list);
2123 return DB_ERROR_UNKNOWN;
2124 }
2125 if (!cmp) {
2126 break;
2127 }
2128 clause_walk = db_clause_next(clause_walk);
2129 }
2130 if (cmp) {
2131 if (!(clause = db_clause_new())
2132 || db_clause_set_field(clause, "id")
2136 || db_clause_list_add(clause_list, clause))
2137 {
2138 db_clause_free(clause);
2139 db_clause_list_free(clause_list);
2140 return DB_ERROR_UNKNOWN;
2141 }
2142 }
2143
2144 zone = zone_list_db_next(zone_list);
2145 }
2146
2147 if (!(zone_list->policy_id_list = policy_list_new(db_object_connection(zone_list->dbo)))
2149 || policy_list_get_by_clauses(zone_list->policy_id_list, clause_list))
2150 {
2151 if (zone_list->policy_id_list) {
2152 policy_list_free(zone_list->policy_id_list);
2153 zone_list->policy_id_list = NULL;
2154 }
2155 db_clause_list_free(clause_list);
2156 return DB_ERROR_UNKNOWN;
2157 }
2158 db_clause_list_free(clause_list);
2159
2160 for (i = 0; i < zone_list->object_list_size; i++) {
2161 if (!(zone_list->object_list[i])) {
2162 return DB_ERROR_UNKNOWN;
2163 }
2164
2165 policy_policy_id = policy_list_begin(zone_list->policy_id_list);
2166 while (policy_policy_id) {
2167 if (db_value_cmp(zone_db_policy_id(zone_list->object_list[i]), policy_id(policy_policy_id), &cmp)) {
2168 return DB_ERROR_UNKNOWN;
2169 }
2170 if (!cmp) {
2171 zone_list->object_list[i]->associated_policy_id = policy_policy_id;
2172 }
2173
2174 policy_policy_id = policy_list_next(zone_list->policy_id_list);
2175 }
2176 }
2177
2178 if (!(clause_list = db_clause_list_new())) {
2179 return DB_ERROR_UNKNOWN;
2180 }
2181 zone = zone_list_db_begin(zone_list);
2182 while (zone) {
2183 if (!(clause = db_clause_new())
2184 || db_clause_set_field(clause, "zoneId")
2188 || db_clause_list_add(clause_list, clause))
2189 {
2190 db_clause_free(clause);
2191 db_clause_list_free(clause_list);
2192 return DB_ERROR_UNKNOWN;
2193 }
2194
2195 zone = zone_list_db_next(zone_list);
2196 }
2197
2201 {
2203 db_clause_list_free(clause_list);
2204 return DB_ERROR_UNKNOWN;
2205 }
2206
2207 for (i = 0; i < zone_list->object_list_size; i++) {
2208 if (!(zone_list->object_list[i])) {
2209 return DB_ERROR_UNKNOWN;
2210 }
2211
2212 count = 0;
2214 while (key_data) {
2215 if (db_value_cmp(zone_db_id(zone_list->object_list[i]), key_data_zone_id(key_data), &cmp)) {
2217 db_clause_list_free(clause_list);
2218 return DB_ERROR_UNKNOWN;
2219 }
2220 if (!cmp) {
2221 count++;
2222 }
2224 }
2225 if (zone_list->object_list[i]->key_data_list) {
2227 zone_list->object_list[i]->key_data_list = NULL;
2228 }
2229 if (!(zone_list->object_list[i]->key_data_list = key_data_list_new(db_object_connection(zone_list->dbo)))) {
2231 db_clause_list_free(clause_list);
2232 return DB_ERROR_UNKNOWN;
2233 }
2234 if (count) {
2235 if (!(zone_list->object_list[i]->key_data_list->object_list = (key_data_t**)calloc(count, sizeof(key_data_t*)))) {
2237 db_clause_list_free(clause_list);
2238 return DB_ERROR_UNKNOWN;
2239 }
2240
2241 j = 0;
2243 while (key_data) {
2244 if (j >= count) {
2246 db_clause_list_free(clause_list);
2247 return DB_ERROR_UNKNOWN;
2248 }
2249 if (db_value_cmp(zone_db_id(zone_list->object_list[i]), key_data_zone_id(key_data), &cmp)) {
2251 db_clause_list_free(clause_list);
2252 return DB_ERROR_UNKNOWN;
2253 }
2254 if (!cmp) {
2255 if (!(zone_list->object_list[i]->key_data_list->object_list[j] = key_data_new_copy(key_data))) {
2257 db_clause_list_free(clause_list);
2258 return DB_ERROR_UNKNOWN;
2259 }
2260 j++;
2261 }
2263 }
2264 if (j != count) {
2266 db_clause_list_free(clause_list);
2267 return DB_ERROR_UNKNOWN;
2268 }
2269 }
2270 zone_list->object_list[i]->key_data_list->object_store = 1;
2271 zone_list->object_list[i]->key_data_list->object_list_size = count;
2272 zone_list->object_list[i]->key_data_list->object_list_first = 1;
2273 }
2274
2278 {
2281 db_clause_list_free(clause_list);
2282 return DB_ERROR_UNKNOWN;
2283 }
2284
2286
2287 for (i = 0; i < zone_list->object_list_size; i++) {
2288 if (!(zone_list->object_list[i])) {
2290 db_clause_list_free(clause_list);
2291 return DB_ERROR_UNKNOWN;
2292 }
2293
2294 count = 0;
2296 while (key_dependency) {
2299 db_clause_list_free(clause_list);
2300 return DB_ERROR_UNKNOWN;
2301 }
2302 if (!cmp) {
2303 count++;
2304 }
2306 }
2307 if (zone_list->object_list[i]->key_dependency_list) {
2309 zone_list->object_list[i]->key_dependency_list = NULL;
2310 }
2313 db_clause_list_free(clause_list);
2314 return DB_ERROR_UNKNOWN;
2315 }
2316 if (count) {
2317 if (!(zone_list->object_list[i]->key_dependency_list->object_list = (key_dependency_t**)calloc(count, sizeof(key_dependency_t*)))) {
2319 db_clause_list_free(clause_list);
2320 return DB_ERROR_UNKNOWN;
2321 }
2322
2323 j = 0;
2325 while (key_dependency) {
2326 if (j >= count) {
2328 db_clause_list_free(clause_list);
2329 return DB_ERROR_UNKNOWN;
2330 }
2333 db_clause_list_free(clause_list);
2334 return DB_ERROR_UNKNOWN;
2335 }
2336 if (!cmp) {
2339 db_clause_list_free(clause_list);
2340 return DB_ERROR_UNKNOWN;
2341 }
2342 j++;
2343 }
2345 }
2346 if (j != count) {
2348 db_clause_list_free(clause_list);
2349 return DB_ERROR_UNKNOWN;
2350 }
2351 }
2352 zone_list->object_list[i]->key_dependency_list->object_store = 1;
2353 zone_list->object_list[i]->key_dependency_list->object_list_size = count;
2355 }
2357 db_clause_list_free(clause_list);
2358
2359 zone_list->object_list_first = 1;
2360 return DB_OK;
2361}
2362
2364 size_t i;
2365
2366 if (!zone_list) {
2367 return DB_ERROR_UNKNOWN;
2368 }
2369 if (!zone_list->dbo) {
2370 return DB_ERROR_UNKNOWN;
2371 }
2372
2373 if (zone_list->result_list) {
2374 db_result_list_free(zone_list->result_list);
2375 }
2376 if (zone_list->object_list_size) {
2377 for (i = 0; i < zone_list->object_list_size; i++) {
2378 if (zone_list->object_list[i]) {
2379 zone_db_free(zone_list->object_list[i]);
2380 }
2381 }
2382 zone_list->object_list_size = 0;
2383 zone_list->object_list_first = 0;
2384 }
2385 if (zone_list->object_list) {
2386 free(zone_list->object_list);
2387 zone_list->object_list = NULL;
2388 }
2389 if (!(zone_list->result_list = db_object_read(zone_list->dbo, NULL, NULL))
2391 {
2392 return DB_ERROR_UNKNOWN;
2393 }
2394 if (zone_list->associated_fetch
2395 && zone_list_db_get_associated(zone_list))
2396 {
2397 return DB_ERROR_UNKNOWN;
2398 }
2399 return DB_OK;
2400}
2401
2403 zone_list_db_t* zone_list;
2404
2405 if (!connection) {
2406 return NULL;
2407 }
2408
2409 if (!(zone_list = zone_list_db_new(connection))
2410 || zone_list_db_get(zone_list))
2411 {
2412 zone_list_db_free(zone_list);
2413 return NULL;
2414 }
2415
2416 return zone_list;
2417}
2418
2420 size_t i;
2421
2422 if (!zone_list) {
2423 return DB_ERROR_UNKNOWN;
2424 }
2425 if (!clause_list) {
2426 return DB_ERROR_UNKNOWN;
2427 }
2428 if (!zone_list->dbo) {
2429 return DB_ERROR_UNKNOWN;
2430 }
2431
2432 if (zone_list->result_list) {
2433 db_result_list_free(zone_list->result_list);
2434 }
2435 if (zone_list->object_list_size) {
2436 for (i = 0; i < zone_list->object_list_size; i++) {
2437 if (zone_list->object_list[i]) {
2438 zone_db_free(zone_list->object_list[i]);
2439 }
2440 }
2441 zone_list->object_list_size = 0;
2442 zone_list->object_list_first = 0;
2443 }
2444 if (zone_list->object_list) {
2445 free(zone_list->object_list);
2446 zone_list->object_list = NULL;
2447 }
2448 if (!(zone_list->result_list = db_object_read(zone_list->dbo, NULL, clause_list))
2450 {
2451 return DB_ERROR_UNKNOWN;
2452 }
2453 if (zone_list->associated_fetch
2454 && zone_list_db_get_associated(zone_list))
2455 {
2456 return DB_ERROR_UNKNOWN;
2457 }
2458 return DB_OK;
2459}
2460
2462 db_clause_list_t* clause_list;
2463 db_clause_t* clause;
2464 size_t i;
2465
2466 if (!zone_list) {
2467 return DB_ERROR_UNKNOWN;
2468 }
2469 if (!zone_list->dbo) {
2470 return DB_ERROR_UNKNOWN;
2471 }
2472 if (!policy_id) {
2473 return DB_ERROR_UNKNOWN;
2474 }
2476 return DB_ERROR_UNKNOWN;
2477 }
2478
2479 if (!(clause_list = db_clause_list_new())) {
2480 return DB_ERROR_UNKNOWN;
2481 }
2482 if (!(clause = db_clause_new())
2483 || db_clause_set_field(clause, "policyId")
2486 || db_clause_list_add(clause_list, clause))
2487 {
2488 db_clause_free(clause);
2489 db_clause_list_free(clause_list);
2490 return DB_ERROR_UNKNOWN;
2491 }
2492
2493 if (zone_list->result_list) {
2494 db_result_list_free(zone_list->result_list);
2495 }
2496 if (zone_list->object_list_size) {
2497 for (i = 0; i < zone_list->object_list_size; i++) {
2498 if (zone_list->object_list[i]) {
2499 zone_db_free(zone_list->object_list[i]);
2500 }
2501 }
2502 zone_list->object_list_size = 0;
2503 zone_list->object_list_first = 0;
2504 }
2505 if (zone_list->object_list) {
2506 free(zone_list->object_list);
2507 zone_list->object_list = NULL;
2508 }
2509 if (!(zone_list->result_list = db_object_read(zone_list->dbo, NULL, clause_list))
2511 {
2512 db_clause_list_free(clause_list);
2513 return DB_ERROR_UNKNOWN;
2514 }
2515 db_clause_list_free(clause_list);
2516 if (zone_list->associated_fetch
2517 && zone_list_db_get_associated(zone_list))
2518 {
2519 return DB_ERROR_UNKNOWN;
2520 }
2521 return DB_OK;
2522}
2523
2525 zone_list_db_t* zone_list;
2526
2527 if (!connection) {
2528 return NULL;
2529 }
2530 if (!policy_id) {
2531 return NULL;
2532 }
2534 return NULL;
2535 }
2536
2537 if (!(zone_list = zone_list_db_new(connection))
2539 {
2540 zone_list_db_free(zone_list);
2541 return NULL;
2542 }
2543
2544 return zone_list;
2545}
2546
2548 const db_result_t* result;
2549
2550 if (!zone_list) {
2551 return NULL;
2552 }
2553
2554 if (zone_list->object_store) {
2555 if (!zone_list->object_list) {
2556 if (!zone_list->result_list) {
2557 return NULL;
2558 }
2559 if (!db_result_list_size(zone_list->result_list)) {
2560 return NULL;
2561 }
2562 if (!(zone_list->object_list = (zone_db_t**)calloc(db_result_list_size(zone_list->result_list), sizeof(zone_db_t*)))) {
2563 return NULL;
2564 }
2565 zone_list->object_list_size = db_result_list_size(zone_list->result_list);
2566 }
2567 if (!(zone_list->object_list[0])) {
2568 if (!zone_list->result_list) {
2569 return NULL;
2570 }
2571 if (!(result = db_result_list_begin(zone_list->result_list))) {
2572 return NULL;
2573 }
2574 if (!(zone_list->object_list[0] = zone_db_new(db_object_connection(zone_list->dbo)))) {
2575 return NULL;
2576 }
2577 if (zone_db_from_result(zone_list->object_list[0], result)) {
2578 return NULL;
2579 }
2580 }
2581 zone_list->object_list_position = 0;
2582 return zone_list->object_list[0];
2583 }
2584
2585 if (!zone_list->result_list) {
2586 return NULL;
2587 }
2588
2589 if (!(result = db_result_list_begin(zone_list->result_list))) {
2590 return NULL;
2591 }
2592 if (!zone_list->zone) {
2593 if (!(zone_list->zone = zone_db_new(db_object_connection(zone_list->dbo)))) {
2594 return NULL;
2595 }
2596 }
2597 if (zone_db_from_result(zone_list->zone, result)) {
2598 return NULL;
2599 }
2600 return zone_list->zone;
2601}
2602
2604 const db_result_t* result;
2605
2606 if (!zone_list) {
2607 return NULL;
2608 }
2609
2610 if (zone_list->object_store) {
2611 if (!zone_list->object_list) {
2612 if (!zone_list->result_list) {
2613 return NULL;
2614 }
2615 if (!db_result_list_size(zone_list->result_list)) {
2616 return NULL;
2617 }
2618 if (!(zone_list->object_list = (zone_db_t**)calloc(db_result_list_size(zone_list->result_list), sizeof(zone_db_t*)))) {
2619 return NULL;
2620 }
2621 zone_list->object_list_size = db_result_list_size(zone_list->result_list);
2622 zone_list->object_list_position = 0;
2623 }
2624 else if (zone_list->object_list_first) {
2625 zone_list->object_list_first = 0;
2626 zone_list->object_list_position = 0;
2627 }
2628 else {
2629 zone_list->object_list_position++;
2630 }
2631 if (zone_list->object_list_position >= zone_list->object_list_size) {
2632 return NULL;
2633 }
2634 if (!(zone_list->object_list[zone_list->object_list_position])) {
2635 if (!zone_list->result_list) {
2636 return NULL;
2637 }
2638 if (!(result = db_result_list_next(zone_list->result_list))) {
2639 return NULL;
2640 }
2641 if (!(zone_list->object_list[zone_list->object_list_position] = zone_db_new(db_object_connection(zone_list->dbo)))) {
2642 return NULL;
2643 }
2644 if (zone_db_from_result(zone_list->object_list[zone_list->object_list_position], result)) {
2645 return NULL;
2646 }
2647 }
2648 return zone_list->object_list[zone_list->object_list_position];
2649 }
2650
2651 if (!zone_list->result_list) {
2652 return NULL;
2653 }
2654
2655 if (!(result = db_result_list_next(zone_list->result_list))) {
2656 return NULL;
2657 }
2658 if (!zone_list->zone) {
2659 if (!(zone_list->zone = zone_db_new(db_object_connection(zone_list->dbo)))) {
2660 return NULL;
2661 }
2662 }
2663 if (zone_db_from_result(zone_list->zone, result)) {
2664 return NULL;
2665 }
2666 return zone_list->zone;
2667}
2668
2670 const db_result_t* result;
2671 zone_db_t* zone;
2672
2673 if (!zone_list) {
2674 return NULL;
2675 }
2676
2677 if (zone_list->object_store) {
2678 if (!(zone = zone_db_new(db_object_connection(zone_list->dbo)))) {
2679 return NULL;
2680 }
2681 if (zone_db_copy(zone, zone_list_db_next(zone_list))) {
2682 zone_db_free(zone);
2683 return NULL;
2684 }
2685 return zone;
2686 }
2687
2688 if (!zone_list->result_list) {
2689 return NULL;
2690 }
2691
2692 if (!(result = db_result_list_next(zone_list->result_list))) {
2693 return NULL;
2694 }
2695 if (!(zone = zone_db_new(db_object_connection(zone_list->dbo)))) {
2696 return NULL;
2697 }
2698 if (zone_db_from_result(zone, result)) {
2699 zone_db_free(zone);
2700 return NULL;
2701 }
2702 return zone;
2703}
2704
2706 if (!zone_list) {
2707 return 0;
2708 }
2709
2710 if (zone_list->object_store
2711 && zone_list->object_list)
2712 {
2713 return zone_list->object_list_size;
2714 }
2715
2716 if (!zone_list->result_list) {
2717 return 0;
2718 }
2719
2720 return db_result_list_size(zone_list->result_list);
2721}
const db_value_t * db_clause_value(const db_clause_t *clause)
Definition: db_clause.c:85
void db_clause_free(db_clause_t *clause)
Definition: db_clause.c:56
db_clause_list_t * db_clause_list_new(void)
Definition: db_clause.c:202
db_clause_t * db_clause_new(void)
Definition: db_clause.c:43
const db_clause_t * db_clause_next(const db_clause_t *clause)
Definition: db_clause.c:179
db_value_t * db_clause_get_value(db_clause_t *clause)
Definition: db_clause.c:187
int db_clause_list_add(db_clause_list_t *clause_list, db_clause_t *clause)
Definition: db_clause.c:226
void db_clause_list_free(db_clause_list_t *clause_list)
Definition: db_clause.c:209
int db_clause_set_operator(db_clause_t *clause, db_clause_operator_t clause_operator)
Definition: db_clause.c:142
int db_clause_set_field(db_clause_t *clause, const char *field)
Definition: db_clause.c:109
const db_clause_t * db_clause_list_begin(const db_clause_list_t *clause_list)
Definition: db_clause.c:255
int db_clause_set_type(db_clause_t *clause, db_clause_type_t type)
Definition: db_clause.c:130
@ DB_CLAUSE_OPERATOR_AND
Definition: db_clause.h:97
@ DB_CLAUSE_OPERATOR_OR
Definition: db_clause.h:101
@ DB_CLAUSE_EQUAL
Definition: db_clause.h:44
#define DB_ERROR_UNKNOWN
Definition: db_error.h:40
#define DB_OK
Definition: db_error.h:36
const db_connection_t * db_object_connection(const db_object_t *object)
Definition: db_object.c:320
db_object_field_t * db_object_field_new(void)
Definition: db_object.c:40
int db_object_update(const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set, const db_clause_list_t *clause_list)
Definition: db_object.c:441
int db_object_field_list_add(db_object_field_list_t *object_field_list, db_object_field_t *object_field)
Definition: db_object.c:254
db_object_t * db_object_new(void)
Definition: db_object.c:304
int db_object_set_table(db_object_t *object, const char *table)
Definition: db_object.c:356
int db_object_field_set_name(db_object_field_t *object_field, const char *name)
Definition: db_object.c:110
int db_object_set_connection(db_object_t *object, const db_connection_t *connection)
Definition: db_object.c:341
db_result_list_t * db_object_read(const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list)
Definition: db_object.c:424
int db_object_field_set_type(db_object_field_t *object_field, db_type_t type)
Definition: db_object.c:122
void db_object_free(db_object_t *object)
Definition: db_object.c:311
db_object_field_list_t * db_object_field_list_new(void)
Definition: db_object.c:174
int db_object_set_object_field_list(db_object_t *object, db_object_field_list_t *object_field_list)
Definition: db_object.c:386
void db_object_field_free(db_object_field_t *object_field)
Definition: db_object.c:69
int db_object_create(const db_object_t *object, const db_object_field_list_t *object_field_list, const db_value_set_t *value_set)
Definition: db_object.c:401
int db_object_delete(const db_object_t *object, const db_clause_list_t *clause_list)
Definition: db_object.c:464
void db_object_field_list_free(db_object_field_list_t *object_field_list)
Definition: db_object.c:199
int db_object_count(const db_object_t *object, const db_join_list_t *join_list, const db_clause_list_t *clause_list, size_t *count)
Definition: db_object.c:481
int db_object_set_primary_key_name(db_object_t *object, const char *primary_key_name)
Definition: db_object.c:371
int db_result_list_fetch_all(db_result_list_t *result_list)
Definition: db_result.c:341
size_t db_result_list_size(const db_result_list_t *result_list)
Definition: db_result.c:333
const db_result_t * db_result_list_next(db_result_list_t *result_list)
Definition: db_result.c:310
const db_result_t * db_result_list_begin(db_result_list_t *result_list)
Definition: db_result.c:290
void db_result_list_free(db_result_list_t *result_list)
Definition: db_result.c:160
db_result_list_t * db_result_list_new_copy(const db_result_list_t *from_result_list)
Definition: db_result.c:142
const db_value_set_t * db_result_value_set(const db_result_t *result)
Definition: db_result.c:97
@ DB_TYPE_PRIMARY_KEY
Definition: db_type.h:62
@ DB_TYPE_REVISION
Definition: db_type.h:97
@ DB_TYPE_TEXT
Definition: db_type.h:82
@ DB_TYPE_INT32
Definition: db_type.h:66
@ DB_TYPE_UINT32
Definition: db_type.h:70
@ DB_TYPE_ANY
Definition: db_type.h:90
int db_value_to_int32(const db_value_t *value, db_type_int32_t *to_int32)
Definition: db_value.c:357
const db_value_t * db_value_set_at(const db_value_set_t *value_set, size_t at)
Definition: db_value.c:742
db_value_t * db_value_set_get(db_value_set_t *value_set, size_t at)
Definition: db_value.c:756
void db_value_set_free(db_value_set_t *value_set)
Definition: db_value.c:697
int db_value_from_uint32(db_value_t *value, db_type_uint32_t from_uint32)
Definition: db_value.c:492
db_value_set_t * db_value_set_new(size_t size)
Definition: db_value.c:622
int db_value_from_text(db_value_t *value, const char *from_text)
Definition: db_value.c:531
int db_value_from_int32(db_value_t *value, db_type_int32_t from_int32)
Definition: db_value.c:479
int db_value_copy(db_value_t *value, const db_value_t *from_value)
Definition: db_value.c:77
int db_value_cmp(const db_value_t *value_a, const db_value_t *value_b, int *result)
Definition: db_value.c:102
size_t db_value_set_size(const db_value_set_t *value_set)
Definition: db_value.c:734
int db_value_to_uint32(const db_value_t *value, db_type_uint32_t *to_uint32)
Definition: db_value.c:372
int db_value_to_text(const db_value_t *value, char **to_text)
Definition: db_value.c:417
int db_value_not_empty(const db_value_t *value)
Definition: db_value.c:347
void db_value_reset(db_value_t *value)
Definition: db_value.c:60
key_data_list_t * key_data_list_new_copy(const key_data_list_t *from_key_data_list)
Definition: key_data.c:1665
int key_data_list_get_by_clauses(key_data_list_t *key_data_list, const db_clause_list_t *clause_list)
Definition: key_data.c:2119
void key_data_list_free(key_data_list_t *key_data_list)
Definition: key_data.c:1694
const key_data_t * key_data_list_begin(key_data_list_t *key_data_list)
Definition: key_data.c:2267
int key_data_list_object_store(key_data_list_t *key_data_list)
Definition: key_data.c:1684
key_data_list_t * key_data_list_new(const db_connection_t *connection)
Definition: key_data.c:1651
const key_data_t * key_data_list_next(key_data_list_t *key_data_list)
Definition: key_data.c:2359
const db_value_t * key_data_zone_id(const key_data_t *key_data)
Definition: key_data.c:561
key_data_t * key_data_new_copy(const key_data_t *key_data)
Definition: key_data.c:285
int key_dependency_list_object_store(key_dependency_list_t *key_dependency_list)
const db_value_t * key_dependency_zone_id(const key_dependency_t *key_dependency)
const key_dependency_t * key_dependency_list_next(key_dependency_list_t *key_dependency_list)
const key_dependency_t * key_dependency_list_begin(key_dependency_list_t *key_dependency_list)
int key_dependency_list_get_by_clauses(key_dependency_list_t *key_dependency_list, const db_clause_list_t *clause_list)
key_dependency_t * key_dependency_new_copy(const key_dependency_t *key_dependency)
void key_dependency_list_free(key_dependency_list_t *key_dependency_list)
key_dependency_list_t * key_dependency_list_new_copy(const key_dependency_list_t *from_key_dependency_list)
key_dependency_list_t * key_dependency_list_new(const db_connection_t *connection)
policy_t * policy_new(const db_connection_t *connection)
Definition: policy.c:479
void policy_list_free(policy_list_t *policy_list)
Definition: policy.c:2664
const policy_t * policy_list_begin(policy_list_t *policy_list)
Definition: policy.c:3158
const policy_t * policy_list_next(policy_list_t *policy_list)
Definition: policy.c:3214
policy_t * policy_new_copy(const policy_t *policy)
Definition: policy.c:499
int policy_copy(policy_t *policy, const policy_t *policy_copy)
Definition: policy.c:547
policy_list_t * policy_list_new_copy(const policy_list_t *from_policy_list)
Definition: policy.c:2635
const db_value_t * policy_id(const policy_t *policy)
Definition: policy.c:805
policy_list_t * policy_list_new(const db_connection_t *connection)
Definition: policy.c:2621
int policy_list_object_store(policy_list_t *policy_list)
Definition: policy.c:2654
int policy_list_get_by_clauses(policy_list_t *policy_list, const db_clause_list_t *clause_list)
Definition: policy.c:3096
int policy_get_by_id(policy_t *policy, const db_value_t *id)
Definition: policy.c:1987
void policy_free(policy_t *policy)
Definition: policy.c:518
size_t object_list_size
Definition: key_data.h:486
int object_list_first
Definition: key_data.h:488
key_data_t ** object_list
Definition: key_data.h:485
int object_store
Definition: key_data.h:484
key_dependency_t ** object_list
Definition: policy.h:60
db_value_t id
Definition: zone_db.h:48
unsigned int ttl_end_ds
Definition: zone_db.h:57
policy_t * private_policy_id
Definition: zone_db.h:52
unsigned int next_zsk_roll
Definition: zone_db.h:68
unsigned int roll_csk_now
Definition: zone_db.h:62
unsigned int ttl_end_dk
Definition: zone_db.h:58
db_object_t * dbo
Definition: zone_db.h:47
char * output_adapter_uri
Definition: zone_db.h:66
unsigned int roll_ksk_now
Definition: zone_db.h:60
unsigned int next_csk_roll
Definition: zone_db.h:69
unsigned int signconf_needs_writing
Definition: zone_db.h:54
int next_change
Definition: zone_db.h:56
char * signconf_path
Definition: zone_db.h:55
db_value_t rev
Definition: zone_db.h:49
unsigned int roll_zsk_now
Definition: zone_db.h:61
key_data_list_t * key_data_list
Definition: zone_db.h:70
unsigned int next_ksk_roll
Definition: zone_db.h:67
db_value_t policy_id
Definition: zone_db.h:50
char * output_adapter_type
Definition: zone_db.h:65
char * input_adapter_type
Definition: zone_db.h:63
unsigned int ttl_end_rs
Definition: zone_db.h:59
char * name
Definition: zone_db.h:53
key_dependency_list_t * key_dependency_list
Definition: zone_db.h:71
const policy_t * associated_policy_id
Definition: zone_db.h:51
char * input_adapter_uri
Definition: zone_db.h:64
int object_store
Definition: zone_db.h:471
size_t object_list_position
Definition: zone_db.h:474
size_t object_list_size
Definition: zone_db.h:473
db_object_t * dbo
Definition: zone_db.h:467
zone_db_t * zone
Definition: zone_db.h:470
int object_list_first
Definition: zone_db.h:475
zone_db_t ** object_list
Definition: zone_db.h:472
policy_list_t * policy_id_list
Definition: zone_db.h:477
db_result_list_t * result_list
Definition: zone_db.h:468
int associated_fetch
Definition: zone_db.h:476
zone_list_db_t * zone_list_db_new_get(const db_connection_t *connection)
Definition: zone_db.c:2402
unsigned int zone_db_roll_zsk_now(const zone_db_t *zone)
Definition: zone_db.c:846
int zone_db_set_input_adapter_type(zone_db_t *zone, const char *input_adapter_type_text)
Definition: zone_db.c:1061
int zone_db_set_ttl_end_dk(zone_db_t *zone, unsigned int ttl_end_dk)
Definition: zone_db.c:1011
int zone_list_db_object_store(zone_list_db_t *zone_list)
Definition: zone_db.c:1979
void zone_db_free(zone_db_t *zone)
Definition: zone_db.c:325
int zone_db_from_result(zone_db_t *zone, const db_result_t *result)
Definition: zone_db.c:662
int zone_db_set_next_ksk_roll(zone_db_t *zone, unsigned int next_ksk_roll)
Definition: zone_db.c:1149
unsigned int zone_db_ttl_end_rs(const zone_db_t *zone)
Definition: zone_db.c:830
zone_list_db_t * zone_list_db_new_copy(const zone_list_db_t *from_zone_list)
Definition: zone_db.c:1960
int zone_db_set_signconf_needs_writing(zone_db_t *zone, unsigned int signconf_needs_writing)
Definition: zone_db.c:959
int zone_db_delete(zone_db_t *zone)
Definition: zone_db.c:1884
const char * zone_db_signconf_path(const zone_db_t *zone)
Definition: zone_db.c:798
unsigned int zone_db_ttl_end_ds(const zone_db_t *zone)
Definition: zone_db.c:814
const db_value_t * zone_db_policy_id(const zone_db_t *zone)
Definition: zone_db.c:736
policy_t * zone_db_get_policy(const zone_db_t *zone)
Definition: zone_db.c:744
int zone_db_set_output_adapter_type(zone_db_t *zone, const char *output_adapter_type_text)
Definition: zone_db.c:1105
int zone_db_set_roll_zsk_now(zone_db_t *zone, unsigned int roll_zsk_now)
Definition: zone_db.c:1041
int zone_db_set_roll_csk_now(zone_db_t *zone, unsigned int roll_csk_now)
Definition: zone_db.c:1051
int zone_db_set_policy_id(zone_db_t *zone, const db_value_t *policy_id)
Definition: zone_db.c:918
unsigned int zone_db_roll_ksk_now(const zone_db_t *zone)
Definition: zone_db.c:838
const char * zone_db_name(const zone_db_t *zone)
Definition: zone_db.c:782
zone_list_db_t * zone_list_db_new_get_by_policy_id(const db_connection_t *connection, const db_value_t *policy_id)
Definition: zone_db.c:2524
const zone_db_t * zone_list_db_begin(zone_list_db_t *zone_list)
Definition: zone_db.c:2547
unsigned int zone_db_next_ksk_roll(const zone_db_t *zone)
Definition: zone_db.c:894
zone_db_t * zone_list_db_get_next(zone_list_db_t *zone_list)
Definition: zone_db.c:2669
zone_list_db_t * zone_list_db_new(const db_connection_t *connection)
Definition: zone_db.c:1946
unsigned int zone_db_next_csk_roll(const zone_db_t *zone)
Definition: zone_db.c:910
int zone_db_create(zone_db_t *zone)
Definition: zone_db.c:1206
int zone_list_db_get_by_clauses(zone_list_db_t *zone_list, const db_clause_list_t *clause_list)
Definition: zone_db.c:2419
int zone_db_set_ttl_end_ds(zone_db_t *zone, unsigned int ttl_end_ds)
Definition: zone_db.c:1001
int zone_db_count(zone_db_t *zone, db_clause_list_t *clause_list, size_t *count)
Definition: zone_db.c:1930
size_t zone_list_db_size(zone_list_db_t *zone_list)
Definition: zone_db.c:2705
int zone_db_set_next_zsk_roll(zone_db_t *zone, unsigned int next_zsk_roll)
Definition: zone_db.c:1159
int zone_db_set_roll_ksk_now(zone_db_t *zone, unsigned int roll_ksk_now)
Definition: zone_db.c:1031
int zone_db_set_next_csk_roll(zone_db_t *zone, unsigned int next_csk_roll)
Definition: zone_db.c:1169
const char * zone_db_input_adapter_uri(const zone_db_t *zone)
Definition: zone_db.c:870
int zone_db_set_signconf_path(zone_db_t *zone, const char *signconf_path_text)
Definition: zone_db.c:969
int zone_db_copy(zone_db_t *zone, const zone_db_t *zone_copy)
Definition: zone_db.c:365
int zone_db_update(zone_db_t *zone)
Definition: zone_db.c:1589
int zone_db_get_by_id(zone_db_t *zone, const db_value_t *id)
Definition: zone_db.c:1466
int zone_list_db_get(zone_list_db_t *zone_list)
Definition: zone_db.c:2363
unsigned int zone_db_ttl_end_dk(const zone_db_t *zone)
Definition: zone_db.c:822
zone_db_t * zone_db_new(const db_connection_t *connection)
Definition: zone_db.c:287
const db_value_t * zone_db_id(const zone_db_t *zone)
Definition: zone_db.c:728
db_clause_t * zone_db_policy_id_clause(db_clause_list_t *clause_list, const db_value_t *policy_id)
Definition: zone_db.c:1179
int zone_db_set_output_adapter_uri(zone_db_t *zone, const char *output_adapter_uri_text)
Definition: zone_db.c:1127
int zone_db_set_name(zone_db_t *zone, const char *name_text)
Definition: zone_db.c:937
const char * zone_db_output_adapter_type(const zone_db_t *zone)
Definition: zone_db.c:878
unsigned int zone_db_next_zsk_roll(const zone_db_t *zone)
Definition: zone_db.c:902
int zone_db_get_by_name(zone_db_t *zone, const char *name)
Definition: zone_db.c:1519
int zone_list_db_copy(zone_list_db_t *zone_list, const zone_list_db_t *from_zone_list)
Definition: zone_db.c:2017
const char * zone_db_output_adapter_uri(const zone_db_t *zone)
Definition: zone_db.c:886
int zone_list_db_get_by_policy_id(zone_list_db_t *zone_list, const db_value_t *policy_id)
Definition: zone_db.c:2461
unsigned int zone_db_signconf_needs_writing(const zone_db_t *zone)
Definition: zone_db.c:790
zone_db_t * zone_db_new_get_by_name(const db_connection_t *connection, const char *name)
Definition: zone_db.c:1569
unsigned int zone_db_roll_csk_now(const zone_db_t *zone)
Definition: zone_db.c:854
int zone_db_set_ttl_end_rs(zone_db_t *zone, unsigned int ttl_end_rs)
Definition: zone_db.c:1021
const zone_db_t * zone_list_db_next(zone_list_db_t *zone_list)
Definition: zone_db.c:2603
int zone_db_next_change(const zone_db_t *zone)
Definition: zone_db.c:806
int zone_db_set_next_change(zone_db_t *zone, int next_change)
Definition: zone_db.c:991
const char * zone_db_input_adapter_type(const zone_db_t *zone)
Definition: zone_db.c:862
void zone_list_db_free(zone_list_db_t *zone_list)
Definition: zone_db.c:1989
zone_db_t * zone_db_new_copy(const zone_db_t *zone)
Definition: zone_db.c:306
int zone_db_set_input_adapter_uri(zone_db_t *zone, const char *input_adapter_uri_text)
Definition: zone_db.c:1083