diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-12-26 21:12:37 +0100 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-12-26 21:12:37 +0100 |
commit | 85f77e5953ce6a60235ea3d5af5799668183b497 (patch) | |
tree | c4237dc60c5d90c94abbb8126b81a05dd870dcd0 /src | |
parent | 5236e631bb3c6f3a31c920709e3fe6c5cd579c14 (diff) |
support BSD arc4random() if available
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/utils.c | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index da23fd8..1d161a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,9 +18,13 @@ if HAVE_ICMPFILTER ptunnel_ng_CFLAGS += -DHAVE_ICMPFILTER=1 endif +if HAVE_ARC4RANDOM +ptunnel_ng_CFLAGS += -DHAVE_ARC4RANDOM=1 +else if HAVE_RANDOM ptunnel_ng_CFLAGS += -DHAVE_RANDOM=1 endif +endif ptunnel_ng_SOURCES = \ md5.c \ diff --git a/src/utils.c b/src/utils.c index 6233753..10e8182 100644 --- a/src/utils.c +++ b/src/utils.c @@ -49,6 +49,9 @@ #include <string.h> #include <time.h> #include <assert.h> +#ifdef HAVE_ARC4RANDOM +#include <bsd/stdlib.h> +#endif #ifndef WIN32 #include <syslog.h> @@ -148,6 +151,9 @@ void print_hexstr(unsigned char *buf, size_t siz) { #endif int pt_random(void) { +#ifdef HAVE_ARC4RANDOM + return arc4random(); +#else #ifdef HAVE_RANDOM #ifndef TIME_UTC #define TIME_UTC 1 @@ -161,4 +167,5 @@ int pt_random(void) { srand(time(0)); return rand(); #endif +#endif } |