OpenDNSSEC-enforcer 1.3.0
/build/buildd/opendnssec-1.3.0/enforcer/ksm/ksm_policy_value.c
Go to the documentation of this file.
00001 /*
00002  * $Id: ksm_policy_value.c 5320 2011-07-12 10:42:26Z jakob $
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  * KsmPolicyValue - 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 KsmPolicyClockskew(KSM_SIGNATURE_POLICY *policy)
00063 {
00064     /* check the argument */
00065     if (policy == NULL) {
00066         MsgLog(KSM_INVARG, "NULL policy");
00067         return -1;
00068     }
00069     return policy->clockskew;
00070 }
00071 
00072 int KsmPolicyKeyLifetime(KSM_KEY_POLICY *policy)
00073 {
00074     /* check the argument */
00075     if (policy == NULL) {
00076         MsgLog(KSM_INVARG, "NULL policy");
00077         return -1;
00078     }
00079     return policy->lifetime;
00080 }
00081 
00082 int KsmPolicyStandbyKeys(KSM_KEY_POLICY *policy)
00083 {
00084     /* check the argument */
00085     if (policy == NULL) {
00086         MsgLog(KSM_INVARG, "NULL policy");
00087         return -1;
00088     }
00089     return policy->overlap;
00090 }
00091 
00092 int KsmPolicyPropagationDelay(KSM_SIGNER_POLICY *policy)
00093 {
00094     /* check the argument */
00095     if (policy == NULL) {
00096         MsgLog(KSM_INVARG, "NULL policy");
00097         return -1;
00098     }
00099     return policy->propdelay;
00100 }
00101 
00102 /*int KsmParameterSigningInterval(KSM_PARCOLL* collection)
00103 //{
00104 //    return collection->signint;
00105 }*/
00106 
00107 int KsmPolicySoaMin(KSM_SIGNER_POLICY *policy)
00108 {
00109     /* check the argument */
00110     if (policy == NULL) {
00111         MsgLog(KSM_INVARG, "NULL policy");
00112         return -1;
00113     }
00114     return policy->soamin;
00115 }
00116 
00117 int KsmPolicySoaTtl(KSM_SIGNER_POLICY *policy)
00118 {
00119     /* check the argument */
00120     if (policy == NULL) {
00121         MsgLog(KSM_INVARG, "NULL policy");
00122         return -1;
00123     }
00124     return policy->soattl;
00125 }
00126 
00127 int KsmPolicyKeyTtl(KSM_KEY_POLICY *policy)
00128 {
00129     /* check the argument */
00130     if (policy == NULL) {
00131         MsgLog(KSM_INVARG, "NULL policy");
00132         return -1;
00133     }
00134     return policy->ttl;
00135 }
00136 
00137 /*
00138  * Initial publication interval
00139  */
00140 int KsmPolicyInitialPublicationInterval(KSM_POLICY *policy)
00141 {
00142     int     ncache;         /* Negative cache time */
00143     int     pubint;         /* Publication interval */
00144 
00145     /* check the argument */
00146     if (policy == NULL) {
00147         MsgLog(KSM_INVARG, "NULL policy");
00148         return -1;
00149     }
00150     ncache = min(policy->signer->soattl, policy->signer->soamin);
00151     pubint = max(policy->zsk->ttl, ncache) + policy->signer->propdelay;
00152 
00153     return pubint;
00154 }