• Main Page
  • Data Structures
  • Files
  • File List
  • Globals

/srv/bpo/opendnssec/opendnssec-1.3.2/signer/src/adapter/adapi.c

Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Copyright (c) 2009-2011 NLNet Labs. All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00016  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00017  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00018  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
00019  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00020  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00021  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
00023  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00024  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
00025  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *
00027  */
00028 
00034 #include "config.h"
00035 #include "adapter/adapi.h"
00036 #include "shared/duration.h"
00037 #include "shared/log.h"
00038 #include "shared/status.h"
00039 #include "shared/util.h"
00040 #include "signer/zone.h"
00041 
00042 #include <ldns/ldns.h>
00043 
00044 static const char* adapi_str = "adapter";
00045 
00046 
00051 uint32_t
00052 adapi_get_serial(zone_type* zone)
00053 {
00054     if (!zone || !zone->zonedata) {
00055         ods_log_error("[%s] unable to get serial: "
00056             "no zone data", adapi_str);
00057         return 0;
00058     }
00059     ods_log_assert(zone);
00060     ods_log_assert(zone->zonedata);
00061     return zone->zonedata->inbound_serial;
00062 }
00063 
00064 
00069 void
00070 adapi_set_serial(zone_type* zone, uint32_t serial)
00071 {
00072     if (!zone || !zone->zonedata) {
00073         ods_log_error("[%s] unable to set serial: "
00074             "no zone data", adapi_str);
00075         return;
00076     }
00077     ods_log_assert(zone);
00078     ods_log_assert(zone->zonedata);
00079     zone->zonedata->inbound_serial = serial;
00080     return;
00081 }
00082 
00083 
00088 ldns_rdf*
00089 adapi_get_origin(zone_type* zone)
00090 {
00091     if (!zone) {
00092         ods_log_error("[%s] unable to get origin: "
00093             "no zone", adapi_str);
00094         return NULL;
00095     }
00096     ods_log_assert(zone);
00097     return zone->dname;
00098 }
00099 
00100 
00105 uint32_t
00106 adapi_get_ttl(zone_type* zone)
00107 {
00108     if (!zone || !zone->zonedata) {
00109         ods_log_error("[%s] unable to get ttl: "
00110             "no zone data", adapi_str);
00111         return 0;
00112     }
00113     ods_log_assert(zone);
00114     ods_log_assert(zone->zonedata);
00115     return zone->zonedata->default_ttl;
00116 }
00117 
00118 
00119 /*
00120  * Do full zone transaction.
00121  *
00122  */
00123 ods_status
00124 adapi_trans_full(zone_type* zone)
00125 {
00126     if (!zone || !zone->zonedata) {
00127         ods_log_error("[%s] unable to start full zone transaction: "
00128             "no zone data", adapi_str);
00129         return ODS_STATUS_ASSERT_ERR;
00130     }
00131     ods_log_assert(zone);
00132     ods_log_assert(zone->zonedata);
00133     if (!zone->signconf) {
00134         ods_log_error("[%s] unable to start full zone transaction: "
00135             "no signer configuration", adapi_str);
00136         return ODS_STATUS_ASSERT_ERR;
00137     }
00138     ods_log_assert(zone->signconf);
00139 
00140     return zonedata_diff(zone->zonedata, zone->signconf->keys);
00141 }
00142 
00143 
00144 /*
00145  * Do incremental zone transaction.
00146  *
00147  */
00148 ods_status
00149 adapi_trans_diff(zone_type* zone)
00150 {
00151     if (!zone || !zone->zonedata) {
00152         ods_log_error("[%s] unable to start incremental zone transaction: "
00153             "no zone data", adapi_str);
00154         return ODS_STATUS_ASSERT_ERR;
00155     }
00156     ods_log_assert(zone);
00157     ods_log_assert(zone->zonedata);
00158 
00159     return ODS_STATUS_OK;
00160 }
00161 
00162 
00167 ods_status
00168 adapi_add_rr(zone_type* zone, ldns_rr* rr)
00169 {
00170     return zone_add_rr(zone, rr, 1);
00171 }
00172 
00173 
00178 ods_status
00179 adapi_del_rr(zone_type* zone, ldns_rr* rr)
00180 {
00181     return zone_del_rr(zone, rr, 1);
00182 }

Generated on Mon Oct 31 2011 14:38:45 for OpenDNSSEC-signer by  doxygen 1.7.1