From 5839197f8ea821b79b0e3bb2939f55feddb8ceaa Mon Sep 17 00:00:00 2001 From: David Waring Date: Wed, 24 Jun 2026 11:07:12 +0100 Subject: [PATCH 1/4] Update to openapi-generator v7.23.0 to fix Read-Only/Write-Only bug --- src/mbsf/AssociatedSessId.cc | 18 +++---- src/mbsf/DistributionSessionInfo.cc | 12 +---- src/mbsf/Nmb2Build.cc | 22 ++++---- src/mbsf/Nmb2Handler.cc | 2 - src/mbsf/UniqueMBSSessionId.cc | 44 +++------------ src/mbsf/UserDataIngSession.cc | 23 +++----- src/mbsf/UserServiceAnnBundle.cc | 4 +- src/mbsf/generator-mbsf | 2 +- .../model-header.mustache | 53 +++++++++++++++++++ .../model-source.mustache | 46 ++++++++++++++++ subprojects/rt-common-shared | 2 +- 11 files changed, 137 insertions(+), 91 deletions(-) create mode 100644 src/mbsf/openapi-generator-templates/model-header.mustache create mode 100644 src/mbsf/openapi-generator-templates/model-source.mustache diff --git a/src/mbsf/AssociatedSessId.cc b/src/mbsf/AssociatedSessId.cc index e7e9c26..c99d3c0 100644 --- a/src/mbsf/AssociatedSessId.cc +++ b/src/mbsf/AssociatedSessId.cc @@ -111,13 +111,13 @@ mb_smf_sc_associated_session_id_t *AssociatedSessId::populateAssociatedSessionId void AssociatedSessId::populateSsm(mb_smf_sc_associated_session_id_t *session_id) { - std::shared_ptr< IpAddr > src_ip_addr = getSourceIpAddr(); - std::optional src_ipv4_addr = src_ip_addr->getIpv4Addr(); - std::optional > src_ipv6_addr = src_ip_addr->getIpv6Addr(); + std::shared_ptr src_ip_addr = getSourceIpAddr(); + std::optional src_ipv4_addr = src_ip_addr->getIpv4Addr(); + std::optional src_ipv6_addr = src_ip_addr->getIpv6Addr(); - std::shared_ptr< IpAddr > dest_ip_addr = getDestIpAddr(); - std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); - std::optional > dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); + std::shared_ptr dest_ip_addr = getDestIpAddr(); + std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); + std::optional dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); if (!src_ip_addr && !dest_ip_addr) { return; @@ -168,10 +168,10 @@ void AssociatedSessId::populateSsm(mb_smf_sc_associated_session_id_t *session_id struct addrinfo *ai_src = NULL, *ai_dest = NULL; void *src_addr = NULL, *dest_addr = NULL; - std::shared_ptr< std::string > src_ipv6 = src_ipv6_addr.value(); - std::shared_ptr< std::string > dest_ipv6 = dest_ipv6_addr.value(); + std::string src_ipv6 = src_ipv6_addr.value(); + std::string dest_ipv6 = dest_ipv6_addr.value(); - if (resolve_src_dest_addr(*src_ipv6, *dest_ipv6, &ai_src, &ai_dest)) + if (resolve_src_dest_addr(src_ipv6, dest_ipv6, &ai_src, &ai_dest)) { if (get_src_dest_of_same_addr_family(AF_INET6, ai_src, ai_dest, &src_addr, &dest_addr)) { diff --git a/src/mbsf/DistributionSessionInfo.cc b/src/mbsf/DistributionSessionInfo.cc index 8060e13..15fca15 100644 --- a/src/mbsf/DistributionSessionInfo.cc +++ b/src/mbsf/DistributionSessionInfo.cc @@ -57,7 +57,6 @@ #include "openapi/model/Event.h" #include "openapi/model/FECConfig.h" #include "openapi/model/IpAddr.h" -#include "openapi/model/Ipv6Addr.h" #include "openapi/model/MBSDistributionSessionInfo.h" #include "openapi/model/MbsServiceArea.h" #include "openapi/model/MbsServiceInfo.h" @@ -84,7 +83,6 @@ using reftools::mbsf::Event; using reftools::mbsf::ExternalMbsServiceArea; using reftools::mbsf::FECConfig; using reftools::mbsf::IpAddr; -using reftools::mbsf::Ipv6Addr; using reftools::mbsf::ObjectDistrMethInfo; using reftools::mbsf::ObjDistributionOperatingMode; using reftools::mbsf::MBSDistributionSessionInfo; @@ -697,14 +695,8 @@ const std::shared_ptr DistributionSessionInfo::populateSsm( src_ip_addr->setIpv4Addr(ssm_source_address); dst_ip_addr->setIpv4Addr(ssm_destination_address); } else if (src_info->ai_family == AF_INET6) { - std::shared_ptr src_ipv6_addr = nullptr; - std::shared_ptr dst_ipv6_addr = nullptr; - src_ipv6_addr.reset(new Ipv6Addr(ssm_source_address)); - dst_ipv6_addr.reset(new Ipv6Addr(ssm_destination_address)); - - src_ip_addr->setIpv6Addr(src_ipv6_addr); - dst_ip_addr->setIpv6Addr(dst_ipv6_addr); - + src_ip_addr->setIpv6Addr(ssm_source_address); + dst_ip_addr->setIpv6Addr(ssm_destination_address); } } diff --git a/src/mbsf/Nmb2Build.cc b/src/mbsf/Nmb2Build.cc index 839bc62..1c955ec 100644 --- a/src/mbsf/Nmb2Build.cc +++ b/src/mbsf/Nmb2Build.cc @@ -67,7 +67,6 @@ #include "openapi/model/DistSessionState.h" #include "openapi/model/DistSessionSubscription.h" #include "openapi/model/IpAddr.h" -#include "openapi/model/Ipv6Addr.h" #include "openapi/model/TunnelAddress.h" #include "openapi/model/MBSUserDataIngSession.h" #include "openapi/model/MBSDistributionSessionInfo.h" @@ -107,7 +106,6 @@ using reftools::mbsf::ObjDistributionOperatingMode; using reftools::mbsf::ObjAcquisitionMethod; using reftools::mbsf::ObjDistributionData; using reftools::mbsf::UpTrafficFlowInfo; -using reftools::mbsf::Ipv6Addr; using reftools::mbsf::PktDistributionData; using reftools::mbsf::PktDistributionOperatingMode; using reftools::mbsf::PacketDistrMethInfo; @@ -323,19 +321,17 @@ std::shared_ptr < TunnelAddress > populate_mbstf_mb_upf_tunnel_addr(ogs_sockaddr for (sa = tunnel_addr; sa; sa = sa->next) { if (sa->ogs_sa_family == AF_INET) { - OGS_ADDR(sa, buf); - std::string ipv4_addr = std::string(buf, strnlen(buf, sizeof(buf))); - tun_addr->setIpv4Addr(ipv4_addr); - ogs_info(" UDP Tunnel = %s:%u", buf, OGS_PORT(sa)); - ogs_info("Received IPv4 tunnel address"); + OGS_ADDR(sa, buf); + std::string ipv4_addr = std::string(buf, strnlen(buf, sizeof(buf))); + tun_addr->setIpv4Addr(ipv4_addr); + ogs_debug(" UDP Tunnel = %s:%u", buf, OGS_PORT(sa)); + ogs_debug("Received IPv4 tunnel address"); } else if (sa->ogs_sa_family == AF_INET6) { - std::shared_ptr < Ipv6Addr > ipv6_addr; - OGS_ADDR(sa, buf); - - ipv6_addr.reset(new Ipv6Addr(buf, std::string::size_type(strnlen(buf, sizeof(buf))))); - - tun_addr->setIpv6Addr(std::make_optional(ipv6_addr)); + std::string ipv6_addr = std::string(buf, strnlen(buf, sizeof(buf))); + tun_addr->setIpv6Addr(ipv6_addr); + ogs_debug(" UDP Tunnel = [%s]:%u", buf, OGS_PORT(sa)); + ogs_debug("Received IPv6 tunnel address"); } tun_addr->setPortNumber(OGS_PORT(sa)); } diff --git a/src/mbsf/Nmb2Handler.cc b/src/mbsf/Nmb2Handler.cc index 7cb73e0..5cac683 100644 --- a/src/mbsf/Nmb2Handler.cc +++ b/src/mbsf/Nmb2Handler.cc @@ -40,7 +40,6 @@ #include "openapi/model/DistSession.h" #include "openapi/model/DistSessionState.h" #include "openapi/model/IpAddr.h" -#include "openapi/model/Ipv6Addr.h" #include "openapi/model/TunnelAddress.h" #include "openapi/model/MBSUserDataIngSession.h" #include "openapi/model/MBSDistributionSessionInfo.h" @@ -70,7 +69,6 @@ using reftools::mbsf::IpAddr; using reftools::mbsf::ObjDistributionOperatingMode; using reftools::mbsf::ObjAcquisitionMethod; using reftools::mbsf::UpTrafficFlowInfo; -using reftools::mbsf::Ipv6Addr; MBSF_NAMESPACE_START diff --git a/src/mbsf/UniqueMBSSessionId.cc b/src/mbsf/UniqueMBSSessionId.cc index a8e30d7..d928546 100644 --- a/src/mbsf/UniqueMBSSessionId.cc +++ b/src/mbsf/UniqueMBSSessionId.cc @@ -30,8 +30,6 @@ #include "openapi/model/ExternalMbsServiceArea.h" #include "openapi/model/GeographicArea.h" #include "openapi/model/IpAddr.h" -#include "openapi/model/Ipv6Addr.h" -#include "openapi/model/Ipv6Prefix.h" #include "openapi/model/MbsServiceArea.h" #include "openapi/model/MbsSessionId.h" #include "openapi/model/Ncgi.h" @@ -48,8 +46,6 @@ using reftools::mbsf::CivicAddress; using reftools::mbsf::ExternalMbsServiceArea; using reftools::mbsf::GeographicArea; using reftools::mbsf::IpAddr; -using reftools::mbsf::Ipv6Addr; -using reftools::mbsf::Ipv6Prefix; using reftools::mbsf::MbsServiceArea; using reftools::mbsf::MbsSessionId; using reftools::mbsf::Ncgi; @@ -65,16 +61,6 @@ struct hash { std::size_t operator()(const IpAddr &ip_addr) const; }; -template <> -struct hash { - std::size_t operator()(const Ipv6Addr &ip_addr) const; -}; - -template <> -struct hash { - std::size_t operator()(const Ipv6Prefix &prefix) const; -}; - template <> struct hash { std::size_t operator()(const PlmnId &plmn_id) const; @@ -134,37 +120,21 @@ std::size_t hash::operator()(const IpAddr &ip_addr) const { std::size_t result{0x8b6fdf2af3de8565}; // random number to initialise auto &ipv4 = ip_addr.getIpv4Addr(); + std::hash str_hash; if (ipv4) { - std::hash str_hash; result ^= str_hash(ipv4.value()); } auto &ipv6 = ip_addr.getIpv6Addr(); if (ipv6) { - std::hash ipv6_hash; - result ^= ipv6_hash(*ipv6.value()); + result ^= str_hash(ipv6.value()); } auto &v6_prefix = ip_addr.getIpv6Prefix(); if (v6_prefix) { - std::hash v6_prefix_hash; - result ^= v6_prefix_hash(*v6_prefix.value()); + result ^= str_hash(v6_prefix.value()); } return result; } -std::size_t hash::operator()(const Ipv6Addr &ip_addr) const -{ - std::size_t result{0x872c51cff3801538}; // random number to initialise - result ^= std::hash{}(ip_addr); - return result; -} - -std::size_t hash::operator()(const Ipv6Prefix &prefix) const -{ - std::size_t result{0x1142047a5d2cfa55}; // random number to initialise - result ^= std::hash{}(prefix); - return result; -} - std::size_t hash::operator()(const MbsSessionId &mbs_session_id) const { std::size_t result{0x78a115e3d0fe74fe}; // random number to initialise @@ -487,11 +457,11 @@ std::string repr(const IpAddr &ip_addr) } auto &ipv6 = ip_addr.getIpv6Addr(); if (ipv6) { - result += "\"" + *ipv6.value() + "\""; + result += "\"" + ipv6.value() + "\""; } auto &prefix = ip_addr.getIpv6Prefix(); if (prefix) { - result += "\"" + *prefix.value() + "\""; + result += "\"" + prefix.value() + "\""; } result += "]"; @@ -931,14 +901,14 @@ static std::strong_ordering ip_addr_ordering(const IpAddr &a, const IpAddr &b) if (!a_ipv6 && b_ipv6) return std::strong_ordering::less; if (a_ipv6 && !b_ipv6) return std::strong_ordering::greater; - if (a_ipv6 && *a_ipv6.value() != *b_ipv6.value()) return *a_ipv6.value() <=> *b_ipv6.value(); + if (a_ipv6 && a_ipv6.value() != b_ipv6.value()) return a_ipv6.value() <=> b_ipv6.value(); const auto &a_ipv6prefix = a.getIpv6Prefix(); const auto &b_ipv6prefix = b.getIpv6Prefix(); if (!a_ipv6prefix && b_ipv6prefix) return std::strong_ordering::less; if (a_ipv6prefix && !b_ipv6prefix) return std::strong_ordering::greater; - if (a_ipv6prefix) return *a_ipv6prefix.value() <=> *b_ipv6prefix.value(); + if (a_ipv6prefix) return a_ipv6prefix.value() <=> b_ipv6prefix.value(); return std::strong_ordering::equal; } diff --git a/src/mbsf/UserDataIngSession.cc b/src/mbsf/UserDataIngSession.cc index 5139b99..45b5c2f 100644 --- a/src/mbsf/UserDataIngSession.cc +++ b/src/mbsf/UserDataIngSession.cc @@ -1054,7 +1054,7 @@ void UserDataIngSession::updateContexts(ogs_pool_id_t stream_id, const std::shar std::shared_ptr ssm_val = ssm.value(); std::shared_ptr dest_ip_addr = ssm_val->getDestIpAddr(); std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); - std::optional > dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); + std::optional dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); std::shared_ptr ssm_data(new Ssm(*ssm_val)); if (info->getDistrMethod()->getValue() == DistributionMethod::VAL_PACKET && info->getPckDistrInfo().value()->getOperatingMode()->getValue() == PktDistributionOperatingMode::VAL_PACKET_FORWARD_ONLY) { @@ -1136,7 +1136,7 @@ void UserDataIngSession::userServiceAnnChannelDistributionSessionInfo() std::shared_ptr ssm_val = ssm.value(); std::shared_ptr dest_ip_addr = ssm_val->getDestIpAddr(); std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); - std::optional > dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); + std::optional dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); std::shared_ptr ssm_data(new Ssm(*ssm_val)); static std::random_device rd; static std::uniform_int_distribution ud(32768, 65535); @@ -1648,9 +1648,10 @@ bool UserDataIngSession::createMbsSession(const std::shared_ptr src_ipv4_addr = src_ip_addr->getIpv4Addr(); std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); - std::optional> src_ipv6_ptr = src_ip_addr->getIpv6Addr(); - std::optional> dest_ipv6_ptr = dest_ip_addr->getIpv6Addr(); - - std::optional src_ipv6_addr; - if (src_ipv6_ptr && *src_ipv6_ptr) { - src_ipv6_addr = **src_ipv6_ptr; - } - - std::optional dest_ipv6_addr; - if (dest_ipv6_ptr && *dest_ipv6_ptr) { - dest_ipv6_addr = **dest_ipv6_ptr; - } + std::optional src_ipv6_addr = src_ip_addr->getIpv6Addr(); + std::optional dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); const char* tmgi_cstr = context_data->MBSSession->tmgi(); ogs_debug("TMGI Error: %s", tmgi_cstr); diff --git a/src/mbsf/UserServiceAnnBundle.cc b/src/mbsf/UserServiceAnnBundle.cc index ade739a..7a103bf 100644 --- a/src/mbsf/UserServiceAnnBundle.cc +++ b/src/mbsf/UserServiceAnnBundle.cc @@ -217,8 +217,8 @@ bool UserServiceAnnBundle::writeServiceDescriptionProtocolDoc(const std::shared_ auto &ssm_source_ipv4 = dist_session_ctx->ssm->getSourceIpAddr()->getIpv4Addr(); auto &ssm_source_ipv6 = dist_session_ctx->ssm->getSourceIpAddr()->getIpv6Addr(); if (ssm_source_ipv6) { - ssm_source = *ssm_source_ipv6.value(); - ssm_dest = *dist_session_ctx->ssm->getDestIpAddr()->getIpv6Addr().value(); + ssm_source = ssm_source_ipv6.value(); + ssm_dest = dist_session_ctx->ssm->getDestIpAddr()->getIpv6Addr().value(); ssm_proto = "IN IP6"; family = AF_INET6; } else if (ssm_source_ipv4) { diff --git a/src/mbsf/generator-mbsf b/src/mbsf/generator-mbsf index 967260a..e3ba974 100755 --- a/src/mbsf/generator-mbsf +++ b/src/mbsf/generator-mbsf @@ -181,7 +181,7 @@ if [ -x "$scriptdir/post-process.sh" ]; then CPP_POST_PROCESS_FILE="$scriptdir/post-process.sh" export CPP_POST_PROCESS_FILE fi -if ! "$rt_common_shared_dir/open5gs-tools/scripts/generate_openapi" -a "${APIS}" -o "$rt_common_shared_dir/mbsf/5G_APIs-overrides" -b "${BRANCH}" -c "$templates_dir/config.yaml" -l cpp-restbed-server -d "$scriptdir/openapi" -g 6.4.0 -P "reftools.mbsf" $DEBUG_FLAG ${CACHE_DIR:+-C "$CACHE_DIR"}; then +if ! "$rt_common_shared_dir/open5gs-tools/scripts/generate_openapi" -a "${APIS}" -o "$rt_common_shared_dir/mbs/5G_APIs-overrides" -b "${BRANCH}" -c "$templates_dir/config.yaml" -l cpp-restbed-server -d "$scriptdir/openapi" -g 7.23.0 -P "reftools.mbsf" $DEBUG_FLAG ${CACHE_DIR:+-C "$CACHE_DIR"}; then echo "Error: Failed to generate OpenAPI model" 1>&2 exit 1 fi diff --git a/src/mbsf/openapi-generator-templates/model-header.mustache b/src/mbsf/openapi-generator-templates/model-header.mustache new file mode 100644 index 0000000..eafd1be --- /dev/null +++ b/src/mbsf/openapi-generator-templates/model-header.mustache @@ -0,0 +1,53 @@ +{{#models}}{{#model}}/************************************************************************** + * {{classname}}.h : {{classname}} object model prototypes + * generated from openapi-generator C++ language Mustache template + * for object model implementation + ************************************************************************** + ///{{#lambda.multiline_comment_4}}{{appDescriptionWithNewLines}}{{/lambda.multiline_comment_4}} + ************************************************************************** + * Template file + * ============= + * License: 5G-MAG Public License (v1.0) + * Author: David Waring + * Copyright: (C)2023-2026 British Broadcasting Corporation + * + * For full license terms please see the LICENSE file distributed with this + * program. If this file is missing then the license can be retrieved from + * https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view + */ + +#ifndef _{{#modelPackage}}{{#lambda.uppercase}}{{#lambda.snakecase}}{{#lambda.camelcase}}{{modelPackage}}{{/lambda.camelcase}}{{/lambda.snakecase}}{{/lambda.uppercase}}_{{/modelPackage}}{{classname}}_H_ +#define _{{#modelPackage}}{{#lambda.uppercase}}{{#lambda.snakecase}}{{#lambda.camelcase}}{{modelPackage}}{{/lambda.camelcase}}{{/lambda.snakecase}}{{/lambda.uppercase}}_{{/modelPackage}}{{classname}}_H_ + +#include +#include +#include +#include +#include "CJson.hh" +#include "ModelObject.hh" +#include "ModelException.hh" +#include "OgsAllocator.hh" +#include "Validator.hh" +#include "ModelMacros.hh" +{{#imports}}{{{this}}} +{{/imports}} +{{#interfaces}} +#include "{{{this}}}.h" +{{/interfaces}} +{{#modelNamespace}} + +namespace {{modelNamespace}} { +{{/modelNamespace}} + +{{^hasVars}}{{^isEnum}}{{#isString}}{{>model-header-string}}{{/isString}}{{^isString}}{{#composedSchemas}}{{#anyOf.0.name}}{{^anyOf.2.name}}{{#anyOf.1.isString}}{{#anyOf.0.isEnum}}{{>model-header-enum-fallback}}{{/anyOf.0.isEnum}}{{^anyOf.0.isEnum}}{{>model-header-object}}{{/anyOf.0.isEnum}}{{/anyOf.1.isString}}{{^anyOf.1.isString}}{{>model-header-object}}{{/anyOf.1.isString}}{{/anyOf.2.name}}{{#anyOf.2.name}}{{>model-header-object}}{{/anyOf.2.name}}{{/anyOf.0.name}}{{^anyOf.0.name}}{{>model-header-object}}{{/anyOf.0.name}}{{/composedSchemas}}{{^composedSchemas}}{{>model-header-object}}{{/composedSchemas}}{{/isString}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{>model-header-enum}}{{/allowableValues}}{{^allowableValues}}{{>model-header-object}}{{/allowableValues}}{{/isEnum}}{{/hasVars}}{{#hasVars}}{{>model-header-object}}{{/hasVars}} +{{#modelNamespace}} + +} /* end namespace */ +{{/modelNamespace}} + +/* vim:ts=8:sts=4:sw=4:expandtab: + */ + +#endif /* _{{#modelPackage}}{{#lambda.uppercase}}{{#lambda.snakecase}}{{#lambda.camelcase}}{{modelPackage}}{{/lambda.camelcase}}{{/lambda.snakecase}}{{/lambda.uppercase}}_{{/modelPackage}}{{classname}}_HH_ */ +{{/model}} +{{/models}} diff --git a/src/mbsf/openapi-generator-templates/model-source.mustache b/src/mbsf/openapi-generator-templates/model-source.mustache new file mode 100644 index 0000000..6ddb33c --- /dev/null +++ b/src/mbsf/openapi-generator-templates/model-source.mustache @@ -0,0 +1,46 @@ +{{#models}}{{#model}}/************************************************************************** + * {{classname}}.cc : {{classname}} object model implementation + * generated from openapi-generator C++ language Mustache template + * for object model implementation + ************************************************************************** + * {{description}} + ************************************************************************** + * Template file + * ============= + * License: 5G-MAG Public License (v1.0) + * Author: David Waring + * Copyright: (C)2023-2026 British Broadcasting Corporation + * + * For full license terms please see the LICENSE file distributed with this + * program. If this file is missing then the license can be retrieved from + * https://drive.google.com/file/d/1cinCiA778IErENZ3JN52VFW-1ffHpx7Z/view + */ +#include +#include +#include + +#include "CJson.hh" +#include "ModelObject.hh" +#include "ModelException.hh" +#include "OgsAllocator.hh" +#include "ProblemCause.hh" + +#include "{{classname}}.h" + +using namespace fiveg_mag_reftools; +{{#modelNamespace}} + +namespace {{modelNamespace}} { +{{/modelNamespace}} + +{{^hasVars}}{{^isEnum}}{{#isString}}{{>model-source-string}}{{/isString}}{{^isString}}{{#composedSchemas}}{{#anyOf.0.name}}{{^anyOf.2.name}}{{#anyOf.1.isString}}{{#anyOf.0.isEnum}}{{>model-source-enum-fallback}}{{/anyOf.0.isEnum}}{{^anyOf.0.isEnum}}{{>model-source-object}}{{/anyOf.0.isEnum}}{{/anyOf.1.isString}}{{^anyOf.1.isString}}{{>model-source-object}}{{/anyOf.1.isString}}{{/anyOf.2.name}}{{#anyOf.2.name}}{{>model-source-object}}{{/anyOf.2.name}}{{/anyOf.0.name}}{{^anyOf.0.name}}{{>model-source-object}}{{/anyOf.0.name}}{{/composedSchemas}}{{^composedSchemas}}{{>model-source-object}}{{/composedSchemas}}{{/isString}}{{/isEnum}}{{#isEnum}}{{#allowableValues}}{{>model-source-enum}}{{/allowableValues}}{{^allowableValues}}{{>model-source-object}}{{/allowableValues}}{{/isEnum}}{{/hasVars}}{{#hasVars}}{{>model-source-object}}{{/hasVars}} +{{#modelNamespace}} + +} /* end namespace */ +{{/modelNamespace}} + +{{/model}} +{{/models}} + +/* vim:ts=8:sts=4:sw=4:expandtab: + */ diff --git a/subprojects/rt-common-shared b/subprojects/rt-common-shared index ad2e35c..e9959cf 160000 --- a/subprojects/rt-common-shared +++ b/subprojects/rt-common-shared @@ -1 +1 @@ -Subproject commit ad2e35cddff0dffeaa3c28b624a9d1e6ed333912 +Subproject commit e9959cf73d8c9211da17fac56534c0dec703f17a From f7a97b0addbf25a33c607859fa3000988b9e51c5 Mon Sep 17 00:00:00 2001 From: David Waring Date: Wed, 24 Jun 2026 11:08:10 +0100 Subject: [PATCH 2/4] Handle PACKET mode (to go with 5G-MAG/rt-mbs-transport-function#64) --- src/mbsf/Nmb2Build.cc | 57 ++++++++++++++++++++---------- src/mbsf/UserDataIngSession.cc | 63 +++++++--------------------------- src/mbsf/UserDataIngSession.hh | 6 ---- 3 files changed, 51 insertions(+), 75 deletions(-) diff --git a/src/mbsf/Nmb2Build.cc b/src/mbsf/Nmb2Build.cc index 1c955ec..a9fbdef 100644 --- a/src/mbsf/Nmb2Build.cc +++ b/src/mbsf/Nmb2Build.cc @@ -303,16 +303,27 @@ std::shared_ptr populate_mbstf_up_traffic_flow_info(const std { std::shared_ptr flow_info = nullptr; - flow_info.reset(new UpTrafficFlowInfo() ); - flow_info->setDestIpAddr(ds_context->ssm->getDestIpAddr()); - flow_info->setPortNumber(ds_context->ssm_port); - flow_info->setSrcIpAddr(ds_context->ssm->getSourceIpAddr()); - if (ds_context->tsi != 0) flow_info->setTransportSessionId(ds_context->tsi); + if (ds_context && ds_context->info) { + auto pkt_distr_info = ds_context->info->getPckDistrInfo(); + if (pkt_distr_info) { + auto pkt_oper_mode = pkt_distr_info.value()->getOperatingMode(); + if (pkt_oper_mode && pkt_oper_mode->getValue() == PktDistributionOperatingMode::VAL_PACKET_FORWARD_ONLY) { + // always an empty upTrafficFlowInfo when using packet distribution PACKET_FORWARD_ONLY operating mode + return flow_info; + } + } + + flow_info.reset(new UpTrafficFlowInfo() ); + flow_info->setDestIpAddr(ds_context->ssm->getDestIpAddr()); + flow_info->setPortNumber(ds_context->ssm_port); + flow_info->setSrcIpAddr(ds_context->ssm->getSourceIpAddr()); + if (ds_context->tsi != 0) flow_info->setTransportSessionId(ds_context->tsi); + } return flow_info; } -std::shared_ptr < TunnelAddress > populate_mbstf_mb_upf_tunnel_addr(ogs_sockaddr_t *tunnel_addr) +std::shared_ptr populate_mbstf_mb_upf_tunnel_addr(ogs_sockaddr_t *tunnel_addr) { ogs_sockaddr_t *sa; char buf[OGS_ADDRSTRLEN + 1]; @@ -381,20 +392,28 @@ static std::shared_ptr populate_mbstf_dist_session_state(const return std::shared_ptr(new DistSessionState(current_state)); } -static std::optional > populate_mbstf_pkt_distribution_data(std::shared_ptr mbs_dist_session_info) +static std::optional> populate_mbstf_pkt_distribution_data(std::shared_ptr mbs_dist_session_info) { - std::shared_ptr< PktDistributionData > mbstf_pkt_dist_data = nullptr; - std::optional > pkt_distr_meth_info = UserDataIngSession::getPktDistributionInfo(mbs_dist_session_info); - if (!pkt_distr_meth_info.has_value()) return std::nullopt; - std::shared_ptr< PktDistributionOperatingMode > operating_mode = UserDataIngSession::getPktDistributionOperatingMode(mbs_dist_session_info); - std::shared_ptr< PktIngestMethod > pkt_ingest_method = UserDataIngSession::getPktIngestMethod(mbs_dist_session_info); - std::shared_ptr< MbStfIngestAddr > ingest_addr = UserDataIngSession::getMbstfIngestAddr(mbs_dist_session_info); - - mbstf_pkt_dist_data.reset(new PktDistributionData()); - mbstf_pkt_dist_data->setPktDistributionOperatingMode(operating_mode); - mbstf_pkt_dist_data->setPktIngestMethod(pkt_ingest_method); - mbstf_pkt_dist_data->setMbStfIngestAddr(ingest_addr); + std::optional> mbstf_pkt_dist_data; + if (mbs_dist_session_info) { + const auto &distr_method = mbs_dist_session_info->getDistrMethod(); + if (distr_method->getValue() == DistributionMethod::VAL_PACKET) { + const auto &pkt_distr_meth_info_opt = mbs_dist_session_info->getPckDistrInfo(); + if (pkt_distr_meth_info_opt) { + const auto &pkt_distr_meth_info = pkt_distr_meth_info_opt.value(); + const auto &operating_mode = pkt_distr_meth_info->getOperatingMode(); + const auto &pkt_ingest_method = pkt_distr_meth_info->getPckIngMethod(); + const auto &ingest_addr = pkt_distr_meth_info->getIngEndpointAddrs(); + + auto pkt_dist_data = std::make_shared(); + pkt_dist_data->setPktDistributionOperatingMode(operating_mode); + pkt_dist_data->setPktIngestMethod(pkt_ingest_method); + pkt_dist_data->setMbStfIngestAddr(ingest_addr); + mbstf_pkt_dist_data = std::move(pkt_dist_data); + } + } + } return mbstf_pkt_dist_data; } @@ -510,7 +529,7 @@ static std::shared_ptr< DistSession > build_nmb2_create_dist_session(const std:: dist_session_state = populate_mbstf_dist_session_state(ing_session, context_data_ptr); - std::string mbr = UserDataIngSession::maxContBitRate(context_data_ptr->info); + std::string mbr = context_data_ptr->info->getMaxContBitRate(); std::shared_ptr subscription = make_mbstf_dist_session_subscription(ing_session->userDataIngSessionId(), context_data_ptr); diff --git a/src/mbsf/UserDataIngSession.cc b/src/mbsf/UserDataIngSession.cc index 45b5c2f..281b8c4 100644 --- a/src/mbsf/UserDataIngSession.cc +++ b/src/mbsf/UserDataIngSession.cc @@ -1056,11 +1056,6 @@ void UserDataIngSession::updateContexts(ogs_pool_id_t stream_id, const std::shar std::optional dest_ipv4_addr = dest_ip_addr->getIpv4Addr(); std::optional dest_ipv6_addr = dest_ip_addr->getIpv6Addr(); std::shared_ptr ssm_data(new Ssm(*ssm_val)); - if (info->getDistrMethod()->getValue() == DistributionMethod::VAL_PACKET && - info->getPckDistrInfo().value()->getOperatingMode()->getValue() == PktDistributionOperatingMode::VAL_PACKET_FORWARD_ONLY) { - /* Never pass source address in PACKET_FORWARD_ONLY mode */ - ssm_data->setSourceIpAddr(nullptr); - } static std::random_device rd; static std::uniform_int_distribution ud(32768, 65535); in_port_t port = ud(rd); @@ -1638,6 +1633,7 @@ bool UserDataIngSession::createMbsSession(const std::shared_ptr mb_smf_mbs_session = nullptr; if (!src_ipv4_addr && !src_ipv6_addr) { + ogs_debug("Making empty MBSMFMBSSession"); mb_smf_mbs_session.reset(new MBSMFMBSSession(mb_smf_sc_mbs_session_new())); mb_smf_mbs_session->setTunnelRequest(true); } else if (src_ipv4_addr && dest_ipv4_addr) { @@ -1685,6 +1681,7 @@ bool UserDataIngSession::createMbsSession(const std::shared_ptr UserDataIngSession::getObjectDistributionUrl(const st return std::nullopt; } -std::optional> UserDataIngSession::getPktDistributionInfo(const std::shared_ptr &info) -{ - return info->getPckDistrInfo(); -} - -std::shared_ptr< PktDistributionOperatingMode > UserDataIngSession::getPktDistributionOperatingMode(const std::shared_ptr &info) -{ - std::optional > pkt_dist_method_info = info->getPckDistrInfo(); - if (pkt_dist_method_info.has_value()) { - std::shared_ptr< PacketDistrMethInfo > dist_method_info = pkt_dist_method_info.value(); - return dist_method_info->getOperatingMode(); - } - return nullptr; -} - -std::shared_ptr< PktIngestMethod > UserDataIngSession::getPktIngestMethod(const std::shared_ptr &info) -{ - std::optional > pkt_dist_method_info = info->getPckDistrInfo(); - if (pkt_dist_method_info.has_value()) { - std::shared_ptr< PacketDistrMethInfo > dist_method_info = pkt_dist_method_info.value(); - return dist_method_info->getPckIngMethod(); - } - return nullptr; -} - -std::shared_ptr< MbStfIngestAddr > UserDataIngSession::getMbstfIngestAddr(const std::shared_ptr &info) -{ - std::optional > pkt_dist_method_info = info->getPckDistrInfo(); - if (pkt_dist_method_info.has_value()) { - std::shared_ptr< PacketDistrMethInfo > dist_method_info = pkt_dist_method_info.value(); - return dist_method_info->getIngEndpointAddrs(); - } - return nullptr; -} - -std::optional UserDataIngSession::getTrafficMarkingInfo(const std::shared_ptr &info) -{ - return info->getTrafficMarkingInfo(); -} - -std::string UserDataIngSession::maxContBitRate(const std::shared_ptr &info) -{ - return info->getMaxContBitRate(); -} - void UserDataIngSession::pendingDeleteResponse(ogs_pool_id_t stream_id) { std::lock_guard lock(*m_deleteRequestsMutex); @@ -2759,6 +2711,17 @@ static void process_mbs_distribution_session_info(const std::shared_ptrinfo->getPckDistrInfo(); + if (pkt_distribution_method_info) { + auto &pkt_ing_endpoint_addr = pkt_distribution_method_info.value()->getIngEndpointAddrs(); + auto &pkt_distribution_data = dist_session->getPktDistributionData(); + if (ogs_likely(pkt_distribution_data)) { + auto &pkt_mbstf_ingest_addr = pkt_distribution_data.value()->getMbStfIngestAddr(); + // merge the MBSTF values from mbStfIngestAddr into the existing ingEndpointAddrs (both MbStfIngestAddr types). + pkt_ing_endpoint_addr->setMbStfIngressTunAddr(pkt_mbstf_ingest_addr->getMbStfIngressTunAddr()); + pkt_ing_endpoint_addr->setMbStfListenAddr(pkt_mbstf_ingest_addr->getMbStfListenAddr()); + } + } } static bool resolve_src_dest_addr(const std::string &src_addr, const std::string &dest_addr, struct addrinfo **src_addrinfo, struct addrinfo **dest_addrinfo) diff --git a/src/mbsf/UserDataIngSession.hh b/src/mbsf/UserDataIngSession.hh index e9e5a07..451cd75 100644 --- a/src/mbsf/UserDataIngSession.hh +++ b/src/mbsf/UserDataIngSession.hh @@ -265,16 +265,10 @@ public: static bool processDistSession(const std::shared_ptr &dist_session); static std::shared_ptr getOperatingMode(const std::shared_ptr &info); - static std::shared_ptr getPktDistributionOperatingMode(const std::shared_ptr &info); static std::shared_ptr getAcquisitionMethod(const std::shared_ptr &info); static std::optional getObjectIngestUrl(const std::shared_ptr &info); static std::optional getObjectDistributionUrl(const std::shared_ptr &info); - static std::optional getTrafficMarkingInfo(const std::shared_ptr &info); - static std::optional > getPktDistributionInfo(const std::shared_ptr &info); - static std::shared_ptr getPktIngestMethod(const std::shared_ptr &info); - static std::shared_ptr getMbstfIngestAddr(const std::shared_ptr &info); static std::list, fiveg_mag_reftools::OgsAllocator>> getObjectAcquisitionIds(const std::shared_ptr &info); - static std::string maxContBitRate(const std::shared_ptr &info); static bool tmgi(mb_smf_sc_tmgi_t *tmgi, const UserDataIngDistSessId &ids); static std::optional getObjectIngestBaseUrl(const std::shared_ptr &session); From 09760fa6610d2ee6befcd73b4edd0f83fd85f7ff Mon Sep 17 00:00:00 2001 From: David Waring Date: Wed, 24 Jun 2026 11:12:42 +0100 Subject: [PATCH 3/4] Bump version for feature addition --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 9471adb..01f9b33 100644 --- a/meson.build +++ b/meson.build @@ -10,7 +10,7 @@ # Meson module fs and its functions like fs.hash_file require atleast meson 0.59.0 project('rt-mbs-function', 'c', 'cpp', - version : '1.0.0', + version : '1.1.0', license : '5G-MAG Public', meson_version : '>= 1.4.0', default_options : [ From 3f29c1d590e5d7ba197b42f4125d9d2942c7f283 Mon Sep 17 00:00:00 2001 From: David Waring Date: Wed, 24 Jun 2026 16:08:12 +0100 Subject: [PATCH 4/4] Update copyright notices --- meson.build | 2 +- src/mbsf/AssociatedSessId.cc | 3 ++- src/mbsf/DistributionSessionInfo.cc | 3 ++- src/mbsf/Nmb2Build.cc | 3 ++- src/mbsf/Nmb2Handler.cc | 2 +- src/mbsf/UniqueMBSSessionId.cc | 2 +- src/mbsf/UserDataIngSession.cc | 3 ++- src/mbsf/UserDataIngSession.hh | 3 ++- src/mbsf/UserServiceAnnBundle.cc | 1 + src/mbsf/generator-mbsf | 4 ++-- 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 01f9b33..a1f7890 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ # License: 5G-MAG Public License (v1.0) -# Copyright: (C) 2024-2025 British Broadcasting Corporation +# Copyright: (C) 2024-2026 British Broadcasting Corporation # Author(s): David Waring # Dev Audsin # diff --git a/src/mbsf/AssociatedSessId.cc b/src/mbsf/AssociatedSessId.cc index c99d3c0..16c70bf 100644 --- a/src/mbsf/AssociatedSessId.cc +++ b/src/mbsf/AssociatedSessId.cc @@ -1,8 +1,9 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: MBS Associated Session Id class ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * Licensed under the License terms and conditions for use, reproduction, and diff --git a/src/mbsf/DistributionSessionInfo.cc b/src/mbsf/DistributionSessionInfo.cc index 15fca15..db4f77a 100644 --- a/src/mbsf/DistributionSessionInfo.cc +++ b/src/mbsf/DistributionSessionInfo.cc @@ -1,8 +1,9 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: MBS Distribution Session Info class ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * Licensed under the License terms and conditions for use, reproduction, and diff --git a/src/mbsf/Nmb2Build.cc b/src/mbsf/Nmb2Build.cc index a9fbdef..776d645 100644 --- a/src/mbsf/Nmb2Build.cc +++ b/src/mbsf/Nmb2Build.cc @@ -1,8 +1,9 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: Nmb2 Build class ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * Licensed under the License terms and conditions for use, reproduction, and diff --git a/src/mbsf/Nmb2Handler.cc b/src/mbsf/Nmb2Handler.cc index 5cac683..ebc8d33 100644 --- a/src/mbsf/Nmb2Handler.cc +++ b/src/mbsf/Nmb2Handler.cc @@ -1,7 +1,7 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: Nmb2 Handler ****************************************************************************** - * Copyright: (C)2024 British Broadcasting Corporation + * Copyright: (C)2024-2026 British Broadcasting Corporation * Author(s): David Waring * License: 5G-MAG Public License v1 * diff --git a/src/mbsf/UniqueMBSSessionId.cc b/src/mbsf/UniqueMBSSessionId.cc index d928546..67876da 100644 --- a/src/mbsf/UniqueMBSSessionId.cc +++ b/src/mbsf/UniqueMBSSessionId.cc @@ -1,7 +1,7 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS: Unique MBS Session Id ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): David Waring * License: 5G-MAG Public License v1 * diff --git a/src/mbsf/UserDataIngSession.cc b/src/mbsf/UserDataIngSession.cc index 281b8c4..13c3121 100644 --- a/src/mbsf/UserDataIngSession.cc +++ b/src/mbsf/UserDataIngSession.cc @@ -1,8 +1,9 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: MBS User Data Ingest Session class ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * Licensed under the License terms and conditions for use, reproduction, and diff --git a/src/mbsf/UserDataIngSession.hh b/src/mbsf/UserDataIngSession.hh index 451cd75..58b904a 100644 --- a/src/mbsf/UserDataIngSession.hh +++ b/src/mbsf/UserDataIngSession.hh @@ -3,8 +3,9 @@ /****************************************************************************** * 5G-MAG Reference Tools: MBS Function: MBS User Data Ingest Session class ****************************************************************************** - * Copyright: (C)2025 British Broadcasting Corporation + * Copyright: (C)2025-2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * Licensed under the License terms and conditions for use, reproduction, and diff --git a/src/mbsf/UserServiceAnnBundle.cc b/src/mbsf/UserServiceAnnBundle.cc index 7a103bf..1f87abb 100644 --- a/src/mbsf/UserServiceAnnBundle.cc +++ b/src/mbsf/UserServiceAnnBundle.cc @@ -3,6 +3,7 @@ ****************************************************************************** * Copyright: (C)2026 British Broadcasting Corporation * Author(s): Dev Audsin + * David Waring * License: 5G-MAG Public License v1 * * For full license terms please see the LICENSE file distributed with this diff --git a/src/mbsf/generator-mbsf b/src/mbsf/generator-mbsf index e3ba974..cd7ed10 100755 --- a/src/mbsf/generator-mbsf +++ b/src/mbsf/generator-mbsf @@ -3,9 +3,9 @@ # 5G-MAG Reference Tools: Generate OpenAPI bindings tool # ====================================================== # -# Author(s): David Waring +# Author(s): David Waring # Dev Audsin -# Copyright: ©2022-2025 British Broadcasting Corporation +# Copyright: ©2022-2026 British Broadcasting Corporation # License: 5G-MAG Public License v1.0 # # Prerequisites: