Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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 <david.waring2@bbc.co.uk>
# Dev Audsin <dev.audsin@bbc.co.uk>
#
Expand All @@ -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 : [
Expand Down
21 changes: 11 additions & 10 deletions src/mbsf/AssociatedSessId.cc
Original file line number Diff line number Diff line change
@@ -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 <dev.audsin@bbc.co.uk>
* David Waring <david.waring2@bbc.co.uk>
* License: 5G-MAG Public License v1
*
* Licensed under the License terms and conditions for use, reproduction, and
Expand Down Expand Up @@ -111,13 +112,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<std::string > src_ipv4_addr = src_ip_addr->getIpv4Addr();
std::optional<std::shared_ptr< std::string > > src_ipv6_addr = src_ip_addr->getIpv6Addr();
std::shared_ptr<IpAddr> src_ip_addr = getSourceIpAddr();
std::optional<std::string> src_ipv4_addr = src_ip_addr->getIpv4Addr();
std::optional<std::string> src_ipv6_addr = src_ip_addr->getIpv6Addr();

std::shared_ptr< IpAddr > dest_ip_addr = getDestIpAddr();
std::optional<std::string > dest_ipv4_addr = dest_ip_addr->getIpv4Addr();
std::optional<std::shared_ptr< std::string > > dest_ipv6_addr = dest_ip_addr->getIpv6Addr();
std::shared_ptr<IpAddr> dest_ip_addr = getDestIpAddr();
std::optional<std::string> dest_ipv4_addr = dest_ip_addr->getIpv4Addr();
std::optional<std::string> dest_ipv6_addr = dest_ip_addr->getIpv6Addr();

if (!src_ip_addr && !dest_ip_addr) {
return;
Expand Down Expand Up @@ -168,10 +169,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))
{
Expand Down
15 changes: 4 additions & 11 deletions src/mbsf/DistributionSessionInfo.cc
Original file line number Diff line number Diff line change
@@ -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 <dev.audsin@bbc.co.uk>
* David Waring <david.waring2@bbc.co.uk>
* License: 5G-MAG Public License v1
*
* Licensed under the License terms and conditions for use, reproduction, and
Expand Down Expand Up @@ -57,7 +58,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"
Expand All @@ -84,7 +84,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;
Expand Down Expand Up @@ -697,14 +696,8 @@ const std::shared_ptr<reftools::mbsf::Ssm> 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<reftools::mbsf::Ipv6Addr> src_ipv6_addr = nullptr;
std::shared_ptr<reftools::mbsf::Ipv6Addr> 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);
}
}

Expand Down
82 changes: 49 additions & 33 deletions src/mbsf/Nmb2Build.cc
Original file line number Diff line number Diff line change
@@ -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 <dev.audsin@bbc.co.uk>
* David Waring <david.waring2@bbc.co.uk>
* License: 5G-MAG Public License v1
*
* Licensed under the License terms and conditions for use, reproduction, and
Expand Down Expand Up @@ -67,7 +68,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"
Expand Down Expand Up @@ -107,7 +107,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;
Expand Down Expand Up @@ -305,16 +304,27 @@ std::shared_ptr<UpTrafficFlowInfo> populate_mbstf_up_traffic_flow_info(const std
{
std::shared_ptr<UpTrafficFlowInfo> 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<TunnelAddress> populate_mbstf_mb_upf_tunnel_addr(ogs_sockaddr_t *tunnel_addr)
{
ogs_sockaddr_t *sa;
char buf[OGS_ADDRSTRLEN + 1];
Expand All @@ -323,19 +333,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));
}
Expand Down Expand Up @@ -385,20 +393,28 @@ static std::shared_ptr<DistSessionState> populate_mbstf_dist_session_state(const
return std::shared_ptr<DistSessionState>(new DistSessionState(current_state));
}

static std::optional<std::shared_ptr< PktDistributionData > > populate_mbstf_pkt_distribution_data(std::shared_ptr<MBSDistributionSessionInfo> mbs_dist_session_info)
static std::optional<std::shared_ptr<PktDistributionData>> populate_mbstf_pkt_distribution_data(std::shared_ptr<MBSDistributionSessionInfo> mbs_dist_session_info)
{

std::shared_ptr< PktDistributionData > mbstf_pkt_dist_data = nullptr;
std::optional<std::shared_ptr< PacketDistrMethInfo > > 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<std::shared_ptr<PktDistributionData>> 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<PktDistributionData>();
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;

}
Expand Down Expand Up @@ -514,7 +530,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<DistSessionSubscription> subscription = make_mbstf_dist_session_subscription(ing_session->userDataIngSessionId(), context_data_ptr);

Expand Down
4 changes: 1 addition & 3 deletions src/mbsf/Nmb2Handler.cc
Original file line number Diff line number Diff line change
@@ -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 <david.waring2@bbc.co.uk>
* License: 5G-MAG Public License v1
*
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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

Expand Down
46 changes: 8 additions & 38 deletions src/mbsf/UniqueMBSSessionId.cc
Original file line number Diff line number Diff line change
@@ -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 <david.waring2@bbc.co.uk>
* License: 5G-MAG Public License v1
*
Expand Down Expand Up @@ -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"
Expand All @@ -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;
Expand All @@ -65,16 +61,6 @@ struct hash<IpAddr> {
std::size_t operator()(const IpAddr &ip_addr) const;
};

template <>
struct hash<Ipv6Addr> {
std::size_t operator()(const Ipv6Addr &ip_addr) const;
};

template <>
struct hash<Ipv6Prefix> {
std::size_t operator()(const Ipv6Prefix &prefix) const;
};

template <>
struct hash<PlmnId> {
std::size_t operator()(const PlmnId &plmn_id) const;
Expand Down Expand Up @@ -134,37 +120,21 @@ std::size_t hash<IpAddr>::operator()(const IpAddr &ip_addr) const
{
std::size_t result{0x8b6fdf2af3de8565}; // random number to initialise
auto &ipv4 = ip_addr.getIpv4Addr();
std::hash<std::string> str_hash;
if (ipv4) {
std::hash<std::string> str_hash;
result ^= str_hash(ipv4.value());
}
auto &ipv6 = ip_addr.getIpv6Addr();
if (ipv6) {
std::hash<Ipv6Addr> ipv6_hash;
result ^= ipv6_hash(*ipv6.value());
result ^= str_hash(ipv6.value());
}
auto &v6_prefix = ip_addr.getIpv6Prefix();
if (v6_prefix) {
std::hash<Ipv6Prefix> v6_prefix_hash;
result ^= v6_prefix_hash(*v6_prefix.value());
result ^= str_hash(v6_prefix.value());
}
return result;
}

std::size_t hash<Ipv6Addr>::operator()(const Ipv6Addr &ip_addr) const
{
std::size_t result{0x872c51cff3801538}; // random number to initialise
result ^= std::hash<std::string>{}(ip_addr);
return result;
}

std::size_t hash<Ipv6Prefix>::operator()(const Ipv6Prefix &prefix) const
{
std::size_t result{0x1142047a5d2cfa55}; // random number to initialise
result ^= std::hash<std::string>{}(prefix);
return result;
}

std::size_t hash<MbsSessionId>::operator()(const MbsSessionId &mbs_session_id) const
{
std::size_t result{0x78a115e3d0fe74fe}; // random number to initialise
Expand Down Expand Up @@ -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 += "]";
Expand Down Expand Up @@ -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;
}
Expand Down
Loading