OpenDNSSEC-enforcer
1.3.4
|
00001 /* 00002 * $Id: ksm_parameter_value.c 2676 2010-01-11 15:31:31Z sion $ 00003 * 00004 * Copyright (c) 2008-2009 Nominet UK. 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 00029 /*+ 00030 * KsmParameterValue - Return Values of Parameters 00031 * 00032 * Abstract: 00033 * This set of functions encapsulates the parameter collection object. 00034 * It provides functions for extracting parameters - and derived 00035 * parameters - from that object. 00036 -*/ 00037 00038 #include "ksm/ksm.h" 00039 #include "ksm/ksmdef.h" 00040 #include "ksm/message.h" 00041 00042 #define max(x,y) ((x) > (y) ? (x) : (y)) 00043 #define min(x,y) ((x) < (y) ? (x) : (y)) 00044 00045 00046 /*+ 00047 * KsmParameterXxxxx - Return Parameter Xxxx 00048 * 00049 * Description: 00050 * Returns the value of the named parameter from the object. In some 00051 * cases, these values are derived from other parameters. 00052 * 00053 * Arguments: 00054 * KSM_PARCOLL* collection 00055 * Parameter collection object. 00056 * 00057 * Returns: 00058 * int 00059 * Value of the parameter. 00060 -*/ 00061 00062 int KsmParameterClockskew(KSM_PARCOLL* collection) 00063 { 00064 /* check the argument */ 00065 if (collection == NULL) { 00066 MsgLog(KSM_INVARG, "NULL collection"); 00067 return -1; 00068 } 00069 return collection->clockskew; 00070 } 00071 00072 int KsmParameterKskLifetime(KSM_PARCOLL* collection) 00073 { 00074 /* check the argument */ 00075 if (collection == NULL) { 00076 MsgLog(KSM_INVARG, "NULL collection"); 00077 return -1; 00078 } 00079 return collection->ksklife; 00080 } 00081 00082 int KsmParameterStandbyKSKeys(KSM_PARCOLL* collection) 00083 { 00084 /* check the argument */ 00085 if (collection == NULL) { 00086 MsgLog(KSM_INVARG, "NULL collection"); 00087 return -1; 00088 } 00089 return collection->standbyksks; 00090 } 00091 00092 int KsmParameterStandbyZSKeys(KSM_PARCOLL* collection) 00093 { 00094 /* check the argument */ 00095 if (collection == NULL) { 00096 MsgLog(KSM_INVARG, "NULL collection"); 00097 return -1; 00098 } 00099 return collection->standbyzsks; 00100 } 00101 00102 int KsmParameterPropagationDelay(KSM_PARCOLL* collection) 00103 { 00104 /* check the argument */ 00105 if (collection == NULL) { 00106 MsgLog(KSM_INVARG, "NULL collection"); 00107 return -1; 00108 } 00109 return collection->propdelay; 00110 } 00111 00112 int KsmParameterSigningInterval(KSM_PARCOLL* collection) 00113 { 00114 /* check the argument */ 00115 if (collection == NULL) { 00116 MsgLog(KSM_INVARG, "NULL collection"); 00117 return -1; 00118 } 00119 return collection->signint; 00120 } 00121 00122 int KsmParameterSoaMin(KSM_PARCOLL* collection) 00123 { 00124 /* check the argument */ 00125 if (collection == NULL) { 00126 MsgLog(KSM_INVARG, "NULL collection"); 00127 return -1; 00128 } 00129 return collection->soamin; 00130 } 00131 00132 int KsmParameterSoaTtl(KSM_PARCOLL* collection) 00133 { 00134 /* check the argument */ 00135 if (collection == NULL) { 00136 MsgLog(KSM_INVARG, "NULL collection"); 00137 return -1; 00138 } 00139 return collection->soattl; 00140 } 00141 00142 int KsmParameterZskLifetime(KSM_PARCOLL* collection) 00143 { 00144 /* check the argument */ 00145 if (collection == NULL) { 00146 MsgLog(KSM_INVARG, "NULL collection"); 00147 return -1; 00148 } 00149 return collection->zsklife; 00150 } 00151 00152 int KsmParameterZskTtl(KSM_PARCOLL* collection) 00153 { 00154 /* check the argument */ 00155 if (collection == NULL) { 00156 MsgLog(KSM_INVARG, "NULL collection"); 00157 return -1; 00158 } 00159 return collection->zskttl; 00160 } 00161 00162 int KsmParameterKskTtl(KSM_PARCOLL* collection) 00163 { 00164 /* check the argument */ 00165 if (collection == NULL) { 00166 MsgLog(KSM_INVARG, "NULL collection"); 00167 return -1; 00168 } 00169 return collection->kskttl; 00170 } 00171 00172 int KsmParameterKskPropagationDelay(KSM_PARCOLL* collection) 00173 { 00174 /* check the argument */ 00175 if (collection == NULL) { 00176 MsgLog(KSM_INVARG, "NULL collection"); 00177 return -1; 00178 } 00179 return collection->kskpropdelay; 00180 } 00181 00182 int KsmParameterRegistrationDelay(KSM_PARCOLL* collection) 00183 { 00184 /* check the argument */ 00185 if (collection == NULL) { 00186 MsgLog(KSM_INVARG, "NULL collection"); 00187 return -1; 00188 } 00189 return collection->regdelay; 00190 } 00191 00192 int KsmParameterPubSafety(KSM_PARCOLL* collection) 00193 { 00194 /* check the argument */ 00195 if (collection == NULL) { 00196 MsgLog(KSM_INVARG, "NULL collection"); 00197 return -1; 00198 } 00199 return collection->pub_safety; 00200 } 00201 00202 int KsmParameterRetSafety(KSM_PARCOLL* collection) 00203 { 00204 /* check the argument */ 00205 if (collection == NULL) { 00206 MsgLog(KSM_INVARG, "NULL collection"); 00207 return -1; 00208 } 00209 return collection->ret_safety; 00210 } 00211 00212 /* 00213 * Initial publication interval 00214 * 00215 * Make sure that you add "publish safety margin" for "real world" use 00216 */ 00217 int KsmParameterInitialPublicationInterval(KSM_PARCOLL* collection) 00218 { 00219 int ncache; /* Negative cache time */ 00220 int pubint; /* Publication interval */ 00221 /* check the argument */ 00222 if (collection == NULL) { 00223 MsgLog(KSM_INVARG, "NULL collection"); 00224 return -1; 00225 } 00226 00227 ncache = min(KsmParameterSoaTtl(collection), 00228 KsmParameterSoaMin(collection)); 00229 pubint = max(KsmParameterZskTtl(collection), ncache) + 00230 KsmParameterPropagationDelay(collection); 00231 00232 return pubint; 00233 }