• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ska-sa / spead2 / 5737423170

pending completion
5737423170

Pull #229

github

web-flow
Merge 0c1f30e0c into 776f8a864
Pull Request #229: Apply black, isort, pyupgrade, pre-commit

1 of 1 new or added line in 1 file covered. (100.0%)

5405 of 7212 relevant lines covered (74.94%)

52755.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.33
/src/recv_udp_base.cpp
1
/* Copyright 2016, 2019, 2023 National Research Foundation (SARAO)
2
 *
3
 * This program is free software: you can redistribute it and/or modify it under
4
 * the terms of the GNU Lesser General Public License as published by the Free
5
 * Software Foundation, either version 3 of the License, or (at your option) any
6
 * later version.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
 * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
11
 * details.
12
 *
13
 * You should have received a copy of the GNU Lesser General Public License
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 */
16

17
/**
18
 * @file
19
 */
20

21
#include <cstddef>
22
#include <cstdint>
23
#include <spead2/recv_packet.h>
24
#include <spead2/recv_stream.h>
25
#include <spead2/recv_udp_base.h>
26
#include <spead2/common_logging.h>
27

28
namespace spead2
29
{
30
namespace recv
31
{
32

33
constexpr std::size_t udp_reader_base::default_max_size;
34

35
bool udp_reader_base::process_one_packet(
14,743✔
36
    stream_base::add_packet_state &state,
37
    const std::uint8_t *data, std::size_t length, std::size_t max_size)
38
{
39
    bool stopped = false;
14,743✔
40
    if (length <= max_size && length > 0)
14,743✔
41
    {
42
        // If it's bigger, the packet might have been truncated
43
        packet_header packet;
44
        std::size_t size = decode_packet(packet, data, length);
14,743✔
45
        if (size == length)
14,736✔
46
        {
47
            state.add_packet(packet);
14,737✔
48
            if (state.is_stopped())
14,740✔
49
            {
50
                log_debug("UDP reader: end of stream detected");
280✔
51
                stopped = true;
280✔
52
            }
53
        }
54
        else if (size != 0)
×
55
        {
56
            log_info("discarding packet due to size mismatch (%1% != %2%)",
×
57
                     size, length);
58
        }
59
    }
14,740✔
60
    else if (length > max_size)
×
61
        log_info("dropped packet due to truncation");
×
62
    return stopped;
14,740✔
63
}
64

65
} // namespace recv
66
} // namespace spead2
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc