diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2016-02-18 15:46:52 +0100 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2016-03-03 16:19:11 +0100 |
commit | 7d1b6b1c79acf9ef00d1f5f35092d12cbf0f3f7f (patch) | |
tree | 9c552ab5946fdef84536620d8bdb2235481ab139 | |
parent | 656d7cd0b4aaab790ec54206212795c2b454d7c6 (diff) |
libui: Don't assume gsm_network and gsm_subscriber_conncetion in libiu
The sgsn uses other data structs so don't require them inside libiu.
Instead keep a private list of ue contexts and iterate through that.
This commit reverts the libui changes of commit
d03faa4bacd4d2a8b9155faf5219a948b73f481c
-rw-r--r-- | openbsc/include/openbsc/iu.h | 6 | ||||
-rw-r--r-- | openbsc/src/gprs/sgsn_main.c | 2 | ||||
-rw-r--r-- | openbsc/src/libiu/iu.c | 28 | ||||
-rw-r--r-- | openbsc/src/osmo-cscn/cscn_main.c | 2 |
4 files changed, 12 insertions, 26 deletions
diff --git a/openbsc/include/openbsc/iu.h b/openbsc/include/openbsc/iu.h index 59571c0d2..dd03c6454 100644 --- a/openbsc/include/openbsc/iu.h +++ b/openbsc/include/openbsc/iu.h @@ -7,10 +7,6 @@ struct gprs_ra_id; struct RANAP_RAB_SetupOrModifiedItemIEs_s; typedef struct RANAP_RAB_SetupOrModifiedItemIEs_s RANAP_RAB_SetupOrModifiedItemIEs_t; -struct iu_cb_ctx { - struct gsm_network *network; -}; - struct ue_conn_ctx { struct llist_head list; struct osmo_sua_link *link; @@ -26,7 +22,7 @@ typedef int (* iu_rab_ass_resp_cb_t )(struct ue_conn_ctx *ue_ctx, uint8_t rab_id RANAP_RAB_SetupOrModifiedItemIEs_t *setup_ies); int iu_init(void *ctx, const char *listen_addr, uint16_t listen_port, - struct gsm_network *network, 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_rab_ass_resp_cb_t ui_rab_ass_resp_cb); int iu_tx(struct msgb *msg, uint8_t sapi); diff --git a/openbsc/src/gprs/sgsn_main.c b/openbsc/src/gprs/sgsn_main.c index 3c0145ea9..2a455fcd0 100644 --- a/openbsc/src/gprs/sgsn_main.c +++ b/openbsc/src/gprs/sgsn_main.c @@ -422,7 +422,7 @@ int main(int argc, char **argv) } asn_debug = 0; - iu_init(tall_bsc_ctx, "127.0.0.2", 14001, NULL, 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_rab_ass_resp); if (daemonize) { rc = osmo_daemonize(); diff --git a/openbsc/src/libiu/iu.c b/openbsc/src/libiu/iu.c index 6923575c8..5431fa942 100644 --- a/openbsc/src/libiu/iu.c +++ b/openbsc/src/libiu/iu.c @@ -33,9 +33,11 @@ int asn1_xer_print = 1; 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; +static LLIST_HEAD(ue_conn_ctx_list); struct ue_conn_ctx *ue_conn_ctx_alloc(struct osmo_sua_link *link, uint32_t conn_id) { @@ -43,22 +45,17 @@ struct ue_conn_ctx *ue_conn_ctx_alloc(struct osmo_sua_link *link, uint32_t conn_ ctx->link = link; ctx->conn_id = conn_id; + llist_add(&ctx->list, &ue_conn_ctx_list); return ctx; } -struct ue_conn_ctx *ue_conn_ctx_find(struct gsm_network *network, - struct osmo_sua_link *link, +struct ue_conn_ctx *ue_conn_ctx_find(struct osmo_sua_link *link, uint32_t conn_id) { - struct gsm_subscriber_connection *gsc; struct ue_conn_ctx *ctx; - llist_for_each_entry(gsc, &network->subscr_conns, entry) { - if (gsc->via_iface != IFACE_IU) - continue; - - ctx = gsc->iu.ue_ctx; + llist_for_each_entry(ctx, &ue_conn_ctx_list, list) { if (ctx->link == link && ctx->conn_id == conn_id) return ctx; } @@ -426,9 +423,6 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) struct osmo_prim_hdr *resp = NULL; int rc; struct ue_conn_ctx *ue; - struct osmo_sua_link *osl = (struct osmo_sua_link*)link; - struct iu_cb_ctx *iu_ctx = (struct iu_cb_ctx*)osmo_sua_link_get_user_priv(osl); - struct gsm_network *network = iu_ctx->network; printf("sccp_sap_up(%s)\n", osmo_scu_prim_name(oph)); @@ -455,7 +449,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) case OSMO_PRIM(OSMO_SCU_PRIM_N_DISCONNECT, PRIM_OP_INDICATION): /* indication of disconnect */ printf("N-DISCONNECT.ind(%u)\n", prim->u.disconnect.conn_id); - ue = ue_conn_ctx_find(network, link, prim->u.disconnect.conn_id); + ue = ue_conn_ctx_find(link, prim->u.disconnect.conn_id); rc = ranap_cn_rx_co(cn_ranap_handle_co, ue, msgb_l2(oph->msg), msgb_l2len(oph->msg)); break; case OSMO_PRIM(OSMO_SCU_PRIM_N_DATA, PRIM_OP_INDICATION): @@ -463,7 +457,7 @@ static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) printf("N-DATA.ind(%u, %s)\n", prim->u.data.conn_id, osmo_hexdump(msgb_l2(oph->msg), msgb_l2len(oph->msg))); /* resolve UE context */ - ue = ue_conn_ctx_find(network, link, prim->u.data.conn_id); + ue = ue_conn_ctx_find(link, prim->u.data.conn_id); rc = ranap_cn_rx_co(cn_ranap_handle_co, ue, msgb_l2(oph->msg), msgb_l2len(oph->msg)); break; case OSMO_PRIM(OSMO_SCU_PRIM_N_UNITDATA, PRIM_OP_INDICATION): @@ -482,19 +476,15 @@ 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, - struct gsm_network *network, 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_rab_ass_resp_cb_t iu_rab_ass_resp_cb) { - struct iu_cb_ctx *iu_ctx; struct osmo_sua_user *user; talloc_asn1_ctx = talloc_named_const(ctx, 1, "asn1"); - iu_ctx = talloc_zero(ctx, struct iu_cb_ctx); - iu_ctx->network = network; - global_iu_recv_cb = iu_recv_cb; global_iu_rab_ass_resp_cb = iu_rab_ass_resp_cb; osmo_sua_set_log_area(DSUA); - user = osmo_sua_user_create(ctx, sccp_sap_up, iu_ctx); + user = osmo_sua_user_create(ctx, sccp_sap_up, ctx); return osmo_sua_server_listen(user, listen_addr, listen_port); } diff --git a/openbsc/src/osmo-cscn/cscn_main.c b/openbsc/src/osmo-cscn/cscn_main.c index 6fab0416e..c7add15a3 100644 --- a/openbsc/src/osmo-cscn/cscn_main.c +++ b/openbsc/src/osmo-cscn/cscn_main.c @@ -447,7 +447,7 @@ TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_i /* TODO: implement A-Interface and remove above legacy stuff. */ /* Set up Iu-CS */ - iu_init(tall_cscn_ctx, "127.0.0.1", 14001, cscn_network, rcvmsg_iu_cs, handle_rab_ass_resp); + iu_init(tall_cscn_ctx, "127.0.0.1", 14001, rcvmsg_iu_cs, handle_rab_ass_resp); if (cscn_cmdline_config.daemonize) { rc = osmo_daemonize(); |