int main(int argc, char **argv) { struct esme esme; char *host = "localhost"; int port = 0; int rc; memset(&esme, 0, sizeof(esme)); osmo_init_logging(&log_info); snprintf((char *) esme.system_id, sizeof(esme.system_id), "mirror"); snprintf((char *) esme.password, sizeof(esme.password), "mirror"); esme.smpp_version = 0x34; if (argc >= 2) host = argv[1]; if (argc >= 3) port = atoi(argv[2]); rc = smpp_esme_init(&esme, host, port); if (rc < 0) exit(1); while (1) { osmo_select_main(0); } exit(0); }
int main(int argc, char **argv) { struct l1fwd_hdl *l1fh; struct femtol1_hdl *fl1h; int rc, i; printf("sizeof(GsmL1_Prim_t) = %zu\n", sizeof(GsmL1_Prim_t)); printf("sizeof(SuperFemto_Prim_t) = %zu\n", sizeof(SuperFemto_Prim_t)); bts_log_init(NULL); /* allocate new femtol1_handle */ fl1h = talloc_zero(NULL, struct femtol1_hdl); INIT_LLIST_HEAD(&fl1h->wlc_list); /* open the actual hardware transport */ for (i = 0; i < ARRAY_SIZE(fl1h->write_q); i++) { rc = l1if_transport_open(i, fl1h); if (rc < 0) exit(1); } /* create our fwd handle */ l1fh = talloc_zero(NULL, struct l1fwd_hdl); l1fh->fl1h = fl1h; fl1h->priv = l1fh; /* Open UDP */ for (i = 0; i < ARRAY_SIZE(l1fh->udp_wq); i++) { struct osmo_wqueue *wq = &l1fh->udp_wq[i]; osmo_wqueue_init(wq, 10); wq->write_cb = udp_write_cb; wq->read_cb = udp_read_cb; wq->bfd.when |= BSC_FD_READ; wq->bfd.data = l1fh; wq->bfd.priv_nr = i; rc = osmo_sock_init_ofd(&wq->bfd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, NULL, fwd_udp_ports[i], OSMO_SOCK_F_BIND); if (rc < 0) { perror("sock_init"); exit(1); } } while (1) { rc = osmo_select_main(0); if (rc < 0) { perror("select"); exit(1); } } exit(0); }
/* osmocom_on_idle */ static gboolean _osmocom_on_idle(gpointer data) { ModemPlugin * modem = data; Osmocom * osmocom = modem; if(osmo_select_main(0) < 0) { osmocom->source = 0; return FALSE; } return TRUE; }
int main(int argc, char ** argv) { struct telnet_connection dummy_conn; handle_options(argc, argv); vty_init(&vty_info); telnet_init(l23_ctx, NULL, vty_port); while(1) { osmo_select_main(0); } return 0; }
int main(int argc, char **argv) { int opt; char *loader_un_path = "/tmp/osmocom_loader"; const char *debugopt; while((opt = getopt(argc, argv, "d:hl:m:v")) != -1) { switch(opt) { case 'd': debugopt = optarg; while(*debugopt) { setdebug(argv[0], *debugopt); debugopt++; } break; case 'l': loader_un_path = optarg; break; case 'm': puts("model selection not implemented"); exit(2); break; case 'v': version(argv[0]); break; case 'h': default: usage(argv[0]); break; } } osmoload.quit = 0; loader_connect(loader_un_path); loader_command(argv[0], argc - optind, argv + optind); while(!osmoload.quit) { osmo_select_main(0); } if(osmoload.binfile) { fclose(osmoload.binfile); } return 0; }
int main(int argc, char *argv[]) { int teip; tall_test = talloc_named_const(NULL, 1, "lapd_test"); osmo_init_logging(&lapd_test_log_info); log_set_log_level(osmo_stderr_target, LOGL_NOTICE); /* * initialize datagram server. */ conn = osmo_dgram_create(tall_test); if (conn == NULL) { fprintf(stderr, "cannot create client\n"); exit(EXIT_FAILURE); } osmo_dgram_set_local_addr(conn, "127.0.0.1"); osmo_dgram_set_local_port(conn, 10001); osmo_dgram_set_remote_addr(conn, "127.0.0.1"); osmo_dgram_set_remote_port(conn, 10000); osmo_dgram_set_read_cb(conn, read_cb); lapd = lapd_instance_alloc(1, lapd_tx_cb, conn, lapd_rx_cb, conn, &lapd_profile_sat); if (lapd == NULL) { LOGP(DLAPDTEST, LOGL_ERROR, "cannot allocate instance\n"); exit(EXIT_FAILURE); } teip = lapd_tei_alloc(lapd, tei); if (teip == 0) { LOGP(DLAPDTEST, LOGL_ERROR, "cannot assign TEI\n"); exit(EXIT_FAILURE); } if (osmo_dgram_open(conn) < 0) { fprintf(stderr, "cannot open client\n"); exit(EXIT_FAILURE); } LOGP(DLAPDTEST, LOGL_NOTICE, "Entering main loop\n"); while(1) { osmo_select_main(0); } }
int main(int argc, char **argv) { struct smsc *smsc = talloc_zero(NULL, struct smsc); int rc; osmo_init_logging(&log_info); strcpy(smsc->system_id, "OpenBSC"); rc = smpp_smsc_init(smsc, 6080); if (rc < 0) exit(1); while (1) { osmo_select_main(0); } }
int main(int argc, char** argv) { printf("Starting... timer\n"); osmo_timer_schedule(&timer_one, 3, 0); osmo_timer_schedule(&timer_two, 5, 0); osmo_timer_schedule(&timer_three, 4, 0); #ifdef HAVE_SYS_SELECT_H while (1) { osmo_select_main(0); } #else printf("Select not supported on this platform!\n"); #endif }
int main(int argc, char **argv) { tall_pcu_ctx = talloc_named_const(NULL, 1, "moiji-mobile Emu-PCU context"); if (!tall_pcu_ctx) abort(); msgb_set_talloc_ctx(tall_pcu_ctx); osmo_init_logging(&gprs_log_info); vty_init(&pcu_vty_info); pcu_vty_init(&gprs_log_info); current_test = 0; init_main_bts(); create_and_connect_bssgp(bts_main_data(), INADDR_LOOPBACK, 23000); for (;;) osmo_select_main(0); return EXIT_SUCCESS; }
int main(int argc, char **argv) { struct log_target *stderr_target; osmo_fsm_log_addr(false); log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_print_filename(stderr_target, 0); g_ctx = NULL; osmo_fsm_register(&fsm); foo(); while (1) { osmo_select_main(0); } exit(0); }
int main(int argc, char **argv) { int rc; struct ctrl_connection *ccon; tall_mgr_ctx = talloc_named_const(NULL, 1, "bts manager"); msgb_talloc_ctx_init(tall_mgr_ctx, 0); srand(time(NULL)); osmo_init_logging2(tall_mgr_ctx, &mgr_log_info); if (classify_bts() != 0) exit(2); osmo_init_ignore_signals(); signal(SIGINT, &signal_handler); signal(SIGTERM, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); rc = parse_options(argc, argv); if (rc < 0) exit(2); sysmobts_mgr_vty_init(); logging_vty_add_cmds(&mgr_log_info); rc = sysmobts_mgr_parse_config(&manager); if (rc < 0) { LOGP(DFIND, LOGL_FATAL, "Cannot parse config file\n"); exit(1); } rc = telnet_init(tall_mgr_ctx, NULL, OSMO_VTY_PORT_BTSMGR); if (rc < 0) { fprintf(stderr, "Error initializing telnet\n"); exit(1); } /* start temperature check timer */ temp_timer.cb = check_temp_timer_cb; check_temp_timer_cb(NULL); /* start operational hours timer */ hours_timer.cb = hours_timer_cb; hours_timer_cb(NULL); /* start uc temperature check timer */ sbts2050_uc_initialize(); /* handle broadcast messages for ipaccess-find */ if (sysmobts_mgr_nl_init() != 0) exit(3); /* Initialize the temperature control */ ccon = osmo_ctrl_conn_alloc(tall_mgr_ctx, NULL); rc = -1; if (ccon) { ccon->write_queue.bfd.data = ccon; rc = osmo_sock_init_ofd(&ccon->write_queue.bfd, AF_INET, SOCK_STREAM, IPPROTO_TCP, "localhost", OSMO_CTRL_PORT_BTS, OSMO_SOCK_F_CONNECT); } if (rc < 0) LOGP(DLCTRL, LOGL_ERROR, "Can't connect to CTRL @ localhost:%u\n", OSMO_CTRL_PORT_BTS); else LOGP(DLCTRL, LOGL_NOTICE, "CTRL connected to locahost:%u\n", OSMO_CTRL_PORT_BTS); sysmobts_mgr_temp_init(&manager, ccon); if (sysmobts_mgr_calib_init(&manager) != 0) exit(3); if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } while (1) { log_reset_context(); osmo_select_main(0); } }
int main(int argc, char *argv[]) { struct gprs_rlcmac_bts *bts; int rc; tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); if (!tall_pcu_ctx) return -ENOMEM; bv_tall_ctx = tall_pcu_ctx; bts = gprs_rlcmac_bts = talloc_zero(tall_pcu_ctx, struct gprs_rlcmac_bts); if (!gprs_rlcmac_bts) return -ENOMEM; bts->fc_interval = 1; bts->initial_cs_dl = bts->initial_cs_ul = 1; bts->cs1 = 1; bts->t3142 = 20; bts->t3169 = 5; bts->t3191 = 5; bts->t3193_msec = 100; bts->t3195 = 5; bts->n3101 = 10; bts->n3103 = 4; bts->n3105 = 8; bts->alpha = 0; /* a = 0.0 */ msgb_set_talloc_ctx(tall_pcu_ctx); osmo_init_logging(&gprs_log_info); vty_init(&pcu_vty_info); pcu_vty_init(&gprs_log_info); handle_options(argc, argv); if ((!!spoof_mcc) + (!!spoof_mnc) == 1) { fprintf(stderr, "--mcc and --mnc must be specified " "together.\n"); exit(0); } rc = vty_read_config_file(config_file, NULL); if (rc < 0 && config_given) { fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); exit(1); } if (rc < 0) fprintf(stderr, "No config file: '%s' Using default config.\n", config_file); rc = telnet_init(tall_pcu_ctx, NULL, 4240); if (rc < 0) { fprintf(stderr, "Error initializing telnet\n"); exit(1); } if (!bts->alloc_algorithm) bts->alloc_algorithm = alloc_algorithm_b; rc = pcu_l1if_open(); if (rc < 0) return rc; signal(SIGINT, sighandler); signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGPIPE, sighandler); signal(SIGABRT, sighandler); signal(SIGUSR1, sighandler); signal(SIGUSR2, sighandler); while (!quit) { osmo_gsm_timers_check(); osmo_gsm_timers_prepare(); osmo_gsm_timers_update(); osmo_select_main(0); #ifdef DEBUG_DIAGRAM gettimeofday(&diagram_time, NULL); #endif } telnet_exit(); pcu_l1if_close(); talloc_free(gprs_rlcmac_bts); talloc_report_full(tall_pcu_ctx, stderr); talloc_free(tall_pcu_ctx); return 0; }
int main(int argc, char **argv) { struct gsm_network dummy_network; int rc; tall_bsc_ctx = talloc_named_const(NULL, 0, "osmo_sgsn"); tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb"); signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); osmo_init_logging(&gprs_log_info); vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&gprs_log_info); sgsn_vty_init(); handle_options(argc, argv); rate_ctr_init(tall_bsc_ctx); rc = telnet_init(tall_bsc_ctx, &dummy_network, 4245); if (rc < 0) exit(1); gprs_ns_set_log_ss(DNS); bssgp_set_log_ss(DBSSGP); sgsn_nsi = gprs_ns_instantiate(&sgsn_ns_cb, tall_bsc_ctx); if (!sgsn_nsi) { LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n"); exit(1); } bssgp_nsi = sgsn_inst.cfg.nsi = sgsn_nsi; gprs_llc_init("/usr/local/lib/osmocom/crypt/"); gprs_ns_vty_init(bssgp_nsi); bssgp_vty_init(); gprs_llc_vty_init(); gprs_sndcp_vty_init(); /* FIXME: register signal handler for SS_L_NS */ rc = sgsn_parse_config(sgsn_inst.config_file, &sgsn_inst.cfg); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); exit(2); } rc = sgsn_gtp_init(&sgsn_inst); if (rc) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on GTP socket\n"); exit(2); } rc = gprs_ns_nsip_listen(sgsn_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n"); exit(2); } rc = gprs_ns_frgre_listen(sgsn_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen GRE " "socket. Do you have CAP_NET_RAW?\n"); exit(2); } if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } while (1) { rc = osmo_select_main(0); if (rc < 0) exit(3); } /* not reached */ exit(0); }
int main(int argc, char **argv) { struct osmo_msc_data *data; int rc; tall_bsc_ctx = talloc_named_const(NULL, 1, "openbsc"); osmo_init_logging(&log_info); bts_init(); e1inp_init(); /* enable filters */ /* This needs to precede handle_options() */ vty_info.copyright = openbsc_copyright; vty_init(&vty_info); bsc_vty_init(&log_info); /* parse options */ handle_options(argc, argv); /* seed the PRNG */ srand(time(NULL)); /* initialize SCCP */ sccp_set_log_area(DSCCP); rc = bsc_bootstrap_network(NULL, config_file); if (rc < 0) { fprintf(stderr, "Bootstrapping the network failed. exiting.\n"); exit(1); } bsc_api_init(bsc_gsmnet, osmo_bsc_api()); data = bsc_gsmnet->msc_data; if (rf_ctl) bsc_replace_string(data, &data->rf_ctrl_name, rf_ctl); if (data->rf_ctrl_name) { data->rf_ctl = osmo_bsc_rf_create(data->rf_ctrl_name, bsc_gsmnet); if (!data->rf_ctl) { fprintf(stderr, "Failed to create the RF service.\n"); exit(1); } } if (osmo_bsc_msc_init(bsc_gsmnet) != 0) { LOGP(DNAT, LOGL_ERROR, "Failed to start up. Exiting.\n"); exit(1); } if (osmo_bsc_sccp_init(bsc_gsmnet) != 0) { LOGP(DNM, LOGL_ERROR, "Failed to register SCCP.\n"); exit(1); } if (osmo_bsc_audio_init(bsc_gsmnet) != 0) { LOGP(DMSC, LOGL_ERROR, "Failed to register audio support.\n"); exit(1); } signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } while (1) { osmo_select_main(0); } return 0; }
int main(int argc, char **argv) { struct gsm_network dummy_network; int rc; tall_bsc_ctx = talloc_named_const(NULL, 0, "nsip_proxy"); tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb"); signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); osmo_init_logging(&gprs_log_info); vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&gprs_log_info); gbproxy_vty_init(); handle_options(argc, argv); rate_ctr_init(tall_bsc_ctx); rc = telnet_init(tall_bsc_ctx, &dummy_network, 4246); if (rc < 0) exit(1); bssgp_nsi = gprs_ns_instantiate(&proxy_ns_cb, tall_bsc_ctx); if (!bssgp_nsi) { LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n"); exit(1); } gbcfg.nsi = bssgp_nsi; gprs_ns_vty_init(bssgp_nsi); gprs_ns_set_log_ss(DNS); bssgp_set_log_ss(DBSSGP); osmo_signal_register_handler(SS_L_NS, &gbprox_signal, NULL); rc = gbproxy_parse_config(config_file, &gbcfg); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); exit(2); } if (!gprs_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 = gprs_ns_nsip_listen(bssgp_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n"); exit(2); } rc = gprs_ns_frgre_listen(bssgp_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen GRE " "socket. Do you have CAP_NET_RAW?\n"); exit(2); } if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } /* Reset all the persistent NS-VCs that we've read from the config */ gbprox_reset_persistent_nsvcs(bssgp_nsi); while (1) { rc = osmo_select_main(0); if (rc < 0) exit(3); } exit(0); }
int main(int argc, char **argv) { struct gsm_network dummy_network; struct sockaddr_in addr; int on = 1, rc; tall_bsc_ctx = talloc_named_const(NULL, 1, "mgcp-callagent"); osmo_init_ignore_signals(); osmo_init_logging(&log_info); cfg = mgcp_config_alloc(); if (!cfg) return -1; #ifdef BUILD_MGCP_TRANSCODING cfg->setup_rtp_processing_cb = &mgcp_transcoding_setup; cfg->rtp_processing_cb = &mgcp_transcoding_process_rtp; cfg->get_net_downlink_format_cb = &mgcp_transcoding_net_downlink_format; #endif vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&log_info); mgcp_vty_init(); handle_options(argc, argv); rc = mgcp_parse_config(config_file, cfg, MGCP_BSC); if (rc < 0) return rc; rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_BSC_MGCP); if (rc < 0) return rc; /* set some callbacks */ cfg->reset_cb = mgcp_rsip_cb; /* we need to bind a socket */ if (rc == 0) { cfg->gw_fd.bfd.when = BSC_FD_READ; cfg->gw_fd.bfd.cb = read_call_agent; cfg->gw_fd.bfd.fd = socket(AF_INET, SOCK_DGRAM, 0); if (cfg->gw_fd.bfd.fd < 0) { perror("Gateway failed to listen"); return -1; } setsockopt(cfg->gw_fd.bfd.fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(cfg->source_port); inet_aton(cfg->source_addr, &addr.sin_addr); if (bind(cfg->gw_fd.bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { perror("Gateway failed to bind"); return -1; } cfg->gw_fd.bfd.data = msgb_alloc(4096, "mgcp-msg"); if (!cfg->gw_fd.bfd.data) { fprintf(stderr, "Gateway memory error.\n"); return -1; } if (cfg->call_agent_addr) { addr.sin_port = htons(2727); inet_aton(cfg->call_agent_addr, &addr.sin_addr); if (connect(cfg->gw_fd.bfd.fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) { LOGP(DMGCP, LOGL_ERROR, "Failed to connect to: '%s'. errno: %d\n", cfg->call_agent_addr, errno); close(cfg->gw_fd.bfd.fd); cfg->gw_fd.bfd.fd = -1; return -1; } } if (osmo_fd_register(&cfg->gw_fd.bfd) != 0) { LOGP(DMGCP, LOGL_FATAL, "Failed to register the fd\n"); return -1; } LOGP(DMGCP, LOGL_NOTICE, "Configured for MGCP.\n"); } /* initialisation */ srand(time(NULL)); if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } /* main loop */ while (1) { osmo_select_main(0); } return 0; }
int bts_main(int argc, char **argv) { struct gsm_bts_role_bts *btsb; struct gsm_bts_trx *trx; struct e1inp_line *line; void *tall_msgb_ctx; int rc, i; printf("((*))\n |\n / \\ OsmoBTS\n"); tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); tall_msgb_ctx = talloc_pool(tall_bts_ctx, 100*1024); msgb_set_talloc_ctx(tall_msgb_ctx); bts_log_init(NULL); handle_options(argc, argv); bts = gsm_bts_alloc(tall_bts_ctx); if (!bts) { fprintf(stderr, "Failed to create BTS structure\n"); exit(1); } for (i = 1; i < trx_num; i++) { trx = gsm_bts_trx_alloc(bts); if (!trx) { fprintf(stderr, "Failed to create TRX structure\n"); exit(1); } } vty_init(&bts_vty_info); e1inp_vty_init(); bts_vty_init(bts, &bts_log_info); /* enable realtime priority for us */ if (rt_prio != -1) { struct sched_param param; memset(¶m, 0, sizeof(param)); param.sched_priority = rt_prio; rc = sched_setscheduler(getpid(), SCHED_RR, ¶m); if (rc != 0) { fprintf(stderr, "Setting SCHED_RR priority(%d) failed: %s\n", param.sched_priority, strerror(errno)); exit(1); } } if (gsmtap_ip) { gsmtap = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1); if (!gsmtap) { fprintf(stderr, "Failed during gsmtap_init()\n"); exit(1); } gsmtap_source_add_sink(gsmtap); } if (bts_init(bts) < 0) { fprintf(stderr, "unable to open bts\n"); exit(1); } abis_init(bts); rc = vty_read_config_file(config_file, NULL); if (rc < 0) { fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); exit(1); } write_pid_file("osmo-bts"); bts_controlif_setup(bts); rc = telnet_init(tall_bts_ctx, NULL, OSMO_VTY_PORT_BTS); if (rc < 0) { fprintf(stderr, "Error initializing telnet\n"); exit(1); } if (pcu_sock_init()) { fprintf(stderr, "PCU L1 socket failed\n"); exit(1); } signal(SIGINT, &signal_handler); //signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); btsb = bts_role_bts(bts); if (!btsb->bsc_oml_host) { fprintf(stderr, "Cannot start BTS without knowing BSC OML IP\n"); exit(1); } line = abis_open(bts, btsb->bsc_oml_host, "sysmoBTS"); if (!line) { fprintf(stderr, "unable to connect to BSC\n"); exit(2); } if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } while (quit < 2) { log_reset_context(); osmo_select_main(0); } return EXIT_SUCCESS; }
int main(int argc, char **argv) { int quit = 0; int rc; char const * home; size_t len; const char osmocomcfg[] = ".osmocom/bb/mobile.cfg"; char *config_file = NULL; printf("%s\n", openbsc_copyright); srand(time(NULL)); INIT_LLIST_HEAD(&ms_list); log_init(&log_info, NULL); stderr_target = log_target_create_stderr(); log_add_target(stderr_target); log_set_all_filter(stderr_target, 1); l23_ctx = talloc_named_const(NULL, 1, "layer2 context"); msgb_set_talloc_ctx(l23_ctx); handle_options(argc, argv); if (!debug_set) log_parse_category_mask(stderr_target, debug_default); log_set_log_level(stderr_target, LOGL_DEBUG); if (gsmtap_ip) { gsmtap_inst = gsmtap_source_init(gsmtap_ip, GSMTAP_UDP_PORT, 1); if (!gsmtap_inst) { fprintf(stderr, "Failed during gsmtap_init()\n"); exit(1); } gsmtap_source_add_sink(gsmtap_inst); } home = getenv("HOME"); if (home != NULL) { len = strlen(home) + 1 + sizeof(osmocomcfg); config_file = talloc_size(l23_ctx, len); if (config_file != NULL) snprintf(config_file, len, "%s/%s", home, osmocomcfg); } /* save the config file directory name */ config_dir = talloc_strdup(l23_ctx, config_file); config_dir = dirname(config_dir); if (use_mncc_sock) rc = l23_app_init(mncc_recv_socket, config_file, vty_port); else rc = l23_app_init(NULL, config_file, vty_port); if (rc) exit(rc); signal(SIGINT, sighandler); signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGPIPE, sighandler); signal(SIGABRT, sighandler); signal(SIGUSR1, sighandler); signal(SIGUSR2, sighandler); if (daemonize) { printf("Running as daemon\n"); rc = osmo_daemonize(); if (rc) fprintf(stderr, "Failed to run as daemon\n"); } while (1) { l23_app_work(&quit); if (quit && llist_empty(&ms_list)) break; osmo_select_main(0); } l23_app_exit(); talloc_free(config_file); talloc_free(config_dir); talloc_report_full(l23_ctx, stderr); return 0; }
int main(int argc, char *argv[]) { struct sched_param param; struct gprs_rlcmac_bts *bts; int rc; tall_pcu_ctx = talloc_named_const(NULL, 1, "Osmo-PCU context"); if (!tall_pcu_ctx) return -ENOMEM; bv_tall_ctx = tall_pcu_ctx; bts = bts_main_data(); bts->fc_interval = 1; bts->initial_cs_dl = bts->initial_cs_ul = 1; bts->cs1 = 1; bts->t3142 = 20; bts->t3169 = 5; bts->t3191 = 5; bts->t3193_msec = 100; bts->t3195 = 5; bts->n3101 = 10; bts->n3103 = 4; bts->n3105 = 8; bts->alpha = 0; /* a = 0.0 */ msgb_set_talloc_ctx(tall_pcu_ctx); osmo_init_logging(&gprs_log_info); vty_init(&pcu_vty_info); pcu_vty_init(&gprs_log_info); handle_options(argc, argv); if ((!!spoof_mcc) + (!!spoof_mnc) == 1) { fprintf(stderr, "--mcc and --mnc must be specified " "together.\n"); exit(0); } rc = vty_read_config_file(config_file, NULL); if (rc < 0 && config_given) { fprintf(stderr, "Failed to parse the config file: '%s'\n", config_file); exit(1); } if (rc < 0) fprintf(stderr, "No config file: '%s' Using default config.\n", config_file); rc = telnet_init(tall_pcu_ctx, NULL, 4240); if (rc < 0) { fprintf(stderr, "Error initializing telnet\n"); exit(1); } if (!bts->alloc_algorithm) bts->alloc_algorithm = alloc_algorithm_b; rc = pcu_l1if_open(); if (rc < 0) return rc; signal(SIGINT, sighandler); signal(SIGHUP, sighandler); signal(SIGTERM, sighandler); signal(SIGPIPE, sighandler); signal(SIGABRT, sighandler); signal(SIGUSR1, sighandler); signal(SIGUSR2, sighandler); /* enable realtime priority for us */ if (rt_prio != -1) { memset(¶m, 0, sizeof(param)); param.sched_priority = rt_prio; rc = sched_setscheduler(getpid(), SCHED_RR, ¶m); if (rc != 0) { fprintf(stderr, "Setting SCHED_RR priority(%d) failed: %s\n", param.sched_priority, strerror(errno)); exit(1); } } while (!quit) { osmo_gsm_timers_check(); osmo_gsm_timers_prepare(); osmo_gsm_timers_update(); osmo_select_main(0); } telnet_exit(); pcu_l1if_close(); bts->bts->timing_advance()->flush(); talloc_report_full(tall_pcu_ctx, stderr); talloc_free(tall_pcu_ctx); return 0; }
int main(int argc, char **argv) { struct l1fwd_hdl *l1fh; struct femtol1_hdl *fl1h; int rc, i; printf("sizeof(GsmL1_Prim_t) = %zu\n", sizeof(GsmL1_Prim_t)); printf("sizeof(SuperFemto_Prim_t) = %zu\n", sizeof(SuperFemto_Prim_t)); bts_log_init(NULL); /* * hack and prevent that two l1fwd-proxy/sysmobts run at the same * time. This is done by binding to the same VTY port. */ rc = osmo_sock_init(AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "127.0.0.1", 4241, OSMO_SOCK_F_BIND); if (rc < 0) { fprintf(stderr, "Failed to bind to the BTS VTY port.\n"); return EXIT_FAILURE; } /* allocate new femtol1_handle */ fl1h = talloc_zero(NULL, struct femtol1_hdl); INIT_LLIST_HEAD(&fl1h->wlc_list); /* open the actual hardware transport */ for (i = 0; i < ARRAY_SIZE(fl1h->write_q); i++) { rc = l1if_transport_open(i, fl1h); if (rc < 0) exit(1); } /* create our fwd handle */ l1fh = talloc_zero(NULL, struct l1fwd_hdl); l1fh->fl1h = fl1h; fl1h->priv = l1fh; /* Open UDP */ for (i = 0; i < ARRAY_SIZE(l1fh->udp_wq); i++) { struct osmo_wqueue *wq = &l1fh->udp_wq[i]; osmo_wqueue_init(wq, 10); wq->write_cb = udp_write_cb; wq->read_cb = udp_read_cb; wq->bfd.when |= BSC_FD_READ; wq->bfd.data = l1fh; wq->bfd.priv_nr = i; rc = osmo_sock_init_ofd(&wq->bfd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, NULL, fwd_udp_ports[i], OSMO_SOCK_F_BIND); if (rc < 0) { perror("sock_init"); exit(1); } } while (1) { rc = osmo_select_main(0); if (rc < 0) { perror("select"); exit(1); } } exit(0); }
int main(int argc, char **argv) { int rc; struct cmdline_cfg _ccfg; struct cmdline_cfg *ccfg = &_ccfg; memset(ccfg, '\0', sizeof(*ccfg)); ccfg->config_file = "./gtphub.conf"; ccfg->restart_counter_file = "./gtphub_restart_count"; struct gtphub_cfg _cfg; struct gtphub_cfg *cfg = &_cfg; memset(cfg, '\0', sizeof(*cfg)); struct gtphub _hub; struct gtphub *hub = &_hub; osmo_gtphub_ctx = talloc_named_const(NULL, 0, "osmo_gtphub"); msgb_talloc_ctx_init(osmo_gtphub_ctx, 0); signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); osmo_init_logging(>phub_log_info); vty_info.copyright = gtphub_copyright; vty_init(&vty_info); logging_vty_add_cmds(>phub_log_info); gtphub_vty_init(hub, cfg); rate_ctr_init(osmo_gtphub_ctx); handle_options(ccfg, argc, argv); rc = gtphub_cfg_read(cfg, ccfg->config_file); if (rc < 0) { LOGP(DGTPHUB, LOGL_FATAL, "Cannot parse config file '%s'\n", ccfg->config_file); exit(2); } /* start telnet after reading config for vty_get_bind_addr() */ rc = telnet_init_dynif(osmo_gtphub_ctx, 0, vty_get_bind_addr(), OSMO_VTY_PORT_GTPHUB); if (rc < 0) exit(1); if (gtphub_start(hub, cfg, next_restart_count(ccfg->restart_counter_file)) != 0) return -1; log_cfg(cfg); if (ccfg->daemonize) { rc = osmo_daemonize(); if (rc < 0) { LOGP(DGTPHUB, LOGL_FATAL, "Error during daemonize"); exit(1); } } while (1) { rc = osmo_select_main(0); if (rc < 0) exit(3); } /* not reached */ exit(0); }
int main(int argc, char **argv) { struct ctrl_handle *ctrl; struct gsm_network dummy_network; int rc; tall_bsc_ctx = talloc_named_const(NULL, 0, "osmo_sgsn"); tall_msgb_ctx = talloc_named_const(tall_bsc_ctx, 0, "msgb"); signal(SIGINT, &signal_handler); signal(SIGABRT, &signal_handler); signal(SIGUSR1, &signal_handler); signal(SIGUSR2, &signal_handler); osmo_init_ignore_signals(); osmo_init_logging(&gprs_log_info); vty_info.copyright = openbsc_copyright; vty_init(&vty_info); logging_vty_add_cmds(&gprs_log_info); sgsn_vty_init(); handle_options(argc, argv); rate_ctr_init(tall_bsc_ctx); rc = telnet_init(tall_bsc_ctx, &dummy_network, OSMO_VTY_PORT_SGSN); if (rc < 0) exit(1); ctrl = sgsn_controlif_setup(NULL, OSMO_CTRL_PORT_SGSN); if (!ctrl) { LOGP(DGPRS, LOGL_ERROR, "Failed to create CTRL interface.\n"); exit(1); } if (sgsn_ctrl_cmds_install() != 0) { LOGP(DGPRS, LOGL_ERROR, "Failed to install CTRL commands.\n"); exit(1); } gprs_ns_set_log_ss(DNS); bssgp_set_log_ss(DBSSGP); sgsn_nsi = gprs_ns_instantiate(&sgsn_ns_cb, tall_bsc_ctx); if (!sgsn_nsi) { LOGP(DGPRS, LOGL_ERROR, "Unable to instantiate NS\n"); exit(1); } bssgp_nsi = sgsn_inst.cfg.nsi = sgsn_nsi; gprs_llc_init("/usr/local/lib/osmocom/crypt/"); sgsn_inst_init(); gprs_ns_vty_init(bssgp_nsi); bssgp_vty_init(); gprs_llc_vty_init(); gprs_sndcp_vty_init(); sgsn_auth_init(); sgsn_cdr_init(&sgsn_inst); /* FIXME: register signal handler for SS_L_NS */ rc = sgsn_parse_config(sgsn_inst.config_file, &sgsn_inst.cfg); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot parse config file\n"); exit(2); } rc = sgsn_gtp_init(&sgsn_inst); if (rc) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on GTP socket\n"); exit(2); } rc = gprs_subscr_init(&sgsn_inst); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot set up subscriber management\n"); exit(2); } rc = gprs_ns_nsip_listen(sgsn_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen on NSIP socket\n"); exit(2); } rc = gprs_ns_frgre_listen(sgsn_nsi); if (rc < 0) { LOGP(DGPRS, LOGL_FATAL, "Cannot bind/listen GRE " "socket. Do you have CAP_NET_RAW?\n"); exit(2); } if (sgsn->cfg.dynamic_lookup) { if (sgsn_ares_init(sgsn) != 0) { LOGP(DGPRS, LOGL_FATAL, "Failed to initialize c-ares(%d)\n", rc); exit(4); } } if (daemonize) { rc = osmo_daemonize(); if (rc < 0) { perror("Error during daemonize"); exit(1); } } while (1) { rc = osmo_select_main(0); if (rc < 0) exit(3); } /* not reached */ exit(0); }