From: Max msuraev@sysmocom.de
--- openbsc/.gitignore | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/openbsc/.gitignore b/openbsc/.gitignore index 28fdcc8..bae3b65 100644 --- a/openbsc/.gitignore +++ b/openbsc/.gitignore @@ -90,3 +90,5 @@ tests/testsuite.log
src/openbsc.cfg* +writtenconfig/ +gtphub_restart_count
From: Max msuraev@sysmocom.de
Add command 'show nat bsc' to display number of configured BSCs.
Sponsored-by: On-Waves ehf --- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index cd8293c..96559b0 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -204,6 +204,14 @@ DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", return CMD_SUCCESS; }
+DEFUN(show_nat_bsc, show_nat_bsc_cmd, "show nat bsc", + SHOW_STR "Display NAT configuration details\n" + "BSCs-related\n") +{ + vty_out(vty, "%d BSCs configured%s", _nat->num_bsc, VTY_NEWLINE); + return CMD_SUCCESS; +} + DEFUN(show_bsc, show_bsc_cmd, "show bsc connections", SHOW_STR BSC_STR "All active connections\n") @@ -1169,6 +1177,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) /* show commands */ install_element_ve(&show_sccp_cmd); install_element_ve(&show_bsc_cmd); + install_element_ve(&show_nat_bsc_cmd); install_element_ve(&show_bsc_cfg_cmd); install_element_ve(&show_stats_cmd); install_element_ve(&show_stats_lac_cmd);
On 04 Apr 2016, at 15:30, msuraev@sysmocom.de wrote:
From: Max msuraev@sysmocom.de
Add command 'show nat bsc' to display number of configured BSCs.
Thank you for moving this to a separate patch.
+DEFUN(show_nat_bsc, show_nat_bsc_cmd, "show nat bsc",
SHOW_STR "Display NAT configuration details\n""BSCs-related\n")+{
- vty_out(vty, "%d BSCs configured%s", _nat->num_bsc, VTY_NEWLINE);
- return CMD_SUCCESS;
+}
If somebody asked me what "show nat bsc" would do, I would not have guessed it prints a number. Can you think of a better name?
"show nat configured-bsc-count"? "show nat bscs-configured"? "show nat num-bscs-configured"?
kind regards holger
From: Max msuraev@sysmocom.de
Introduce new configuration option bscs-config-file which includes BSC configuration from the given file. Both absolute and relative (to the main config file) paths are supported. Add 'show bscs-config' command to display current BSC configuration. Note: it is still possible to have BSC configuration in the main file (provided proper index number is used) and in runtime but BSC configuration is no longer saved automatically. The management of included configuration file is left to external tools. Update configuration examples.
Fixes: OS#1669 Sponsored-by: On-Waves ehf --- openbsc/doc/examples/osmo-bsc_nat/bscs.config | 13 +++++++ openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg | 8 +---- openbsc/include/openbsc/bsc_nat.h | 5 +++ openbsc/osmoappdesc.py | 3 ++ openbsc/src/osmo-bsc_nat/bsc_nat.c | 13 ++++++- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 40 ++++++++++++++++++++-- 6 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 openbsc/doc/examples/osmo-bsc_nat/bscs.config
diff --git a/openbsc/doc/examples/osmo-bsc_nat/bscs.config b/openbsc/doc/examples/osmo-bsc_nat/bscs.config new file mode 100644 index 0000000..176debe --- /dev/null +++ b/openbsc/doc/examples/osmo-bsc_nat/bscs.config @@ -0,0 +1,13 @@ +nat + bsc 0 + token lol + location_area_code 1234 + description bsc + max-endpoints 32 + paging forbidden 0 + bsc 1 + token wat + location_area_code 5678 + description bsc + max-endpoints 32 + paging forbidden 0 diff --git a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg index 737d104..2e00bc2 100644 --- a/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg +++ b/openbsc/doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg @@ -62,11 +62,5 @@ nat timeout ping 20 timeout pong 5 ip-dscp 0 + bscs-config-file bscs.config access-list bla imsi-allow ^11$ - - bsc 0 - token bla - location_area_code 1234 - description bsc - max-endpoints 32 - paging forbidden 0 diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index 309adb1..ab1c590 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -264,6 +264,10 @@ struct bsc_nat {
struct bsc_endpoint *bsc_endpoints;
+ /* path to file with BSC config */ + char *include_file; + char *include_base; + /* filter */ char *acc_lst_name;
@@ -336,6 +340,7 @@ void sccp_connection_destroy(struct nat_sccp_connection *); void bsc_close_connection(struct bsc_connection *);
const char *bsc_con_type_to_string(int type); +const char *bsc_nat_resolve_path(void *ctx, const char *base, const char *name);
/** * parse the given message into the above structure diff --git a/openbsc/osmoappdesc.py b/openbsc/osmoappdesc.py index 76f03fc..d10ecae 100644 --- a/openbsc/osmoappdesc.py +++ b/openbsc/osmoappdesc.py @@ -26,6 +26,9 @@ nitb_e1_configs = [ "doc/examples/osmo-nitb/rbs2308/openbsc.cfg" ]
+copy_files = [ + "doc/examples/osmo-bsc_nat/bscs.config" +]
app_configs = { "osmo-bsc": ["doc/examples/osmo-bsc/osmo-bsc.cfg"], diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index cacb919..7dcacfd 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -34,6 +34,7 @@ #include <time.h> #include <unistd.h> #include <fcntl.h> +#include <libgen.h>
#define _GNU_SOURCE #include <getopt.h> @@ -1451,6 +1452,12 @@ static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what) return 0; }
+const char *bsc_nat_resolve_path(void *ctx, const char *base, const char *name) +{ + return ('/' == name[0]) ? name : talloc_asprintf(ctx, "%s/%s", base, + name); +} + static void print_usage() { printf("Usage: bsc_nat\n"); @@ -1626,6 +1633,8 @@ int main(int argc, char **argv) local_addr.s_addr = INADDR_ANY; handle_options(argc, argv);
+ nat->include_base = dirname(talloc_strdup(tall_bsc_ctx, config_file)); + rate_ctr_init(tall_bsc_ctx); osmo_stats_init(tall_bsc_ctx);
@@ -1651,7 +1660,9 @@ int main(int argc, char **argv) /* seed the PRNG */ srand(time(NULL));
- + LOGP(DNAT, LOGL_NOTICE, "BSCs configured from %s\n", + bsc_nat_resolve_path(tall_bsc_ctx, nat->include_base, + nat->include_file));
/* * Setup the MGCP code.. diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 96559b0..8def3ed 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -96,6 +96,8 @@ static int config_write_nat(struct vty *vty) vty_out(vty, " timeout auth %d%s", _nat->auth_timeout, VTY_NEWLINE); vty_out(vty, " timeout ping %d%s", _nat->ping_timeout, VTY_NEWLINE); vty_out(vty, " timeout pong %d%s", _nat->pong_timeout, VTY_NEWLINE); + if (_nat->include_file) + vty_out(vty, " bscs-config-file %s%s", _nat->include_file, VTY_NEWLINE); if (_nat->token) vty_out(vty, " token %s%s", _nat->token, VTY_NEWLINE); vty_out(vty, " ip-dscp %d%s", _nat->bsc_ip_dscp, VTY_NEWLINE); @@ -181,6 +183,15 @@ static int config_write_bsc(struct vty *vty) return CMD_SUCCESS; }
+DEFUN(show_bscs, show_bscs_cmd, "show bscs-config", + SHOW_STR "Show configured BSCs\n" + "Both from included file and vty\n") +{ + vty_out(vty, "BSCs configuration loaded from %s:%s", + bsc_nat_resolve_path(_nat, _nat->include_base, + _nat->include_file), VTY_NEWLINE); + return config_write_bsc(vty); +}
DEFUN(show_sccp, show_sccp_cmd, "show sccp connections", SHOW_STR "Display information about SCCP\n" @@ -495,6 +506,24 @@ DEFUN(cfg_nat_acc_lst_name, return CMD_SUCCESS; }
+DEFUN(cfg_nat_include, + cfg_nat_include_cmd, + "bscs-config-file NAME", + "Set the filename of the BSC configuration to include.\n" + "The filename to be included.") +{ + const char *path = bsc_nat_resolve_path(_nat, _nat->include_base, + argv[0]); + int rc = vty_read_config_file(path, NULL); + if (rc < 0) { + vty_out(vty, "Failed to parse the config file %s: %s%s", path, + strerror(-rc), VTY_NEWLINE); + return CMD_WARNING; + } + bsc_replace_string(_nat, &_nat->include_file, argv[0]); + return CMD_SUCCESS; +} + DEFUN(cfg_nat_no_acc_lst_name, cfg_nat_no_acc_lst_name_cmd, "no access-list-name", @@ -871,8 +900,11 @@ DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>", /* verify that the LACs are unique */ llist_for_each_entry(tmp, &_nat->bsc_configs, entry) { if (bsc_config_handles_lac(tmp, lac)) { - vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE); - return CMD_ERR_INCOMPLETE; + if (tmp->nr != conf->nr) { + vty_out(vty, "%% LAC %d is already used.%s", lac, + VTY_NEWLINE); + return CMD_ERR_INCOMPLETE; + } } }
@@ -1185,6 +1217,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element_ve(&show_msc_cmd); install_element_ve(&test_regex_cmd); install_element_ve(&show_bsc_mgcp_cmd); + install_element_ve(&show_bscs_cmd); install_element_ve(&show_bar_lst_cmd); install_element_ve(&show_prefix_tree_cmd); install_element_ve(&show_ussd_connection_cmd); @@ -1206,6 +1239,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat) install_element(NAT_NODE, &cfg_nat_bsc_ip_tos_cmd); install_element(NAT_NODE, &cfg_nat_acc_lst_name_cmd); install_element(NAT_NODE, &cfg_nat_no_acc_lst_name_cmd); + install_element(NAT_NODE, &cfg_nat_include_cmd); install_element(NAT_NODE, &cfg_nat_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_no_imsi_black_list_fn_cmd); install_element(NAT_NODE, &cfg_nat_ussd_lst_name_cmd); @@ -1242,7 +1276,7 @@ int bsc_nat_vty_init(struct bsc_nat *nat)
/* BSC subgroups */ install_element(NAT_NODE, &cfg_bsc_cmd); - install_node(&bsc_node, config_write_bsc); + install_node(&bsc_node, NULL); vty_install_default(NAT_BSC_NODE); install_element(NAT_BSC_NODE, &cfg_bsc_token_cmd); install_element(NAT_BSC_NODE, &cfg_bsc_auth_key_cmd);
On 04 Apr 2016, at 15:30, msuraev@sysmocom.de wrote:
Hi Max,
+const char *bsc_nat_resolve_path(void *ctx, const char *base, const char *name) +{
- return ('/' == name[0]) ? name : talloc_asprintf(ctx, "%s/%s", base,
name);+}
I had hinted to you to repeat config reload (and relative paths) and observing memory consumption by using top -p `pidof osmo-bsc_nat`.
This routine is problematic either way in C.
Semantic:
Sometimes new memory will be allocated sometimes not
Responsibility:
Sometimes the callers needs to call talloc_free, sometimes not.
Result:
a.) Caller will never call talloc_free => sometimes leaks b.) Caller will always call talloc_free => sometimes crashes
Solution:
Make the semantic consistent
So please, take this leak and make yourself familiar with valgrind, talloc leak check, etc. It is important to learn from it. See my previous mail for an example how to script it.
kind regards holger
From: Max msuraev@sysmocom.de
Add vty tests for BSC configuration reloading. Load BSCs configuration on bscs-config-file command: * remove all runtime configured BSC not in the config file * close connections to all BSC with updated token value
Fixes: OS#1670 Sponsored-by: On-Waves ehf --- openbsc/include/openbsc/bsc_nat.h | 7 +- openbsc/src/osmo-bsc_nat/bsc_nat.c | 4 +- openbsc/src/osmo-bsc_nat/bsc_nat_vty.c | 38 ++++++++- openbsc/tests/vty_test_runner.py | 140 ++++++++++++++++++++++++++++++++- 4 files changed, 183 insertions(+), 6 deletions(-)
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h index ab1c590..419f111 100644 --- a/openbsc/include/openbsc/bsc_nat.h +++ b/openbsc/include/openbsc/bsc_nat.h @@ -35,10 +35,11 @@ #include <osmocom/gsm/protocol/gsm_04_08.h>
#include <regex.h> +#include <stdbool.h>
#define DIR_BSC 1 #define DIR_MSC 2 - +#define DEFAULT_TOKEN_VALUE "__UNKNOWN__" #define PAGIN_GROUP_UNASSIGNED -1
struct sccp_source_reference; @@ -164,6 +165,10 @@ struct bsc_config { /* audio handling */ int max_endpoints;
+ /* used internally for reload handling */ + bool remove; + bool token_updated; + /* backpointer */ struct bsc_nat *nat;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 7dcacfd..9bbb253 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -1321,8 +1321,8 @@ static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) bsc->cfg ? bsc->cfg->nr : -1); else LOGP(DNAT, LOGL_ERROR, - "Stream error on BSC Nr: %d. Failed to parse ip access message: %d\n", - bsc->cfg ? bsc->cfg->nr : -1, ret); + "Stream error on BSC Nr: %d. Failed to parse ip access message: %d (%s)\n", + bsc->cfg ? bsc->cfg->nr : -1, ret, strerror(-ret));
bsc_close_connection(bsc); return -1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c index 8def3ed..495e505 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c @@ -39,6 +39,7 @@ #include <osmocom/sccp/sccp.h>
#include <stdlib.h> +#include <stdbool.h>
static struct bsc_nat *_nat;
@@ -512,15 +513,40 @@ DEFUN(cfg_nat_include, "Set the filename of the BSC configuration to include.\n" "The filename to be included.") { + int rc; + struct bsc_config *cf1, *cf2; + struct bsc_connection *con1, *con2; const char *path = bsc_nat_resolve_path(_nat, _nat->include_base, argv[0]); - int rc = vty_read_config_file(path, NULL); + + llist_for_each_entry_safe(cf1, cf2, &_nat->bsc_configs, entry) { + cf1->remove = true; + cf1->token_updated = false; + } + + rc = vty_read_config_file(path, NULL); if (rc < 0) { vty_out(vty, "Failed to parse the config file %s: %s%s", path, strerror(-rc), VTY_NEWLINE); return CMD_WARNING; } + bsc_replace_string(_nat, &_nat->include_file, argv[0]); + + llist_for_each_entry_safe(con1, con2, &_nat->bsc_connections, + list_entry) { + if (con1->cfg) + if (con1->cfg->token_updated || con1->cfg->remove) + bsc_close_connection(con1); + } + + llist_for_each_entry_safe(cf1, cf2, &_nat->bsc_configs, entry) { + if (cf1->remove) { + bsc_config_free(cf1); + _nat->num_bsc--; + } + } + return CMD_SUCCESS; }
@@ -836,13 +862,14 @@ DEFUN(cfg_bsc, cfg_bsc_cmd, "bsc BSC_NR", return CMD_WARNING; } else if (bsc_nr == _nat->num_bsc) { /* allocate a new one */ - bsc = bsc_config_alloc(_nat, "unknown"); + bsc = bsc_config_alloc(_nat, DEFAULT_TOKEN_VALUE); } else bsc = bsc_config_num(_nat, bsc_nr);
if (!bsc) return CMD_WARNING;
+ bsc->remove = false; vty->index = bsc; vty->node = NAT_BSC_NODE;
@@ -855,6 +882,13 @@ DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", { struct bsc_config *conf = vty->index;
+ if (strncmp(conf->token, DEFAULT_TOKEN_VALUE, 16) != 0 && + strncmp(conf->token, argv[0], 128) != 0) { + vty_out(vty, "updated token: %s -> %s%s", conf->token, argv[0], + VTY_NEWLINE); + conf->token_updated = true; + } + bsc_replace_string(conf, &conf->token, argv[0]); return CMD_SUCCESS; } diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py index 8db0825..8e117b2 100644 --- a/openbsc/tests/vty_test_runner.py +++ b/openbsc/tests/vty_test_runner.py @@ -584,12 +584,56 @@ class TestVTYBSC(TestVTYGenericBSC): class TestVTYNAT(TestVTYGenericBSC):
def vty_command(self): - return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-c", + return ["./src/osmo-bsc_nat/osmo-bsc_nat", "-l", "127.0.0.1", "-c", "doc/examples/osmo-bsc_nat/osmo-bsc_nat.cfg"]
def vty_app(self): return (4244, "src/osmo-bsc_nat/osmo-bsc_nat", "OsmoBSCNAT", "nat")
+ def testBSCreload(self): + # use separate ip to avoid interference with other tests + ip = "127.0.0.4" + self.vty.enable() + bscs1 = self.vty.command("show bsc-config") + nat_bsc_reload(self) + bscs2 = self.vty.command("show bsc-config") + # check that multiple calls to bscs-config-file give the same result + self.assertEquals(bscs1, bscs2) + + # add new bsc + self.vty.command("configure terminal") + self.vty.command("nat") + self.vty.command("bsc 2") + self.vty.command("token key") + self.vty.command("location_area_code 666") + self.vty.command("end") + + # update bsc token + self.vty.command("configure terminal") + self.vty.command("nat") + self.vty.command("bsc 1") + self.vty.command("token xyu") + self.vty.command("end") + + nat_msc_ip(self, ip) + msc = nat_msc_test(self, ip) + b0 = nat_bsc_sock_test(0, "lol") + b1 = nat_bsc_sock_test(1, "xyu") + b2 = nat_bsc_sock_test(2, "key") + + self.assertEquals("3 BSCs configured", self.vty.command("show nat bsc")) + self.assertTrue(3 == nat_bsc_num_con(self)) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + + nat_bsc_reload(self) + bscs2 = self.vty.command("show bsc-config") + # check that the reset to initial config succeeded + self.assertEquals(bscs1, bscs2) + + self.assertEquals("2 BSCs configured", self.vty.command("show nat bsc")) + self.assertTrue(1 == nat_bsc_num_con(self)) + self.assertEquals("MSC is connected: 1", self.vty.command("show msc connection")) + def testVtyTree(self): self.vty.enable() self.assertTrue(self.vty.verify('configure terminal', [''])) @@ -971,6 +1015,100 @@ def add_nat_test(suite, workdir): test = unittest.TestLoader().loadTestsFromTestCase(TestVTYNAT) suite.addTest(test)
+def nat_bsc_reload(x): + x.vty.command("configure terminal") + x.vty.command("nat") + x.vty.command("bscs-config-file bscs.config") + x.vty.command("end") + +def nat_msc_ip(x, ip): + x.vty.command("configure terminal") + x.vty.command("nat") + x.vty.command("msc ip " + ip) + x.vty.command("end") + +def data2str(d): + return "".join("{:02x}".format(ord(c)) for c in d) + +def nat_msc_test(x, ip, verbose = False): + msc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + msc.settimeout(32) + msc.bind((ip, 5000)) + msc.listen(5) + if (verbose): + print "MSC is ready at " + ip + while "MSC is connected: 0" == x.vty.command("show msc connection"): + conn, addr = msc.accept() + if (verbose): + print "MSC got connection from ", addr + return conn + +def ipa_send_pong(x, verbose = False): + if (verbose): + print "\tBSC -> NAT: PONG!" + x.send("\x00\x01\xfe\x01") + +def ipa_send_ping(x, verbose = False): + if (verbose): + print "\tBSC -> NAT: PING?" + x.send("\x00\x01\xfe\x00") + +def ipa_send_ack(x, verbose = False): + if (verbose): + print "\tBSC -> NAT: IPA ID ACK" + x.send("\x00\x01\xfe\x06") + +def ipa_handle_small(x, verbose = False): + s = data2str(x.recv(4)) + if "0001fe00" == s: + if (verbose): + print "\tBSC <- NAT: PING?" + ipa_send_pong(x, verbose) + elif "0001fe06" == s: + if (verbose): + print "\tBSC <- NAT: IPA ID ACK" + ipa_send_ack(x, verbose) + elif "0001fe00" == s: + if (verbose): + print "\tBSC <- NAT: PONG!" + else: + if (verbose): + print "\tBSC <- NAT: ", s + +def ipa_send_reset(x, verbose = False): + if (verbose): + print "\tBSC -> NAT: RESET" + x.send("\x00\x12\xfd\x09\x00\x03\x05\x07\x02\x42\xfe\x02\x42\xfe\x06\x00\x04\x30\x04\x01\x20") + +def ipa_send_resp(x, tk, verbose = False): + if (verbose): + print "\tBSC -> NAT: IPA ID RESP" + x.send("\x00\x07\xfe\x05\x00\x04\x01" + tk) + +def ipa_handle_resp(x, tk, verbose = False): + s = data2str(x.recv(38)) + if "0023fe040108010701020103010401050101010011" in s: + ipa_send_resp(x, tk, verbose) + else: + if (verbose): + print "\tBSC <- NAT: ", s + +def nat_bsc_num_con(x): + return len(x.vty.command("show bsc connections").split('\n')) + +def nat_bsc_sock_test(nr, tk, verbose = False): + bsc = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + bsc.bind(('127.0.0.1' + str(nr), 0)) + bsc.connect(('127.0.0.1', 5000)) + if (verbose): + print "BSC%d " %nr + print "\tconnected to %s:%d" % bsc.getpeername() + ipa_handle_small(bsc, verbose) + ipa_handle_resp(bsc, tk, verbose) + bsc.recv(27) # MGCP msg + ipa_handle_small(bsc, verbose) + return bsc + def add_bsc_test(suite, workdir): if not os.path.isfile(os.path.join(workdir, "src/osmo-bsc/osmo-bsc")): print("Skipping the BSC test")