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