Coverage Report

Created: 2025-11-12 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openthread/tests/nexus/platform/nexus_node.hpp
Line
Count
Source
1
/*
2
 *  Copyright (c) 2024, The OpenThread Authors.
3
 *  All rights reserved.
4
 *
5
 *  Redistribution and use in source and binary forms, with or without
6
 *  modification, are permitted provided that the following conditions are met:
7
 *  1. Redistributions of source code must retain the above copyright
8
 *     notice, this list of conditions and the following disclaimer.
9
 *  2. Redistributions in binary form must reproduce the above copyright
10
 *     notice, this list of conditions and the following disclaimer in the
11
 *     documentation and/or other materials provided with the distribution.
12
 *  3. Neither the name of the copyright holder nor the
13
 *     names of its contributors may be used to endorse or promote products
14
 *     derived from this software without specific prior written permission.
15
 *
16
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
 *  POSSIBILITY OF SUCH DAMAGE.
27
 */
28
29
#ifndef OT_NEXUS_NODE_HPP_
30
#define OT_NEXUS_NODE_HPP_
31
32
#include "instance/instance.hpp"
33
34
#include "nexus_alarm.hpp"
35
#include "nexus_core.hpp"
36
#include "nexus_mdns.hpp"
37
#include "nexus_radio.hpp"
38
#include "nexus_settings.hpp"
39
#include "nexus_trel.hpp"
40
#include "nexus_utils.hpp"
41
42
namespace ot {
43
namespace Nexus {
44
45
class Platform
46
{
47
public:
48
    Radio    mRadio;
49
    Alarm    mAlarm;
50
    Mdns     mMdns;
51
    Settings mSettings;
52
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
53
    Trel mTrel;
54
#endif
55
    bool mPendingTasklet;
56
57
protected:
58
    Platform(void)
59
24.1k
        : mPendingTasklet(false)
60
24.1k
    {
61
24.1k
    }
62
};
63
64
class Node : public Platform, public Heap::Allocatable<Node>, public LinkedListEntry<Node>, private Instance
65
{
66
    friend class Heap::Allocatable<Node>;
67
68
public:
69
    enum JoinMode : uint8_t
70
    {
71
        kAsFtd,
72
        kAsFed,
73
        kAsMed,
74
        kAsSed,
75
    };
76
77
    void Reset(void);
78
    void Form(void);
79
    void Join(Node &aNode, JoinMode aJoinMode = kAsFtd);
80
    void AllowList(Node &aNode);
81
    void UnallowList(Node &aNode);
82
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
83
    void GetTrelSockAddr(Ip6::SockAddr &aSockAddr) const;
84
#endif
85
86
    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
87
88
    template <typename Type> Type &Get(void)
89
120k
    {
90
120k
        Core::Get().SetActiveNode(this);
91
120k
        return Instance::Get<Type>();
92
120k
    }
ot::Mle::Mle& ot::Nexus::Node::Get<ot::Mle::Mle>()
Line
Count
Source
89
48.3k
    {
90
48.3k
        Core::Get().SetActiveNode(this);
91
48.3k
        return Instance::Get<Type>();
92
48.3k
    }
ot::Srp::Server& ot::Nexus::Node::Get<ot::Srp::Server>()
Line
Count
Source
89
24.1k
    {
90
24.1k
        Core::Get().SetActiveNode(this);
91
24.1k
        return Instance::Get<Type>();
92
24.1k
    }
ot::MeshCoP::ActiveDatasetManager& ot::Nexus::Node::Get<ot::MeshCoP::ActiveDatasetManager>()
Line
Count
Source
89
24.1k
    {
90
24.1k
        Core::Get().SetActiveNode(this);
91
24.1k
        return Instance::Get<Type>();
92
24.1k
    }
ot::ThreadNetif& ot::Nexus::Node::Get<ot::ThreadNetif>()
Line
Count
Source
89
24.1k
    {
90
24.1k
        Core::Get().SetActiveNode(this);
91
24.1k
        return Instance::Get<Type>();
92
24.1k
    }
Unexecuted instantiation: ot::Mac::Filter& ot::Nexus::Node::Get<ot::Mac::Filter>()
Unexecuted instantiation: ot::Mac::Mac& ot::Nexus::Node::Get<ot::Mac::Mac>()
93
94
    Instance &GetInstance(void)
95
36.5M
    {
96
36.5M
        Core::Get().SetActiveNode(this);
97
36.5M
        return *this;
98
36.5M
    }
99
100
0
    uint32_t GetId(void) { return GetInstance().GetId(); }
101
102
23.6M
    static Node &From(otInstance *aInstance) { return static_cast<Node &>(*aInstance); }
103
104
    using Platform::mAlarm;
105
    using Platform::mMdns;
106
    using Platform::mPendingTasklet;
107
    using Platform::mRadio;
108
    using Platform::mSettings;
109
#if OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
110
    using Platform::mTrel;
111
#endif
112
113
    Node *mNext;
114
115
private:
116
24.1k
    Node(void) = default;
117
};
118
119
23.6M
inline Node &AsNode(otInstance *aInstance) { return Node::From(aInstance); }
120
121
} // namespace Nexus
122
} // namespace ot
123
124
#endif // OT_NEXUS_NODE_HPP_