1135446Strhodes/* 2193149Sdougb * Copyright (C) 2004-2007, 2009 Internet Systems Consortium, Inc. ("ISC") 3135446Strhodes * Copyright (C) 1999-2001 Internet Software Consortium. 4135446Strhodes * 5193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any 6135446Strhodes * purpose with or without fee is hereby granted, provided that the above 7135446Strhodes * copyright notice and this permission notice appear in all copies. 8135446Strhodes * 9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11135446Strhodes * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15135446Strhodes * PERFORMANCE OF THIS SOFTWARE. 16135446Strhodes */ 17135446Strhodes 18234010Sdougb/* $Id: random.h,v 1.20 2009/01/17 23:47:43 tbox Exp $ */ 19135446Strhodes 20135446Strhodes#ifndef ISC_RANDOM_H 21135446Strhodes#define ISC_RANDOM_H 1 22135446Strhodes 23135446Strhodes#include <isc/lang.h> 24135446Strhodes#include <isc/types.h> 25135446Strhodes 26193149Sdougb/*! \file isc/random.h 27170222Sdougb * \brief Implements a random state pool which will let the caller return a 28193149Sdougb * series of possibly non-reproducible random values. 29170222Sdougb * 30170222Sdougb * Note that the 31135446Strhodes * strength of these numbers is not all that high, and should not be 32135446Strhodes * used in cryptography functions. It is useful for jittering values 33135446Strhodes * a bit here and there, such as timeouts, etc. 34135446Strhodes */ 35135446Strhodes 36135446StrhodesISC_LANG_BEGINDECLS 37135446Strhodes 38135446Strhodesvoid 39135446Strhodesisc_random_seed(isc_uint32_t seed); 40170222Sdougb/*%< 41135446Strhodes * Set the initial seed of the random state. 42135446Strhodes */ 43135446Strhodes 44135446Strhodesvoid 45135446Strhodesisc_random_get(isc_uint32_t *val); 46170222Sdougb/*%< 47135446Strhodes * Get a random value. 48135446Strhodes * 49135446Strhodes * Requires: 50135446Strhodes * val != NULL. 51135446Strhodes */ 52135446Strhodes 53135446Strhodesisc_uint32_t 54135446Strhodesisc_random_jitter(isc_uint32_t max, isc_uint32_t jitter); 55170222Sdougb/*%< 56135446Strhodes * Get a random value between (max - jitter) and (max). 57135446Strhodes * This is useful for jittering timer values. 58135446Strhodes */ 59135446Strhodes 60135446StrhodesISC_LANG_ENDDECLS 61135446Strhodes 62135446Strhodes#endif /* ISC_RANDOM_H */ 63