int bts_model_init(struct gsm_bts *bts) { struct gsm_bts_role_bts *btsb; struct stat st; static struct osmo_fd accept_fd, read_fd; int rc; btsb = bts_role_bts(bts); btsb->support.ciphers = CIPHER_A5(1) | CIPHER_A5(2) | CIPHER_A5(3); rc = oml_router_init(bts, OML_ROUTER_PATH, &accept_fd, &read_fd); if (rc < 0) { fprintf(stderr, "Error creating the OML router: %s rc=%d\n", OML_ROUTER_PATH, rc); exit(1); } if (stat(SYSMOBTS_RF_LOCK_PATH, &st) == 0) { LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n"); exit(23); } bts_model_vty_init(bts); return 0; }
int main(int argc, char **argv) { tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); msgb_talloc_ctx_init(tall_bts_ctx, 0); bts_log_init(NULL); bts = gsm_bts_alloc(tall_bts_ctx); if (bts_init(bts) < 0) { fprintf(stderr, "unable to open bts\n"); exit(1); } btsb = bts_role_bts(bts); test_cipher_parsing(); printf("Success\n"); return 0; }
int main(int argc, char **argv) { void *tall_msgb_ctx; tall_bts_ctx = talloc_named_const(NULL, 1, "OsmoBTS context"); tall_msgb_ctx = talloc_named_const(tall_bts_ctx, 1, "msgb"); msgb_set_talloc_ctx(tall_msgb_ctx); bts_log_init(NULL); bts = gsm_bts_alloc(tall_bts_ctx); if (bts_init(bts) < 0) { fprintf(stderr, "unable to open bts\n"); exit(1); } btsb = bts_role_bts(bts); test_agch_queue_length_computation(); test_agch_queue(); printf("Success\n"); return 0; }
/* Apply the rules from 05.02 6.3.1.3 Mapping of BCCH Data */ uint8_t *bts_sysinfo_get(struct gsm_bts *bts, struct gsm_time *g_time) { struct gsm_bts_role_bts *btsb = bts_role_bts(bts); unsigned int tc4_cnt = 0; unsigned int tc4_sub[4]; /* System information type 2 bis or 2 ter messages are sent if * needed, as determined by the system operator. If only one of * them is needed, it is sent when TC = 5. If both are needed, * 2bis is sent when TC = 5 and 2ter is sent at least once * within any of 4 consecutive occurrences of TC = 4. */ /* System information type 2 quater is sent if needed, as * determined by the system operator. If sent on BCCH Norm, it * shall be sent when TC = 5 if neither of 2bis and 2ter are * used, otherwise it shall be sent at least once within any of * 4 consecutive occurrences of TC = 4. If sent on BCCH Ext, it * is sent at least once within any of 4 consecutive occurrences * of TC = 5. */ /* System Information type 9 is sent in those blocks with * TC = 4 which are specified in system information type 3 as * defined in 3GPP TS 04.08. */ /* System Information Type 13 need only be sent if GPRS support * is indicated in one or more of System Information Type 3 or 4 * or 7 or 8 messages. These messages also indicate if the * message is sent on the BCCH Norm or if the message is * transmitted on the BCCH Ext. In the case that the message is * sent on the BCCH Norm, it is sent at least once within any of * 4 consecutive occurrences of TC = 4. */ /* We only implement BCCH Norm at this time */ switch (g_time->tc) { case 0: /* System Information Type 1 need only be sent if * frequency hopping is in use or when the NCH is * present in a cell. If the MS finds another message * when TC = 0, it can assume that System Information * Type 1 is not in use. */ return GSM_BTS_SI(bts, SYSINFO_TYPE_1); case 1: /* A SI 2 message will be sent at least every time TC = 1. */ return GSM_BTS_SI(bts, SYSINFO_TYPE_2); case 2: return GSM_BTS_SI(bts, SYSINFO_TYPE_3); case 3: return GSM_BTS_SI(bts, SYSINFO_TYPE_4); case 4: /* iterate over 2ter, 2quater, 9, 13 */ /* determine how many SI we need to send on TC=4, * and which of them we send when */ if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter) && BTS_HAS_SI(bts, SYSINFO_TYPE_2bis)) { tc4_sub[tc4_cnt] = SYSINFO_TYPE_2ter; tc4_cnt += 1; } if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) || BTS_HAS_SI(bts, SYSINFO_TYPE_2ter))) { tc4_sub[tc4_cnt] = SYSINFO_TYPE_2quater; tc4_cnt += 1; } if (BTS_HAS_SI(bts, SYSINFO_TYPE_13)) { tc4_sub[tc4_cnt] = SYSINFO_TYPE_13; tc4_cnt += 1; } if (BTS_HAS_SI(bts, SYSINFO_TYPE_9)) { /* FIXME: check SI3 scheduling info! */ tc4_sub[tc4_cnt] = SYSINFO_TYPE_9; tc4_cnt += 1; } /* simply send SI2 if we have nothing else to send */ if (tc4_cnt == 0) return GSM_BTS_SI(bts, SYSINFO_TYPE_2); else { /* increment static counter by one, modulo count */ btsb->si.tc4_ctr = (btsb->si.tc4_ctr + 1) % tc4_cnt; return GSM_BTS_SI(bts, tc4_sub[btsb->si.tc4_ctr]); } case 5: /* 2bis, 2ter, 2quater */ if (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && !BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) return GSM_BTS_SI(bts, SYSINFO_TYPE_2bis); else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2ter) && !BTS_HAS_SI(bts, SYSINFO_TYPE_2bis)) return GSM_BTS_SI(bts, SYSINFO_TYPE_2ter); else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) return GSM_BTS_SI(bts, SYSINFO_TYPE_2bis); else if (BTS_HAS_SI(bts, SYSINFO_TYPE_2quater) && !BTS_HAS_SI(bts, SYSINFO_TYPE_2bis) && !BTS_HAS_SI(bts, SYSINFO_TYPE_2ter)) return GSM_BTS_SI(bts, SYSINFO_TYPE_2quater); break; case 6: return GSM_BTS_SI(bts, SYSINFO_TYPE_3); case 7: return GSM_BTS_SI(bts, SYSINFO_TYPE_4); } return NULL; }
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; }
#define SHOW_TRX_STR \ SHOW_STR \ TRX_STR #define DSP_TRACE_F_STR "DSP Trace Flag\n" static struct gsm_bts *vty_bts; /* configuration */ DEFUN(cfg_bts_auto_band, cfg_bts_auto_band_cmd, "auto-band", "Automatically select band for ARFCN based on configured band\n") { struct gsm_bts *bts = vty->index; struct gsm_bts_role_bts *btsb = bts_role_bts(bts); btsb->auto_band = 1; return CMD_SUCCESS; } DEFUN(cfg_bts_no_auto_band, cfg_bts_no_auto_band_cmd, "no auto-band", NO_STR "Automatically select band for ARFCN based on configured band\n") { struct gsm_bts *bts = vty->index; struct gsm_bts_role_bts *btsb = bts_role_bts(bts); btsb->auto_band = 0; return CMD_SUCCESS; }