aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2016-03-16 10:35:09 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2016-03-16 10:35:09 +0100
commitd04db9d90758d2abd572336942fd7e9246d41a22 (patch)
tree7b2a69c4dffa49b26f4c40db5f2430bda1a1f280
parent3c94c2c5975774282e49d2d9a1d2041b01c8378e (diff)
libiu: Replace RAB assignment response callback with a general one
The new iu event callback will now be called for RAB assignment response, IU release and security mode complete
-rw-r--r--openbsc/include/openbsc/iu.h13
-rw-r--r--openbsc/src/gprs/sgsn_libgtp.c29
-rw-r--r--openbsc/src/gprs/sgsn_main.c4
-rw-r--r--openbsc/src/libiu/iu.c17
4 files changed, 47 insertions, 16 deletions
diff --git a/openbsc/include/openbsc/iu.h b/openbsc/include/openbsc/iu.h
index d85d9a871..4d35b2076 100644
--- a/openbsc/include/openbsc/iu.h
+++ b/openbsc/include/openbsc/iu.h
@@ -12,19 +12,28 @@ struct ue_conn_ctx {
uint32_t conn_id;
};
+enum iu_event_type {
+ IU_EVENT_RAB_ASSIGN,
+ IU_EVENT_IU_RELEASE,
+ IU_EVENT_SECURITY_MODE_COMPLETE,
+};
+
/* Implementations of iu_recv_cb_t shall find the ue_conn_ctx in msg->dst. */
typedef int (* iu_recv_cb_t )(struct msgb *msg, struct gprs_ra_id *ra_id,
/* TODO is ra_id only used for gprs? ^ */
uint16_t *sai);
+typedef int (* iu_event_cb_t )(struct ue_conn_ctx *ue_ctx, enum iu_event_type type,
+ void *data);
+
typedef int (* iu_rab_ass_resp_cb_t )(struct ue_conn_ctx *ue_ctx, uint8_t rab_id,
struct RANAP_RAB_SetupOrModifiedItemIEs_s *setup_ies);
int iu_init(void *ctx, const char *listen_addr, uint16_t listen_port,
- iu_recv_cb_t iu_recv_cb, iu_rab_ass_resp_cb_t ui_rab_ass_resp_cb);
+ iu_recv_cb_t iu_recv_cb, iu_event_cb_t iu_event_cb);
int iu_tx(struct msgb *msg, uint8_t sapi);
int iu_rab_act_cs(struct ue_conn_ctx *ue_ctx, uint32_t rtp_ip, uint16_t rtp_port);
-int iu_rab_act_ps(struct sgsn_pdp_ctx *pdp);
+int iu_rab_act_ps(uint8_t rab_id, struct sgsn_pdp_ctx *pdp);
int iu_rab_deact(struct ue_conn_ctx *ue_ctx, uint8_t rab_id);
diff --git a/openbsc/src/gprs/sgsn_libgtp.c b/openbsc/src/gprs/sgsn_libgtp.c
index e48c103f1..1077cce5d 100644
--- a/openbsc/src/gprs/sgsn_libgtp.c
+++ b/openbsc/src/gprs/sgsn_libgtp.c
@@ -393,14 +393,16 @@ reject:
}
/* Callback for RAB assignment response */
-int sgsn_ranap_rab_ass_resp(struct ue_conn_ctx *ctx, uint8_t rab_id, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies)
+int sgsn_ranap_rab_ass_resp(struct ue_conn_ctx *ctx, RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies)
{
- int rc = -1;
+ uint8_t rab_id;
struct sgsn_mm_ctx *mm;
struct sgsn_pdp_ctx *pdp = NULL;
uint32_t gtp_tei;
RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies->raB_SetupOrModifiedItem;
+ rab_id = item->rAB_ID.buf[0];
+
mm = sgsn_mm_ctx_by_ue_ctx(ctx);
/* XXX: Error handling */
@@ -427,6 +429,29 @@ int sgsn_ranap_rab_ass_resp(struct ue_conn_ctx *ctx, uint8_t rab_id, RANAP_RAB_S
}
+int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, int type, void *data)
+{
+ int rc = -1;
+
+ switch (type) {
+ case IU_EVENT_RAB_ASSIGN:
+ rc = sgsn_ranap_rab_ass_resp(ctx, (RANAP_RAB_SetupOrModifiedItemIEs_t *)data);
+ break;
+ case IU_EVENT_IU_RELEASE:
+ /* Clean up ue_conn_ctx here */
+ break;
+ case IU_EVENT_SECURITY_MODE_COMPLETE:
+ /* Continue authentication here */
+ break;
+ default:
+ LOGP(DRANAP, LOGL_NOTICE, "Unknown event received: %i\n", type);
+ rc = -1;
+ break;
+ }
+ return rc;
+}
+
+
/* Confirmation of a PDP Context Delete */
static int delete_pdp_conf(struct pdp_t *pdp, void *cbp, int cause)
{
diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c
index ff9841205..01a11218e 100644
--- a/openbsc/src/gprs/sgsn_main.c
+++ b/openbsc/src/gprs/sgsn_main.c
@@ -305,7 +305,7 @@ static const struct log_info gprs_log_info = {
int asn_debug;
-int sgsn_ranap_rab_ass_resp(struct ue_conn_ctx *ctx, uint8_t rab_id, struct RANAP_RAB_SetupOrModifiedItemIEs_s *setup_ies);
+int sgsn_ranap_iu_event(struct ue_conn_ctx *ctx, int type, void *data);
int main(int argc, char **argv)
{
@@ -422,7 +422,7 @@ int main(int argc, char **argv)
}
asn_debug = 0;
- iu_init(tall_bsc_ctx, "127.0.0.2", 14001, gsm0408_gprs_rcvmsg_iu, sgsn_ranap_rab_ass_resp);
+ iu_init(tall_bsc_ctx, "127.0.0.2", 14001, gsm0408_gprs_rcvmsg_iu, sgsn_ranap_iu_event);
if (daemonize) {
rc = osmo_daemonize();
diff --git a/openbsc/src/libiu/iu.c b/openbsc/src/libiu/iu.c
index 6f0078f31..2381c3c1c 100644
--- a/openbsc/src/libiu/iu.c
+++ b/openbsc/src/libiu/iu.c
@@ -35,7 +35,7 @@ void *talloc_asn1_ctx;
iu_recv_cb_t global_iu_recv_cb = NULL;
-iu_rab_ass_resp_cb_t global_iu_rab_ass_resp_cb = NULL;
+iu_event_cb_t global_iu_event_cb = NULL;
static LLIST_HEAD(ue_conn_ctx_list);
@@ -252,23 +252,20 @@ static int ranap_handle_co_iu_rel_req(struct ue_conn_ctx *ctx, RANAP_Iu_ReleaseR
static int ranap_handle_co_rab_ass_resp(struct ue_conn_ctx *ctx, RANAP_RAB_AssignmentResponseIEs_t *ies)
{
int rc = -1;
- uint8_t rab_id;
LOGP(DRANAP, LOGL_INFO, "RAB Asignment Response:");
if (ies->presenceMask & RAB_ASSIGNMENTRESPONSEIES_RANAP_RAB_SETUPORMODIFIEDLIST_PRESENT) {
/* TODO: Iterate over list of SetupOrModifiedList IEs and handle each one */
RANAP_IE_t *ranap_ie = ies->raB_SetupOrModifiedList.raB_SetupOrModifiedList_ies.list.array[0];
RANAP_RAB_SetupOrModifiedItemIEs_t setup_ies;
- RANAP_RAB_SetupOrModifiedItem_t *item = &setup_ies.raB_SetupOrModifiedItem;
+
rc = ranap_decode_rab_setupormodifieditemies_fromlist(&setup_ies, &ranap_ie->value);
if (rc) {
LOGP(DRANAP, LOGL_ERROR, "Error in ranap_decode_rab_setupormodifieditemies()\n");
return rc;
}
- rab_id = item->rAB_ID.buf[0];
-
- rc = global_iu_rab_ass_resp_cb(ctx, rab_id, &setup_ies);
+ rc = global_iu_event_cb(ctx, IU_EVENT_RAB_ASSIGN, &setup_ies);
ranap_free_rab_setupormodifieditemies(&setup_ies);
}
@@ -311,12 +308,12 @@ static void cn_ranap_handle_co(void *ctx, ranap_message *message)
case RANAP_ProcedureCode_id_SecurityModeControl:
/* Security Mode Complete */
LOGP(DRANAP, LOGL_NOTICE, "FIXME: Handle security mode complete\n");
- rc = -1;
+ rc = global_iu_event_cb(ctx, IU_EVENT_SECURITY_MODE_COMPLETE, NULL);
break;
case RANAP_ProcedureCode_id_Iu_Release:
/* Iu Release Complete */
LOGP(DRANAP, LOGL_NOTICE, "FIXME: Handle Iu release complete\n");
- rc = -1;
+ rc = global_iu_event_cb(ctx, IU_EVENT_IU_RELEASE, NULL);
break;
default:
rc = -1;
@@ -476,13 +473,13 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link)
}
int iu_init(void *ctx, const char *listen_addr, uint16_t listen_port,
- iu_recv_cb_t iu_recv_cb, iu_rab_ass_resp_cb_t iu_rab_ass_resp_cb)
+ iu_recv_cb_t iu_recv_cb, iu_event_cb_t iu_event_cb)
{
struct osmo_sua_user *user;
talloc_asn1_ctx = talloc_named_const(ctx, 1, "asn1");
global_iu_recv_cb = iu_recv_cb;
- global_iu_rab_ass_resp_cb = iu_rab_ass_resp_cb;
+ global_iu_event_cb = iu_event_cb;
osmo_sua_set_log_area(DSUA);
user = osmo_sua_user_create(ctx, sccp_sap_up, ctx);
return osmo_sua_server_listen(user, listen_addr, listen_port);