summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/edi/STIDecoder.cpp14
-rw-r--r--lib/edi/STIDecoder.hpp7
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/edi/STIDecoder.cpp b/lib/edi/STIDecoder.cpp
index d387f1e..2de828b 100644
--- a/lib/edi/STIDecoder.cpp
+++ b/lib/edi/STIDecoder.cpp
@@ -70,6 +70,12 @@ void STIDecoder::setMaxDelay(int num_af_packets)
m_dispatcher.setMaxDelay(num_af_packets);
}
+void STIDecoder::filter_stream_index(bool enable, uint16_t index)
+{
+ m_filter_stream = enable;
+ m_filtered_stream_index = index;
+}
+
#define AFPACKET_HEADER_LEN 10 // includes SYNC
bool STIDecoder::decode_starptr(const std::vector<uint8_t>& value, const tag_name_t& /*n*/)
@@ -173,6 +179,14 @@ bool STIDecoder::decode_ssn(const std::vector<uint8_t>& value, const tag_name_t&
n = (uint16_t)(name[2]) << 8;
n |= (uint16_t)(name[3]);
+ if (n == 0) {
+ etiLog.level(warn) << "EDI: Stream index SSnn tag is zero";
+ }
+
+ if (m_filter_stream and m_filtered_stream_index != n) {
+ return true;
+ }
+
sti.stream_index = n - 1; // n is 1-indexed
sti.rfa = value[0] >> 3;
sti.tid = value[0] & 0x07;
diff --git a/lib/edi/STIDecoder.hpp b/lib/edi/STIDecoder.hpp
index f85f789..5e71ce7 100644
--- a/lib/edi/STIDecoder.hpp
+++ b/lib/edi/STIDecoder.hpp
@@ -119,6 +119,10 @@ class STIDecoder {
*/
void setMaxDelay(int num_af_packets);
+ /* Enable/disable stream-index filtering.
+ * index==0 is out of spec, but some encoders do it anyway. */
+ void filter_stream_index(bool enable, uint16_t index);
+
private:
bool decode_starptr(const std::vector<uint8_t>& value, const tag_name_t& n);
bool decode_dsti(const std::vector<uint8_t>& value, const tag_name_t& n);
@@ -132,6 +136,9 @@ class STIDecoder {
STIDataCollector& m_data_collector;
TagDispatcher m_dispatcher;
+
+ bool m_filter_stream = false;
+ uint16_t m_filtered_stream_index = 1;
};
}