aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openbsc/include/openbsc/bsc_nat.h8
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c8
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c32
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c38
4 files changed, 85 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 9d55c9378..340525d25 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -234,6 +234,10 @@ struct msc_config {
struct llist_head dests;
struct bsc_msc_dest *main_dest;
struct bsc_msc_connection *msc_con;
+
+ /* imsi white and blacklist */
+ char *acc_lst_name;
+
char *token;
unsigned nr;
struct bsc_nat *nat;
@@ -276,6 +280,7 @@ struct bsc_nat {
/* MSC connections */
struct llist_head msc_configs;
unsigned num_msc;
+ unsigned default_msc;
/* timeouts */
int auth_timeout;
@@ -359,6 +364,9 @@ struct msc_config *msc_config_by_num(struct bsc_nat *nat, unsigned num);
struct msc_config *msc_config_by_con(struct bsc_nat *nat, const struct bsc_msc_connection *msc_con);
void msc_config_free(struct msc_config *);
+struct bsc_msc_connection *msc_conn_by_num(struct bsc_nat *nat, unsigned num);
+struct bsc_msc_connection *msc_conn_by_imsi(struct bsc_nat *nat, const char *imsi);
+
struct bsc_nat *bsc_nat_alloc(void);
struct bsc_connection *bsc_connection_alloc(struct bsc_nat *nat);
void bsc_nat_set_msc_ip(struct msc_config *msc, const char *ip);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 3012b8a12..037f3e758 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1154,7 +1154,13 @@ static int forward_sccp_to_msc(struct bsc_connection *bsc, struct msgb *msg)
goto exit2;
con = patch_sccp_src_ref_to_msc(msg, parsed, bsc);
OSMO_ASSERT(con);
- con->msc_con = bsc->nat->msc_con;
+
+ con->msc_con = msc_conn_by_imsi(bsc->nat, imsi);
+ if (!con->msc_con) { /* Fall back to default MSC */
+ LOGP(DNAT, LOGL_NOTICE, "Falling back to default MSC\n");
+ con->msc_con = msc_conn_by_num(bsc->nat, bsc->nat->default_msc);
+ }
+
con_msc = con->msc_con;
con->filter_state.con_type = con_type;
con->filter_state.imsi_checked = filter;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 0f72eb408..324e87b5d 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -253,6 +253,38 @@ struct msc_config *msc_config_by_con(struct bsc_nat *nat, const struct bsc_msc_c
return NULL;
}
+struct bsc_msc_connection *msc_conn_by_num(struct bsc_nat *nat, unsigned num)
+{
+ struct msc_config *conf;
+
+ conf = msc_config_by_num(nat, num);
+
+ if (!conf)
+ return NULL;
+
+ return conf->msc_con;
+}
+
+struct bsc_msc_connection *msc_conn_by_imsi(struct bsc_nat *nat, const char *imsi)
+{
+ struct msc_config *conf;
+
+ if (!imsi)
+ return NULL;
+
+ llist_for_each_entry(conf, &nat->msc_configs, entry) {
+ struct bsc_msg_acc_lst *acc;
+ acc = bsc_msg_acc_lst_find(&nat->access_lists, conf->acc_lst_name);
+ if (!acc)
+ continue;
+
+ if (!bsc_msg_acc_lst_check_allow(acc, imsi))
+ return conf->msc_con;
+ }
+
+ return NULL;
+}
+
void msc_config_free(struct msc_config *cfg)
{
llist_del(&cfg->entry);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index 4a1c97490..1b9983da4 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -826,6 +826,14 @@ DEFUN(cfg_nat_use_ipa_for_mgcp,
return CMD_SUCCESS;
}
+DEFUN(cfg_nat_default_msc,
+ cfg_nat_default_msc_cmd,
+ "default msc NR",
+ "The MSC to route messages to by default\n" "MSC number\n")
+{
+ _nat->default_msc = atoi(argv[0]);
+}
+
DEFUN(cfg_nat_sdp_amr_mode_set,
cfg_nat_sdp_amr_mode_set_cmd,
"sdp-ensure-amr-mode-set",
@@ -1114,6 +1122,33 @@ DEFUN(cfg_msc_port,
return CMD_SUCCESS;
}
+DEFUN(cfg_msc_acc_lst_name,
+ cfg_msc_acc_lst_name_cmd,
+ "access-list-name NAME",
+ "Set the name of the access list to use.\n"
+ "The name of the to be used access list.")
+{
+ struct msc_config *conf = vty->index;
+
+ osmo_talloc_replace_string(conf, &conf->acc_lst_name, argv[0]);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_msc_no_acc_lst_name,
+ cfg_msc_no_acc_lst_name_cmd,
+ "no access-list-name",
+ NO_STR "Do not use an access-list for the MSC.\n")
+{
+ struct msc_config *conf = vty->index;
+
+ if (conf->acc_lst_name) {
+ talloc_free(conf->acc_lst_name);
+ conf->acc_lst_name = NULL;
+ }
+
+ return CMD_SUCCESS;
+}
+
DEFUN(test_regex, test_regex_cmd,
"test regex PATTERN STRING",
"Test utilities\n"
@@ -1324,6 +1359,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(NAT_NODE, &cfg_nat_ussd_token_cmd);
install_element(NAT_NODE, &cfg_nat_ussd_local_cmd);
install_element(NAT_NODE, &cfg_nat_use_ipa_for_mgcp_cmd);
+ install_element(NAT_NODE, &cfg_nat_default_msc_cmd);
bsc_msg_lst_vty_init(nat, &nat->access_lists, NAT_NODE);
@@ -1377,6 +1413,8 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
install_element(NAT_MSC_NODE, &cfg_msc_token_cmd);
install_element(NAT_MSC_NODE, &cfg_msc_ip_cmd);
install_element(NAT_MSC_NODE, &cfg_msc_port_cmd);
+ install_element(NAT_MSC_NODE, &cfg_msc_acc_lst_name_cmd);
+ install_element(NAT_MSC_NODE, &cfg_msc_no_acc_lst_name_cmd);
mgcp_vty_init();