Coverage Report

Created: 2024-04-14 06:53

/src/wpantund/src/ncp-spinel/SpinelNCPThreadDataset.h
Line
Count
Source
1
/*
2
 *
3
 * Copyright (c) 2017 Nest Labs, Inc.
4
 * All rights reserved.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 *
18
 */
19
20
#ifndef __wpantund__SpinelNCPThreadDataset__
21
#define __wpantund__SpinelNCPThreadDataset__
22
23
#include "spinel.h"
24
#include "ValueMap.h"
25
26
using namespace nl;
27
using namespace nl::wpantund;
28
29
namespace nl {
30
namespace wpantund {
31
32
class ThreadDataset
33
{
34
public:
35
  template <typename Type>
36
  struct Optional
37
  {
38
  public:
39
218k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<unsigned long>::Optional()
Line
Count
Source
39
31.1k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<nl::Data>::Optional()
Line
Count
Source
39
62.3k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::Optional()
Line
Count
Source
39
15.5k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<in6_addr>::Optional()
Line
Count
Source
39
31.1k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<unsigned int>::Optional()
Line
Count
Source
39
31.1k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<unsigned short>::Optional()
Line
Count
Source
39
15.5k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<unsigned char>::Optional()
Line
Count
Source
39
15.5k
    Optional(void): mValue(), mHasValue(false) { }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::Optional()
Line
Count
Source
39
15.5k
    Optional(void): mValue(), mHasValue(false) { }
40
41
218k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<unsigned long>::clear()
Line
Count
Source
41
31.1k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<nl::Data>::clear()
Line
Count
Source
41
62.3k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::clear()
Line
Count
Source
41
15.5k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<in6_addr>::clear()
Line
Count
Source
41
31.1k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<unsigned int>::clear()
Line
Count
Source
41
31.1k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<unsigned short>::clear()
Line
Count
Source
41
15.5k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<unsigned char>::clear()
Line
Count
Source
41
15.5k
    void clear(void) { mHasValue = false; }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::clear()
Line
Count
Source
41
15.5k
    void clear(void) { mHasValue = false; }
42
8.55k
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<unsigned long>::has_value() const
Line
Count
Source
42
1.22k
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<nl::Data>::has_value() const
Line
Count
Source
42
2.44k
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::has_value() const
Line
Count
Source
42
611
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<in6_addr>::has_value() const
Line
Count
Source
42
1.22k
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<unsigned int>::has_value() const
Line
Count
Source
42
1.22k
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<unsigned short>::has_value() const
Line
Count
Source
42
611
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<unsigned char>::has_value() const
Line
Count
Source
42
611
    bool has_value(void) const { return mHasValue; }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::has_value() const
Line
Count
Source
42
611
    bool has_value(void) const { return mHasValue; }
43
2.61k
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<unsigned long>::get() const
Line
Count
Source
43
29
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<nl::Data>::get() const
Line
Count
Source
43
290
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::get() const
Line
Count
Source
43
121
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<in6_addr>::get() const
Line
Count
Source
43
89
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<unsigned int>::get() const
Line
Count
Source
43
2.00k
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<unsigned short>::get() const
Line
Count
Source
43
18
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<unsigned char>::get() const
Line
Count
Source
43
18
    const Type &get(void) const { return mValue; }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::get() const
Line
Count
Source
43
38
    const Type &get(void) const { return mValue; }
44
362
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<unsigned long>::set(unsigned long const&)
Line
Count
Source
44
44
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<nl::Data>::set(nl::Data const&)
Line
Count
Source
44
95
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::set(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
44
68
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<in6_addr>::set(in6_addr const&)
Line
Count
Source
44
64
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<unsigned int>::set(unsigned int const&)
Line
Count
Source
44
44
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<unsigned short>::set(unsigned short const&)
Line
Count
Source
44
14
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<unsigned char>::set(unsigned char const&)
Line
Count
Source
44
15
    void set(const Type &value) { mValue = value; mHasValue = true; }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::set(nl::wpantund::ThreadDataset::SecurityPolicy const&)
Line
Count
Source
44
18
    void set(const Type &value) { mValue = value; mHasValue = true; }
45
362
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<unsigned long>::operator=(unsigned long const&)
Line
Count
Source
45
44
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<nl::Data>::operator=(nl::Data const&)
Line
Count
Source
45
95
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::operator=(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)
Line
Count
Source
45
68
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<in6_addr>::operator=(in6_addr const&)
Line
Count
Source
45
64
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<unsigned int>::operator=(unsigned int const&)
Line
Count
Source
45
44
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<unsigned short>::operator=(unsigned short const&)
Line
Count
Source
45
14
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<unsigned char>::operator=(unsigned char const&)
Line
Count
Source
45
15
    void operator=(const Type &value) { set(value); }
nl::wpantund::ThreadDataset::Optional<nl::wpantund::ThreadDataset::SecurityPolicy>::operator=(nl::wpantund::ThreadDataset::SecurityPolicy const&)
Line
Count
Source
45
18
    void operator=(const Type &value) { set(value); }
46
47
  private:
48
    Type mValue;
49
    bool mHasValue;
50
  };
51
52
  struct SecurityPolicy {
53
    uint16_t mKeyRotationTime;
54
    uint8_t  mFlags;
55
  };
56
57
15.5k
  ThreadDataset(void) { clear(); }
58
59
  void clear(void);
60
61
  void convert_to_valuemap(ValueMap &map);
62
  void convert_to_string_list(std::list<std::string> &list);
63
64
  int  set_from_spinel_frame(const uint8_t *data_in, spinel_size_t data_len);
65
  void convert_to_spinel_frame(Data &frame, bool include_value = true);
66
67
  Optional<uint64_t>         mActiveTimestamp;
68
  Optional<uint64_t>         mPendingTimestamp;
69
  Optional<Data>             mMasterKey;
70
  Optional<std::string>      mNetworkName;
71
  Optional<Data>             mExtendedPanId;
72
  Optional<struct in6_addr>  mMeshLocalPrefix;
73
  Optional<uint32_t>         mDelay;
74
  Optional<uint16_t>         mPanId;
75
  Optional<uint8_t>          mChannel;
76
  Optional<Data>             mPSKc;
77
  Optional<uint32_t>         mChannelMaskPage0;
78
  Optional<SecurityPolicy>   mSecurityPolicy;
79
  Optional<Data>             mRawTlvs;
80
  Optional<struct in6_addr>  mDestIpAddress;
81
82
private:
83
  enum
84
  {
85
    kMeshLocalPrefixLen = 64,
86
  };
87
88
  int parse_dataset_entry(const uint8_t *data_in, spinel_size_t data_len);
89
};
90
91
}; // namespace wpantund
92
}; // namespace nl
93
94
95
#endif /* defined(__wpantund__SpinelNCPThreadDataset__) */