/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* DESCRIPTION: Contains utilities relating to TTL calculation.
*/
#include <unistd.h>
#include <syslog.h>
#include <errno.h>
#include <strings.h>
#include <ndbm.h>
#include "ypsym.h"
#include "ypdefs.h"
#include "shim.h"
#include "yptol.h"
#include "../ldap_util.h"
/*
* Constants used in time calculations
*/
/*
* Decs
*/
/*
* FUNCTION: has_entry_expired()
*
* DESCRIPTION: Determines if an individual entry has expired.
*
* INPUTS: Map control structure for an open map
* Entry key
*
* OUTPUTS: TRUE = Entry has expired or cannot be found this will cause
* missing entries to be pulled out of the DIT.
* FALSE = Entry has not expired
*
*/
{
char *key_name;
return (FALSE);
/* Get expiry time entry for key */
/*
* If we failed to get a map expiry key, which must always be
* present, then something is seriously wrong. Try to recreate
* the map.
*/
"for map %s. Will attempt to recreate map",
return (TRUE);
}
/*
* Not a problem just no TTL entry for this entry. Maybe it has
* not yet been downloaded. Maybe it will be handled by a
* service other than NIS. Check if the entire map has expired.
* This prevents repeated LDAP reads when requests are made for
* nonexistant entries.
*/
if (has_map_expired(map)) {
/* Kick of a map update */
}
/* Don't update the entry */
return (FALSE);
}
/*
* Need to malloc some memory before can syslog the key name
* but this may fail. Solution log a simple message first THEn
* a more detailed one if it works.
*/
"Invalid TTL key in map %s. error %d",
/* Log the key name */
"Could not alloc memory for keyname");
} else {
"Key name was %s", key_name);
}
/* Update it Anyway */
return (TRUE);
}
/* Get current time */
/*
* Because dptr may not be int aligned need to build an int
* out of what it points to or will get a bus error
*/
}
/*
* FUNCTION: has_map_expired()
*
* DESCRIPTION: Determines if an entire map has expire
*
* INPUTS: Map control structure for an open map
*
* OUTPUTS: TRUE = Map has expired
* FALSE Map has not expired
*
*/
{
/* Set up datum with magic expiry key */
/* Call has_entry_expired() with magic map expiry key */
}
/*
* FUNCTION: update_entry_ttl()
*
* DESCRIPTION: Updates the TTL for one map entry
*
* INPUTS: Map control structure for an open map
* Entry key
* Flag indication if TTL should be max, min or random
*
* OUTPUTS: SUCCESS = TTL updated
* FAILURE = TTL not updated
*
*/
{
int ttl;
/* Get current time */
/* Get TTL from mapping file */
return (FAILURE);
/* Convert time into a datum */
/* Set expiry time entry for key */
errno = 0;
"(errno=%d)", errno);
return (FAILURE);
}
return (SUCCESS);
}
/*
* FUNCTION: update_map_ttl()
*
* DESCRIPTION: Updates the TTL for entire map. This can be called either with
* the map open (map_ctrl DBM pointer set up) or the map closed
* (map_ctrl DBM pointers not set). The latter case will occur
* when we have just created a new map.
*
* This function must open the TTL map but, in either case, must
* return with the map_ctrl in it's original state.
*
* INPUTS: Map control structure for an open map
*
* OUTPUTS: SUCCESS = TTL updated
* FAILURE = TTL not updated
*
*/
{
/* Set up datum with magic expiry key */
/* If TTL not open open it */
return (FAILURE);
}
/* Call update_entry_ttl() with magic map expiry key */
/* If we had to open TTL file close it */
if (!map_was_open) {
}
return (ret);
}
/*
* FUNCTION: add_to_timeval()
*
* DESCRIPTION: Adds an int to a timeval
*
* NOTE : Seems strange that there is not a library function to do this
* if one exists then this function can be removed.
*
* NOTE : Does not handle UNIX clock wrap round but this is a much bigger
* problem.
*
* INPUTS: Time value to add to
* Time value to add in seconds
*
* OUTPUTS: SUCCESS = Addition successful
* FAILURE = Addition failed (probably wrapped)
*
*/
{
long usec;
/* Add seconds part */
/* Check for clock wrap */
return (FAILURE);
}
return (SUCCESS);
}
/*
* FUNCTION: is_greater_timeval()
*
* DESCRIPTION: Compares two timevals
*
* NOTE : Seems strange that there is not a library function to do this
* if one exists then this function can be removed.
*
* INPUTS: First time value
* Time value to compare it with
*
* OUTPUTS: TRUE t1 > t2
* FALSE t1 <= t2
*
*/
{
return (TRUE);
return (TRUE);
else
return (FALSE);
}
return (FALSE);
}