diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-07-21 22:20:49 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2018-07-23 20:55:45 +0100 |
commit | 812866daab20dbb9242d7b3a7f417f6d0e1d8a0e (patch) | |
tree | e1c46e87d74000766d043e3d2b07731b8104b4d0 /src/host/layer23/include | |
parent | fd33dcc2023dad960157023b7d5de586612dc5f5 (diff) |
Move from libc random() to osmo_get_rand_id (2nd attempt)
When starting multiple mobile in the same second, the libc random number
generator will be seeded to exactly the same value.
The random bits inside the RACH request(s) will be exactly the same
across multiple mobile and when the channel fails they all pick the same
randomized back-off timing.
Use stronger random numbers and replace all calls to random(2) with
osmo_get_rand_id. Add a fallback to try random().
[v2: Add helper to make sure the result is int and between 0 and
RAND_MAX]
Change-Id: Icdd4be88c62bba1e9d954568e48f0c12a67ac182
Diffstat (limited to 'src/host/layer23/include')
-rw-r--r-- | src/host/layer23/include/osmocom/bb/common/Makefile.am | 2 | ||||
-rw-r--r-- | src/host/layer23/include/osmocom/bb/common/utils.h | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/Makefile.am b/src/host/layer23/include/osmocom/bb/common/Makefile.am index 945c73db..cd3437e3 100644 --- a/src/host/layer23/include/osmocom/bb/common/Makefile.am +++ b/src/host/layer23/include/osmocom/bb/common/Makefile.am @@ -1,2 +1,2 @@ noinst_HEADERS = l1ctl.h l1l2_interface.h l23_app.h logging.h \ - networks.h gps.h sysinfo.h osmocom_data.h + networks.h gps.h sysinfo.h osmocom_data.h utils.h diff --git a/src/host/layer23/include/osmocom/bb/common/utils.h b/src/host/layer23/include/osmocom/bb/common/utils.h new file mode 100644 index 00000000..8ca61f82 --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/utils.h @@ -0,0 +1,3 @@ +#pragma once + +int layer23_random(void); |