diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-04-01 15:17:18 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2008-04-01 15:17:18 +0200 |
commit | 7fd96c5b04177a412d9ef12b2f4620b587fe8ed6 (patch) | |
tree | ccdbbe3c7fbef5b738c0688fe3aff4d6e9550127 /source4 | |
parent | f41b9a9dde0dcad17e3a137537548f9bd9ab3901 (diff) | |
download | samba-7fd96c5b04177a412d9ef12b2f4620b587fe8ed6.tar.gz samba-7fd96c5b04177a412d9ef12b2f4620b587fe8ed6.tar.bz2 samba-7fd96c5b04177a412d9ef12b2f4620b587fe8ed6.zip |
Add userdata argument to reseed callback function.
(This used to be commit d4272bc6bcfcd71fa93edb25bb33d6458e8b33cd)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/util/genrand.c | 8 | ||||
-rw-r--r-- | source4/lib/util/tests/genrand.c | 4 | ||||
-rw-r--r-- | source4/lib/util/util.h | 2 |
3 files changed, 8 insertions, 6 deletions
diff --git a/source4/lib/util/genrand.c b/source4/lib/util/genrand.c index 5751db23d6..7df4ec4e20 100644 --- a/source4/lib/util/genrand.c +++ b/source4/lib/util/genrand.c @@ -37,15 +37,17 @@ static unsigned int bytes_since_reseed = 0; static int urand_fd = -1; -static void (*reseed_callback)(int *newseed); +static void (*reseed_callback)(void *userdata, int *newseed); +static void *reseed_callback_userdata = NULL; /** Copy any user given reseed data. **/ -_PUBLIC_ void set_rand_reseed_callback(void (*fn)(int *)) +_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *userdata) { reseed_callback = fn; + reseed_callback_userdata = userdata; set_need_random_reseed(); } @@ -61,7 +63,7 @@ _PUBLIC_ void set_need_random_reseed(void) static void get_rand_reseed_data(int *reseed_data) { if (reseed_callback) { - reseed_callback(reseed_data); + reseed_callback(reseed_callback_userdata, reseed_data); } else { *reseed_data = 0; } diff --git a/source4/lib/util/tests/genrand.c b/source4/lib/util/tests/genrand.c index 205a66352f..5fe229c089 100644 --- a/source4/lib/util/tests/genrand.c +++ b/source4/lib/util/tests/genrand.c @@ -22,14 +22,14 @@ #include "includes.h" #include "torture/torture.h" -static void dummy_reseed(int *d) +static void dummy_reseed(void *userdata, int *d) { *d = 42; } static bool test_reseed_callback(struct torture_context *tctx) { - set_rand_reseed_callback(dummy_reseed); + set_rand_reseed_callback(dummy_reseed, NULL); return true; } diff --git a/source4/lib/util/util.h b/source4/lib/util/util.h index 26700587ef..60c8437634 100644 --- a/source4/lib/util/util.h +++ b/source4/lib/util/util.h @@ -218,7 +218,7 @@ _PUBLIC_ struct in_addr sys_inet_makeaddr(int net, int host); /** Copy any user given reseed data. **/ -_PUBLIC_ void set_rand_reseed_callback(void (*fn)(int *)); +_PUBLIC_ void set_rand_reseed_callback(void (*fn)(void *, int *), void *); /** * Tell the random number generator it needs to reseed. |