pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40961?usp=email )
Change subject: Split Iu RANAP RAB PS act/deact over different layers ...................................................................... Split Iu RANAP RAB PS act/deact over different layers Properly separate logic acting on objects vs logic building and generating RANAP msg on the wire. Change-Id: I98788468b7e50619cfd99b3aef2311bb601fb6be --- M include/osmocom/sgsn/gprs_ranap.h M include/osmocom/sgsn/mmctx.h M include/osmocom/sgsn/pdpctx.h M src/sgsn/gprs_gmm.c M src/sgsn/gprs_ranap.c M src/sgsn/mmctx.c M src/sgsn/pdpctx.c M src/sgsn/sgsn_libgtp.c 8 files changed, 71 insertions(+), 41 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/61/40961/1 diff --git a/include/osmocom/sgsn/gprs_ranap.h b/include/osmocom/sgsn/gprs_ranap.h index 80b57e6..e2450bd 100644 --- a/include/osmocom/sgsn/gprs_ranap.h +++ b/include/osmocom/sgsn/gprs_ranap.h @@ -1,5 +1,7 @@ #pragma once +#include "config.h" + #include <osmocom/core/msgb.h> #ifdef BUILD_IU @@ -11,12 +13,11 @@ struct sgsn_mm_ctx; struct sgsn_pdp_ctx; -void activate_pdp_rabs(struct sgsn_mm_ctx *ctx); int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type type, void *data); -int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp); int ranap_iu_tx(struct msgb *msg, uint8_t sapi); -int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id); +int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, + uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei); int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, int send_ck, int new_key); int ranap_iu_tx_common_id(struct ranap_ue_conn_ctx *ue_ctx, const char *imsi); diff --git a/include/osmocom/sgsn/mmctx.h b/include/osmocom/sgsn/mmctx.h index 760e2c4..c0a5735 100644 --- a/include/osmocom/sgsn/mmctx.h +++ b/include/osmocom/sgsn/mmctx.h @@ -289,3 +289,5 @@ /* Called on subscriber data updates */ void sgsn_update_subscriber_data(struct sgsn_mm_ctx *mmctx); + +void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx); diff --git a/include/osmocom/sgsn/pdpctx.h b/include/osmocom/sgsn/pdpctx.h index 39d744a..a4bbd97 100644 --- a/include/osmocom/sgsn/pdpctx.h +++ b/include/osmocom/sgsn/pdpctx.h @@ -1,5 +1,7 @@ #pragma once +#include "config.h" + #include <stdint.h> #include <netinet/in.h> #include <inttypes.h> @@ -94,5 +96,10 @@ void sgsn_pdp_ctx_terminate(struct sgsn_pdp_ctx *pdp); void sgsn_pdp_ctx_free(struct sgsn_pdp_ctx *pdp); +#ifdef BUILD_IU +int sgsn_pdp_ctx_iu_rab_activate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id); +int sgsn_pdp_ctx_iu_rab_deactivate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id); +#endif /* ifdef BUILD_IU */ + char *gprs_pdpaddr2str(uint8_t *pdpa, uint8_t len, bool return_ipv6); diff --git a/src/sgsn/gprs_gmm.c b/src/sgsn/gprs_gmm.c index d2627a3..5a67fdd 100644 --- a/src/sgsn/gprs_gmm.c +++ b/src/sgsn/gprs_gmm.c @@ -1013,8 +1013,9 @@ osmo_fsm_inst_dispatch(ctx->iu.mm_state_fsm, E_PMM_PS_CONN_ESTABLISH, NULL); rc = gsm48_tx_gmm_service_ack(ctx); - if (ctx->iu.service.type != GPRS_SERVICE_T_SIGNALLING) - activate_pdp_rabs(ctx); + if (ctx->ran_type == MM_CTX_T_UTRAN_Iu && + ctx->iu.service.type != GPRS_SERVICE_T_SIGNALLING) + sgsn_mm_ctx_iu_activate_rabs(ctx); return rc; #endif diff --git a/src/sgsn/gprs_ranap.c b/src/sgsn/gprs_ranap.c index c0bef33..981ec64 100644 --- a/src/sgsn/gprs_ranap.c +++ b/src/sgsn/gprs_ranap.c @@ -86,17 +86,6 @@ } #endif -/* Send RAB activation requests for all PDP contexts */ -void activate_pdp_rabs(struct sgsn_mm_ctx *ctx) -{ - struct sgsn_pdp_ctx *pdp; - if (ctx->ran_type != MM_CTX_T_UTRAN_Iu) - return; - llist_for_each_entry(pdp, &ctx->pdp_list, list) { - iu_rab_act_ps(pdp->nsapi, pdp); - } -} - /* Callback for RAB assignment response */ static int sgsn_ranap_rab_ass_resp(struct sgsn_mm_ctx *ctx, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies) { @@ -299,34 +288,18 @@ ctx->iu.ue_ctx = NULL; } -int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp) +int sgsn_ranap_iu_tx_rab_ps_ass_req(struct ranap_ue_conn_ctx *ue_ctx, + uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei) { struct msgb *msg; - struct sgsn_mm_ctx *mm = pdp->mm; - struct ranap_ue_conn_ctx *uectx; - uint32_t ggsn_ip; - bool use_x213_nsap; + bool use_x213_nsap = (ue_ctx->rab_assign_addr_enc == RANAP_NSAP_ADDR_ENC_X213); - uectx = mm->iu.ue_ctx; - use_x213_nsap = (uectx->rab_assign_addr_enc == RANAP_NSAP_ADDR_ENC_X213); - - /* Get the IP address for ggsn user plane */ - memcpy(&ggsn_ip, pdp->lib->gsnru.v, pdp->lib->gsnru.l); - ggsn_ip = htonl(ggsn_ip); - - LOGP(DRANAP, LOGL_DEBUG, "Assigning RAB: rab_id=%d, ggsn_ip=%x," - " teid_gn=%x, use_x213_nsap=%d\n", + LOGP(DRANAP, LOGL_DEBUG, + "Assigning RAB: rab_id=%u, ggsn_ip=%x, teid_gn=%x, use_x213_nsap=%d\n", rab_id, ggsn_ip, pdp->lib->teid_gn, use_x213_nsap); - msg = ranap_new_msg_rab_assign_data(rab_id, ggsn_ip, - pdp->lib->teid_gn, use_x213_nsap); - return sgsn_sccp_user_iups_tx_data_req(uectx->scu_iups, uectx->conn_id, msg); -} - -int ranap_iu_rab_deact(struct ranap_ue_conn_ctx *ue_ctx, uint8_t rab_id) -{ - /* FIXME */ - return -1; + msg = ranap_new_msg_rab_assign_data(rab_id, gtp_ip, gtp_tei, use_x213_nsap); + return sgsn_sccp_user_iups_tx_data_req(ue_ctx->scu_iups, ue_ctx->conn_id, msg); } int ranap_iu_tx_sec_mode_cmd(struct ranap_ue_conn_ctx *uectx, struct osmo_auth_vector *vec, diff --git a/src/sgsn/mmctx.c b/src/sgsn/mmctx.c index 40f902b..c7601ad 100644 --- a/src/sgsn/mmctx.c +++ b/src/sgsn/mmctx.c @@ -281,6 +281,16 @@ #endif } +/* Send RAB activation requests for all PDP contexts */ +void sgsn_mm_ctx_iu_activate_rabs(struct sgsn_mm_ctx *ctx) +{ + struct sgsn_pdp_ctx *pdp; + OSMO_ASSERT(ctx->ran_type == MM_CTX_T_UTRAN_Iu); + + llist_for_each_entry(pdp, &ctx->pdp_list, list) + sgsn_pdp_ctx_iu_rab_activate(pdp, pdp->nsapi); +} + /* this is a hard _free_ function, it doesn't clean up the PDP contexts * in libgtp! */ diff --git a/src/sgsn/pdpctx.c b/src/sgsn/pdpctx.c index e779420..b9f462c 100644 --- a/src/sgsn/pdpctx.c +++ b/src/sgsn/pdpctx.c @@ -19,6 +19,8 @@ * */ +#include "config.h" + #include <stdint.h> #include <osmocom/core/linuxlist.h> @@ -36,6 +38,7 @@ #include <osmocom/sgsn/gprs_llc_xid.h> #include <osmocom/sgsn/gprs_sndcp.h> #include <osmocom/sgsn/gprs_llc.h> +#include <osmocom/sgsn/gprs_ranap.h> #include <osmocom/sgsn/gprs_sm.h> #include <osmocom/sgsn/gtp.h> @@ -156,3 +159,36 @@ talloc_free(pdp); } + +#ifdef BUILD_IU +int sgsn_pdp_ctx_iu_rab_activate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id) +{ + struct sgsn_mm_ctx *mm = pdp->mm; + struct ranap_ue_conn_ctx *ue_ctx; + uint32_t ggsn_ip; + + OSMO_ASSERT(mm->ran_type == MM_CTX_T_UTRAN_Iu); + ue_ctx = mm->iu.ue_ctx; + + /* Get the IP address for ggsn user plane */ + memcpy(&ggsn_ip, pdp->lib->gsnru.v, pdp->lib->gsnru.l); + ggsn_ip = htonl(ggsn_ip); + + LOGPDPCTXP(pdp, LOGL_INFO, "Activate RAB: rab_id=%u, ggsn_ip=%x, teid_gn=%x\n", + rab_id, ggsn_ip, pdp->lib->teid_gn) + + return sgsn_ranap_iu_tx_rab_ps_ass_req(ue_ctx, rab_id, ggsn_ip, pdp->lib->teid_gn); +} + +int sgsn_pdp_ctx_iu_rab_deactivate(struct sgsn_pdp_ctx *pdp, uint8_t rab_id) +{ + struct sgsn_mm_ctx *mm = pdp->mm; + + OSMO_ASSERT(mm->ran_type == MM_CTX_T_UTRAN_Iu); + + LOGPDPCTXP(pdp, LOGL_NOTICE, "Release RAB: rab_id=%u not supported!\n", rab_id); + //struct ranap_ue_conn_ctx *ue_ctx = mm->iu.ue_ctx; + // TODO: add new function similar to sgsn_ranap_iu_tx_rab_ps_ass_req() but requesting relese of RAB. + return -ENOTSUP; +} +#endif /* ifdef BUILD_IU */ diff --git a/src/sgsn/sgsn_libgtp.c b/src/sgsn/sgsn_libgtp.c index edfe250..e637967 100644 --- a/src/sgsn/sgsn_libgtp.c +++ b/src/sgsn/sgsn_libgtp.c @@ -439,7 +439,7 @@ } else if (pctx->mm->ran_type == MM_CTX_T_UTRAN_Iu) { #ifdef BUILD_IU /* Activate a radio bearer */ - iu_rab_act_ps(pdp->nsapi, pctx); + sgsn_pdp_ctx_iu_rab_activate(pctx, pdp->nsapi); return 0; #else return -ENOTSUP; @@ -564,7 +564,7 @@ } else { #ifdef BUILD_IU /* Deactivate radio bearer */ - ranap_iu_rab_deact(pctx->mm->iu.ue_ctx, 1); + sgsn_pdp_ctx_iu_rab_deactivate(pctx, 1); #else return -ENOTSUP; #endif -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/40961?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I98788468b7e50619cfd99b3aef2311bb601fb6be Gerrit-Change-Number: 40961 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de>