This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/6681 host/trxcon: introduce a new 'trxcon' application This app is similar to the osmocon, but designed to connect L2 & L3 apps with SDR transceiver insted of obsolete Calypso based hardware. Change-Id: Ie3c17f19aad9c26f3c49966a7c96b65911f62369 --- M src/Makefile A src/host/trxcon/.gitignore A src/host/trxcon/Makefile.am A src/host/trxcon/configure.ac A src/host/trxcon/logging.c A src/host/trxcon/logging.h A src/host/trxcon/trxcon.c 7 files changed, 350 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/81/6681/1 diff --git a/src/Makefile b/src/Makefile index f5e2128..dedc40e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -12,8 +12,7 @@ TOPDIR=$(shell pwd) all: libosmocore-target nofirmware firmware mtk-firmware - -nofirmware: layer23 osmocon gsmmap virtphy +nofirmware: layer23 osmocon trxcon gsmmap virtphy libosmocore-target: shared/libosmocore/build-target/src/.libs/libosmocore.a @@ -58,6 +57,19 @@ host/virt_phy/virtphy: host/virt_phy/Makefile make -C host/virt_phy +.PHONY: trxcon +trxcon: host/trxcon/trxcon + +host/trxcon/configure: host/trxcon/configure.ac + cd host/trxcon && autoreconf -i + +host/trxcon/Makefile: host/trxcon/configure + cd host/trxcon && ./configure $(HOST_CONFARGS) + +host/trxcon/trxcon: host/trxcon/Makefile + make -C host/trxcon + + .PHONY: gsmmap gsmmap: host/gsmmap/gsmmap @@ -99,6 +111,7 @@ make -C host/osmocon $@ make -C host/gsmmap $@ make -C host/virt_phy $@ + make -C host/trxcon $@ make -C target/firmware $@ make -C target/firmware -f Makefile.mtk $@ @@ -108,5 +121,6 @@ make -C host/osmocon $@ make -C host/gsmmap $@ make -C host/virt_phy $@ + make -C host/trxcon $@ # 'firmware' also handles 'mtk-firmware' make -C target/firmware $@ diff --git a/src/host/trxcon/.gitignore b/src/host/trxcon/.gitignore new file mode 100644 index 0000000..d6b28ee --- /dev/null +++ b/src/host/trxcon/.gitignore @@ -0,0 +1,26 @@ +# autoreconf by-products +*.in + +aclocal.m4 +autom4te.cache/ +configure +depcomp +install-sh +missing +compile + +# configure by-products +.deps/ +Makefile + +config.status +version.h + +# build by-products +*.o + +trxcon + +# various +.version +.tarball-version diff --git a/src/host/trxcon/Makefile.am b/src/host/trxcon/Makefile.am new file mode 100644 index 0000000..00869d9 --- /dev/null +++ b/src/host/trxcon/Makefile.am @@ -0,0 +1,29 @@ +AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 + +# versioning magic +BUILT_SOURCES = $(top_srcdir)/.version +$(top_srcdir)/.version: + echo $(VERSION) > $@-t && mv $@-t $@ +dist-hook: + echo $(VERSION) > $(distdir)/.tarball-version + +AM_CPPFLAGS = \ + $(all_includes) \ + -I$(top_srcdir)/include \ + $(NULL) + +AM_CFLAGS = \ + -Wall \ + $(LIBOSMOCORE_CFLAGS) \ + $(NULL) + +bin_PROGRAMS = trxcon + +trxcon_SOURCES = \ + logging.c \ + trxcon.c \ + $(NULL) + +trxcon_LDADD = \ + $(LIBOSMOCORE_LIBS) \ + $(NULL) diff --git a/src/host/trxcon/configure.ac b/src/host/trxcon/configure.ac new file mode 100644 index 0000000..c411d04 --- /dev/null +++ b/src/host/trxcon/configure.ac @@ -0,0 +1,23 @@ +dnl Process this file with autoconf to produce a configure script +AC_INIT([trxcon], [0.0.0]) +AM_INIT_AUTOMAKE + +dnl kernel style compile messages +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +dnl checks for programs +AC_PROG_MAKE_SET +AC_PROG_CC +AC_PROG_INSTALL + +dnl checks for libraries +PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore) +PKG_CHECK_MODULES(LIBOSMOCODING, libosmocoding) + +dnl checks for header files +AC_HEADER_STDC + +dnl Checks for typedefs, structures and compiler characteristics + +AC_OUTPUT( + Makefile) diff --git a/src/host/trxcon/logging.c b/src/host/trxcon/logging.c new file mode 100644 index 0000000..136cc76 --- /dev/null +++ b/src/host/trxcon/logging.c @@ -0,0 +1,52 @@ +/* + * OsmocomBB <-> SDR connection bridge + * + * (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <osmocom/core/application.h> +#include <osmocom/core/logging.h> +#include <osmocom/core/utils.h> + +#include "logging.h" + +static struct log_info_cat trx_log_info_cat[] = { + [DAPP] = { + .name = "DAPP", + .description = "Application", + .color = "\033[1;35m", + .enabled = 1, .loglevel = LOGL_NOTICE, + }, +}; + +static const struct log_info trx_log_info = { + .cat = trx_log_info_cat, + .num_cat = ARRAY_SIZE(trx_log_info_cat), +}; + +int trx_log_init(const char *category_mask) +{ + osmo_init_logging(&trx_log_info); + + if (category_mask) + log_parse_category_mask(osmo_stderr_target, category_mask); + + return 0; +} diff --git a/src/host/trxcon/logging.h b/src/host/trxcon/logging.h new file mode 100644 index 0000000..4149e4f --- /dev/null +++ b/src/host/trxcon/logging.h @@ -0,0 +1,11 @@ +#pragma once + +#include <osmocom/core/logging.h> + +#define DEBUG_DEFAULT "DAPP" + +enum { + DAPP +}; + +int trx_log_init(const char *category_mask); diff --git a/src/host/trxcon/trxcon.c b/src/host/trxcon/trxcon.c new file mode 100644 index 0000000..03664ca --- /dev/null +++ b/src/host/trxcon/trxcon.c @@ -0,0 +1,193 @@ +/* + * OsmocomBB <-> SDR connection bridge + * + * (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <stdint.h> +#include <string.h> +#include <getopt.h> +#include <unistd.h> +#include <signal.h> + +#include <osmocom/core/msgb.h> +#include <osmocom/core/talloc.h> +#include <osmocom/core/signal.h> +#include <osmocom/core/select.h> +#include <osmocom/core/application.h> + +#include "logging.h" + +#define COPYRIGHT \ + "Copyright (C) 2016-2017 by Vadim Yanitskiy <axilirator at gmail.com>\n" \ + "License GPLv2+: GNU GPL version 2 or later " \ + "<http://gnu.org/licenses/gpl.html>\n" \ + "This is free software: you are free to change and redistribute it.\n" \ + "There is NO WARRANTY, to the extent permitted by law.\n\n" + +static struct { + const char *debug_mask; + int daemonize; + int quit; + + const char *trx_ip; + uint16_t trx_base_port; + const char *bind_socket; +} app_data; + +void *tall_trx_ctx = NULL; + +static void print_usage(const char *app) +{ + printf("Usage: %s\n", app); +} + +static void print_help(void) +{ + printf(" Some help...\n"); + printf(" -h --help this text\n"); + printf(" -d --debug Change debug flags. Default: %s\n", DEBUG_DEFAULT); + printf(" -i --trx-ip IP address of host runing TRX (default 127.0.0.1)\n"); + printf(" -p --trx-port Base port of TRX instance (default 5700)\n"); + printf(" -s --socket Listening socket for layer23 (default /tmp/osmocom_l2)\n"); + printf(" -D --daemonize Run as daemon\n"); +} + +static void handle_options(int argc, char **argv) +{ + while (1) { + int option_index = 0, c; + static struct option long_options[] = { + {"help", 0, 0, 'h'}, + {"debug", 1, 0, 'd'}, + {"socket", 1, 0, 's'}, + {"trx-ip", 1, 0, 'i'}, + {"trx-port", 1, 0, 'p'}, + {"daemonize", 0, 0, 'D'}, + {0, 0, 0, 0} + }; + + c = getopt_long(argc, argv, "d:i:p:s:Dh", + long_options, &option_index); + if (c == -1) + break; + + switch (c) { + case 'h': + print_usage(argv[0]); + print_help(); + exit(0); + break; + case 'd': + app_data.debug_mask = optarg; + break; + case 'i': + app_data.trx_ip = optarg; + break; + case 'p': + app_data.trx_base_port = atoi(optarg); + break; + case 's': + app_data.bind_socket = optarg; + break; + case 'D': + app_data.daemonize = 1; + break; + default: + break; + } + } +} + +static void init_defaults(void) +{ + app_data.bind_socket = "/tmp/osmocom_l2"; + app_data.trx_ip = "127.0.0.1"; + app_data.trx_base_port = 5700; + + app_data.debug_mask = NULL; + app_data.daemonize = 0; + app_data.quit = 0; +} + +static void signal_handler(int signal) +{ + fprintf(stderr, "signal %u received\n", signal); + + switch (signal) { + case SIGINT: + app_data.quit++; + break; + case SIGABRT: + case SIGUSR1: + case SIGUSR2: + talloc_report_full(tall_trx_ctx, stderr); + break; + default: + break; + } +} + +int main(int argc, char **argv) +{ + int rc = 0; + + printf("%s", COPYRIGHT); + init_defaults(); + handle_options(argc, argv); + + /* Init talloc memory management system */ + tall_trx_ctx = talloc_init("trxcon context"); + msgb_talloc_ctx_init(tall_trx_ctx, 0); + + /* Setup signal handlers */ + signal(SIGINT, &signal_handler); + signal(SIGUSR1, &signal_handler); + signal(SIGUSR2, &signal_handler); + osmo_init_ignore_signals(); + + /* Init logging system */ + trx_log_init(app_data.debug_mask); + + /* Currently nothing to do */ + print_usage(argv[0]); + print_help(); + goto exit; + + if (app_data.daemonize) { + rc = osmo_daemonize(); + if (rc < 0) { + perror("Error during daemonize"); + goto exit; + } + } + + while (!app_data.quit) + osmo_select_main(0); + +exit: + /* Make Valgrind happy */ + log_fini(); + talloc_free(tall_trx_ctx); + + return rc; +} -- To view, visit https://gerrit.osmocom.org/6681 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie3c17f19aad9c26f3c49966a7c96b65911f62369 Gerrit-PatchSet: 1 Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Owner: Harald Welte <laforge at gnumonks.org>