1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef ROUTER_ADVERTISEMENT_PARAMS_H
17 #define ROUTER_ADVERTISEMENT_PARAMS_H
18 
19 #include <any>
20 #include <cstring>
21 #include <iostream>
22 #include <map>
23 #include <netinet/in.h>
24 #include <set>
25 #include <sstream>
26 #include <string>
27 #include <vector>
28 
29 namespace OHOS {
30 namespace NetManagerStandard {
31 static constexpr int32_t IPV6_MIN_MTU = 1400;
32 static constexpr uint8_t DEFAULT_HOPLIMIT = 254;
33 
34 struct IpPrefix {
35     in6_addr address = {};
36     in6_addr prefix = {};
37     uint32_t prefixesLength = 0;
38 };
39 
40 class RaParams {
41 public:
42     bool hasDefaultRoute_ = false;
43     uint8_t hopLimit_ = DEFAULT_HOPLIMIT;
44     int32_t mtu_ = IPV6_MIN_MTU;
45     std::string name_;
46     uint32_t index_ = 0;
47     std::string macAddr_;
48     std::vector<IpPrefix> prefixes_;
49     std::vector<in6_addr> dnses_;
50 
51 public:
52     RaParams();
53     ~RaParams() = default;
54     void Set(const RaParams &raParam);
55     bool ContainsPrefix(const IpPrefix &pre);
56     bool ContainsDns(const in6_addr &dns);
57     void Clear();
58 };
59 
60 } // namespace NetManagerStandard
61 } // namespace OHOS
62 #endif // #define ROUTER_ADVERTISEMENT_PARAMS_H