OpenDNSSEC-enforcer  1.4.8.2
ksm_parameter_value.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2009 Nominet UK. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 /*+
28  * KsmParameterValue - Return Values of Parameters
29  *
30  * Abstract:
31  * This set of functions encapsulates the parameter collection object.
32  * It provides functions for extracting parameters - and derived
33  * parameters - from that object.
34 -*/
35 
36 #include "ksm/ksm.h"
37 #include "ksm/ksmdef.h"
38 #include "ksm/message.h"
39 
40 #define max(x,y) ((x) > (y) ? (x) : (y))
41 #define min(x,y) ((x) < (y) ? (x) : (y))
42 
43 
44 /*+
45  * KsmParameterXxxxx - Return Parameter Xxxx
46  *
47  * Description:
48  * Returns the value of the named parameter from the object. In some
49  * cases, these values are derived from other parameters.
50  *
51  * Arguments:
52  * KSM_PARCOLL* collection
53  * Parameter collection object.
54  *
55  * Returns:
56  * int
57  * Value of the parameter.
58 -*/
59 
61 {
62  /* check the argument */
63  if (collection == NULL) {
64  MsgLog(KSM_INVARG, "NULL collection");
65  return -1;
66  }
67  return collection->clockskew;
68 }
69 
71 {
72  /* check the argument */
73  if (collection == NULL) {
74  MsgLog(KSM_INVARG, "NULL collection");
75  return -1;
76  }
77  return collection->ksklife;
78 }
79 
81 {
82  /* check the argument */
83  if (collection == NULL) {
84  MsgLog(KSM_INVARG, "NULL collection");
85  return -1;
86  }
87  return collection->standbyksks;
88 }
89 
91 {
92  /* check the argument */
93  if (collection == NULL) {
94  MsgLog(KSM_INVARG, "NULL collection");
95  return -1;
96  }
97  return collection->standbyzsks;
98 }
99 
101 {
102  /* check the argument */
103  if (collection == NULL) {
104  MsgLog(KSM_INVARG, "NULL collection");
105  return -1;
106  }
107  return collection->propdelay;
108 }
109 
111 {
112  /* check the argument */
113  if (collection == NULL) {
114  MsgLog(KSM_INVARG, "NULL collection");
115  return -1;
116  }
117  return collection->signint;
118 }
119 
121 {
122  /* check the argument */
123  if (collection == NULL) {
124  MsgLog(KSM_INVARG, "NULL collection");
125  return -1;
126  }
127  return collection->soamin;
128 }
129 
131 {
132  /* check the argument */
133  if (collection == NULL) {
134  MsgLog(KSM_INVARG, "NULL collection");
135  return -1;
136  }
137  return collection->soattl;
138 }
139 
141 {
142  /* check the argument */
143  if (collection == NULL) {
144  MsgLog(KSM_INVARG, "NULL collection");
145  return -1;
146  }
147  return collection->zsklife;
148 }
149 
151 {
152  /* check the argument */
153  if (collection == NULL) {
154  MsgLog(KSM_INVARG, "NULL collection");
155  return -1;
156  }
157  return collection->zskttl;
158 }
159 
161 {
162  /* check the argument */
163  if (collection == NULL) {
164  MsgLog(KSM_INVARG, "NULL collection");
165  return -1;
166  }
167  return collection->kskttl;
168 }
169 
171 {
172  /* check the argument */
173  if (collection == NULL) {
174  MsgLog(KSM_INVARG, "NULL collection");
175  return -1;
176  }
177  return collection->kskpropdelay;
178 }
179 
181 {
182  /* check the argument */
183  if (collection == NULL) {
184  MsgLog(KSM_INVARG, "NULL collection");
185  return -1;
186  }
187  return collection->regdelay;
188 }
189 
191 {
192  /* check the argument */
193  if (collection == NULL) {
194  MsgLog(KSM_INVARG, "NULL collection");
195  return -1;
196  }
197  return collection->pub_safety;
198 }
199 
201 {
202  /* check the argument */
203  if (collection == NULL) {
204  MsgLog(KSM_INVARG, "NULL collection");
205  return -1;
206  }
207  return collection->ret_safety;
208 }
209 
211 {
212  /* check the argument */
213  if (collection == NULL) {
214  MsgLog(KSM_INVARG, "NULL collection");
215  return -1;
216  }
217  return collection->rfc5011;
218 }
219 
221 {
222  /* check the argument */
223  if (collection == NULL) {
224  MsgLog(KSM_INVARG, "NULL collection");
225  return -1;
226  }
227  return collection->revoke;
228 }
229 
230 /*
231  * Initial publication interval
232  *
233  * Make sure that you add "publish safety margin" for "real world" use
234  */
236 {
237  int ncache; /* Negative cache time */
238  int pubint; /* Publication interval */
239  /* check the argument */
240  if (collection == NULL) {
241  MsgLog(KSM_INVARG, "NULL collection");
242  return -1;
243  }
244 
245  ncache = min(KsmParameterSoaTtl(collection),
246  KsmParameterSoaMin(collection));
247  pubint = max(KsmParameterZskTtl(collection), ncache) +
248  KsmParameterPropagationDelay(collection);
249 
250  return pubint;
251 }
int revoke
Definition: ksm.h:502
#define max(x, y)
#define KSM_INVARG
Definition: ksmdef.h:66
int KsmParameterRegistrationDelay(KSM_PARCOLL *collection)
int KsmParameterRfc5011(KSM_PARCOLL *collection)
int KsmParameterZskLifetime(KSM_PARCOLL *collection)
int kskttl
Definition: ksm.h:492
int pub_safety
Definition: ksm.h:495
int KsmParameterRetSafety(KSM_PARCOLL *collection)
int rfc5011
Definition: ksm.h:501
int KsmParameterKskPropagationDelay(KSM_PARCOLL *collection)
#define min(x, y)
int MsgLog(int status,...)
Definition: message.c:335
int clockskew
Definition: ksm.h:481
int regdelay
Definition: ksm.h:494
int ret_safety
Definition: ksm.h:496
int ksklife
Definition: ksm.h:482
int KsmParameterSoaTtl(KSM_PARCOLL *collection)
int KsmParameterRevoke(KSM_PARCOLL *collection)
int KsmParameterPropagationDelay(KSM_PARCOLL *collection)
int KsmParameterStandbyZSKeys(KSM_PARCOLL *collection)
int propdelay
Definition: ksm.h:485
int KsmParameterZskTtl(KSM_PARCOLL *collection)
int KsmParameterKskLifetime(KSM_PARCOLL *collection)
int zskttl
Definition: ksm.h:491
int KsmParameterStandbyKSKeys(KSM_PARCOLL *collection)
int standbyzsks
Definition: ksm.h:484
int signint
Definition: ksm.h:486
int kskpropdelay
Definition: ksm.h:493
int KsmParameterSoaMin(KSM_PARCOLL *collection)
int zsklife
Definition: ksm.h:490
int KsmParameterKskTtl(KSM_PARCOLL *collection)
int standbyksks
Definition: ksm.h:483
int KsmParameterPubSafety(KSM_PARCOLL *collection)
int KsmParameterInitialPublicationInterval(KSM_PARCOLL *collection)
int soattl
Definition: ksm.h:488
int KsmParameterClockskew(KSM_PARCOLL *collection)
int KsmParameterSigningInterval(KSM_PARCOLL *collection)
int soamin
Definition: ksm.h:487