From c5dbbc5e14a8d7ec3fbf7ef19cf1303b2fbe0166 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 9 Aug 2022 17:19:53 +0200 Subject: [PATCH] build: add --enable-pfcp, make PFCP dep optional Related: SYS#5895 Change-Id: I6d50c60bccda767910217243bdfb4a6fad1e39c1 --- configure.ac | 13 +++++++++++-- debian/rules | 1 + src/osmo-hnbgw/Makefile.am | 19 ++++++++++++++----- src/osmo-hnbgw/context_map.c | 4 ++++ src/osmo-hnbgw/hnbgw.c | 6 ++++++ src/osmo-hnbgw/hnbgw_cn.c | 8 +++++++- src/osmo-hnbgw/hnbgw_rua.c | 3 +++ src/osmo-hnbgw/hnbgw_vty.c | 10 ++++++++++ src/osmo-hnbgw/tdefs.c | 7 +++++++ 9 files changed, 63 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 0f2a7c4..6bfb080 100644 --- a/configure.ac +++ b/configure.ac @@ -61,8 +61,17 @@ PKG_CHECK_MODULES(LIBOSMORUA, libosmo-rua >= 1.3.0) PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 1.3.0) PKG_CHECK_MODULES(LIBOSMOHNBAP, libosmo-hnbap >= 1.3.0) PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.10.0) -PKG_CHECK_MODULES(LIBOSMOGTLV, libosmo-gtlv >= 0.1.0) -PKG_CHECK_MODULES(LIBOSMOPFCP, libosmo-pfcp >= 0.1.0) + +# Enable PFCP support for GTP tunnel mapping via UPF +AC_ARG_ENABLE([pfcp], [AS_HELP_STRING([--enable-pfcp], [Build with PFCP support, for GTP tunnel mapping via UPF])], + [osmo_ac_pfcp="$enableval"],[osmo_ac_pfcp="no"]) +if test "x$osmo_ac_pfcp" = "xyes" ; then + PKG_CHECK_MODULES(LIBOSMOGTLV, libosmo-gtlv >= 0.1.0) + PKG_CHECK_MODULES(LIBOSMOPFCP, libosmo-pfcp >= 0.1.0) + AC_DEFINE(ENABLE_PFCP, 1, [Define to build with PFCP support]) +fi +AM_CONDITIONAL(ENABLE_PFCP, test "x$osmo_ac_pfcp" = "xyes") +AC_SUBST(osmo_ac_pfcp) dnl checks for header files AC_HEADER_STDC diff --git a/debian/rules b/debian/rules index bce8ed6..f341a84 100755 --- a/debian/rules +++ b/debian/rules @@ -46,6 +46,7 @@ # debmake generated override targets CONFIGURE_FLAGS += --with-systemdsystemunitdir=/lib/systemd/system --enable-manuals +CONFIGURE_FLAGS += --enable-pfcp override_dh_auto_configure: dh_auto_configure -- $(CONFIGURE_FLAGS) # diff --git a/src/osmo-hnbgw/Makefile.am b/src/osmo-hnbgw/Makefile.am index 4d2403d..1d907ba 100644 --- a/src/osmo-hnbgw/Makefile.am +++ b/src/osmo-hnbgw/Makefile.am @@ -20,8 +20,6 @@ AM_CFLAGS = \ $(LIBOSMORANAP_CFLAGS) \ $(LIBOSMOHNBAP_CFLAGS) \ $(LIBOSMOMGCPCLIENT_CFLAGS) \ - $(LIBOSMOGTLV_CFLAGS) \ - $(LIBOSMOPFCP_CFLAGS) \ $(NULL) AM_LDFLAGS = \ @@ -37,14 +35,11 @@ osmo_hnbgw_SOURCES = \ hnbgw_hnbap.c \ hnbgw_rua.c \ hnbgw_ranap.c \ - hnbgw_pfcp.c \ hnbgw_vty.c \ context_map.c \ hnbgw_cn.c \ ranap_rab_ass.c \ mgw_fsm.c \ - ps_rab_ass_fsm.c \ - ps_rab_fsm.c \ tdefs.c \ $(NULL) @@ -63,6 +58,20 @@ osmo_hnbgw_LDADD = \ $(LIBOSMOMGCPCLIENT_LIBS) \ $(LIBSCTP_LIBS) \ $(LIBOSMOMGCPCLIENT_LIBS) \ + $(NULL) + +if ENABLE_PFCP +AM_CFLAGS += \ + $(LIBOSMOGTLV_CFLAGS) \ + $(LIBOSMOPFCP_CFLAGS) \ + $(NULL) +osmo_hnbgw_LDADD += \ $(LIBOSMOGTLV_LIBS) \ $(LIBOSMOPFCP_LIBS) \ $(NULL) +osmo_hnbgw_SOURCES += \ + hnbgw_pfcp.c \ + ps_rab_ass_fsm.c \ + ps_rab_fsm.c \ + $(NULL) +endif diff --git a/src/osmo-hnbgw/context_map.c b/src/osmo-hnbgw/context_map.c index 6bd4f6c..c069651 100644 --- a/src/osmo-hnbgw/context_map.c +++ b/src/osmo-hnbgw/context_map.c @@ -19,6 +19,8 @@ * */ +#include "config.h" + /* an expired mapping is destroyed after 1..2 * EXPIRY_TIMER_SECS */ #define EXPIRY_TIMER_SECS 23 @@ -166,7 +168,9 @@ void context_map_deactivate(struct hnbgw_context_map *map) OSMO_ASSERT(map->mgw_fi == NULL); } +#if ENABLE_PFCP hnbgw_gtpmap_release(map); +#endif } static struct osmo_timer_list context_map_tmr; diff --git a/src/osmo-hnbgw/hnbgw.c b/src/osmo-hnbgw/hnbgw.c index 8b72a8f..526622b 100644 --- a/src/osmo-hnbgw/hnbgw.c +++ b/src/osmo-hnbgw/hnbgw.c @@ -61,7 +61,9 @@ #include #include +#if ENABLE_PFCP #include +#endif #include #include @@ -104,7 +106,9 @@ static struct hnb_gw *hnb_gw_create(void *ctx) gw->config.mgcp_client = talloc_zero(tall_hnb_ctx, struct mgcp_client_conf); mgcp_client_conf_init(gw->config.mgcp_client); +#if ENABLE_PFCP gw->config.pfcp.remote_port = OSMO_PFCP_PORT; +#endif return gw; } @@ -718,8 +722,10 @@ int main(int argc, char **argv) return -EINVAL; } +#if ENABLE_PFCP /* If UPF is configured, set up PFCP socket and send Association Setup Request to UPF */ hnbgw_pfcp_init(g_hnb_gw); +#endif if (hnbgw_cmdline_config.daemonize) { rc = osmo_daemonize(); diff --git a/src/osmo-hnbgw/hnbgw_cn.c b/src/osmo-hnbgw/hnbgw_cn.c index 0f1ed07..893ee2a 100644 --- a/src/osmo-hnbgw/hnbgw_cn.c +++ b/src/osmo-hnbgw/hnbgw_cn.c @@ -18,6 +18,8 @@ * */ +#include "config.h" + #include #include @@ -29,7 +31,9 @@ #include #include +#if ENABLE_PFCP #include +#endif #include #include @@ -356,7 +360,6 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink, struct hnbgw_context_map *map; ranap_message *message; int rc; - struct hnb_gw *hnb_gw = cnlink->gw; /* Usually connection-oriented data is always passed transparently towards the specific HNB, via a RUA * connection identified by conn_id. An exception is made for RANAP RAB AssignmentRequest and @@ -385,7 +388,9 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink, mgw_fsm_release(map); break; } +#if ENABLE_PFCP } else { + struct hnb_gw *hnb_gw = cnlink->gw; /* Packet-Switched. Set up mapping of GTP ports via UPF */ switch (message->procedureCode) { @@ -408,6 +413,7 @@ static int handle_cn_data_ind(struct hnbgw_cnlink *cnlink, hnbgw_gtpmap_release(map); break; } +#endif } ranap_ran_rx_co_free(message); } diff --git a/src/osmo-hnbgw/hnbgw_rua.c b/src/osmo-hnbgw/hnbgw_rua.c index f3ce5d9..9234ac4 100644 --- a/src/osmo-hnbgw/hnbgw_rua.c +++ b/src/osmo-hnbgw/hnbgw_rua.c @@ -18,6 +18,7 @@ * */ +#include "config.h" #include #include @@ -285,8 +286,10 @@ int rua_to_scu(struct hnb_context *hnb, /* mgw_fsm_handle_rab_ass_resp() takes ownership of prim->oph and (ranap) message */ return mgw_fsm_handle_rab_ass_resp(map, &prim->oph, message); } +#if ENABLE_PFCP /* ps_rab_ass_fsm takes ownership of prim->oph and RANAP message */ return hnbgw_gtpmap_rx_rab_ass_resp(map, &prim->oph, message); +#endif } ranap_cn_rx_co_free(message); } diff --git a/src/osmo-hnbgw/hnbgw_vty.c b/src/osmo-hnbgw/hnbgw_vty.c index 03f6617..3f76c6f 100644 --- a/src/osmo-hnbgw/hnbgw_vty.c +++ b/src/osmo-hnbgw/hnbgw_vty.c @@ -18,6 +18,8 @@ * */ +#include "config.h" + #include #include @@ -362,6 +364,8 @@ DEFUN(cfg_hnbgw_iups_remote_addr, return CMD_SUCCESS; } +#if ENABLE_PFCP + static struct cmd_node pfcp_node = { PFCP_NODE, "%s(config-hnbgw-pfcp)# ", @@ -403,6 +407,8 @@ DEFUN(cfg_pfcp_local_port, cfg_pfcp_local_port_cmd, return CMD_SUCCESS; } +#endif /* ENABLE_PFCP */ + static int config_write_hnbgw(struct vty *vty) { vty_out(vty, "hnbgw%s", VTY_NEWLINE); @@ -466,6 +472,7 @@ static int config_write_hnbgw_mgcp(struct vty *vty) return CMD_SUCCESS; } +#if ENABLE_PFCP static int config_write_hnbgw_pfcp(struct vty *vty) { vty_out(vty, " pfcp%s", VTY_NEWLINE); @@ -476,6 +483,7 @@ static int config_write_hnbgw_pfcp(struct vty *vty) return CMD_SUCCESS; } +#endif void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx) { @@ -515,11 +523,13 @@ void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx) install_element(HNBGW_NODE, &cfg_hnbgw_mgcp_cmd); install_node(&mgcp_node, config_write_hnbgw_mgcp); +#if ENABLE_PFCP install_node(&pfcp_node, config_write_hnbgw_pfcp); install_element(HNBGW_NODE, &cfg_hnbgw_pfcp_cmd); install_element(PFCP_NODE, &cfg_pfcp_local_addr_cmd); install_element(PFCP_NODE, &cfg_pfcp_local_port_cmd); install_element(PFCP_NODE, &cfg_pfcp_remote_addr_cmd); +#endif mgcp_client_vty_init(tall_hnb_ctx, MGCP_NODE, g_hnb_gw->config.mgcp_client); osmo_tdef_vty_groups_init(HNBGW_NODE, hnbgw_tdef_group); diff --git a/src/osmo-hnbgw/tdefs.c b/src/osmo-hnbgw/tdefs.c index 5113dd3..d798345 100644 --- a/src/osmo-hnbgw/tdefs.c +++ b/src/osmo-hnbgw/tdefs.c @@ -14,8 +14,13 @@ * GNU General Public License for more details. */ +#include "config.h" + #include + +#if ENABLE_PFCP #include +#endif struct osmo_tdef mgw_fsm_T_defs[] = { {.T = -1001, .default_val = 5, .desc = "Timeout for HNB side call-leg (to-HNB) creation" }, @@ -34,6 +39,8 @@ struct osmo_tdef ps_T_defs[] = { struct osmo_tdef_group hnbgw_tdef_group[] = { {.name = "mgw", .tdefs = mgw_fsm_T_defs, .desc = "MGW (Media Gateway) interface" }, {.name = "ps", .tdefs = ps_T_defs, .desc = "timers for Packet Switched domain" }, +#if ENABLE_PFCP {.name = "pfcp", .tdefs = osmo_pfcp_tdefs, .desc = "PFCP timers" }, +#endif { } };