OpenThread  1.05.03.02
otns.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, 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 
34 #ifndef UTILS_OTNS_HPP_
35 #define UTILS_OTNS_HPP_
36 
37 #include "openthread-core-config.h"
38 
39 #if (OPENTHREAD_MTD || OPENTHREAD_FTD) && OPENTHREAD_CONFIG_OTNS_ENABLE
40 
41 #include <openthread/thread.h>
42 #include <openthread/thread_ftd.h>
44 
45 #include "coap/coap_message.hpp"
46 #include "common/locator.hpp"
47 #include "common/non_copyable.hpp"
48 #include "common/notifier.hpp"
49 #include "mac/mac_frame.hpp"
50 #include "mac/mac_types.hpp"
51 #include "net/ip6_address.hpp"
53 #include "thread/topology.hpp"
54 
55 namespace ot {
56 namespace Utils {
57 
62 class Otns : public InstanceLocator, private NonCopyable
63 {
64  friend class ot::Notifier;
65 
66 public:
73  explicit Otns(Instance &aInstance)
74  : InstanceLocator(aInstance)
75  {
76  }
77 
84  static void EmitShortAddress(uint16_t aShortAddress);
85 
92  static void EmitExtendedAddress(const Mac::ExtAddress &aExtAddress);
93 
103  static void EmitPingRequest(const Ip6::Address &aPeerAddress,
104  uint16_t aPingLength,
105  uint32_t aTimestamp,
106  uint8_t aHopLimit);
107 
117  static void EmitPingReply(const Ip6::Address &aPeerAddress,
118  uint16_t aPingLength,
119  uint32_t aTimestamp,
120  uint8_t aHopLimit);
121 
129  static void EmitNeighborChange(NeighborTable::Event aEvent, const Neighbor &aNeighbor);
130 
137  static void EmitTransmit(const Mac::TxFrame &aFrame);
138 
145  static void EmitDeviceMode(Mle::DeviceMode aMode);
146 
154  static void EmitCoapSend(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
155 
164  static void EmitCoapSendFailure(Error aError, Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
165 
173  static void EmitCoapReceive(const Coap::Message &aMessage, const Ip6::MessageInfo &aMessageInfo);
174 
175 private:
176  static void EmitStatus(const char *aFmt, ...);
177  void HandleNotifierEvents(Events aEvents);
178 };
179 
180 } // namespace Utils
181 } // namespace ot
182 
183 #endif //(OPENTHREAD_MTD || OPENTHREAD_FTD) && OPENTHREAD_CONFIG_OTNS_ENABLE
184 
185 #endif // UTILS_OTNS_HPP_
Definition: cli.cpp:92
Event
Definition: neighbor_table.hpp:74
This file includes the abstraction for the platform OTNS utilities.
Definition: notifier.hpp:197
This file defines the OpenThread Thread API (for both FTD and MTD).
Coap::Message Message
A TMF message.
Definition: tmf.hpp:47
otError Error
Definition: error.hpp:49
InstanceLocator(void)=default
This file defines the OpenThread Thread API (FTD only).
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale