summaryrefslogtreecommitdiffstats
path: root/src/MuxElements.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-16 16:37:38 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-08-16 16:37:38 +0200
commitd57f046c40e716069d37f9e6b7911afd41c7b116 (patch)
treefd7cec78dd7fd8c3e195aab2a3a01c9525fd37bb /src/MuxElements.cpp
parent76bd144a8bbedfceceeb9ad2975a3d3f9436e311 (diff)
downloaddabmux-d57f046c40e716069d37f9e6b7911afd41c7b116.tar.gz
dabmux-d57f046c40e716069d37f9e6b7911afd41c7b116.tar.bz2
dabmux-d57f046c40e716069d37f9e6b7911afd41c7b116.zip
Add support for sending empty linkage sets to clear receiver databases
Diffstat (limited to 'src/MuxElements.cpp')
-rw-r--r--src/MuxElements.cpp43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/MuxElements.cpp b/src/MuxElements.cpp
index e19c93d..9c1fc7a 100644
--- a/src/MuxElements.cpp
+++ b/src/MuxElements.cpp
@@ -665,26 +665,35 @@ bool dabEnsemble::validate_linkage_sets()
{
for (const auto& ls : linkagesets) {
const std::string keyserviceuid = ls->keyservice;
- const auto& keyservice = std::find_if(
- services.cbegin(),
- services.cend(),
- [&](const std::shared_ptr<DabService>& srv) {
+ if (keyserviceuid.empty()) {
+ if (not ls->id_list.empty()) {
+ etiLog.log(error, "Linkage set 0x%04x with empty key service "
+ "should have an empty list.", ls->lsn);
+ return false;
+ }
+ }
+ else {
+ const auto& keyservice = std::find_if(
+ services.cbegin(),
+ services.cend(),
+ [&](const std::shared_ptr<DabService>& srv) {
return srv->uid == keyserviceuid;
- });
+ });
- if (keyservice == services.end()) {
- etiLog.log(error, "Invalid key service %s in linkage set 0x%04x",
- keyserviceuid.c_str(), ls->lsn);
- return false;
- }
+ if (keyservice == services.end()) {
+ etiLog.log(error, "Invalid key service %s in linkage set 0x%04x",
+ keyserviceuid.c_str(), ls->lsn);
+ return false;
+ }
- // need to add key service to num_ids
- const size_t num_ids = 1 + ls->id_list.size();
- if (num_ids > 0x0F) {
- etiLog.log(error,
- "Too many links for linkage set 0x%04x",
- ls->lsn);
- return false;
+ // need to add key service to num_ids
+ const size_t num_ids = 1 + ls->id_list.size();
+ if (num_ids > 0x0F) {
+ etiLog.log(error,
+ "Too many links for linkage set 0x%04x",
+ ls->lsn);
+ return false;
+ }
}
}