build: add --enable-pfcp, make PFCP dep optional

Related: SYS#5895
Change-Id: I6d50c60bccda767910217243bdfb4a6fad1e39c1
This commit is contained in:
Neels Hofmeyr 2022-08-09 17:19:53 +02:00
parent 44f5a336a8
commit e6201765cf
8 changed files with 62 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -61,7 +61,9 @@
#include <osmocom/sigtran/protocol/m3ua.h>
#include <osmocom/sigtran/sccp_sap.h>
#if ENABLE_PFCP
#include <osmocom/pfcp/pfcp_proto.h>
#endif
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/hnbgw/hnbgw_hnbap.h>
@ -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();

View File

@ -18,6 +18,8 @@
*
*/
#include "config.h"
#include <arpa/inet.h>
#include <errno.h>
@ -29,7 +31,9 @@
#include <osmocom/sigtran/sccp_sap.h>
#include <osmocom/sigtran/sccp_helpers.h>
#if ENABLE_PFCP
#include <osmocom/pfcp/pfcp_cp_peer.h>
#endif
#include <osmocom/hnbgw/hnbgw.h>
#include <osmocom/hnbgw/hnbgw_rua.h>
@ -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);
}

View File

@ -18,6 +18,7 @@
*
*/
#include "config.h"
#include <osmocom/core/msgb.h>
#include <osmocom/core/utils.h>
@ -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);
}

View File

@ -18,6 +18,8 @@
*
*/
#include "config.h"
#include <string.h>
#include <osmocom/core/socket.h>
@ -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);

View File

@ -14,8 +14,13 @@
* GNU General Public License for more details.
*/
#include "config.h"
#include <osmocom/hnbgw/tdefs.h>
#if ENABLE_PFCP
#include <osmocom/pfcp/pfcp_endpoint.h>
#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
{ }
};