• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 APN_ITEM_H
17 #define APN_ITEM_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "refbase.h"
23 
24 #include "cellular_data_constant.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 struct PdpProfile;
29 struct ApnActivateInfo {
30     uint64_t actSuccTime;
31     uint32_t duration;
32     uint32_t reason;
33     uint32_t apnId;
34 };
35 
36 struct ApnActivateReportInfo {
37     uint32_t actTimes;
38     uint32_t averDuration;
39     uint32_t topReason;
40     uint32_t actSuccTimes;
41 };
42 class ApnItem : public RefBase {
43 public:
44     ApnItem();
45     ~ApnItem();
46     std::vector<std::string> GetApnTypes() const;
47     bool CanDealWithType(const std::string &type) const;
48     void MarkBadApn(bool badApn);
49     bool IsBadApn() const;
50     static sptr<ApnItem> MakeDefaultApn(const std::string &apnType);
51     static sptr<ApnItem> MakeApn(const PdpProfile &apnData);
52     static bool IsSimilarPdpProfile(const PdpProfile &newPdpProfile, const PdpProfile &oldPdpProfile);
IsSimilarProperty(const std::string & newProp,const std::string & oldProp)53     static inline bool IsSimilarProperty(const std::string &newProp, const std::string &oldProp)
54     {
55         return (newProp == oldProp) || (newProp.empty()) || (oldProp.empty());
56     }
57 
58 private:
59     static sptr<ApnItem> BuildOtherApnAttributes(sptr<ApnItem> &apnItem, const PdpProfile &apnData);
60     static bool IsSimilarProtocol(const std::string &newProtocol, const std::string &oldProtocol);
61 
62 public:
63     constexpr static int ALL_APN_ITEM_CHAR_LENGTH = 256;
64     struct Attribute {
65         char types_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
66         char numeric_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
67         int32_t profileId_ = 0;
68         char protocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
69         char roamingProtocol_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
70         int32_t authType_ = 0;
71         char apn_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
72         char apnName_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
73         char user_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
74         char password_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
75         bool isRoamingApn_ = false;
76         char homeUrl_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
77         char proxyIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
78         char mmsIpAddress_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
79         bool isEdited_ = false;
80         /* For networkslice*/
81         char snssai_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
82         uint8_t sscMode_ = 0;
83         char dnn_[ALL_APN_ITEM_CHAR_LENGTH] = { 0 };
84         int32_t PduSessionType_ = 0;
85         uint8_t RouteBitmap_ = 0;
86     } attr_;
87 
88 private:
89     std::vector<std::string> apnTypes_;
90     bool badApn_ = false;
91 };
92 } // namespace Telephony
93 } // namespace OHOS
94 #endif // APN_ITEM_H
95