• 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 OHOS_AT_DATA_H
17 #define OHOS_AT_DATA_H
18 
19 #include <stddef.h>
20 #include <stdint.h>
21 
22 #include "hril_vendor_data_defs.h"
23 
24 #define NET_NODE "usb0"
25 
26 // Default maxTransferUnit value
27 #define DEFAULT_MTU 0
28 
29 #define MAX_CID 11 // GU is 1~16 (currently only 11 is supported, and it can be expanded to 16 in the future).
30 #define MIN_CID 1 // GU is 1~16 (currently only 11 is supported, and it can be expanded to 16 in the future).
31 #define MAX_PDP_NUM 11
32 
33 #define ACTIVATE 1
34 #define DEACTIVATE 0
35 
36 #define ADDR_MASK 0xFF
37 #define ADDR_OFFSET_0BIT 0
38 #define ADDR_OFFSET_8BIT 8
39 #define ADDR_OFFSET_16BIT 16
40 #define ADDR_OFFSET_24BIT 24
41 #define ADDR_OFFSET_32BIT 32
42 #define IPV4_INDEX_MAX 4
43 #define IPV4_MASK_LEN_MIN 8
44 #define IPV4_MASK_MIN 0x000000FF
45 #define IPV4_MASK_MAX 0xFCFFFFFF
46 #define IPV4_BIT_MASK 0x80
47 
48 #define DELAY_WAIT_MS (1000 * 1000)
49 
50 #define DEFAULT_CID (-1)
51 
52 #define QUERY_MAX_COUNT 6
53 #define QUERY_DELAY_MS 500
54 #define DELAY_US_OFFSET 1000
55 
56 #define CALLBACK_DELAY_MS 50
57 
58 #define VERIFY_TYPE_MIN 0
59 #define VERIFY_TYPE_MAX 2
60 
61 /* 3GPP TS 27.007 V17.3.0 (2021-09)
62  * Mobile termination error result code +CME ERROR */
63 typedef enum {
64     PDP_CME_ERR_INCORRECT_PASSWORD = 16, /* incorrect password */
65     PDP_CME_ERR_NO_NETWORK_SERVICE = 30, /* no network service */
66     PDP_CME_ERR_INCORRECT_PARAMETERS = 50, /* Incorrect parameters */
67     PDP_CME_ERR_ROAMING_NOT_ALLOWED = 113, /* Roaming not allowed in this location area */
68     PDP_CME_ERR_NETWORK_FAILURE = 117, /* Network failure */
69     PDP_CME_ERR_SHORTAGE_RESOURCES = 126, /* Insufficient resources */
70     PDP_CME_ERR_MISSING_OR_UNKNOWN_APN = 127, /* Missing or unknown APN */
71     PDP_CME_ERR_UNKNOWN_PDP_ADDR_OR_TYPE = 128, /* Unknown PDP address or PDP type */
72     PDP_CME_ERR_USER_VERIFICATION = 129, /* User authentication or authorization failed */
73     PDP_CME_ERR_ACTIVATION_REJECTED_GGSN = 130, /* Activation rejected by GGSN, Serving GW or PDN GW */
74     PDP_CME_ERR_SERVICE_ACTIVATION_REJECTED_UNSPECIFIED = 131, /* Activation rejected, unspecified */
75     PDP_CME_ERR_SERVICE_OPTION_NOT_SUPPORTED = 132, /* Service option not supported */
76     PDP_CME_ERR_SERVICE_OPTION_NOT_SUBSCRIBED = 133, /* Requested service option not subscribed */
77     PDP_CME_ERR_SERVICE_OPTION_TEMPORARILY_OUT_OF_ORDER = 134, /* Service option temporarily out of order */
78     PDP_CME_ERR_NSAPI_ALREADY_USED = 135, /* NSAPI already used */
79     PDP_CME_ERR_REGULAR_DEACTIVATION = 136, /* Regular deactivation */
80     PDP_CME_ERR_UNKNOWN_PDP_CONTEXT = 143, /* Unknown PDP context */
81     PDP_CME_ERR_PROTOCOL_ERRORS = 176, /* Protocol error, unspecified */
82     PDP_CME_ERR_OPERATOR_DETERMINED_BARRING = 177, /* Operator Determined Barring */
83     PDP_CME_ERR_NO_PDP_CONTEXT_ACTIVATED = 185, /* No PDP context activated */
84     PDP_CME_ERR_IPV4_ONLY_ALLOWED = 192, /* PDP type IPv4 only allowed */
85     PDP_CME_ERR_IPV6_ONLY_ALLOWED = 193, /* PDP type IPv6 only allowed */
86     PDP_CME_ERR_IPV4V6_ONLY_ALLOWED = 196, /* PDP type IPv4v6 only allowed */
87     PDP_CME_ERR_NON_IP_ONLY_ALLOWED = 197, /* PDP type non IP only allowed */
88     PDP_CME_ERR_MULT_ACCESSES_PDN_NOT_ALLOWED = 200, /* Multiple accesses to a PDN connection not allowed */
89 } ModemErrorCode;
90 
91 typedef struct {
92     int32_t cid;
93     char *ipType;
94     char *apn;
95 } PDNInfo;
96 
97 void ReqSetInitApnInfo(const ReqDataInfo *requestInfo, const HRilDataInfo *data);
98 void ReqActivatePdpContext(const ReqDataInfo *requestInfo, const HRilDataInfo *data);
99 void ReqDeactivatePdpContext(const ReqDataInfo *requestInfo, const HRilDataInfo *data);
100 void ReqGetPdpContextList(const ReqDataInfo *requestInfo);
101 void ReqGetLinkBandwidthInfo(const ReqDataInfo *requestInfo, const int32_t cid);
102 void ReqSetLinkBandwidthReportingRule(const ReqDataInfo *requestInfo, const HRilLinkBandwidthReportingRule *data);
103 void PdpContextListUpdate(void);
104 void ReqSetDataPermitted(const ReqDataInfo *requestInfo, const int32_t dataPermitted);
105 #endif // OHOS_AT_DATA_H
106