Coverage Report

Created: 2026-04-29 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/systemd/src/libsystemd-network/icmp6-test-util.c
Line
Count
Source
1
/* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3
#include <sys/uio.h>
4
#include <unistd.h>
5
6
#include "fd-util.h"
7
#include "icmp6-test-util.h"
8
#include "icmp6-util.h"
9
#include "time-util.h"
10
11
int test_fd[2] = EBADF_PAIR;
12
13
static struct in6_addr dummy_link_local = {
14
        .s6_addr = {
15
                0xfe, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
16
                0x12, 0x34, 0x56, 0xff, 0xfe, 0x78, 0x9a, 0xbc,
17
        },
18
};
19
20
7.46k
int icmp6_bind(int ifindex, bool is_router) {
21
7.46k
        if (!is_router && socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
22
0
                return -errno;
23
24
7.46k
        return test_fd[is_router];
25
7.46k
}
26
27
9.96k
int icmp6_send(int fd, const struct in6_addr *dst, const struct iovec *iov, size_t n_iov) {
28
9.96k
        return writev(fd, iov, n_iov);
29
9.96k
}
30
31
int icmp6_receive(
32
                int fd,
33
                void *buffer,
34
                size_t size,
35
                struct in6_addr *ret_sender,
36
14.5k
                triple_timestamp *ret_timestamp) {
37
38
14.5k
        assert_se(read(fd, buffer, size) == (ssize_t) size);
39
40
14.5k
        if (ret_timestamp)
41
14.5k
                triple_timestamp_now(ret_timestamp);
42
43
14.5k
        if (ret_sender)
44
14.5k
                *ret_sender = dummy_link_local;
45
46
14.5k
        return 0;
47
14.5k
}