diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index d42f775d9..5f7de1aef 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -18,7 +18,8 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ gprs_gb_parse.h smpp.h meas_feed.h gprs_gsup_messages.h \ gprs_gsup_client.h bsc_msg_filter.h \ oap.h oap_messages.h \ - gtphub.h + gtphub.h \ + iu.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/gprs_gmm.h b/openbsc/include/openbsc/gprs_gmm.h index e0d8f7781..b4df65092 100644 --- a/openbsc/include/openbsc/gprs_gmm.h +++ b/openbsc/include/openbsc/gprs_gmm.h @@ -11,6 +11,8 @@ int gsm48_tx_gsm_act_pdp_acc(struct sgsn_pdp_ctx *pdp); int gsm48_tx_gsm_deact_pdp_acc(struct sgsn_pdp_ctx *pdp); int gsm0408_gprs_rcvmsg_gb(struct msgb *msg, struct gprs_llc_llme *llme); +int gsm0408_gprs_rcvmsg_iu(struct msgb *msg, struct gprs_ra_id *ra_id, + uint16_t *sai); int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx); int gsm0408_gprs_force_reattach_oldmsg(struct msgb *msg); void gsm0408_gprs_access_granted(struct sgsn_mm_ctx *mmctx); diff --git a/openbsc/include/openbsc/iu.h b/openbsc/include/openbsc/iu.h new file mode 100644 index 000000000..b9d55877b --- /dev/null +++ b/openbsc/include/openbsc/iu.h @@ -0,0 +1,9 @@ +#pragma once + +struct msgb; +struct gprs_ra_id; + +typedef int (* iu_recv_cb_t )(struct msgb *msg, struct gprs_ra_id *ra_id, + uint16_t *sai); + +int iu_tx(struct msgb *msg, uint8_t sapi); diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c index cf0d3ecb5..56d892f3a 100644 --- a/openbsc/src/gprs/gprs_gmm.c +++ b/openbsc/src/gprs/gprs_gmm.c @@ -55,6 +55,7 @@ #include #include #include +#include #include @@ -138,7 +139,7 @@ static int gsm48_gmm_sendmsg(struct msgb *msg, int command, rate_ctr_inc(&mm->ctrg->ctr[GMM_CTR_PKTS_SIG_OUT]); if (msg->dst) - return gprs_iu_tx(msg, GPRS_SAPI_GMM, mm); + return iu_tx(msg, GPRS_SAPI_GMM); /* caller needs to provide TLLI, BVCI and NSEI */ return gprs_llc_tx_ui(msg, GPRS_SAPI_GMM, command, mm); diff --git a/openbsc/src/gprs/sgsn_iu.c b/openbsc/src/gprs/sgsn_iu.c index 388f65935..edd31ffe6 100644 --- a/openbsc/src/gprs/sgsn_iu.c +++ b/openbsc/src/gprs/sgsn_iu.c @@ -18,14 +18,21 @@ #include #include +#include #include #include +#include #include +#include + +#include int asn1_xer_print = 1; void *talloc_asn1_ctx; +iu_recv_cb_t global_iu_recv_cb = NULL; + struct ue_conn_ctx { struct llist_head list; struct osmo_sua_link *link; @@ -125,6 +132,7 @@ int gprs_transp_upd_key(struct sgsn_mm_ctx *mm) return 0; } + static int ranap_handle_co_initial_ue(void *ctx, RANAP_InitialUE_MessageIEs_t *ies) { struct gprs_ra_id ra_id; @@ -138,7 +146,8 @@ static int ranap_handle_co_initial_ue(void *ctx, RANAP_InitialUE_MessageIEs_t *i /* Feed into the MM layer */ msg->dst = ctx; - gsm0408_gprs_rcvmsg_iu(msg, ra_id, sai); + global_iu_recv_cb(msg, &ra_id, sai); + // gsm0408_gprs_rcvmsg_iu(msg, ra_id, sai); return 0; } @@ -182,7 +191,7 @@ static int ranap_handle_co_err_ind(void *ctx, RANAP_ErrorIndicationIEs_t *ies) return 0; } -int gprs_iu_tx(struct msgb *msg, uint8_t sapi, struct mm_context *mm) +int iu_tx(struct msgb *msg, uint8_t sapi) { struct ue_conn_ctx *uectx = msg->dst; struct osmo_scu_prim *prim; @@ -405,13 +414,15 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) return 0; } -int sgsn_iu_init(void *ctx) +int sgsn_iu_init(void *ctx, iu_recv_cb_t iu_recv_cb) { struct osmo_sua_user *user; int rc; talloc_asn1_ctx = talloc_named_const(ctx, 1, "asn1"); + global_iu_recv_cb = iu_recv_cb; + osmo_sua_set_log_area(DSUA); user = osmo_sua_user_create(ctx, sccp_sap_up, ctx); diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index bb898fe7c..b0f758049 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -418,7 +418,7 @@ int main(int argc, char **argv) } asn_debug = 0; - sgsn_iu_init(tall_bsc_ctx); + sgsn_iu_init(tall_bsc_ctx, gsm0408_gprs_rcvmsg_iu); if (daemonize) { rc = osmo_daemonize();