bsc: Add access lists to the MSC and the BSC
It is a bit arbitary to decide which one is the global
and which one is the local one. We might change it around.
I don't think we want to introduce it based on BTS.
diff --git a/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg b/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
index d746196..fd4c3d7 100644
--- a/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
+++ b/openbsc/doc/examples/osmo-bsc/osmo-bsc.cfg
@@ -98,3 +98,8 @@
timeout-ping 20
timeout-pong 5
dest 192.168.100.11 6666 0
+ access-list-name msc-list
+ no access-list-name
+bsc
+ no access-list-name
+ access-list-name bsc-list
diff --git a/openbsc/include/openbsc/osmo_bsc.h b/openbsc/include/openbsc/osmo_bsc.h
index 19b879f..7df16cc 100644
--- a/openbsc/include/openbsc/osmo_bsc.h
+++ b/openbsc/include/openbsc/osmo_bsc.h
@@ -4,6 +4,7 @@
#define OSMO_BSC_H
#include "bsc_api.h"
+#include "bsc_msg_filter.h"
#define BSS_SEND_USSD 1
@@ -41,6 +42,8 @@
struct gsm_subscriber_connection *conn;
uint8_t new_subscriber;
+
+ struct bsc_filter_state filter_state;
};
struct bsc_api *osmo_bsc_api();
diff --git a/openbsc/include/openbsc/osmo_msc_data.h b/openbsc/include/openbsc/osmo_msc_data.h
index bdc762a..2d863aa 100644
--- a/openbsc/include/openbsc/osmo_msc_data.h
+++ b/openbsc/include/openbsc/osmo_msc_data.h
@@ -92,6 +92,8 @@
/* ussd text when MSC has entered the grace period */
char *ussd_grace_txt;
+
+ char *acc_lst_name;
};
/*
@@ -112,6 +114,8 @@
/* ussd text when there is no MSC available */
char *ussd_no_msc_txt;
+
+ char *acc_lst_name;
};
diff --git a/openbsc/src/osmo-bsc/Makefile.am b/openbsc/src/osmo-bsc/Makefile.am
index 6248fcd..b4a2cba 100644
--- a/openbsc/src/osmo-bsc/Makefile.am
+++ b/openbsc/src/osmo-bsc/Makefile.am
@@ -9,7 +9,9 @@
osmo_bsc_grace.c osmo_bsc_msc.c osmo_bsc_sccp.c \
osmo_bsc_filter.c osmo_bsc_bssap.c osmo_bsc_audio.c osmo_bsc_ctrl.c
# once again since TRAU uses CC symbol :(
-osmo_bsc_LDADD = $(top_builddir)/src/libbsc/libbsc.a \
+osmo_bsc_LDADD = \
+ $(top_builddir)/src/libfilter/libfilter.a \
+ $(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libmsc/libmsc.a \
$(top_builddir)/src/libbsc/libbsc.a \
$(top_builddir)/src/libtrau/libtrau.a \
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index 5c38855..77c9bf9 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -179,6 +179,7 @@
int main(int argc, char **argv)
{
+ struct llist_head access_lists;
struct osmo_msc_data *msc;
struct osmo_bsc_data *data;
int rc;
@@ -196,6 +197,9 @@
vty_info.copyright = openbsc_copyright;
vty_init(&vty_info);
bsc_vty_init(&log_info);
+ bsc_msg_lst_vty_init(tall_bsc_ctx, &access_lists, BSC_NODE);
+
+ INIT_LLIST_HEAD(&access_lists);
/* parse options */
handle_options(argc, argv);
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_vty.c b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
index bbbba1c..06ad77d 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_vty.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_vty.c
@@ -1,5 +1,5 @@
/* Osmo BSC VTY Configuration */
-/* (C) 2009-2014 by Holger Hans Peter Freyther
+/* (C) 2009-2015 by Holger Hans Peter Freyther
* (C) 2009-2014 by On-Waves
* All Rights Reserved
*
@@ -24,6 +24,7 @@
#include <openbsc/vty.h>
#include <openbsc/gsm_subscriber.h>
#include <openbsc/debug.h>
+#include <openbsc/bsc_msg_filter.h>
#include <osmocom/core/talloc.h>
#include <osmocom/vty/logging.h>
@@ -175,6 +176,9 @@
if (msc->local_pref)
vty_out(vty, " local-prefix %s%s", msc->local_pref, VTY_NEWLINE);
+ if (msc->acc_lst_name)
+ vty_out(vty, " access-list-name %s%s", msc->acc_lst_name, VTY_NEWLINE);
+
/* write amr options */
write_msc_amr_options(vty, msc);
}
@@ -210,6 +214,8 @@
vty_out(vty, " missing-msc-text %s%s", bsc->ussd_no_msc_txt, VTY_NEWLINE);
else
vty_out(vty, " no missing-msc-text%s", VTY_NEWLINE);
+ if (bsc->acc_lst_name)
+ vty_out(vty, " access-list-name %s%s", bsc->acc_lst_name, VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -625,6 +631,33 @@
AMR_COMMAND(5_15)
AMR_COMMAND(4_75)
+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 osmo_msc_data *msc = osmo_msc_data(vty);
+
+ bsc_replace_string(msc, &msc->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 "Remove the access list from the NAT.\n")
+{
+ struct osmo_msc_data *msc = osmo_msc_data(vty);
+
+ if (msc->acc_lst_name) {
+ talloc_free(msc->acc_lst_name);
+ msc->acc_lst_name = NULL;
+ }
+
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_net_bsc_mid_call_text,
cfg_net_bsc_mid_call_text_cmd,
"mid-call-text .TEXT",
@@ -681,6 +714,33 @@
return CMD_SUCCESS;
}
+DEFUN(cfg_bsc_acc_lst_name,
+ cfg_bsc_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 osmo_bsc_data *bsc = osmo_bsc_data(vty);
+
+ bsc_replace_string(bsc, &bsc->acc_lst_name, argv[0]);
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_bsc_no_acc_lst_name,
+ cfg_bsc_no_acc_lst_name_cmd,
+ "no access-list-name",
+ NO_STR "Remove the access list from the BSC\n")
+{
+ struct osmo_bsc_data *bsc = osmo_bsc_data(vty);
+
+ if (bsc->acc_lst_name) {
+ talloc_free(bsc->acc_lst_name);
+ bsc->acc_lst_name = NULL;
+ }
+
+ return CMD_SUCCESS;
+}
+
DEFUN(show_statistics,
show_statistics_cmd,
"show statistics",
@@ -805,6 +865,8 @@
install_element(BSC_NODE, &cfg_net_no_rf_off_time_cmd);
install_element(BSC_NODE, &cfg_net_bsc_missing_msc_ussd_cmd);
install_element(BSC_NODE, &cfg_net_bsc_no_missing_msc_text_cmd);
+ install_element(BSC_NODE, &cfg_bsc_acc_lst_name_cmd);
+ install_element(BSC_NODE, &cfg_bsc_no_acc_lst_name_cmd);
install_node(&msc_node, config_write_msc);
vty_install_default(MSC_NODE);
@@ -839,6 +901,8 @@
install_element(MSC_NODE, &cfg_net_msc_amr_5_90_cmd);
install_element(MSC_NODE, &cfg_net_msc_amr_5_15_cmd);
install_element(MSC_NODE, &cfg_net_msc_amr_4_75_cmd);
+ install_element(MSC_NODE, &cfg_msc_acc_lst_name_cmd);
+ install_element(MSC_NODE, &cfg_msc_no_acc_lst_name_cmd);
install_element_ve(&show_statistics_cmd);
install_element_ve(&show_mscs_cmd);