aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2018-01-08 14:43:53 +0100
committerHarald Welte <laforge@gnumonks.org>2018-01-19 15:11:00 +0000
commit25c65c3d1f39f55340180273201cf91a1d10d741 (patch)
tree43615c9ca564f469e313487339259ee9cb3cb18d
parent6789c84457eb278f4ad144f90c29fd7420899e60 (diff)
Use gsm48_encode_ra() for RAI encoding
It has stricter type signature which increase the chance of spotting misuse either via compiler warning or with automated scan. This also paves the way for gsm48_construct_ra() deprecation in libosmocore. Change-Id: I2c0f082dc7214ed57a40dad0788e34b838dfac97 Related: OS#1640
-rw-r--r--src/gprs/gb_proxy_patch.c12
-rw-r--r--src/gprs/gprs_gmm.c4
-rw-r--r--src/gprs/sgsn_libgtp.c2
-rw-r--r--src/libcommon/gsm_data.c9
-rw-r--r--tests/gbproxy/gbproxy_test.c14
5 files changed, 16 insertions, 25 deletions
diff --git a/src/gprs/gb_proxy_patch.c b/src/gprs/gb_proxy_patch.c
index 48627550..1be9c245 100644
--- a/src/gprs/gb_proxy_patch.c
+++ b/src/gprs/gb_proxy_patch.c
@@ -32,7 +32,7 @@
extern void *tall_bsc_ctx;
/* patch RA identifier in place */
-static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer,
+static void gbproxy_patch_raid(struct gsm48_ra_id *raid_enc, struct gbproxy_peer *peer,
int to_bss, const char *log_text)
{
struct gbproxy_patch_state *state = &peer->patch_state;
@@ -47,7 +47,7 @@ static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer,
if (!state->local_mcc || !state->local_mnc)
return;
- gsm48_parse_ra(&raid, raid_enc);
+ gsm48_parse_ra(&raid, (uint8_t *)raid_enc);
old_mcc = raid.mcc;
old_mnc = raid.mnc;
@@ -76,7 +76,7 @@ static void gbproxy_patch_raid(uint8_t *raid_enc, struct gbproxy_peer *peer,
old_mcc, old_mnc, raid.lac, raid.rac,
raid.mcc, raid.mnc, raid.lac, raid.rac);
- gsm48_construct_ra(raid_enc, &raid);
+ gsm48_encode_ra(raid_enc, &raid);
rate_ctr_inc(&peer->ctrg->ctr[counter]);
}
@@ -233,14 +233,14 @@ int gbproxy_patch_llc(struct msgb *msg, uint8_t *llc, size_t llc_len,
}
if (parse_ctx->raid_enc) {
- gbproxy_patch_raid(parse_ctx->raid_enc, peer, parse_ctx->to_bss,
+ gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->raid_enc, peer, parse_ctx->to_bss,
parse_ctx->llc_msg_name);
have_patched = 1;
}
if (parse_ctx->old_raid_enc && !parse_ctx->old_raid_is_foreign) {
/* TODO: Patch to invalid if P-TMSI unknown. */
- gbproxy_patch_raid(parse_ctx->old_raid_enc, peer, parse_ctx->to_bss,
+ gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->old_raid_enc, peer, parse_ctx->to_bss,
parse_ctx->llc_msg_name);
have_patched = 1;
}
@@ -286,7 +286,7 @@ void gbproxy_patch_bssgp(struct msgb *msg, uint8_t *bssgp, size_t bssgp_len,
int err_ctr = -1;
if (parse_ctx->bssgp_raid_enc)
- gbproxy_patch_raid(parse_ctx->bssgp_raid_enc, peer,
+ gbproxy_patch_raid((struct gsm48_ra_id *)parse_ctx->bssgp_raid_enc, peer,
parse_ctx->to_bss, "BSSGP");
if (parse_ctx->need_decryption &&
diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 77a55372..9313e989 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -448,7 +448,7 @@ static int gsm48_tx_gmm_att_ack(struct sgsn_mm_ctx *mm)
aa->att_result = 1; /* GPRS only */
aa->ra_upd_timer = gprs_secs_to_tmr_floor(sgsn->cfg.timers.T3312);
aa->radio_prio = 4; /* lowest */
- gsm48_construct_ra((uint8_t *)&aa->ra_id, &mm->ra);
+ gsm48_encode_ra(&aa->ra_id, &mm->ra);
#if 0
/* Optional: P-TMSI signature */
@@ -1505,7 +1505,7 @@ static int gsm48_tx_gmm_ra_upd_ack(struct sgsn_mm_ctx *mm)
rua->upd_result = 0; /* RA updated */
rua->ra_upd_timer = gprs_secs_to_tmr_floor(sgsn->cfg.timers.T3312);
- gsm48_construct_ra((uint8_t *)&rua->ra_id, &mm->ra);
+ gsm48_encode_ra(&rua->ra_id, &mm->ra);
#if 0
/* Optional: P-TMSI signature */
diff --git a/src/gprs/sgsn_libgtp.c b/src/gprs/sgsn_libgtp.c
index 1032230a..ae293f1d 100644
--- a/src/gprs/sgsn_libgtp.c
+++ b/src/gprs/sgsn_libgtp.c
@@ -268,7 +268,7 @@ struct sgsn_pdp_ctx *sgsn_create_pdp_ctx(struct sgsn_ggsn_ctx *ggsn,
raid = mmctx->ra;
raid.lac = 0xFFFE;
raid.rac = 0xFF;
- gsm48_construct_ra(pdp->rai.v, &raid);
+ gsm48_encode_ra((struct gsm48_ra_id *)pdp->rai.v, &raid);
/* Encode User Location Information accordint to TS 29.060 7.7.51 */
pdp->userloc_given = 1;
diff --git a/src/libcommon/gsm_data.c b/src/libcommon/gsm_data.c
index a2837f38..6400963a 100644
--- a/src/libcommon/gsm_data.c
+++ b/src/libcommon/gsm_data.c
@@ -311,15 +311,6 @@ void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts)
raid->rac = bts->gprs.rac;
}
-int gsm48_ra_id_by_bts(uint8_t *buf, struct gsm_bts *bts)
-{
- struct gprs_ra_id raid;
-
- gprs_ra_id_by_bts(&raid, bts);
-
- return gsm48_construct_ra(buf, &raid);
-}
-
int gsm_parse_reg(void *ctx, regex_t *reg, char **str, int argc, const char **argv)
{
int ret;
diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c
index 3ebdccba..080c96bb 100644
--- a/tests/gbproxy/gbproxy_test.c
+++ b/tests/gbproxy/gbproxy_test.c
@@ -222,9 +222,9 @@ static int dump_peers(FILE *stream, int indent, time_t now,
const uint8_t *convert_ra(struct gprs_ra_id *raid)
{
- static uint8_t buf[6];
- gsm48_construct_ra(buf, raid);
- return buf;
+ static struct gsm48_ra_id r;
+ gsm48_encode_ra(&r, raid);
+ return (const uint8_t *)&r;
}
/* DTAP - Attach Request */
@@ -582,7 +582,7 @@ static void send_bssgp_ul_unitdata(
OSMO_ASSERT(bssgp_msg_size <= sizeof(msg));
- gsm48_construct_ra(msg + 10, raid);
+ gsm48_encode_ra((struct gsm48_ra_id *)(msg + 10), raid);
msg[1] = (uint8_t)(tlli >> 24);
msg[2] = (uint8_t)(tlli >> 16);
msg[3] = (uint8_t)(tlli >> 8);
@@ -713,7 +713,7 @@ static void send_bssgp_suspend(struct gprs_ns_inst *nsi,
msg[5] = (uint8_t)(tlli >> 8);
msg[6] = (uint8_t)(tlli >> 0);
- gsm48_construct_ra(msg + 9, raid);
+ gsm48_encode_ra((struct gsm48_ra_id *)(msg + 9), raid);
send_ns_unitdata(nsi, "BVC_SUSPEND", src_addr, 0, msg, sizeof(msg));
}
@@ -735,7 +735,7 @@ static void send_bssgp_suspend_ack(struct gprs_ns_inst *nsi,
msg[5] = (uint8_t)(tlli >> 8);
msg[6] = (uint8_t)(tlli >> 0);
- gsm48_construct_ra(msg + 9, raid);
+ gsm48_encode_ra((struct gsm48_ra_id *)(msg + 9), raid);
send_ns_unitdata(nsi, "BVC_SUSPEND_ACK", src_addr, 0, msg, sizeof(msg));
}
@@ -795,7 +795,7 @@ static void send_bssgp_paging(struct gprs_ns_inst *nsi,
if (raid) {
msg[bssgp_msg_size] = BSSGP_IE_ROUTEING_AREA;
msg[bssgp_msg_size+1] = 0x86;
- gsm48_construct_ra(msg + bssgp_msg_size + 2, raid);
+ gsm48_encode_ra((struct gsm48_ra_id *)(msg + bssgp_msg_size + 2), raid);
bssgp_msg_size += 8;
}