diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-31 19:38:18 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-31 19:38:18 +0200 |
commit | ee8b2de4b795fbc3b292e14c9f088244a7e08690 (patch) | |
tree | 561cfa9b830d315e4307d8c1aeceb1c475e192da /src/fastd.h | |
parent | 0c82651c30bf543903ca05df4e5b179201353ee1 (diff) | |
download | fastd-ee8b2de4b795fbc3b292e14c9f088244a7e08690.tar fastd-ee8b2de4b795fbc3b292e14c9f088244a7e08690.zip |
ecfxp: refresh session key periodically
Diffstat (limited to 'src/fastd.h')
-rw-r--r-- | src/fastd.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h index dc425ba..e9d30a0 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -93,6 +93,7 @@ struct _fastd_config { fastd_protocol *protocol; char *secret; unsigned key_valid; + unsigned key_refresh; fastd_peer_config *peers; @@ -123,6 +124,8 @@ struct _fastd_context { size_t eth_addr_size; size_t n_eth_addr; fastd_peer_eth_addr *eth_addr; + + unsigned int randseed; }; void fastd_printf(const fastd_context *ctx, const char *format, ...); @@ -133,6 +136,11 @@ void fastd_configure(fastd_context *ctx, fastd_config *conf, int argc, char *con void fastd_random_bytes(fastd_context *ctx, void *buffer, size_t len, bool secure); +static inline int fastd_rand(fastd_context *ctx, int min, int max) { + unsigned int r = (unsigned int)rand_r(&ctx->randseed); + return (r%(max-min) + min); +} + #define pr_log(ctx, level, prefix, args...) do { \ if ((ctx)->conf == NULL || (level) <= (ctx)->conf->loglevel) { \ fputs(prefix, stderr); fastd_printf(ctx, args); fputs("\n", stderr); \ |