示例#1
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);
}
示例#2
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;
}
示例#3
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;
}
示例#4
0
文件: main.c 项目: jemmy655/osmo
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(&param, 0, sizeof(param));
		param.sched_priority = rt_prio;
		rc = sched_setscheduler(getpid(), SCHED_RR, &param);
		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;
}
示例#5
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);
}