aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/tests/sgsn/sgsn_test.c
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2016-07-05 15:19:12 +0200
committerHarald Welte <laforge@gnumonks.org>2016-07-16 21:03:30 +0000
commit4011e728d22a9affbe41fb2bfc8e69c14bd706ab (patch)
treeb0d6d66b7511cbd52a8204bb19535732e14f2d65 /openbsc/tests/sgsn/sgsn_test.c
parent9759374adbb632ff5f8a4b739e0f62a9c9017622 (diff)
SGSN: use unique AUTH REQ reference
The A&C reference number specified in 3GPP TS 24.008 ยง 10.5.5.19 identifies particular request sent by network with the related response sent by MS. The value transparently copied from request to response by MS: the spec do not specify what exactly should be in there so we use rand() to decrease chance for collisions. Note: variable named 'rand' clashes with standard function rand() so it was renamed. Change-Id: I3638821a9b4a0532b28dbbb50faa30c4082579f6 Related: OS#1582
Diffstat (limited to 'openbsc/tests/sgsn/sgsn_test.c')
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index d568807dd..e8e05f6e9 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -101,6 +101,25 @@ int bssgp_tx_dl_ud(struct msgb *msg, uint16_t pdu_lifetime,
return 0;
}
+/* override, requires '-Wl,--wrap=RAND_bytes' */
+int __real_RAND_bytes(unsigned char *buf, int num);
+int mock_RAND_bytes(unsigned char *buf, int num);
+int (*RAND_bytes_cb)(unsigned char *, int) =
+ &mock_RAND_bytes;
+
+int __wrap_RAND_bytes(unsigned char *buf, int num)
+{
+ return (*RAND_bytes_cb)(buf, num);
+}
+/* make results of A&C ref predictable */
+int mock_RAND_bytes(unsigned char *buf, int num)
+{
+ if (num > 1)
+ return __real_RAND_bytes(buf, num);
+ buf[0] = 0;
+ return 1;
+}
+
/* override, requires '-Wl,--wrap=sgsn_update_subscriber_data' */
void __real_sgsn_update_subscriber_data(struct sgsn_mm_ctx *);
void (*update_subscriber_data_cb)(struct sgsn_mm_ctx *) =