From patchwork Thu Oct 15 22:13:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neels Hofmeyr X-Patchwork-Id: 530943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (tmp.osmocom.org [144.76.43.76]) by ozlabs.org (Postfix) with ESMTP id C13F414029E for ; Fri, 16 Oct 2015 09:14:21 +1100 (AEDT) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 525DC896D; Thu, 15 Oct 2015 22:14:18 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from mail.sysmocom.de (mail.sysmocom.de [IPv6:2a01:4f8:191:444c::2:4]) by lists.osmocom.org (Postfix) with ESMTP id E462C8900 for ; Thu, 15 Oct 2015 22:14:16 +0000 (UTC) Received: from localhost.localdomain (unknown [37.120.3.39]) by mail.sysmocom.de (Postfix) with ESMTPSA id 358861BEEB2 for ; Thu, 15 Oct 2015 22:14:16 +0000 (UTC) From: Neels Hofmeyr To: openbsc@lists.osmocom.org Subject: [PATCH 03/15] gtphub: add skeletal gtphub.[hc] Date: Fri, 16 Oct 2015 00:13:47 +0200 Message-Id: <1444947239-17582-4-git-send-email-nhofmeyr@sysmocom.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444947239-17582-1-git-send-email-nhofmeyr@sysmocom.de> References: <1444947239-17582-1-git-send-email-nhofmeyr@sysmocom.de> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Sponsored-by: On-Waves ehf 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..7c89db1 --- /dev/null +++ b/openbsc/include/openbsc/gtphub.h @@ -0,0 +1,96 @@ +/* GTP Hub Implementation */ + +/* (C) 2015 by sysmocom s.f.m.c. GmbH + * 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 . + */ + +#pragma once + +#include +#include + +#include + + +/* 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_sgsns[GTPH_PORT_N]; + struct gtphub_cfg_bind to_ggsns[GTPH_PORT_N]; +}; + + +/* state */ + +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_sgsns[GTPH_PORT_N]; + struct gtphub_bind to_ggsns[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 66d0625..f2f914d 100644 --- a/openbsc/src/gprs/Makefile.am +++ b/openbsc/src/gprs/Makefile.am @@ -34,5 +34,5 @@ osmo_sgsn_LDADD = \ -lgtp $(OSMO_LIBS) $(LIBOSMOABIS_LIBS) $(LIBCARES_LIBS) \ $(LIBCRYPTO_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 + * 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 . + */ + +#include + +#include +#include + +#include +#include + +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; +} +