entropy.c revision ec5347e2c775f027573ce5648b910361aa926c01
bc6f4c1c4c1b739fd06d2de05b77b9d08c4d8a5aTinderbox User * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Copyright (C) 2000-2003 Internet Software Consortium.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * Permission to use, copy, modify, and/or distribute this software for any
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * purpose with or without fee is hereby granted, provided that the above
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * copyright notice and this permission notice appear in all copies.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * PERFORMANCE OF THIS SOFTWARE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt/* $Id: entropy.c,v 1.79 2007/06/18 23:47:48 tbox Exp $ */
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * This is the system dependent part of the ISC entropy API.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#include <sys/param.h> /* Openserver 5.0.6A and FD_SETSIZE */
42cf2ff7bad81c5a1f5d3be29d06e12504c3af24Evan Hunt * There is only one variable in the entropy data structures that is not
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * system independent, but pulling the structure that uses it into this file
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * ultimately means pulling several other independent structures here also to
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * resolve their interdependencies. Thus only the problem variable's type
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * is defined here.
8a2ab2b9203120c3e2a883a5ee8c0b5d60c1808cEvan Hunttypedef struct {
8a2ab2b9203120c3e2a883a5ee8c0b5d60c1808cEvan Huntstatic unsigned int
8a2ab2b9203120c3e2a883a5ee8c0b5d60c1808cEvan Huntget_from_filesource(isc_entropysource_t *source, isc_uint32_t desired) {
ce6f0c122140647b5652c0d4de523c994fcfea08Michał Kępień desired = desired / 8 + (((desired & 0x07) > 0) ? 1 : 0);
desired -= n;
goto out;
err:
out:
return (added);
unsigned int added;
added = 0;
while (desired > 0) {
goto out;
goto err;
goto eagain_loop;
goto out;
goto err;
goto eagain_loop;
case isc_usocketsource_wrote:
goto eagain_loop;
goto out;
goto err;
goto err;
if (sz_to_recv != 0U) {
goto out;
goto err;
goto err;
goto out;
desired -= n;
goto out;
err:
out:
return (added);
unsigned int added;
unsigned int remaining;
unsigned int needed;
unsigned int nsource;
if (needed == 0) {
added = 0;
unsigned int got;
if (remaining == 0)
got = 0;
case ENTROPY_SOURCETYPE_FILE:
int fds;
if (fds > 0)
goto again_file;
unsigned int got;
got = 0;
int cc;
if (fd >= 0) {
if (fd >= 0) {
case isc_usocketsource_wrote:
if (maxfd < 0)
if (cc < 0)
return (cc);
static isc_result_t
int ret;
int flags;
#ifdef USE_FIONBIO_IOCTL
#ifdef USE_FIONBIO_IOCTL
strbuf);
return (ISC_R_UNEXPECTED);
return (ISC_R_SUCCESS);
int fd;
goto errout;
#if defined(S_ISSOCK)
if (is_usocket)
if (fd < 0) {
goto errout;
goto closefd;
if (is_usocket) {
#ifdef ISC_PLATFORM_HAVESALEN
#if !defined(SUN_LEN)
sizeof(struct sockaddr_un)) < 0) {
goto closefd;
goto closefd;
if (is_usocket) {
if (is_connected)
return (ISC_R_SUCCESS);
return (ret);