From cb5f37d93b0f40468f141d87714060511a265288 Mon Sep 17 00:00:00 2001 From: Michael Graff Date: Wed, 15 Dec 1999 01:49:07 +0000 Subject: [PATCH] add lfsr.h --- lib/isc/include/isc/Makefile.in | 2 +- lib/isc/include/isc/lfsr.h | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 lib/isc/include/isc/lfsr.h diff --git a/lib/isc/include/isc/Makefile.in b/lib/isc/include/isc/Makefile.in index c654adf01a..383aaec70b 100644 --- a/lib/isc/include/isc/Makefile.in +++ b/lib/isc/include/isc/Makefile.in @@ -21,7 +21,7 @@ top_srcdir = @top_srcdir@ HEADERS = assertions.h base64.h boolean.h buffer.h bufferlist.h \ commandline.h error.h event.h eventclass.h \ - heap.h int.h interfaceiter.h lang.h lex.h lib.h \ + heap.h int.h interfaceiter.h lang.h lex.h lfsr.h lib.h \ list.h magic.h mem.h msgcat.h mutexblock.h netaddr.h \ print.h random.h rbtgen.h region.h result.h \ resultclass.h rwlock.h serial.h sockaddr.h socket.h str.h \ diff --git a/lib/isc/include/isc/lfsr.h b/lib/isc/include/isc/lfsr.h new file mode 100644 index 0000000000..0068ce84ea --- /dev/null +++ b/lib/isc/include/isc/lfsr.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_LFSR_H +#define ISC_LFSR_H 1 + +#include + +/* + * The members of this structure can be used by the application, but care + * needs to be taken to not change state once the lfsr is in operation. + */ +typedef struct { + isc_uint32_t state; /* previous state */ + isc_uint32_t bits; /* length */ + isc_uint32_t tap; /* bit taps */ +} isc_lfsr_t; + +/* + * This structure contains some standard LFSR values that can be used. + * One can use the isc_lfsr_findlfsr() to search for one with at least + * a certain number of bits. + */ +extern isc_lfsr_t isc_lfsr_standard[]; + +ISC_LANG_BEGINDECLS + +isc_uint32_t isc_lfsr_generate(isc_lfsr_t *lfsr); +isc_uint32_t isc_lfsr_skipgenerate(isc_lfsr_t *lfsr, unsigned int skip); +isc_uint32_t isc_lfsr_lfsrskipgenerate(isc_lfsr_t *lfsr1, isc_lfsr_t *lfsr2, + unsigned int skipbits); + +ISC_LANG_ENDDECLS + +#endif /* ISC_LFSR_H */