aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/gprs
diff options
context:
space:
mode:
Diffstat (limited to 'openbsc/src/gprs')
-rw-r--r--openbsc/src/gprs/Makefile.am2
-rw-r--r--openbsc/src/gprs/gb_proxy.c2
-rw-r--r--openbsc/src/gprs/gb_proxy_patch.c1
-rw-r--r--openbsc/src/gprs/gb_proxy_peer.c1
-rw-r--r--openbsc/src/gprs/gprs_gb_parse.c58
-rw-r--r--openbsc/src/gprs/gprs_gmm.c22
-rw-r--r--openbsc/src/gprs/gprs_gsup_messages.c419
-rw-r--r--openbsc/src/gprs/gprs_sgsn.c2
-rw-r--r--openbsc/src/gprs/gprs_subscriber.c131
-rw-r--r--openbsc/src/gprs/gprs_utils.c136
-rw-r--r--openbsc/src/gprs/gsm_04_08_gprs.c116
-rw-r--r--openbsc/src/gprs/gtphub.c10
-rw-r--r--openbsc/src/gprs/gtphub_ares.c2
-rw-r--r--openbsc/src/gprs/oap.c43
-rw-r--r--openbsc/src/gprs/oap_messages.c20
-rw-r--r--openbsc/src/gprs/sgsn_auth.c3
-rw-r--r--openbsc/src/gprs/sgsn_libgtp.c2
-rw-r--r--openbsc/src/gprs/sgsn_vty.c14
18 files changed, 171 insertions, 813 deletions
diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am
index 187b07ed9..d098559f9 100644
--- a/openbsc/src/gprs/Makefile.am
+++ b/openbsc/src/gprs/Makefile.am
@@ -30,7 +30,7 @@ osmo_sgsn_SOURCES = gprs_gmm.c gprs_sgsn.c gprs_sndcp.c gprs_sndcp_vty.c \
sgsn_main.c sgsn_vty.c sgsn_libgtp.c \
gprs_llc.c gprs_llc_parse.c gprs_llc_vty.c crc24.c \
sgsn_ctrl.c sgsn_auth.c gprs_subscriber.c \
- gprs_gsup_messages.c gprs_utils.c gprs_gsup_client.c \
+ gprs_utils.c gprs_gsup_client.c \
gsm_04_08_gprs.c sgsn_cdr.c sgsn_ares.c \
oap.c oap_messages.c
diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 6e6b03b86..111f05208 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -48,7 +48,7 @@
#include <openbsc/gprs_llc.h>
#include <openbsc/gsm_04_08.h>
-#include <openbsc/gsm_04_08_gprs.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <openbsc/gprs_utils.h>
#include <openssl/rand.h>
diff --git a/openbsc/src/gprs/gb_proxy_patch.c b/openbsc/src/gprs/gb_proxy_patch.c
index c1d2497db..7bddc4494 100644
--- a/openbsc/src/gprs/gb_proxy_patch.c
+++ b/openbsc/src/gprs/gb_proxy_patch.c
@@ -23,7 +23,6 @@
#include <openbsc/gprs_utils.h>
#include <openbsc/gprs_gb_parse.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/gsm_data.h>
#include <openbsc/debug.h>
diff --git a/openbsc/src/gprs/gb_proxy_peer.c b/openbsc/src/gprs/gb_proxy_peer.c
index c2cdd0e67..5365ff0fa 100644
--- a/openbsc/src/gprs/gb_proxy_peer.c
+++ b/openbsc/src/gprs/gb_proxy_peer.c
@@ -24,7 +24,6 @@
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_data_shared.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/debug.h>
#include <osmocom/gprs/protocol/gsm_08_18.h>
diff --git a/openbsc/src/gprs/gprs_gb_parse.c b/openbsc/src/gprs/gprs_gb_parse.c
index 63ac9028d..f11d93aef 100644
--- a/openbsc/src/gprs/gprs_gb_parse.c
+++ b/openbsc/src/gprs/gprs_gb_parse.c
@@ -19,12 +19,12 @@
*/
#include <osmocom/gsm/gsm48.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <openbsc/gprs_gb_parse.h>
#include <openbsc/gprs_utils.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/debug.h>
#include <osmocom/gprs/gprs_bssgp.h>
@@ -38,7 +38,7 @@ static int gprs_gb_parse_gmm_attach_req(uint8_t *data, size_t data_len,
parse_ctx->llc_msg_name = "ATTACH_REQ";
/* Skip MS network capability */
- if (gprs_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
+ if (osmo_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
value_len < 1 || value_len > 8)
/* invalid */
return 0;
@@ -46,10 +46,10 @@ static int gprs_gb_parse_gmm_attach_req(uint8_t *data, size_t data_len,
/* Skip Attach type */
/* Skip Ciphering key sequence number */
/* Skip DRX parameter */
- gprs_shift_v_fixed(&data, &data_len, 3, NULL);
+ osmo_shift_v_fixed(&data, &data_len, 3, NULL);
/* Get Mobile identity */
- if (gprs_shift_lv(&data, &data_len, &value, &value_len) <= 0 ||
+ if (osmo_shift_lv(&data, &data_len, &value, &value_len) <= 0 ||
value_len < 5 || value_len > 8)
/* invalid */
return 0;
@@ -61,7 +61,7 @@ static int gprs_gb_parse_gmm_attach_req(uint8_t *data, size_t data_len,
parse_ctx->imsi_len = value_len;
}
- if (gprs_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
return 0;
parse_ctx->old_raid_enc = value;
@@ -82,21 +82,21 @@ static int gprs_gb_parse_gmm_attach_ack(uint8_t *data, size_t data_len,
/* Skip Periodic RA update timer */
/* Skip Radio priority for SMS */
/* Skip Spare half octet */
- gprs_shift_v_fixed(&data, &data_len, 3, NULL);
+ osmo_shift_v_fixed(&data, &data_len, 3, NULL);
- if (gprs_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
return 0;
parse_ctx->raid_enc = value;
/* Skip P-TMSI signature (P-TMSI signature, opt, TV, length 4) */
- gprs_match_tv_fixed(&data, &data_len, GSM48_IE_GMM_PTMSI_SIG, 3, NULL);
+ osmo_match_shift_tv_fixed(&data, &data_len, GSM48_IE_GMM_PTMSI_SIG, 3, NULL);
/* Skip Negotiated READY timer value (GPRS timer, opt, TV, length 2) */
- gprs_match_tv_fixed(&data, &data_len, GSM48_IE_GMM_TIMER_READY, 1, NULL);
+ osmo_match_shift_tv_fixed(&data, &data_len, GSM48_IE_GMM_TIMER_READY, 1, NULL);
/* Allocated P-TMSI (Mobile identity, opt, TLV, length 7) */
- if (gprs_match_tlv(&data, &data_len, GSM48_IE_GMM_ALLOC_PTMSI,
+ if (osmo_match_shift_tlv(&data, &data_len, GSM48_IE_GMM_ALLOC_PTMSI,
&value, &value_len) > 0 &&
gprs_is_mi_tmsi(value, value_len))
parse_ctx->new_ptmsi_enc = value + 1;
@@ -111,7 +111,7 @@ static int gprs_gb_parse_gmm_attach_rej(uint8_t *data, size_t data_len,
parse_ctx->llc_msg_name = "ATTACH_REJ";
/* GMM cause */
- if (gprs_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
return 0;
parse_ctx->invalidate_tlli = 1;
@@ -132,7 +132,7 @@ static int gprs_gb_parse_gmm_detach_req(uint8_t *data, size_t data_len,
/* Skip spare half octet */
/* Get Detach type */
- if (gprs_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
/* invalid */
return 0;
@@ -150,7 +150,7 @@ static int gprs_gb_parse_gmm_detach_req(uint8_t *data, size_t data_len,
parse_ctx->invalidate_tlli = 1;
/* Get P-TMSI (Mobile identity), see GSM 24.008, 9.4.5.2 */
- if (gprs_match_tlv(&data, &data_len,
+ if (osmo_match_shift_tlv(&data, &data_len,
GSM48_IE_GMM_ALLOC_PTMSI, &value, &value_len) > 0)
{
if (gprs_is_mi_tmsi(value, value_len))
@@ -170,9 +170,9 @@ static int gprs_gb_parse_gmm_ra_upd_req(uint8_t *data, size_t data_len,
/* Skip Update type */
/* Skip GPRS ciphering key sequence number */
- gprs_shift_v_fixed(&data, &data_len, 1, NULL);
+ osmo_shift_v_fixed(&data, &data_len, 1, NULL);
- if (gprs_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
return 0;
parse_ctx->old_raid_enc = value;
@@ -190,14 +190,14 @@ static int gprs_gb_parse_gmm_ra_upd_rej(uint8_t *data, size_t data_len,
parse_ctx->llc_msg_name = "RA_UPD_REJ";
/* GMM cause */
- if (gprs_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
return 0;
cause = value[0];
/* Force to standby, 1/2 */
/* spare bits, 1/2 */
- if (gprs_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 1, &value) <= 0)
return 0;
force_standby = (value[0] & 0x07) == 0x01;
@@ -221,18 +221,18 @@ static int gprs_gb_parse_gmm_ra_upd_ack(uint8_t *data, size_t data_len,
/* Skip Force to standby */
/* Skip Update result */
/* Skip Periodic RA update timer */
- gprs_shift_v_fixed(&data, &data_len, 2, NULL);
+ osmo_shift_v_fixed(&data, &data_len, 2, NULL);
- if (gprs_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
return 0;
parse_ctx->raid_enc = value;
/* Skip P-TMSI signature (P-TMSI signature, opt, TV, length 4) */
- gprs_match_tv_fixed(&data, &data_len, GSM48_IE_GMM_PTMSI_SIG, 3, NULL);
+ osmo_match_shift_tv_fixed(&data, &data_len, GSM48_IE_GMM_PTMSI_SIG, 3, NULL);
/* Allocated P-TMSI (Mobile identity, opt, TLV, length 7) */
- if (gprs_match_tlv(&data, &data_len, GSM48_IE_GMM_ALLOC_PTMSI,
+ if (osmo_match_shift_tlv(&data, &data_len, GSM48_IE_GMM_ALLOC_PTMSI,
&value, &value_len) > 0 &&
gprs_is_mi_tmsi(value, value_len))
parse_ctx->new_ptmsi_enc = value + 1;
@@ -252,11 +252,11 @@ static int gprs_gb_parse_gmm_ptmsi_reall_cmd(uint8_t *data, size_t data_len,
"Got P-TMSI Reallocation Command which is not covered by unit tests yet.\n");
/* Allocated P-TMSI */
- if (gprs_shift_lv(&data, &data_len, &value, &value_len) > 0 &&
+ if (osmo_shift_lv(&data, &data_len, &value, &value_len) > 0 &&
gprs_is_mi_tmsi(value, value_len))
parse_ctx->new_ptmsi_enc = value + 1;
- if (gprs_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, 6, &value) <= 0)
return 0;
parse_ctx->raid_enc = value;
@@ -273,7 +273,7 @@ static int gprs_gb_parse_gmm_id_resp(uint8_t *data, size_t data_len,
parse_ctx->llc_msg_name = "ID_RESP";
/* Mobile identity, Mobile identity 10.5.1.4, M LV 2-10 */
- if (gprs_shift_lv(&data, &data_len, &value, &value_len) <= 0 ||
+ if (osmo_shift_lv(&data, &data_len, &value, &value_len) <= 0 ||
value_len < 1 || value_len > 9)
/* invalid */
return 0;
@@ -299,22 +299,22 @@ static int gprs_gb_parse_gsm_act_pdp_req(uint8_t *data, size_t data_len,
/* Skip Requested NSAPI */
/* Skip Requested LLC SAPI */
- gprs_shift_v_fixed(&data, &data_len, 2, NULL);
+ osmo_shift_v_fixed(&data, &data_len, 2, NULL);
/* Skip Requested QoS (support 04.08 and 24.008) */
- if (gprs_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
+ if (osmo_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
value_len < 4 || value_len > 14)
/* invalid */
return 0;
/* Skip Requested PDP address */
- if (gprs_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
+ if (osmo_shift_lv(&data, &data_len, NULL, &value_len) <= 0 ||
value_len < 2 || value_len > 18)
/* invalid */
return 0;
/* Access point name */
- old_len = gprs_match_tlv(&data, &data_len,
+ old_len = osmo_match_shift_tlv(&data, &data_len,
GSM48_IE_GSM_APN, &value, &value_len);
if (old_len > 0 && value_len >=1 && value_len <= 100) {
@@ -332,7 +332,7 @@ int gprs_gb_parse_dtap(uint8_t *data, size_t data_len,
uint8_t pdisc;
uint8_t msg_type;
- if (gprs_shift_v_fixed(&data, &data_len, sizeof(*g48h), (uint8_t **)&g48h) <= 0)
+ if (osmo_shift_v_fixed(&data, &data_len, sizeof(*g48h), (uint8_t **)&g48h) <= 0)
return 0;
parse_ctx->g48_hdr = g48h;
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index f32854d74..2304c1a01 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -564,9 +564,9 @@ static int gsm48_rx_gmm_auth_ciph_resp(struct sgsn_mm_ctx *ctx,
at = &ctx->auth_triplet;
- if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES) != sizeof(at->sres) ||
- memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->sres,
- sizeof(at->sres)) != 0) {
+ if (TLVP_LEN(&tp, GSM48_IE_GMM_AUTH_SRES) != sizeof(at->vec.sres) ||
+ memcmp(TLVP_VAL(&tp, GSM48_IE_GMM_AUTH_SRES), at->vec.sres,
+ sizeof(at->vec.sres)) != 0) {
LOGMMCTXP(LOGL_NOTICE, ctx, "Received SRES doesn't match\n");
rc = gsm48_tx_gmm_auth_ciph_rej(ctx);
@@ -757,7 +757,8 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
struct gsm_auth_tuple *at = &ctx->auth_triplet;
mmctx_timer_start(ctx, 3360, sgsn->cfg.timers.T3360);
- return gsm48_tx_gmm_auth_ciph_req(ctx, at->rand, at->key_seq,
+ return gsm48_tx_gmm_auth_ciph_req(ctx, at->vec.rand,
+ at->key_seq,
GPRS_ALGO_GEA0);
}
@@ -1090,7 +1091,6 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
ctx->gb.cell_id = cid;
else if (ctx->ran_type == MM_CTX_T_UTRAN_Iu) {
unsigned char tmp_rand[16];
- struct osmo_auth_vector vec;
/* Ki 000102030405060708090a0b0c0d0e0f */
struct osmo_sub_auth_data auth = {
.type = OSMO_AUTH_TYPE_GSM,
@@ -1107,15 +1107,10 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
RAND_bytes(tmp_rand, 16);
- memset(&vec, 0, sizeof(vec));
- osmo_auth_gen_vec(&vec, &auth, tmp_rand);
-
-
+ memset(&ctx->auth_triplet.vec, 0, sizeof(ctx->auth_triplet.vec));
+ osmo_auth_gen_vec(&ctx->auth_triplet.vec, &auth, tmp_rand);
ctx->auth_triplet.key_seq = 0;
- memcpy(&ctx->auth_triplet.rand, &tmp_rand, sizeof(ctx->auth_triplet.rand));
- memcpy(&ctx->auth_triplet.sres, &vec.sres, sizeof(ctx->auth_triplet.sres));
- memcpy(&ctx->auth_triplet.kc, &vec.kc, sizeof(ctx->auth_triplet.kc));
}
/* Update MM Context with other data */
@@ -1821,7 +1816,8 @@ static void mmctx_timer_cb(void *_mm)
}
at = &mm->auth_triplet;
- gsm48_tx_gmm_auth_ciph_req(mm, at->rand, at->key_seq, GPRS_ALGO_GEA0);
+ gsm48_tx_gmm_auth_ciph_req(mm, at->vec.rand, at->key_seq,
+ GPRS_ALGO_GEA0);
osmo_timer_schedule(&mm->timer, sgsn->cfg.timers.T3360, 0);
break;
case 3370: /* waiting for IDENTITY RESPONSE */
diff --git a/openbsc/src/gprs/gprs_gsup_messages.c b/openbsc/src/gprs/gprs_gsup_messages.c
deleted file mode 100644
index 07485f7f9..000000000
--- a/openbsc/src/gprs/gprs_gsup_messages.c
+++ /dev/null
@@ -1,419 +0,0 @@
-/* GPRS Subscriber Update Protocol message encoder/decoder */
-
-/*
- * (C) 2014 by Sysmocom s.f.m.c. GmbH
- * (C) 2015 by Holger Hans Peter Freyther
- * All Rights Reserved
- *
- * Author: Jacob Erlbeck
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#include <openbsc/gprs_gsup_messages.h>
-
-#include <openbsc/debug.h>
-#include <openbsc/gprs_utils.h>
-#include <openbsc/utils.h>
-
-#include <osmocom/gsm/tlv.h>
-#include <osmocom/core/msgb.h>
-
-#include <stdint.h>
-
-static int decode_pdp_info(uint8_t *data, size_t data_len,
- struct gprs_gsup_pdp_info *pdp_info)
-{
- int rc;
- uint8_t tag;
- uint8_t *value;
- size_t value_len;
-
- /* specific parts */
- while (data_len > 0) {
- enum gprs_gsup_iei iei;
-
- rc = gprs_shift_tlv(&data, &data_len, &tag, &value, &value_len);
- if (rc < 0)
- return -GMM_CAUSE_PROTO_ERR_UNSPEC;
-
- iei = tag;
-
- switch (iei) {
- case GPRS_GSUP_PDP_CONTEXT_ID_IE:
- pdp_info->context_id = decode_big_endian(value, value_len);
- break;
-
- case GPRS_GSUP_PDP_TYPE_IE:
- pdp_info->pdp_type =
- decode_big_endian(value, value_len) & 0x0fff;
- break;
-
- case GPRS_GSUP_ACCESS_POINT_NAME_IE:
- pdp_info->apn_enc = value;
- pdp_info->apn_enc_len = value_len;
- break;
-
- case GPRS_GSUP_PDP_QOS_IE:
- pdp_info->qos_enc = value;
- pdp_info->qos_enc_len = value_len;
- break;
-
- default:
- LOGP(DGPRS, LOGL_ERROR,
- "GSUP IE type %d not expected in PDP info\n", iei);
- continue;
- }
- }
-
- return 0;
-}
-
-static int decode_auth_info(uint8_t *data, size_t data_len,
- struct gsm_auth_tuple *auth_tuple)
-{
- int rc;
- uint8_t tag;
- uint8_t *value;
- size_t value_len;
- enum gprs_gsup_iei iei;
-
- /* specific parts */
- while (data_len > 0) {
- rc = gprs_shift_tlv(&data, &data_len, &tag, &value, &value_len);
- if (rc < 0)
- return -GMM_CAUSE_PROTO_ERR_UNSPEC;
-
- iei = tag;
-
- switch (iei) {
- case GPRS_GSUP_RAND_IE:
- if (value_len != sizeof(auth_tuple->rand))
- goto parse_error;
-
- memcpy(auth_tuple->rand, value, value_len);
- break;
-
- case GPRS_GSUP_SRES_IE:
- if (value_len != sizeof(auth_tuple->sres))
- goto parse_error;
-
- memcpy(auth_tuple->sres, value, value_len);
- break;
-
- case GPRS_GSUP_KC_IE:
- if (value_len != sizeof(auth_tuple->kc))
- goto parse_error;
-
- memcpy(auth_tuple->kc, value, value_len);
- break;
-
- default:
- LOGP(DGPRS, LOGL_ERROR,
- "GSUP IE type %d not expected in PDP info\n", iei);
- continue;
- }
- }
-
- return 0;
-
-parse_error:
- LOGP(DGPRS, LOGL_ERROR,
- "GSUP IE type %d, length %zu invalid in PDP info\n", iei, value_len);
-
- return -1;
-}
-
-int gprs_gsup_decode(const uint8_t *const_data, size_t data_len,
- struct gprs_gsup_message *gsup_msg)
-{
- int rc;
- uint8_t tag;
- /* the shift/match functions expect non-const pointers, but we'll
- * either copy the data or cast pointers back to const before returning
- * them
- */
- uint8_t *data = (uint8_t *)const_data;
- uint8_t *value;
- size_t value_len;
- static const struct gprs_gsup_pdp_info empty_pdp_info = {0};
- static const struct gsm_auth_tuple empty_auth_info = {0};
- static const struct gprs_gsup_message empty_gsup_message = {0};
-
- *gsup_msg = empty_gsup_message;
-
- /* generic part */
- rc = gprs_shift_v_fixed(&data, &data_len, 1, &value);
- if (rc < 0)
- return -GMM_CAUSE_INV_MAND_INFO;
-
- gsup_msg->message_type = decode_big_endian(value, 1);
-
- rc = gprs_match_tlv(&data, &data_len, GPRS_GSUP_IMSI_IE,
- &value, &value_len);
-
- if (rc <= 0)
- return -GMM_CAUSE_INV_MAND_INFO;
-
- if (value_len * 2 + 1 > sizeof(gsup_msg->imsi))
- return -GMM_CAUSE_INV_MAND_INFO;
-
- /* Note that gsm48_decode_bcd_number expects the number of encoded IMSI
- * octets in the first octet. By coincidence (the TLV encoding) the byte
- * before the value part already contains this length so we can use it
- * here.
- */
- OSMO_ASSERT(value[-1] == value_len);
- gsm48_decode_bcd_number(gsup_msg->imsi, sizeof(gsup_msg->imsi),
- value - 1, 0);
-
- /* specific parts */
- while (data_len > 0) {
- enum gprs_gsup_iei iei;
- struct gprs_gsup_pdp_info pdp_info;
- struct gsm_auth_tuple auth_info;
-
- rc = gprs_shift_tlv(&data, &data_len, &tag, &value, &value_len);
- if (rc < 0)
- return -GMM_CAUSE_PROTO_ERR_UNSPEC;
-
- iei = tag;
-
- switch (iei) {
- case GPRS_GSUP_IMSI_IE:
- case GPRS_GSUP_PDP_TYPE_IE:
- case GPRS_GSUP_ACCESS_POINT_NAME_IE:
- case GPRS_GSUP_RAND_IE:
- case GPRS_GSUP_SRES_IE:
- case GPRS_GSUP_KC_IE:
- LOGP(DGPRS, LOGL_NOTICE,
- "GSUP IE type %d not expected (ignored)\n", iei);
- continue;
-
- case GPRS_GSUP_CAUSE_IE:
- gsup_msg->cause = decode_big_endian(value, value_len);
- break;
-
- case GPRS_GSUP_CANCEL_TYPE_IE:
- gsup_msg->cancel_type =
- decode_big_endian(value, value_len) + 1;
- break;
-
- case GPRS_GSUP_PDP_INFO_COMPL_IE:
- gsup_msg->pdp_info_compl = 1;
- break;
-
- case GPRS_GSUP_FREEZE_PTMSI_IE:
- gsup_msg->freeze_ptmsi = 1;
- break;
-
- case GPRS_GSUP_PDP_CONTEXT_ID_IE:
- /* When these IE appear in the top-level part of the
- * message, they are used by Delete Subscr Info to delete
- * single entries. We don't have an extra list for
- * these but use the PDP info list instead */
-
- /* fall through */
-
- case GPRS_GSUP_PDP_INFO_IE:
- if (gsup_msg->num_pdp_infos >= GPRS_GSUP_MAX_NUM_PDP_INFO) {
- LOGP(DGPRS, LOGL_ERROR,
- "GSUP IE type %d (PDP_INFO) max exceeded\n",
- iei);
- return -GMM_CAUSE_COND_IE_ERR;
- }
-
- pdp_info = empty_pdp_info;
-
- if (iei == GPRS_GSUP_PDP_INFO_IE) {
- rc = decode_pdp_info(value, value_len, &pdp_info);
- if (rc < 0)
- return rc;
- pdp_info.have_info = 1;
- } else {
- pdp_info.context_id =
- decode_big_endian(value, value_len);
- }
-
- gsup_msg->pdp_infos[gsup_msg->num_pdp_infos++] =
- pdp_info;
- break;
-
- case GPRS_GSUP_AUTH_TUPLE_IE:
- if (gsup_msg->num_auth_tuples >= GPRS_GSUP_MAX_NUM_AUTH_INFO) {
- LOGP(DGPRS, LOGL_ERROR,
- "GSUP IE type %d (AUTH_INFO) max exceeded\n",
- iei);
- return -GMM_CAUSE_INV_MAND_INFO;
- }
-
- auth_info = empty_auth_info;
- auth_info.key_seq = gsup_msg->num_auth_tuples;
-
- rc = decode_auth_info(value, value_len, &auth_info);
- if (rc < 0)
- return rc;
-
- gsup_msg->auth_tuples[gsup_msg->num_auth_tuples++] =
- auth_info;
- break;
-
- case GPRS_GSUP_MSISDN_IE:
- gsup_msg->msisdn_enc = value;
- gsup_msg->msisdn_enc_len = value_len;
- break;
-
- case GPRS_GSUP_HLR_NUMBER_IE:
- gsup_msg->hlr_enc = value;
- gsup_msg->hlr_enc_len = value_len;
- break;
-
- default:
- LOGP(DGPRS, LOGL_NOTICE,
- "GSUP IE type %d unknown\n", iei);
- continue;
- }
- }
-
- return 0;
-}
-
-static void encode_pdp_info(struct msgb *msg, enum gprs_gsup_iei iei,
- const struct gprs_gsup_pdp_info *pdp_info)
-{
- uint8_t *len_field;
- size_t old_len;
- uint8_t u8;
-
- len_field = msgb_tlv_put(msg, iei, 0, NULL) - 1;
- old_len = msgb_length(msg);
-
- u8 = pdp_info->context_id;
- msgb_tlv_put(msg, GPRS_GSUP_PDP_CONTEXT_ID_IE, sizeof(u8), &u8);
-
- if (pdp_info->pdp_type) {
- msgb_tlv_put(msg, GPRS_GSUP_PDP_TYPE_IE,
- GPRS_GSUP_PDP_TYPE_SIZE,
- encode_big_endian(pdp_info->pdp_type | 0xf000,
- GPRS_GSUP_PDP_TYPE_SIZE));
- }
-
- if (pdp_info->apn_enc) {
- msgb_tlv_put(msg, GPRS_GSUP_ACCESS_POINT_NAME_IE,
- pdp_info->apn_enc_len, pdp_info->apn_enc);
- }
-
- if (pdp_info->qos_enc) {
- msgb_tlv_put(msg, GPRS_GSUP_PDP_QOS_IE,
- pdp_info->qos_enc_len, pdp_info->qos_enc);
- }
-
- /* Update length field */
- *len_field = msgb_length(msg) - old_len;
-}
-
-static void encode_auth_info(struct msgb *msg, enum gprs_gsup_iei iei,
- const struct gsm_auth_tuple *auth_tuple)
-{
- uint8_t *len_field;
- size_t old_len;
-
- len_field = msgb_tlv_put(msg, iei, 0, NULL) - 1;
- old_len = msgb_length(msg);
-
- msgb_tlv_put(msg, GPRS_GSUP_RAND_IE,
- sizeof(auth_tuple->rand), auth_tuple->rand);
-
- msgb_tlv_put(msg, GPRS_GSUP_SRES_IE,
- sizeof(auth_tuple->sres), auth_tuple->sres);
-
- msgb_tlv_put(msg, GPRS_GSUP_KC_IE,
- sizeof(auth_tuple->kc), auth_tuple->kc);
-
- /* Update length field */
- *len_field = msgb_length(msg) - old_len;
-}
-
-void gprs_gsup_encode(struct msgb *msg, const struct gprs_gsup_message *gsup_msg)
-{
- uint8_t u8;
- int idx;
- uint8_t bcd_buf[GSM48_MI_SIZE] = {0};
- size_t bcd_len;
-
- /* generic part */
- OSMO_ASSERT(gsup_msg->message_type);
- msgb_v_put(msg, gsup_msg->message_type);
-
- bcd_len = gsm48_encode_bcd_number(bcd_buf, sizeof(bcd_buf), 0,
- gsup_msg->imsi);
-
- OSMO_ASSERT(bcd_len > 1);
-
- /* Note that gsm48_encode_bcd_number puts the length into the first
- * octet. Since msgb_tlv_put will add this length byte, we'll have to
- * skip it */
- msgb_tlv_put(msg, GPRS_GSUP_IMSI_IE, bcd_len - 1, &bcd_buf[1]);
-
- /* specific parts */
- if (gsup_msg->msisdn_enc)
- msgb_tlv_put(msg, GPRS_GSUP_MSISDN_IE,
- gsup_msg->msisdn_enc_len, gsup_msg->msisdn_enc);
- if (gsup_msg->hlr_enc)
- msgb_tlv_put(msg, GPRS_GSUP_HLR_NUMBER_IE,
- gsup_msg->hlr_enc_len, gsup_msg->hlr_enc);
-
- if ((u8 = gsup_msg->cause))
- msgb_tlv_put(msg, GPRS_GSUP_CAUSE_IE, sizeof(u8), &u8);
-
- if ((u8 = gsup_msg->cancel_type)) {
- u8 -= 1;
- msgb_tlv_put(msg, GPRS_GSUP_CANCEL_TYPE_IE, sizeof(u8), &u8);
- }
-
- if (gsup_msg->pdp_info_compl)
- msgb_tlv_put(msg, GPRS_GSUP_PDP_INFO_COMPL_IE, 0, &u8);
-
- if (gsup_msg->freeze_ptmsi)
- msgb_tlv_put(msg, GPRS_GSUP_FREEZE_PTMSI_IE, 0, &u8);
-
- for (idx = 0; idx < gsup_msg->num_pdp_infos; idx++) {
- const struct gprs_gsup_pdp_info *pdp_info;
-
- pdp_info = &gsup_msg->pdp_infos[idx];
-
- if (pdp_info->context_id == 0)
- continue;
-
- if (pdp_info->have_info) {
- encode_pdp_info(msg, GPRS_GSUP_PDP_INFO_IE, pdp_info);
- } else {
- u8 = pdp_info->context_id;
- msgb_tlv_put(msg, GPRS_GSUP_PDP_CONTEXT_ID_IE,
- sizeof(u8), &u8);
- }
- }
-
- for (idx = 0; idx < gsup_msg->num_auth_tuples; idx++) {
- const struct gsm_auth_tuple *auth_info;
-
- auth_info = &gsup_msg->auth_tuples[idx];
-
- if (auth_info->key_seq == GSM_KEY_SEQ_INVAL)
- continue;
-
- encode_auth_info(msg, GPRS_GSUP_AUTH_TUPLE_IE, auth_info);
- }
-}
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 6d0596a48..9e7143540 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -29,12 +29,12 @@
#include <osmocom/core/backtrace.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/sgsn.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/gprs_gmm.h>
#include <openbsc/gprs_utils.h>
#include <openbsc/signal.h>
diff --git a/openbsc/src/gprs/gprs_subscriber.c b/openbsc/src/gprs/gprs_subscriber.c
index 3467293be..71f5ff188 100644
--- a/openbsc/src/gprs/gprs_subscriber.c
+++ b/openbsc/src/gprs/gprs_subscriber.c
@@ -20,13 +20,14 @@
*
*/
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
+#include <osmocom/gsm/gsup.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/gprs_gsup_client.h>
#include <openbsc/sgsn.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/gprs_gmm.h>
-#include <openbsc/gprs_gsup_messages.h>
#include <openbsc/gprs_utils.h>
#include <openbsc/debug.h>
@@ -158,14 +159,14 @@ void gprs_subscr_cancel(struct gsm_subscriber *subscr)
}
static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
struct msgb *msg = gprs_gsup_msgb_alloc();
if (strlen(gsup_msg->imsi) == 0 && subscr)
strncpy(gsup_msg->imsi, subscr->imsi, sizeof(gsup_msg->imsi) - 1);
- gprs_gsup_encode(msg, gsup_msg);
+ osmo_gsup_encode(msg, gsup_msg);
LOGGSUBSCRP(LOGL_INFO, subscr,
"Sending GSUP, will send: %s\n", msgb_hexdump(msg));
@@ -179,38 +180,38 @@ static int gprs_subscr_tx_gsup_message(struct gsm_subscriber *subscr,
}
static int gprs_subscr_tx_gsup_error_reply(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_orig,
+ struct osmo_gsup_message *gsup_orig,
enum gsm48_gmm_cause cause)
{
- struct gprs_gsup_message gsup_reply = {0};
+ struct osmo_gsup_message gsup_reply = {0};
strncpy(gsup_reply.imsi, gsup_orig->imsi, sizeof(gsup_reply.imsi) - 1);
gsup_reply.cause = cause;
gsup_reply.message_type =
- GPRS_GSUP_TO_MSGT_ERROR(gsup_orig->message_type);
+ OSMO_GSUP_TO_MSGT_ERROR(gsup_orig->message_type);
return gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
}
static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
unsigned idx;
struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
LOGGSUBSCRP(LOGL_INFO, subscr,
- "Got SendAuthenticationInfoResult, num_auth_tuples = %zu\n",
- gsup_msg->num_auth_tuples);
+ "Got SendAuthenticationInfoResult, num_auth_vectors = %zu\n",
+ gsup_msg->num_auth_vectors);
- if (gsup_msg->num_auth_tuples > 0) {
+ if (gsup_msg->num_auth_vectors > 0) {
memset(sdata->auth_triplets, 0, sizeof(sdata->auth_triplets));
for (idx = 0; idx < ARRAY_SIZE(sdata->auth_triplets); idx++)
sdata->auth_triplets[idx].key_seq = GSM_KEY_SEQ_INVAL;
}
- for (idx = 0; idx < gsup_msg->num_auth_tuples; idx++) {
- size_t key_seq = gsup_msg->auth_tuples[idx].key_seq;
+ for (idx = 0; idx < gsup_msg->num_auth_vectors; idx++) {
+ size_t key_seq = idx;
LOGGSUBSCRP(LOGL_DEBUG, subscr,
"Adding auth tuple, cksn = %zu\n", key_seq);
if (key_seq >= ARRAY_SIZE(sdata->auth_triplets)) {
@@ -219,7 +220,8 @@ static int gprs_subscr_handle_gsup_auth_res(struct gsm_subscriber *subscr,
key_seq);
continue;
}
- sdata->auth_triplets[key_seq] = gsup_msg->auth_tuples[idx];
+ sdata->auth_triplets[key_seq].vec = gsup_msg->auth_vectors[idx];
+ sdata->auth_triplets[key_seq].key_seq = key_seq;
}
sdata->auth_triplets_updated = 1;
@@ -259,7 +261,7 @@ static struct sgsn_subscriber_pdp_data *gprs_subscr_pdp_data_get_by_id(
static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
unsigned idx;
@@ -296,7 +298,7 @@ static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr,
}
for (idx = 0; idx < gsup_msg->num_pdp_infos; idx++) {
- struct gprs_gsup_pdp_info *pdp_info = &gsup_msg->pdp_infos[idx];
+ struct osmo_gsup_pdp_info *pdp_info = &gsup_msg->pdp_infos[idx];
size_t ctx_id = pdp_info->context_id;
struct sgsn_subscriber_pdp_data *pdp_data;
@@ -336,8 +338,11 @@ static void gprs_subscr_gsup_insert_data(struct gsm_subscriber *subscr,
}
static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
+ /* contrary to MAP, we allow piggy-backing subscriber data onto
+ * the UPDATE LOCATION RESULT, and don't mandate the use of a
+ * separate nested INSERT SUBSCRIBER DATA transaction */
gprs_subscr_gsup_insert_data(subscr, gsup_msg);
subscr->authorized = 1;
@@ -349,6 +354,22 @@ static int gprs_subscr_handle_gsup_upd_loc_res(struct gsm_subscriber *subscr,
return 0;
}
+static int gprs_subscr_handle_gsup_isd_req(struct gsm_subscriber *subscr,
+ struct osmo_gsup_message *gsup_msg)
+{
+ struct osmo_gsup_message gsup_reply = {0};
+
+ gprs_subscr_gsup_insert_data(subscr, gsup_msg);
+
+ subscr->authorized = 1;
+ subscr->sgsn_data->error_cause = SGSN_ERROR_CAUSE_NONE;
+ subscr->flags |= GPRS_SUBSCRIBER_ENABLE_PURGE;
+ gprs_subscr_update(subscr);
+
+ gsup_reply.message_type = OSMO_GSUP_MSGT_INSERT_DATA_RESULT;
+ return gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
+}
+
static int check_cause(int cause)
{
switch (cause) {
@@ -366,7 +387,7 @@ static int check_cause(int cause)
}
static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
unsigned idx;
struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
@@ -419,7 +440,7 @@ static int gprs_subscr_handle_gsup_auth_err(struct gsm_subscriber *subscr,
}
static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
int cause_err;
@@ -465,9 +486,9 @@ static int gprs_subscr_handle_gsup_upd_loc_err(struct gsm_subscriber *subscr,
}
static int gprs_subscr_handle_gsup_purge_no_subscr(
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
- if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
+ if (OSMO_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
LOGGSUPP(LOGL_NOTICE, gsup_msg,
"Purge MS has failed with cause '%s' (%d)\n",
get_value_string(gsm48_gmm_cause_names, gsup_msg->cause),
@@ -480,7 +501,7 @@ static int gprs_subscr_handle_gsup_purge_no_subscr(
}
static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
LOGGSUBSCRP(LOGL_INFO, subscr, "Completing purge MS\n");
@@ -492,7 +513,7 @@ static int gprs_subscr_handle_gsup_purge_res(struct gsm_subscriber *subscr,
}
static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
LOGGSUBSCRP(LOGL_NOTICE, subscr,
"Purge MS has failed with cause '%s' (%d)\n",
@@ -525,17 +546,17 @@ static int gprs_subscr_handle_gsup_purge_err(struct gsm_subscriber *subscr,
}
static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr,
- struct gprs_gsup_message *gsup_msg)
+ struct osmo_gsup_message *gsup_msg)
{
- struct gprs_gsup_message gsup_reply = {0};
+ struct osmo_gsup_message gsup_reply = {0};
int is_update_procedure = !gsup_msg->cancel_type ||
- gsup_msg->cancel_type == GPRS_GSUP_CANCEL_TYPE_UPDATE;
+ gsup_msg->cancel_type == OSMO_GSUP_CANCEL_TYPE_UPDATE;
LOGGSUBSCRP(LOGL_INFO, subscr, "Cancelling MS subscriber (%s)\n",
is_update_procedure ?
"update procedure" : "subscription withdraw");
- gsup_reply.message_type = GPRS_GSUP_MSGT_LOCATION_CANCEL_RESULT;
+ gsup_reply.message_type = OSMO_GSUP_MSGT_LOCATION_CANCEL_RESULT;
gprs_subscr_tx_gsup_message(subscr, &gsup_reply);
if (is_update_procedure)
@@ -552,16 +573,16 @@ static int gprs_subscr_handle_loc_cancel_req(struct gsm_subscriber *subscr,
return 0;
}
-static int gprs_subscr_handle_unknown_imsi(struct gprs_gsup_message *gsup_msg)
+static int gprs_subscr_handle_unknown_imsi(struct osmo_gsup_message *gsup_msg)
{
- if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) {
+ if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg->message_type)) {
gprs_subscr_tx_gsup_error_reply(NULL, gsup_msg,
GMM_CAUSE_IMSI_UNKNOWN);
LOGP(DGPRS, LOGL_NOTICE,
"Unknown IMSI %s, discarding GSUP request "
"of type 0x%02x\n",
gsup_msg->imsi, gsup_msg->message_type);
- } else if (GPRS_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
+ } else if (OSMO_GSUP_IS_MSGT_ERROR(gsup_msg->message_type)) {
LOGP(DGPRS, LOGL_NOTICE,
"Unknown IMSI %s, discarding GSUP error "
"of type 0x%02x, cause '%s' (%d)\n",
@@ -584,10 +605,10 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg)
size_t data_len = msgb_l2len(msg);
int rc = 0;
- struct gprs_gsup_message gsup_msg = {0};
+ struct osmo_gsup_message gsup_msg = {0};
struct gsm_subscriber *subscr;
- rc = gprs_gsup_decode(data, data_len, &gsup_msg);
+ rc = osmo_gsup_decode(data, data_len, &gsup_msg);
if (rc < 0) {
LOGP(DGPRS, LOGL_ERROR,
"decoding GSUP message fails with error '%s' (%d)\n",
@@ -598,21 +619,21 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg)
if (!gsup_msg.imsi[0]) {
LOGP(DGPRS, LOGL_ERROR, "Missing IMSI in GSUP message\n");
- if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
+ if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
gprs_subscr_tx_gsup_error_reply(NULL, &gsup_msg,
GMM_CAUSE_INV_MAND_INFO);
return -GMM_CAUSE_INV_MAND_INFO;
}
- if (!gsup_msg.cause && GPRS_GSUP_IS_MSGT_ERROR(gsup_msg.message_type))
+ if (!gsup_msg.cause && OSMO_GSUP_IS_MSGT_ERROR(gsup_msg.message_type))
gsup_msg.cause = GMM_CAUSE_NET_FAIL;
subscr = gprs_subscr_get_by_imsi(gsup_msg.imsi);
if (!subscr) {
switch (gsup_msg.message_type) {
- case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
- case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
+ case OSMO_GSUP_MSGT_PURGE_MS_RESULT:
+ case OSMO_GSUP_MSGT_PURGE_MS_ERROR:
return gprs_subscr_handle_gsup_purge_no_subscr(&gsup_msg);
default:
return gprs_subscr_handle_unknown_imsi(&gsup_msg);
@@ -623,36 +644,39 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg)
"Received GSUP message of type 0x%02x\n", gsup_msg.message_type);
switch (gsup_msg.message_type) {
- case GPRS_GSUP_MSGT_LOCATION_CANCEL_REQUEST:
+ case OSMO_GSUP_MSGT_LOCATION_CANCEL_REQUEST:
rc = gprs_subscr_handle_loc_cancel_req(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_SEND_AUTH_INFO_RESULT:
+ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_RESULT:
rc = gprs_subscr_handle_gsup_auth_res(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_SEND_AUTH_INFO_ERROR:
+ case OSMO_GSUP_MSGT_SEND_AUTH_INFO_ERROR:
rc = gprs_subscr_handle_gsup_auth_err(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_UPDATE_LOCATION_RESULT:
+ case OSMO_GSUP_MSGT_UPDATE_LOCATION_RESULT:
rc = gprs_subscr_handle_gsup_upd_loc_res(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_UPDATE_LOCATION_ERROR:
+ case OSMO_GSUP_MSGT_UPDATE_LOCATION_ERROR:
rc = gprs_subscr_handle_gsup_upd_loc_err(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_PURGE_MS_ERROR:
+ case OSMO_GSUP_MSGT_PURGE_MS_ERROR:
rc = gprs_subscr_handle_gsup_purge_err(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_PURGE_MS_RESULT:
+ case OSMO_GSUP_MSGT_PURGE_MS_RESULT:
rc = gprs_subscr_handle_gsup_purge_res(subscr, &gsup_msg);
break;
- case GPRS_GSUP_MSGT_INSERT_DATA_REQUEST:
- case GPRS_GSUP_MSGT_DELETE_DATA_REQUEST:
+ case OSMO_GSUP_MSGT_INSERT_DATA_REQUEST:
+ rc = gprs_subscr_handle_gsup_isd_req(subscr, &gsup_msg);
+ break;
+
+ case OSMO_GSUP_MSGT_DELETE_DATA_REQUEST:
LOGGSUBSCRP(LOGL_ERROR, subscr,
"Rx GSUP message type %d not yet implemented\n",
gsup_msg.message_type);
@@ -665,7 +689,7 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg)
LOGGSUBSCRP(LOGL_ERROR, subscr,
"Rx GSUP message type %d not valid at SGSN\n",
gsup_msg.message_type);
- if (GPRS_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
+ if (OSMO_GSUP_IS_MSGT_REQUEST(gsup_msg.message_type))
gprs_subscr_tx_gsup_error_reply(
subscr, &gsup_msg, GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL);
rc = -GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL;
@@ -680,11 +704,11 @@ int gprs_subscr_rx_gsup_message(struct msgb *msg)
int gprs_subscr_purge(struct gsm_subscriber *subscr)
{
struct sgsn_subscriber_data *sdata = subscr->sgsn_data;
- struct gprs_gsup_message gsup_msg = {0};
+ struct osmo_gsup_message gsup_msg = {0};
LOGGSUBSCRP(LOGL_INFO, subscr, "purging MS subscriber\n");
- gsup_msg.message_type = GPRS_GSUP_MSGT_PURGE_MS_REQUEST;
+ gsup_msg.message_type = OSMO_GSUP_MSGT_PURGE_MS_REQUEST;
/* Provide the HLR number in case it is known */
gsup_msg.hlr_enc_len = sdata->hlr_len;
@@ -695,23 +719,23 @@ int gprs_subscr_purge(struct gsm_subscriber *subscr)
int gprs_subscr_query_auth_info(struct gsm_subscriber *subscr)
{
- struct gprs_gsup_message gsup_msg = {0};
+ struct osmo_gsup_message gsup_msg = {0};
LOGGSUBSCRP(LOGL_INFO, subscr,
"subscriber auth info is not available\n");
- gsup_msg.message_type = GPRS_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
+ gsup_msg.message_type = OSMO_GSUP_MSGT_SEND_AUTH_INFO_REQUEST;
return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
}
int gprs_subscr_location_update(struct gsm_subscriber *subscr)
{
- struct gprs_gsup_message gsup_msg = {0};
+ struct osmo_gsup_message gsup_msg = {0};
LOGGSUBSCRP(LOGL_INFO, subscr,
"subscriber data is not available\n");
- gsup_msg.message_type = GPRS_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
+ gsup_msg.message_type = OSMO_GSUP_MSGT_UPDATE_LOCATION_REQUEST;
return gprs_subscr_tx_gsup_message(subscr, &gsup_msg);
}
@@ -755,8 +779,9 @@ struct gsm_subscriber *gprs_subscr_get_or_create_by_mmctx(struct sgsn_mm_ctx *mm
}
if (strcpy(subscr->equipment.imei, mmctx->imei) != 0) {
- strncpy(subscr->equipment.imei, mmctx->imei, GSM_IMEI_LENGTH-1);
- subscr->equipment.imei[GSM_IMEI_LENGTH-1] = 0;
+ strncpy(subscr->equipment.imei, mmctx->imei,
+ sizeof(subscr->equipment.imei)-1);
+ subscr->equipment.imei[sizeof(subscr->equipment.imei)-1] = 0;
}
if (subscr->lac != mmctx->ra.lac)
diff --git a/openbsc/src/gprs/gprs_utils.c b/openbsc/src/gprs/gprs_utils.c
index 895a03384..64ed9788d 100644
--- a/openbsc/src/gprs/gprs_utils.c
+++ b/openbsc/src/gprs/gprs_utils.c
@@ -20,11 +20,11 @@
*
*/
#include <openbsc/gprs_utils.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/gsm48.h>
@@ -266,140 +266,6 @@ void gprs_parse_tmsi(const uint8_t *value, uint32_t *tmsi)
*tmsi = ntohl(tmsi_be);
}
-/* TODO: Move shift functions to libosmocore */
-
-int gprs_shift_v_fixed(uint8_t **data, size_t *data_len,
- size_t len, uint8_t **value)
-{
- if (len > *data_len)
- goto fail;
-
- if (value)
- *value = *data;
-
- *data += len;
- *data_len -= len;
-
- return len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-int gprs_match_tv_fixed(uint8_t **data, size_t *data_len,
- uint8_t tag, size_t len,
- uint8_t **value)
-{
- size_t ie_len;
-
- if (*data_len == 0)
- goto fail;
-
- if ((*data)[0] != tag)
- return 0;
-
- if (len > *data_len - 1)
- goto fail;
-
- if (value)
- *value = *data + 1;
-
- ie_len = len + 1;
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-int gprs_match_tlv(uint8_t **data, size_t *data_len,
- uint8_t expected_tag, uint8_t **value, size_t *value_len)
-{
- int rc;
- uint8_t tag;
- uint8_t *old_data = *data;
- size_t old_data_len = *data_len;
-
- rc = gprs_shift_tlv(data, data_len, &tag, value, value_len);
-
- if (rc > 0 && tag != expected_tag) {
- *data = old_data;
- *data_len = old_data_len;
- return 0;
- }
-
- return rc;
-}
-
-int gprs_shift_tlv(uint8_t **data, size_t *data_len,
- uint8_t *tag, uint8_t **value, size_t *value_len)
-{
- size_t len;
- size_t ie_len;
-
- if (*data_len < 2)
- goto fail;
-
- len = (*data)[1];
- if (len > *data_len - 2)
- goto fail;
-
- if (tag)
- *tag = (*data)[0];
- if (value)
- *value = *data + 2;
- if (value_len)
- *value_len = len;
-
- ie_len = len + 2;
-
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
-int gprs_shift_lv(uint8_t **data, size_t *data_len,
- uint8_t **value, size_t *value_len)
-{
- size_t len;
- size_t ie_len;
-
- if (*data_len < 1)
- goto fail;
-
- len = (*data)[0];
- if (len > *data_len - 1)
- goto fail;
-
- if (value)
- *value = *data + 1;
- if (value_len)
- *value_len = len;
-
- ie_len = len + 1;
- *data += ie_len;
- *data_len -= ie_len;
-
- return ie_len;
-
-fail:
- *data += *data_len;
- *data_len = 0;
- return -1;
-}
-
int gprs_ra_id_equals(const struct gprs_ra_id *id1,
const struct gprs_ra_id *id2)
{
diff --git a/openbsc/src/gprs/gsm_04_08_gprs.c b/openbsc/src/gprs/gsm_04_08_gprs.c
index ed0172862..90657eb05 100644
--- a/openbsc/src/gprs/gsm_04_08_gprs.c
+++ b/openbsc/src/gprs/gsm_04_08_gprs.c
@@ -19,126 +19,12 @@
*
*/
+/* TODO: Move this to osmocom/gsm/protocol/gsm_04_08_gprs.h ? */
#include <openbsc/gsm_04_08_gprs.h>
#include <osmocom/core/utils.h>
-/* Protocol related stuff, should go into libosmocore */
-
-/* 10.5.5.14 GPRS MM Cause / Table 10.5.147 */
-const struct value_string gsm48_gmm_cause_names_[] = {
- { GMM_CAUSE_IMSI_UNKNOWN, "IMSI unknown in HLR" },
- { GMM_CAUSE_ILLEGAL_MS, "Illegal MS" },
- { GMM_CAUSE_ILLEGAL_ME, "Illegal ME" },
- { GMM_CAUSE_GPRS_NOTALLOWED, "GPRS services not allowed" },
- { GMM_CAUSE_GPRS_OTHER_NOTALLOWED,
- "GPRS services and non-GPRS services not allowed" },
- { GMM_CAUSE_MS_ID_NOT_DERIVED,
- "MS identity cannot be derived by the network" },
- { GMM_CAUSE_IMPL_DETACHED, "Implicitly detached" },
- { GMM_CAUSE_PLMN_NOTALLOWED, "PLMN not allowed" },
- { GMM_CAUSE_LA_NOTALLOWED, "Location Area not allowed" },
- { GMM_CAUSE_ROAMING_NOTALLOWED,
- "Roaming not allowed in this location area" },
- { GMM_CAUSE_NO_GPRS_PLMN,
- "GPRS services not allowed in this PLMN" },
- { GMM_CAUSE_MSC_TEMP_NOTREACH, "MSC temporarily not reachable" },
- { GMM_CAUSE_NET_FAIL, "Network failure" },
- { GMM_CAUSE_CONGESTION, "Congestion" },
- { GMM_CAUSE_SEM_INCORR_MSG, "Semantically incorrect message" },
- { GMM_CAUSE_INV_MAND_INFO, "Invalid mandatory information" },
- { GMM_CAUSE_MSGT_NOTEXIST_NOTIMPL,
- "Message type non-existant or not implemented" },
- { GMM_CAUSE_MSGT_INCOMP_P_STATE,
- "Message type not compatible with protocol state" },
- { GMM_CAUSE_IE_NOTEXIST_NOTIMPL,
- "Information element non-existent or not implemented" },
- { GMM_CAUSE_COND_IE_ERR, "Conditional IE error" },
- { GMM_CAUSE_MSG_INCOMP_P_STATE,
- "Message not compatible with protocol state " },
- { GMM_CAUSE_PROTO_ERR_UNSPEC, "Protocol error, unspecified" },
- { 0, NULL }
-};
-
-const struct value_string *gsm48_gmm_cause_names = gsm48_gmm_cause_names_;
-
-/* 10.5.6.6 SM Cause / Table 10.5.157 */
-const struct value_string gsm48_gsm_cause_names_[] = {
- { GSM_CAUSE_INSUFF_RSRC, "Insufficient resources" },
- { GSM_CAUSE_MISSING_APN, "Missing or unknown APN" },
- { GSM_CAUSE_UNKNOWN_PDP, "Unknown PDP address or PDP type" },
- { GSM_CAUSE_AUTH_FAILED, "User Authentication failed" },
- { GSM_CAUSE_ACT_REJ_GGSN, "Activation rejected by GGSN" },
- { GSM_CAUSE_ACT_REJ_UNSPEC, "Activation rejected, unspecified" },
- { GSM_CAUSE_SERV_OPT_NOTSUPP, "Service option not supported" },
- { GSM_CAUSE_REQ_SERV_OPT_NOTSUB,
- "Requested service option not subscribed" },
- { GSM_CAUSE_SERV_OPT_TEMP_OOO,
- "Service option temporarily out of order" },
- { GSM_CAUSE_NSAPI_IN_USE, "NSAPI already used" },
- { GSM_CAUSE_DEACT_REGULAR, "Regular deactivation" },
- { GSM_CAUSE_QOS_NOT_ACCEPTED, "QoS not accepted" },
- { GSM_CAUSE_NET_FAIL, "Network Failure" },
- { GSM_CAUSE_REACT_RQD, "Reactivation required" },
- { GSM_CAUSE_FEATURE_NOTSUPP, "Feature not supported " },
- { GSM_CAUSE_INVALID_TRANS_ID, "Invalid transaction identifier" },
- { GSM_CAUSE_SEM_INCORR_MSG, "Semantically incorrect message" },
- { GSM_CAUSE_INV_MAND_INFO, "Invalid mandatory information" },
- { GSM_CAUSE_MSGT_NOTEXIST_NOTIMPL,
- "Message type non-existant or not implemented" },
- { GSM_CAUSE_MSGT_INCOMP_P_STATE,
- "Message type not compatible with protocol state" },
- { GSM_CAUSE_IE_NOTEXIST_NOTIMPL,
- "Information element non-existent or not implemented" },
- { GSM_CAUSE_COND_IE_ERR, "Conditional IE error" },
- { GSM_CAUSE_MSG_INCOMP_P_STATE,
- "Message not compatible with protocol state " },
- { GSM_CAUSE_PROTO_ERR_UNSPEC, "Protocol error, unspecified" },
- { 0, NULL }
-};
-
-const struct value_string *gsm48_gsm_cause_names = gsm48_gsm_cause_names_;
-
-/* 10.5.5.2 */
-const struct value_string gprs_att_t_strs_[] = {
- { GPRS_ATT_T_ATTACH, "GPRS attach" },
- { GPRS_ATT_T_ATT_WHILE_IMSI, "GPRS attach while IMSI attached" },
- { GPRS_ATT_T_COMBINED, "Combined GPRS/IMSI attach" },
- { 0, NULL }
-};
-
-const struct value_string *gprs_att_t_strs = gprs_att_t_strs_;
-
-const struct value_string gprs_upd_t_strs_[] = {
- { GPRS_UPD_T_RA, "RA updating" },
- { GPRS_UPD_T_RA_LA, "combined RA/LA updating" },
- { GPRS_UPD_T_RA_LA_IMSI_ATT, "combined RA/LA updating + IMSI attach" },
- { GPRS_UPD_T_PERIODIC, "periodic updating" },
- { 0, NULL }
-};
-
-const struct value_string *gprs_upd_t_strs = gprs_upd_t_strs_;
-
-/* 10.5.5.5 */
-const struct value_string gprs_det_t_mo_strs_[] = {
- { GPRS_DET_T_MO_GPRS, "GPRS detach" },
- { GPRS_DET_T_MO_IMSI, "IMSI detach" },
- { GPRS_DET_T_MO_COMBINED, "Combined GPRS/IMSI detach" },
- { 0, NULL }
-};
-
-const struct value_string *gprs_det_t_mo_strs = gprs_det_t_mo_strs_;
-
-const struct value_string gprs_det_t_mt_strs_[] = {
- { GPRS_DET_T_MT_REATT_REQ, "re-attach required" },
- { GPRS_DET_T_MT_REATT_NOTREQ, "re-attach not required" },
- { GPRS_DET_T_MT_IMSI, "IMSI detach (after VLR failure)" },
- { 0, NULL }
-};
-
-const struct value_string *gprs_det_t_mt_strs = gprs_det_t_mt_strs_;
-
const struct value_string gprs_service_t_strs_[] = {
{ GPRS_SERVICE_T_SIGNALLING, "signalling" },
{ GPRS_SERVICE_T_DATA, "data" },
diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c
index e8bd3aee7..58300ea13 100644
--- a/openbsc/src/gprs/gtphub.c
+++ b/openbsc/src/gprs/gtphub.c
@@ -1434,14 +1434,16 @@ static int gtphub_unmap_header_tei(struct gtphub_peer_port **to_port_p,
p->header_tei_rx, gtphub_port_str(from_port));
return -1;
}
- OSMO_ASSERT(*unmapped_from_tun);
+
+ if (unmapped_from_tun) {
+ OSMO_ASSERT(*unmapped_from_tun);
+ LOG(LOGL_DEBUG, "Unmapped TEI coming from: %s\n",
+ gtphub_tunnel_str(*unmapped_from_tun));
+ }
uint32_t unmapped_tei = to->tei_orig;
set_tei(p, unmapped_tei);
- LOG(LOGL_DEBUG, "Unmapped TEI coming from: %s\n",
- gtphub_tunnel_str(*unmapped_from_tun));
-
/* May be NULL for an invalidated tunnel. */
*to_port_p = to->peer;
diff --git a/openbsc/src/gprs/gtphub_ares.c b/openbsc/src/gprs/gtphub_ares.c
index 947f2ddd5..667013b8b 100644
--- a/openbsc/src/gprs/gtphub_ares.c
+++ b/openbsc/src/gprs/gtphub_ares.c
@@ -55,7 +55,7 @@ struct ggsn_lookup {
struct gtphub *hub;
- char imsi_str[GSM_IMSI_LENGTH];
+ char imsi_str[GSM23003_IMSI_MAX_DIGITS+1];
char apn_ni_str[GSM_APN_LENGTH];
char apn_oi_str[GSM_APN_LENGTH];
int have_3dig_mnc;
diff --git a/openbsc/src/gprs/oap.c b/openbsc/src/gprs/oap.c
index 1426702dd..c7c97774d 100644
--- a/openbsc/src/gprs/oap.c
+++ b/openbsc/src/gprs/oap.c
@@ -20,10 +20,12 @@
*
*/
+#include <string.h>
+
+#include <osmocom/core/utils.h>
#include <osmocom/crypt/auth.h>
#include <openbsc/oap.h>
-#include <openbsc/utils.h>
#include <openbsc/debug.h>
#include <openbsc/oap_messages.h>
@@ -69,12 +71,19 @@ static int oap_evaluate_challenge(const struct oap_state *state,
const uint8_t *rx_autn,
uint8_t *tx_xres)
{
+ struct osmo_auth_vector vec;
+
+ struct osmo_sub_auth_data auth = {
+ .type = OSMO_AUTH_TYPE_UMTS,
+ .algo = OSMO_AUTH_ALG_MILENAGE,
+ };
+
osmo_static_assert(sizeof(((struct osmo_sub_auth_data*)0)->u.umts.k)
== sizeof(state->secret_k), _secret_k_size_match);
osmo_static_assert(sizeof(((struct osmo_sub_auth_data*)0)->u.umts.opc)
== sizeof(state->secret_opc), _secret_opc_size_match);
- switch(state->state) {
+ switch (state->state) {
case OAP_UNINITIALIZED:
case OAP_DISABLED:
return -1;
@@ -82,13 +91,6 @@ static int oap_evaluate_challenge(const struct oap_state *state,
break;
}
- struct osmo_auth_vector vec;
-
- struct osmo_sub_auth_data auth = {
- .type = OSMO_AUTH_TYPE_UMTS,
- .algo = OSMO_AUTH_ALG_MILENAGE,
- };
-
memcpy(auth.u.umts.k, state->secret_k, sizeof(auth.u.umts.k));
memcpy(auth.u.umts.opc, state->secret_opc, sizeof(auth.u.umts.opc));
memset(auth.u.umts.amf, '\0', sizeof(auth.u.umts.amf));
@@ -103,7 +105,7 @@ static int oap_evaluate_challenge(const struct oap_state *state,
return -3;
}
- if (constant_time_cmp(vec.autn, rx_autn, sizeof(vec.autn)) != 0) {
+ if (osmo_constant_time_cmp(vec.autn, rx_autn, sizeof(vec.autn)) != 0) {
LOGP(DGPRS, LOGL_ERROR, "OAP: AUTN mismatch!\n");
LOGP(DGPRS, LOGL_INFO, "OAP: AUTN from server: %s\n",
osmo_hexdump_nospc(rx_autn, sizeof(vec.autn)));
@@ -117,11 +119,11 @@ static int oap_evaluate_challenge(const struct oap_state *state,
return 0;
}
-struct msgb *oap_encoded(const struct oap_message *oap_msg)
+struct msgb *oap_encoded(const struct osmo_oap_message *oap_msg)
{
struct msgb *msg = msgb_alloc_headroom(1000, 64, __func__);
OSMO_ASSERT(msg);
- oap_encode(msg, oap_msg);
+ osmo_oap_encode(msg, oap_msg);
return msg;
}
@@ -129,12 +131,13 @@ struct msgb *oap_encoded(const struct oap_message *oap_msg)
* On error, return NULL. */
static struct msgb* oap_msg_register(uint16_t client_id)
{
+ struct osmo_oap_message oap_msg = {0};
+
if (client_id < 1) {
LOGP(DGPRS, LOGL_ERROR, "OAP: Invalid client ID: %d\n", client_id);
return NULL;
}
- struct oap_message oap_msg = {0};
oap_msg.message_type = OAP_MSGT_REGISTER_REQUEST;
oap_msg.client_id = client_id;
return oap_encoded(&oap_msg);
@@ -155,7 +158,7 @@ int oap_register(struct oap_state *state, struct msgb **msg_tx)
* On error, return NULL. */
static struct msgb* oap_msg_challenge_response(uint8_t *xres)
{
- struct oap_message oap_reply = {0};
+ struct osmo_oap_message oap_reply = {0};
oap_reply.message_type = OAP_MSGT_CHALLENGE_RESULT;
memcpy(oap_reply.xres, xres, sizeof(oap_reply.xres));
@@ -164,10 +167,12 @@ static struct msgb* oap_msg_challenge_response(uint8_t *xres)
}
static int handle_challenge(struct oap_state *state,
- struct oap_message *oap_rx,
+ struct osmo_oap_message *oap_rx,
struct msgb **msg_tx)
{
int rc;
+ uint8_t xres[8];
+
if (!(oap_rx->rand_present && oap_rx->autn_present)) {
LOGP(DGPRS, LOGL_ERROR,
"OAP challenge incomplete (rand_present: %d, autn_present: %d)\n",
@@ -176,7 +181,6 @@ static int handle_challenge(struct oap_state *state,
goto failure;
}
- uint8_t xres[8];
rc = oap_evaluate_challenge(state,
oap_rx->rand,
oap_rx->autn,
@@ -201,17 +205,16 @@ failure:
int oap_handle(struct oap_state *state, const struct msgb *msg_rx, struct msgb **msg_tx)
{
- *msg_tx = NULL;
-
uint8_t *data = msgb_l2(msg_rx);
size_t data_len = msgb_l2len(msg_rx);
+ struct osmo_oap_message oap_msg = {0};
int rc = 0;
- struct oap_message oap_msg = {0};
+ *msg_tx = NULL;
OSMO_ASSERT(data);
- rc = oap_decode(data, data_len, &oap_msg);
+ rc = osmo_oap_decode(&oap_msg, data, data_len);
if (rc < 0) {
LOGP(DGPRS, LOGL_ERROR,
"Decoding OAP message failed with error '%s' (%d)\n",
diff --git a/openbsc/src/gprs/oap_messages.c b/openbsc/src/gprs/oap_messages.c
index eb520532a..d81723fd6 100644
--- a/openbsc/src/gprs/oap_messages.c
+++ b/openbsc/src/gprs/oap_messages.c
@@ -20,11 +20,10 @@
*
*/
+#include <osmocom/core/utils.h>
#include <openbsc/oap_messages.h>
#include <openbsc/debug.h>
-#include <openbsc/gprs_utils.h>
-#include <openbsc/utils.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/msgb.h>
@@ -32,8 +31,8 @@
#include <stdint.h>
-int oap_decode(const uint8_t *const_data, size_t data_len,
- struct oap_message *oap_msg)
+int osmo_oap_decode(struct osmo_oap_message *oap_msg,
+ const uint8_t *const_data, size_t data_len)
{
int rc;
uint8_t tag;
@@ -48,16 +47,16 @@ int oap_decode(const uint8_t *const_data, size_t data_len,
memset(oap_msg, 0, sizeof(*oap_msg));
/* message type */
- rc = gprs_shift_v_fixed(&data, &data_len, 1, &value);
+ rc = osmo_shift_v_fixed(&data, &data_len, 1, &value);
if (rc < 0)
return -GMM_CAUSE_INV_MAND_INFO;
- oap_msg->message_type = decode_big_endian(value, 1);
+ oap_msg->message_type = osmo_decode_big_endian(value, 1);
/* specific parts */
while (data_len > 0) {
enum oap_iei iei;
- rc = gprs_shift_tlv(&data, &data_len, &tag, &value, &value_len);
+ rc = osmo_shift_tlv(&data, &data_len, &tag, &value, &value_len);
if (rc < 0)
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
@@ -72,7 +71,7 @@ int oap_decode(const uint8_t *const_data, size_t data_len,
return -GMM_CAUSE_PROTO_ERR_UNSPEC;
}
- oap_msg->client_id = decode_big_endian(value, value_len);
+ oap_msg->client_id = osmo_decode_big_endian(value, value_len);
if (oap_msg->client_id == 0) {
LOGP(DGPRS, LOGL_NOTICE,
@@ -145,7 +144,7 @@ int oap_decode(const uint8_t *const_data, size_t data_len,
return 0;
}
-void oap_encode(struct msgb *msg, const struct oap_message *oap_msg)
+void osmo_oap_encode(struct msgb *msg, const struct osmo_oap_message *oap_msg)
{
uint8_t u8;
@@ -159,7 +158,8 @@ void oap_encode(struct msgb *msg, const struct oap_message *oap_msg)
if (oap_msg->client_id > 0)
msgb_tlv_put(msg, OAP_CLIENT_ID_IE, sizeof(oap_msg->client_id),
- encode_big_endian(oap_msg->client_id, sizeof(oap_msg->client_id)));
+ osmo_encode_big_endian(oap_msg->client_id,
+ sizeof(oap_msg->client_id)));
if (oap_msg->rand_present)
msgb_tlv_put(msg, OAP_RAND_IE, sizeof(oap_msg->rand), oap_msg->rand);
diff --git a/openbsc/src/gprs/sgsn_auth.c b/openbsc/src/gprs/sgsn_auth.c
index b83294d30..4b69a0d10 100644
--- a/openbsc/src/gprs/sgsn_auth.c
+++ b/openbsc/src/gprs/sgsn_auth.c
@@ -19,17 +19,18 @@
*
*/
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <openbsc/sgsn.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/gprs_gmm.h>
#include <openbsc/gsm_subscriber.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/debug.h>
const struct value_string auth_state_names[] = {
{ SGSN_AUTH_ACCEPTED, "accepted"},
{ SGSN_AUTH_REJECTED, "rejected"},
{ SGSN_AUTH_UNKNOWN, "unknown"},
+ { SGSN_AUTH_AUTHENTICATE, "authenticate" },
{ 0, NULL }
};
diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c
index 2a3ee01f0..303fa887c 100644
--- a/openbsc/src/gprs/sgsn_libgtp.c
+++ b/openbsc/src/gprs/sgsn_libgtp.c
@@ -39,8 +39,8 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/crypt/auth.h>
#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/signal.h>
#include <openbsc/debug.h>
#include <openbsc/sgsn.h>
diff --git a/openbsc/src/gprs/sgsn_vty.c b/openbsc/src/gprs/sgsn_vty.c
index 00c2761d6..02c0f318c 100644
--- a/openbsc/src/gprs/sgsn_vty.c
+++ b/openbsc/src/gprs/sgsn_vty.c
@@ -27,13 +27,13 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/gsm/protocol/gsm_04_08_gprs.h>
#include <openbsc/debug.h>
#include <openbsc/sgsn.h>
#include <osmocom/gprs/gprs_ns.h>
#include <openbsc/gprs_sgsn.h>
#include <openbsc/vty.h>
-#include <openbsc/gsm_04_08_gprs.h>
#include <openbsc/gprs_gsup_client.h>
#include <osmocom/vty/command.h>
@@ -613,11 +613,11 @@ static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr,
vty_out(vty, " seq # : %d, ",
at->key_seq);
vty_out(vty, " RAND : %s, ",
- osmo_hexdump(at->rand, sizeof(at->rand)));
+ osmo_hexdump(at->vec.rand, sizeof(at->vec.rand)));
vty_out(vty, " SRES : %s, ",
- osmo_hexdump(at->sres, sizeof(at->sres)));
+ osmo_hexdump(at->vec.sres, sizeof(at->vec.sres)));
vty_out(vty, " Kc : %s%s",
- osmo_hexdump(at->kc, sizeof(at->kc)),
+ osmo_hexdump(at->vec.kc, sizeof(at->vec.kc)),
VTY_NEWLINE);
}
@@ -704,17 +704,17 @@ DEFUN(update_subscr_insert_auth_triplet, update_subscr_insert_auth_triplet_cmd,
OSMO_ASSERT(subscr->sgsn_data);
- if (osmo_hexparse(sres_str, &at.sres[0], sizeof(at.sres)) < 0) {
+ if (osmo_hexparse(sres_str, &at.vec.sres[0], sizeof(at.vec.sres)) < 0) {
vty_out(vty, "%% invalid SRES value '%s'%s",
sres_str, VTY_NEWLINE);
goto failed;
}
- if (osmo_hexparse(rand_str, &at.rand[0], sizeof(at.rand)) < 0) {
+ if (osmo_hexparse(rand_str, &at.vec.rand[0], sizeof(at.vec.rand)) < 0) {
vty_out(vty, "%% invalid RAND value '%s'%s",
rand_str, VTY_NEWLINE);
goto failed;
}
- if (osmo_hexparse(kc_str, &at.kc[0], sizeof(at.kc)) < 0) {
+ if (osmo_hexparse(kc_str, &at.vec.kc[0], sizeof(at.vec.kc)) < 0) {
vty_out(vty, "%% invalid Kc value '%s'%s",
kc_str, VTY_NEWLINE);
goto failed;