From 030312043a84b0bfaf35c36790e56e3016c68661 Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Fri, 23 Jun 2017 10:13:27 +0200 Subject: wip: vty: make msc sccp addressesconfigurable Currently all sccp addresses on the msc (and bsc) side are hardcoded. Prepare the msc code to make the associated BSCs configurble. Make the compiler link libosmo-sccp properly and start using the sccp addressbook feature of libosmoc-sccp. --- openbsc/include/openbsc/a_iface.h | 19 +++++++++++++++++-- openbsc/include/openbsc/gsm_data.h | 3 +++ openbsc/src/gprs/Makefile.am | 2 ++ openbsc/src/libcommon-cs/common_cs.c | 1 + openbsc/src/libcommon/common_vty.c | 22 +++++++++++++++------- openbsc/src/libmsc/a_iface.c | 30 +++++++++--------------------- openbsc/src/osmo-bsc_mgcp/Makefile.am | 1 + openbsc/src/osmo-msc/msc_main.c | 1 + 8 files changed, 49 insertions(+), 30 deletions(-) diff --git a/openbsc/include/openbsc/a_iface.h b/openbsc/include/openbsc/a_iface.h index 34dfca67a..6da2715e9 100644 --- a/openbsc/include/openbsc/a_iface.h +++ b/openbsc/include/openbsc/a_iface.h @@ -18,6 +18,23 @@ * */ +#pragma once + +#include + +/* A struct to keep a context information about the BSCs we are associated with */ +struct bsc_context { + struct llist_head list; + + /* To be filled up by the user (VTY) */ + struct osmo_sccp_addr called_addr; /* BSC (remote) */ + struct osmo_sccp_addr calling_addr; /* MSC (local) */ + + /* Automatically filled up by a_init() */ + struct a_reset_ctx reset; /* Reset FSM (one per BSC) */ + struct osmo_sccp_user *sccp_user; /* SCCP user (the same for all) */ +}; + /* Initalize A interface connection between to MSC and BSC */ int a_init(void *ctx, const char *name, uint32_t local_pc, const char *listen_addr, const char *remote_addr, uint16_t local_port, struct gsm_network *network); @@ -40,5 +57,3 @@ void a_clear_all(struct osmo_sccp_user *scu, struct osmo_sccp_addr *bsc_addr); /* Delete info of a closed connection from the active connection list */ void a_delete_bsc_con(uint32_t conn_id); - -#pragma once diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index b07cac4a8..84855aca3 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -478,6 +478,9 @@ struct gsm_network { struct { enum nsap_addr_enc rab_assign_addr_enc; } iu; + + /* A list with all associated BSCs */ + struct llist_head bscs; }; struct osmo_esme; diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am index cb0997902..e05eb79ff 100644 --- a/openbsc/src/gprs/Makefile.am +++ b/openbsc/src/gprs/Makefile.am @@ -34,6 +34,7 @@ OSMO_LIBS = \ $(LIBOSMOCTRL_LIBS) \ $(LIBOSMOGB_LIBS) \ $(LIBGTP_LIBS) \ + $(LIBOSMOSIGTRAN_LIBS) \ $(NULL) bin_PROGRAMS = \ @@ -128,5 +129,6 @@ osmo_gtphub_LDADD = \ $(LIBOSMOVTY_LIBS) \ $(LIBCARES_LIBS) \ $(LIBGTP_LIBS) \ + $(LIBOSMOSIGTRAN_LIBS) \ -lrt \ $(NULL) diff --git a/openbsc/src/libcommon-cs/common_cs.c b/openbsc/src/libcommon-cs/common_cs.c index d94381b4c..59d496d28 100644 --- a/openbsc/src/libcommon-cs/common_cs.c +++ b/openbsc/src/libcommon-cs/common_cs.c @@ -65,6 +65,7 @@ struct gsm_network *gsm_network_init(void *ctx, INIT_LLIST_HEAD(&net->trans_list); INIT_LLIST_HEAD(&net->upqueue); INIT_LLIST_HEAD(&net->subscr_conns); + INIT_LLIST_HEAD(&net->bscs); net->bsc_subscribers = talloc_zero(net, struct llist_head); INIT_LLIST_HEAD(net->bsc_subscribers); diff --git a/openbsc/src/libcommon/common_vty.c b/openbsc/src/libcommon/common_vty.c index 6e1c10b00..fcda91841 100644 --- a/openbsc/src/libcommon/common_vty.c +++ b/openbsc/src/libcommon/common_vty.c @@ -34,6 +34,7 @@ #include #include #include +#include int bsc_vty_go_parent(struct vty *vty) @@ -108,6 +109,7 @@ int bsc_vty_go_parent(struct vty *vty) vty->node = SMPP_NODE; vty->index = NULL; break; + case SMPP_NODE: case MGCP_NODE: case GBPROXY_NODE: @@ -117,13 +119,15 @@ int bsc_vty_go_parent(struct vty *vty) case MSC_NODE: case MNCC_INT_NODE: case NITB_NODE: - default: - if (bsc_vty_is_config_node(vty, vty->node)) - vty->node = CONFIG_NODE; - else - vty->node = ENABLE_NODE; - + vty->node = CONFIG_NODE; vty->index = NULL; + break; + case SUBSCR_NODE: + vty->node = ENABLE_NODE; + vty->index = NULL; + break; + default: + osmo_ss7_vty_go_parent(vty); } return vty->node; @@ -131,6 +135,11 @@ int bsc_vty_go_parent(struct vty *vty) int bsc_vty_is_config_node(struct vty *vty, int node) { + /* Check if libosmo-sccp declares the node in + * question as config node */ + if (osmo_ss7_is_config_node(vty, node)) + return 1; + switch (node) { /* add items that are not config */ case OML_NODE: @@ -138,7 +147,6 @@ int bsc_vty_is_config_node(struct vty *vty, int node) case SUBSCR_NODE: case CONFIG_NODE: return 0; - default: return 1; } diff --git a/openbsc/src/libmsc/a_iface.c b/openbsc/src/libmsc/a_iface.c index 9c85faca3..fbd5b9329 100644 --- a/openbsc/src/libmsc/a_iface.c +++ b/openbsc/src/libmsc/a_iface.c @@ -40,9 +40,6 @@ #include #include -#define SSN_BSSAP 254 /* SCCP_SSN_BSSAP */ -#define SENDER_PC 1 /* Our local point code */ - /* A pointer to the GSM network we work with. By the current paradigm, * there can only be one gsm_network per MSC. The pointer is set once * when calling a_init() */ @@ -65,20 +62,6 @@ struct bsc_conn { * list is of type struct bsc_conn (see above) */ static LLIST_HEAD(active_connections); -/* Context information about the BSC, will be used only internally in this - * file to manage the BSCs we are associated with */ -struct bsc_context { - struct llist_head list; - struct a_reset_ctx reset; /* Reset FSM (one per BSC) */ - struct osmo_sccp_addr called_addr; /* BSC (remote) */ - struct osmo_sccp_addr calling_addr; /* MSC (local) */ - struct osmo_sccp_user *sccp_user; /* SCCP user (the same for all) */ -}; - -/* List with BSCs we are associated with. This list is of type - * struct bsc_context (see above) */ -static LLIST_HEAD(bsc_context_list); - /* Record info of a new active connection in the active connection list */ static void record_bsc_con(void *ctx, struct osmo_sccp_addr *called_addr, struct osmo_sccp_addr *calling_addr, uint32_t conn_id) @@ -132,7 +115,7 @@ static struct a_reset_ctx *get_reset_ctx_by_sccp_addr(struct osmo_sccp_addr *add if (!addr) return NULL; - llist_for_each_entry(bsc_ctx, &bsc_context_list, list) { + llist_for_each_entry(bsc_ctx, &gsm_network->bscs, list) { if (memcmp(&bsc_ctx->called_addr, addr, sizeof(*addr)) == 0) return &bsc_ctx->reset; } @@ -216,7 +199,7 @@ int a_iface_tx_paging(const char *imsi, uint32_t tmsi, uint16_t lac) cil.id_list_len = 1; /* Deliver paging request to all known BSCs */ - llist_for_each_entry(bsc_ctx, &bsc_context_list, list) { + llist_for_each_entry(bsc_ctx, &gsm_network->bscs, list) { if (a_reset_conn_ready(&bsc_ctx->reset)) { LOGP(DMSC, LOGL_DEBUG, "Passing paging message from MSC %s to BSC %s (imsi=%s, tmsi=0x%08x, lac=%u)\n", @@ -517,6 +500,11 @@ static void a_reset_cb(void *priv) int a_init(void *ctx, const char *name, uint32_t local_pc, const char *listen_addr, const char *remote_addr, uint16_t local_port, struct gsm_network *network) { + + +#define SSN_BSSAP 254 /* SCCP_SSN_BSSAP */ +#define SENDER_PC 1 /* Our local point code */ + /* FIXME: Remove hardcoded parameters, use parameters in parameter list */ struct osmo_sccp_instance *sccp; struct osmo_sccp_user *scu; @@ -538,7 +526,7 @@ int a_init(void *ctx, const char *name, uint32_t local_pc, bsc_ctx = talloc_zero(NULL, struct bsc_context); bsc_ctx->reset.priv = bsc_ctx; bsc_ctx->reset.cb = a_reset_cb; - llist_add_tail(&bsc_ctx->list, &bsc_context_list); + llist_add_tail(&bsc_ctx->list, &gsm_network->bscs); bsc_ctx->called_addr.presence = OSMO_SCCP_ADDR_T_SSN | OSMO_SCCP_ADDR_T_PC; bsc_ctx->called_addr.ssn = SCCP_SSN_BSSAP; bsc_ctx->called_addr.ri = OSMO_SCCP_RI_SSN_PC; @@ -551,7 +539,7 @@ int a_init(void *ctx, const char *name, uint32_t local_pc, bsc_ctx = NULL; /* Start reset procedure for all BSC connections */ - llist_for_each_entry(bsc_ctx, &bsc_context_list, list) { + llist_for_each_entry(bsc_ctx, &gsm_network->bscs, list) { a_reset_start(&bsc_ctx->reset); } diff --git a/openbsc/src/osmo-bsc_mgcp/Makefile.am b/openbsc/src/osmo-bsc_mgcp/Makefile.am index a19a4ebc0..b4e0d8564 100644 --- a/openbsc/src/osmo-bsc_mgcp/Makefile.am +++ b/openbsc/src/osmo-bsc_mgcp/Makefile.am @@ -31,5 +31,6 @@ osmo_bsc_mgcp_LDADD = \ $(LIBOSMONETIF_LIBS) \ $(LIBBCG729_LIBS) \ $(LIBRARY_GSM) \ + $(LIBOSMOSIGTRAN_LIBS) \ -lrt \ $(NULL) diff --git a/openbsc/src/osmo-msc/msc_main.c b/openbsc/src/osmo-msc/msc_main.c index 83d8fa4aa..c79332cd3 100644 --- a/openbsc/src/osmo-msc/msc_main.c +++ b/openbsc/src/osmo-msc/msc_main.c @@ -354,6 +354,7 @@ int main(int argc, char **argv) vty_init(&msc_vty_info); osmo_ss7_init(); + osmo_ss7_vty_init_sg(); /* Parse options */ handle_options(argc, argv); -- cgit v1.2.3