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/OpenBSC@lists.osmocom.org/.
Neels Hofmeyr nhofmeyr at sysmocom.deSponsored-by: On-Waves ehf --- openbsc/include/openbsc/Makefile.am | 3 +- openbsc/include/openbsc/gtphub.h | 98 +++++++++++++++++++++++++++++++++++++ openbsc/src/gprs/Makefile.am | 2 +- openbsc/src/gprs/gtphub.c | 45 +++++++++++++++++ 4 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 openbsc/include/openbsc/gtphub.h create mode 100644 openbsc/src/gprs/gtphub.c diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index 254f43d..c5dd6af 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -16,7 +16,8 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ arfcn_range_encode.h nat_rewrite_trie.h bsc_nat_callstats.h \ osmux.h mgcp_transcode.h gprs_utils.h \ gprs_gb_parse.h smpp.h meas_feed.h gprs_gsup_messages.h \ - gprs_gsup_client.h bsc_msg_filter.h + gprs_gsup_client.h bsc_msg_filter.h \ + gtphub.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/gtphub.h b/openbsc/include/openbsc/gtphub.h new file mode 100644 index 0000000..cd4c215 --- /dev/null +++ b/openbsc/include/openbsc/gtphub.h @@ -0,0 +1,98 @@ +/* GTP Hub Implementation */ + +/* (C) 2015 by sysmocom s.f.m.c. GmbH <info at sysmocom.de> + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include <stdint.h> +#include <sys/socket.h> + +#include <osmocom/core/select.h> + + +/* general */ + +enum gtphub_port_idx { + GTPH_PORT_CONTROL = 0, + GTPH_PORT_USER = 1, + GTPH_PORT_N +}; + +extern const char* const gtphub_port_idx_names[GTPH_PORT_N]; + + +/* config */ + +struct gtphub_cfg_addr { + const char *addr_str; + uint16_t port; +}; + +struct gtphub_cfg_bind { + struct gtphub_cfg_addr bind; +}; + +struct gtphub_cfg { + struct gtphub_cfg_bind to_clients[GTPH_PORT_N]; + struct gtphub_cfg_bind to_servers[GTPH_PORT_N]; +}; + + +/* state */ + +struct gtphub; + +struct gtphub_addr { + struct sockaddr_storage a; + socklen_t l; +}; + +struct gtphub_peer { + struct llist_head entry; + + struct gtphub_addr addr; +}; + +struct gtphub_bind { + struct osmo_fd ofd; + + /* list of struct gtphub_peer */ + struct llist_head peers; +}; + +struct gtphub { + struct gtphub_bind to_clients[GTPH_PORT_N]; + struct gtphub_bind to_servers[GTPH_PORT_N]; +}; + + +/* api */ + +void gtphub_zero(struct gtphub *hub); +int gtphub_init(struct gtphub *hub, struct gtphub_cfg *cfg); + +/* Create a new gtphub_peer instance added to peers_list. + * Initialize to all-zero. Return a pointer to the new instance, or NULL on + * error. */ +struct gtphub_peer *gtphub_peer_new(struct gtphub_bind *bind); + +/* Remove a gtphub_peer from its list and free it. */ +void gtphub_peer_del(struct gtphub_peer *peer); + diff --git a/openbsc/src/gprs/Makefile.am b/openbsc/src/gprs/Makefile.am index 753a073..9053766 100644 --- a/openbsc/src/gprs/Makefile.am +++ b/openbsc/src/gprs/Makefile.am @@ -33,5 +33,5 @@ osmo_sgsn_LDADD = \ $(top_builddir)/src/libcommon/libcommon.a \ -lgtp $(OSMO_LIBS) $(LIBOSMOABIS_LIBS) $(LIBCARES_LIBS) -lrt -osmo_gtphub_SOURCES = gtphub_main.c +osmo_gtphub_SOURCES = gtphub_main.c gtphub.c osmo_gtphub_LDADD = $(LIBOSMOCORE_LIBS) -lrt diff --git a/openbsc/src/gprs/gtphub.c b/openbsc/src/gprs/gtphub.c new file mode 100644 index 0000000..ffe0d4a --- /dev/null +++ b/openbsc/src/gprs/gtphub.c @@ -0,0 +1,45 @@ +/* GTP Hub Implementation */ + +/* (C) 2015 by sysmocom s.f.m.c. GmbH <info at sysmocom.de> + * All Rights Reserved + * + * Author: Neels Hofmeyr + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <string.h> + +#include <openbsc/gtphub.h> +#include <openbsc/debug.h> + +#include <osmocom/core/utils.h> +#include <osmocom/core/logging.h> + +void *osmo_gtphub_ctx; + +#define LOGERR(fmt, args...) \ + LOGP(DGTPHUB, LOGL_ERROR, fmt, ##args) + +void gtphub_zero(struct gtphub *hub) +{ + memset(hub, '\0', sizeof(*hub)); +} + +int gtphub_init(struct gtphub *hub, struct gtphub_cfg *cfg) +{ + LOGERR("%s not implemented\n", __func__); + return -1; +} + -- 2.1.4