OpenDNSSEC-enforcer  1.4.8.2
ksm_policy_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  * KsmPolicyValue - 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 (policy == NULL) {
64  MsgLog(KSM_INVARG, "NULL policy");
65  return -1;
66  }
67  return policy->clockskew;
68 }
69 
71 {
72  /* check the argument */
73  if (policy == NULL) {
74  MsgLog(KSM_INVARG, "NULL policy");
75  return -1;
76  }
77  return policy->lifetime;
78 }
79 
81 {
82  /* check the argument */
83  if (policy == NULL) {
84  MsgLog(KSM_INVARG, "NULL policy");
85  return -1;
86  }
87  return policy->overlap;
88 }
89 
91 {
92  /* check the argument */
93  if (policy == NULL) {
94  MsgLog(KSM_INVARG, "NULL policy");
95  return -1;
96  }
97  return policy->propdelay;
98 }
99 
100 /*int KsmParameterSigningInterval(KSM_PARCOLL* collection)
101 //{
102 // return collection->signint;
103 }*/
104 
106 {
107  /* check the argument */
108  if (policy == NULL) {
109  MsgLog(KSM_INVARG, "NULL policy");
110  return -1;
111  }
112  return policy->soamin;
113 }
114 
116 {
117  /* check the argument */
118  if (policy == NULL) {
119  MsgLog(KSM_INVARG, "NULL policy");
120  return -1;
121  }
122  return policy->soattl;
123 }
124 
126 {
127  /* check the argument */
128  if (policy == NULL) {
129  MsgLog(KSM_INVARG, "NULL policy");
130  return -1;
131  }
132  return policy->ttl;
133 }
134 
135 /*
136  * Initial publication interval
137  */
139 {
140  int ncache; /* Negative cache time */
141  int pubint; /* Publication interval */
142 
143  /* check the argument */
144  if (policy == NULL) {
145  MsgLog(KSM_INVARG, "NULL policy");
146  return -1;
147  }
148  ncache = min(policy->signer->soattl, policy->signer->soamin);
149  pubint = max(policy->zsk->ttl, ncache) + policy->signer->propdelay;
150 
151  return pubint;
152 }
int KsmPolicyClockskew(KSM_SIGNATURE_POLICY *policy)
int overlap
Definition: ksm.h:216
#define KSM_INVARG
Definition: ksmdef.h:66
int KsmPolicyKeyLifetime(KSM_KEY_POLICY *policy)
KSM_KEY_POLICY * zsk
Definition: ksm.h:254
int MsgLog(int status,...)
Definition: message.c:335
int KsmPolicySoaTtl(KSM_SIGNER_POLICY *policy)
int KsmPolicySoaMin(KSM_SIGNER_POLICY *policy)
int KsmPolicyKeyTtl(KSM_KEY_POLICY *policy)
#define max(x, y)
KSM_SIGNER_POLICY * signer
Definition: ksm.h:249
int KsmPolicyStandbyKeys(KSM_KEY_POLICY *policy)
int propdelay
Definition: ksm.h:175
int ttl
Definition: ksm.h:217
int lifetime
Definition: ksm.h:211
int KsmPolicyInitialPublicationInterval(KSM_POLICY *policy)
#define min(x, y)
int KsmPolicyPropagationDelay(KSM_SIGNER_POLICY *policy)