diff options
Diffstat (limited to 'src/pcu_main.cpp')
-rw-r--r-- | src/pcu_main.cpp | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/src/pcu_main.cpp b/src/pcu_main.cpp index 003cabb4..ec7bddd4 100644 --- a/src/pcu_main.cpp +++ b/src/pcu_main.cpp @@ -11,10 +11,6 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <pcu_l1_if.h> @@ -32,10 +28,12 @@ #include <bts.h> #include <osmocom/pcu/pcuif_proto.h> #include "gprs_bssgp_pcu.h" +#include "alloc_algo.h" extern "C" { #include "pcu_vty.h" #include "coding_scheme.h" +#include "pcu_l1_if_phy.h" #include <osmocom/gprs/gprs_bssgp.h> #include <osmocom/gprs/gprs_ns2.h> #include <osmocom/vty/telnet_interface.h> @@ -64,7 +62,7 @@ extern void *bv_tall_ctx; static int quit = 0; static int rt_prio = -1; static bool daemonize = false; -static const char *gsmtap_addr = "localhost"; // FIXME: use gengetopt's default value instead +static const char *gsmtap_addr; static void print_help() { @@ -74,9 +72,7 @@ static void print_help() " -m --mcc MCC Use given MCC instead of value provided by BTS\n" " -n --mnc MNC Use given MNC instead of value provided by BTS\n" " -V --version Print version\n" - " -r --realtime PRIO Use SCHED_RR with the specified priority\n" " -D --daemonize Fork the process into a background daemon\n" - " -i --gsmtap-ip The destination IP used for GSMTAP\n" "\nVTY reference generation:\n" " --vty-ref-mode MODE VTY reference generation mode (e.g. 'expert').\n" " --vty-ref-xml Generate the VTY reference XML output and exit.\n" @@ -162,9 +158,13 @@ static void handle_options(int argc, char **argv) break; case 'i': gsmtap_addr = optarg; + fprintf(stderr, "Command line argument '-i' is deprecated, use VTY " + "parameter 'gsmtap-remote-host %s' instead.\n", gsmtap_addr); break; case 'r': rt_prio = atoi(optarg); + fprintf(stderr, "Command line argument '-r' is deprecated, use VTY " + "cpu-sched node setting 'policy rr %d' instead.\n", rt_prio); break; case 'D': daemonize = true; @@ -239,6 +239,7 @@ int main(int argc, char *argv[]) pcu->pcu_sock_path = talloc_strdup(tall_pcu_ctx, PCU_SOCK_DEFAULT); + osmo_fsm_log_addr(false); msgb_talloc_ctx_init(tall_pcu_ctx, 0); osmo_stats_init(tall_pcu_ctx); @@ -250,6 +251,12 @@ int main(int argc, char *argv[]) osmo_cpu_sched_vty_init(tall_pcu_ctx); logging_vty_add_deprecated_subsys(tall_pcu_ctx, "bssgp"); +#ifdef ENABLE_DIRECT_PHY + rc = l1if_init(); + if (rc < 0) + return -EINVAL; +#endif + handle_options(argc, argv); if ((!!spoof_mcc) + (!!spoof_mnc) == 1) { fprintf(stderr, "--mcc and --mnc must be specified " @@ -257,13 +264,6 @@ int main(int argc, char *argv[]) exit(0); } - pcu->gsmtap = gsmtap_source_init(gsmtap_addr, GSMTAP_UDP_PORT, 1); - - if (pcu->gsmtap) - gsmtap_source_add_sink(pcu->gsmtap); - else - fprintf(stderr, "Failed to initialize GSMTAP for %s\n", gsmtap_addr); - pcu->nsi = gprs_ns2_instantiate(tall_pcu_ctx, gprs_ns_prim_cb, NULL); if (!pcu->nsi) { LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n"); @@ -282,8 +282,32 @@ int main(int argc, char *argv[]) fprintf(stderr, "No config file: '%s' Using default config.\n", config_file); - rc = telnet_init_dynif(tall_pcu_ctx, NULL, vty_get_bind_addr(), - OSMO_VTY_PORT_PCU); + /* Accept a GSMTAP host from VTY config, but a commandline option overrides that. */ + if (gsmtap_addr) { + if (pcu->gsmtap_remote_host != NULL) { + LOGP(DLGLOBAL, LOGL_NOTICE, + "Command line argument '-i %s' overrides " + "'gsmtap-remote-host %s' from the config file\n", + gsmtap_addr, pcu->gsmtap_remote_host); + talloc_free(pcu->gsmtap_remote_host); + } + pcu->gsmtap_remote_host = talloc_strdup(pcu, gsmtap_addr); + } + + if (pcu->gsmtap_remote_host) { + LOGP(DLGLOBAL, LOGL_NOTICE, + "Setting up GSMTAP Um forwarding to '%s:%u'\n", + pcu->gsmtap_remote_host, GSMTAP_UDP_PORT); + pcu->gsmtap = gsmtap_source_init(pcu->gsmtap_remote_host, + GSMTAP_UDP_PORT, 1); + if (pcu->gsmtap == NULL) { + fprintf(stderr, "Failed during gsmtap_source_init()\n"); + exit(1); + } + gsmtap_source_add_sink(pcu->gsmtap); + } + + rc = telnet_init_default(tall_pcu_ctx, NULL, OSMO_VTY_PORT_PCU); if (rc < 0) { fprintf(stderr, "Error initializing telnet\n"); exit(1); |