diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-10-02 18:13:24 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-10-02 18:13:24 +0200 |
commit | 20e7c628347ec0e4a6469b53b98b5309c74a47f0 (patch) | |
tree | 3ee868b8535029ba055801954aec2ec2b22c3ea3 /lib/edi/common.hpp | |
parent | 37b60a6aab4abb47bb052db6fb1b49fe277e4bdc (diff) | |
download | dabmux-20e7c628347ec0e4a6469b53b98b5309c74a47f0.tar.gz dabmux-20e7c628347ec0e4a6469b53b98b5309c74a47f0.tar.bz2 dabmux-20e7c628347ec0e4a6469b53b98b5309c74a47f0.zip |
Common ba7f317: Improve EDI TCP receive
Diffstat (limited to 'lib/edi/common.hpp')
-rw-r--r-- | lib/edi/common.hpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/edi/common.hpp b/lib/edi/common.hpp index e8c57c1..5e31984 100644 --- a/lib/edi/common.hpp +++ b/lib/edi/common.hpp @@ -49,13 +49,6 @@ struct frame_timestamp_t { static frame_timestamp_t from_unix_epoch(std::time_t time, uint32_t tai_utc_offset, uint32_t tsta); }; -struct decode_state_t { - decode_state_t(bool _complete, size_t _num_bytes_consumed) : - complete(_complete), num_bytes_consumed(_num_bytes_consumed) {} - bool complete; - size_t num_bytes_consumed; -}; - using tag_name_t = std::array<uint8_t, 4>; std::string tag_name_to_human_readable(const tag_name_t& name); @@ -122,7 +115,17 @@ class TagDispatcher { } private: - decode_state_t decode_afpacket(const std::vector<uint8_t> &input_data); + enum class decode_state_e { + Ok, MissingData, Error + }; + struct decode_result_t { + decode_result_t(decode_state_e _st, size_t _num_bytes_consumed) : + st(_st), num_bytes_consumed(_num_bytes_consumed) {} + decode_state_e st; + size_t num_bytes_consumed; + }; + + decode_result_t decode_afpacket(const std::vector<uint8_t> &input_data); bool decode_tagpacket(const std::vector<uint8_t> &payload); PFT::PFT m_pft; |