diff options
-rw-r--r-- | openbsc/include/openbsc/gb_proxy.h | 4 | ||||
-rw-r--r-- | openbsc/src/gprs/gb_proxy_main.c | 22 | ||||
-rw-r--r-- | openbsc/src/gprs/gb_proxy_vty.c | 46 | ||||
-rw-r--r-- | openbsc/src/gprs/osmo_gbproxy.cfg | 12 |
4 files changed, 19 insertions, 65 deletions
diff --git a/openbsc/include/openbsc/gb_proxy.h b/openbsc/include/openbsc/gb_proxy.h index 8979aac84..ad0405fd6 100644 --- a/openbsc/include/openbsc/gb_proxy.h +++ b/openbsc/include/openbsc/gb_proxy.h @@ -13,11 +13,7 @@ struct gbproxy_config { u_int32_t nsip_listen_ip; u_int16_t nsip_listen_port; - u_int32_t nsip_sgsn_ip; - u_int16_t nsip_sgsn_port; - u_int16_t nsip_sgsn_nsei; - u_int16_t nsip_sgsn_nsvci; /* misc */ struct gprs_ns_inst *nsi; diff --git a/openbsc/src/gprs/gb_proxy_main.c b/openbsc/src/gprs/gb_proxy_main.c index 02b31815a..68d07ae32 100644 --- a/openbsc/src/gprs/gb_proxy_main.c +++ b/openbsc/src/gprs/gb_proxy_main.c @@ -188,7 +188,6 @@ extern void *tall_msgb_ctx; int main(int argc, char **argv) { struct gsm_network dummy_network; - struct sockaddr_in sin; int rc; tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy"); @@ -207,7 +206,7 @@ int main(int argc, char **argv) vty_init("Osmocom Gb Proxy", PACKAGE_VERSION, openbsc_copyright); logging_vty_add_cmds(); - gbproxy_vty_init(); + gbproxy_vty_init(); handle_options(argc, argv); @@ -232,15 +231,18 @@ int main(int argc, char **argv) exit(2); } - nsip_listen(bssgp_nsi, gbcfg.nsip_listen_port); - - /* 'establish' the outgoing connection to the SGSN */ - sin.sin_family = AF_INET; - sin.sin_port = htons(gbcfg.nsip_sgsn_port); - sin.sin_addr.s_addr = htonl(gbcfg.nsip_sgsn_ip); - nsip_connect(bssgp_nsi, &sin, gbcfg.nsip_sgsn_nsei, - gbcfg.nsip_sgsn_nsvci); + if (!nsvc_by_nsei(gbcfg.nsi, gbcfg.nsip_sgsn_nsei)) { + LOGP(DGPRS, LOGL_FATAL, "You cannot proxy to NSEI %u " + "without creating that NSEI before\n", + gbcfg.nsip_sgsn_nsei); + exit(2); + } + rc = nsip_listen(bssgp_nsi, gbcfg.nsip_listen_port); + if (rc < 0) { + LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n"); + exit(2); + } /* Reset all the persistent NS-VCs that we've read from the config */ gbprox_reset_persistent_nsvcs(bssgp_nsi); diff --git a/openbsc/src/gprs/gb_proxy_vty.c b/openbsc/src/gprs/gb_proxy_vty.c index 7ee2833ed..4b71b1bd2 100644 --- a/openbsc/src/gprs/gb_proxy_vty.c +++ b/openbsc/src/gprs/gb_proxy_vty.c @@ -58,15 +58,8 @@ static int config_write_gbproxy(struct vty *vty) } vty_out(vty, " nsip bss local port %u%s", g_cfg->nsip_listen_port, VTY_NEWLINE); - ia.s_addr = htonl(g_cfg->nsip_sgsn_ip); - vty_out(vty, " nsip sgsn remote ip %s%s", inet_ntoa(ia), - VTY_NEWLINE); - vty_out(vty, " nsip sgsn remote port %u%s", g_cfg->nsip_sgsn_port, - VTY_NEWLINE); vty_out(vty, " nsip sgsn nsei %u%s", g_cfg->nsip_sgsn_nsei, VTY_NEWLINE); - vty_out(vty, " nsip sgsn nsvci %u%s", g_cfg->nsip_sgsn_nsvci, - VTY_NEWLINE); return CMD_SUCCESS; } @@ -104,31 +97,6 @@ DEFUN(cfg_nsip_bss_local_port, return CMD_SUCCESS; } - -DEFUN(cfg_nsip_sgsn_ip, - cfg_nsip_sgsn_ip_cmd, - "nsip sgsn remote ip A.B.C.D", - "Set the IP of the SGSN to which the proxy shall connect") -{ - struct in_addr ia; - - inet_aton(argv[0], &ia); - g_cfg->nsip_sgsn_ip = ntohl(ia.s_addr); - - return CMD_SUCCESS; -} - -DEFUN(cfg_nsip_sgsn_port, - cfg_nsip_sgsn_port_cmd, - "nsip sgsn remote port <0-65534>", - "Set the UDP port of the SGSN to which the proxy shall connect") -{ - unsigned int port = atoi(argv[0]); - - g_cfg->nsip_sgsn_port = port; - return CMD_SUCCESS; -} - DEFUN(cfg_nsip_sgsn_nsei, cfg_nsip_sgsn_nsei_cmd, "nsip sgsn nsei <0-65534>", @@ -140,17 +108,6 @@ DEFUN(cfg_nsip_sgsn_nsei, return CMD_SUCCESS; } -DEFUN(cfg_nsip_sgsn_nsvci, - cfg_nsip_sgsn_nsvci_cmd, - "nsip sgsn nsvci <0-65534>", - "Set the NSVCI to be used in the connection with the SGSN") -{ - unsigned int port = atoi(argv[0]); - - g_cfg->nsip_sgsn_nsvci = port; - return CMD_SUCCESS; -} - int gbproxy_vty_init(void) { install_element_ve(&show_gbproxy_cmd); @@ -162,10 +119,7 @@ int gbproxy_vty_init(void) install_element(GBPROXY_NODE, &ournode_end_cmd); install_element(GBPROXY_NODE, &cfg_nsip_bss_local_ip_cmd); install_element(GBPROXY_NODE, &cfg_nsip_bss_local_port_cmd); - install_element(GBPROXY_NODE, &cfg_nsip_sgsn_ip_cmd); - install_element(GBPROXY_NODE, &cfg_nsip_sgsn_port_cmd); install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsei_cmd); - install_element(GBPROXY_NODE, &cfg_nsip_sgsn_nsvci_cmd); return 0; } diff --git a/openbsc/src/gprs/osmo_gbproxy.cfg b/openbsc/src/gprs/osmo_gbproxy.cfg index d51b04a11..29dbe93aa 100644 --- a/openbsc/src/gprs/osmo_gbproxy.cfg +++ b/openbsc/src/gprs/osmo_gbproxy.cfg @@ -6,8 +6,10 @@ line vty no login ! gbproxy - nsip bss local port 23000 - nsip sgsn remote ip 127.0.0.1 - nsip sgsn remote port 7777 - nsip sgsn nsei 101 - nsip sgsn nsvci 101 + nsip bss local port 23000 + nsip sgsn nsei 101 +ns + nse 101 nsvci 101 + nse 101 remote-ip 192.168.100.239 + nse 101 remote-port 7777 + nse 101 remote-role sgsn |