blob: a48031277ad562e50b5861b98370a562133fb9ee [file] [log] [blame]
b.liu4e243dc2023-11-27 11:20:00 +08001#ifndef __LYNQ_QSER_DATA_H__
2#define __LYNQ_QSER_DATA_H__
3#ifdef __cplusplus
4extern "C" {
5#endif
6#include <stdbool.h>
7#include <netinet/in.h>
8
9typedef enum {
10 QSER_DATA_CALL_ERROR_NONE = 0,
11 QSER_DATA_CALL_ERROR_INVALID_PARAMS,
b.liuf37bd332024-03-18 13:51:24 +080012 QSER_DATA_CALL_ERROR_NO_INIT,
13 QSER_DATA_CALL_ERROR_PDP_ACTIVATE,
14 QSER_DATA_CALL_ERROR_PDP_NO_ACTIVATE,
15 QSER_DATA_CALL_ERROR_IDX_NO_EXIST,
16 QSER_DATA_CALL_ERROR_UNKNOWN,
b.liu4e243dc2023-11-27 11:20:00 +080017} qser_data_call_error_e;
18
19typedef enum {
20 QSER_DATA_CALL_DISCONNECTED = 0, /*!< call is disconnected */
21 QSER_DATA_CALL_CONNECTED, /*!< call is connected */
22} qser_data_call_state_e;
23
24typedef enum {
25 QSER_DATA_CALL_TYPE_IPV4 = 0, /*!< IPv4 call. */
26 QSER_DATA_CALL_TYPE_IPV6, /*!< IPv6 call. */
27 QSER_DATA_CALL_TYPE_IPV4V6, /*!< IPv4 and IPv6 call (Only used call start or stop). */
28} qser_data_call_ip_family_e;
29
30typedef enum {
31 QSER_APN_PDP_TYPE_IPV4 = 0,
32 QSER_APN_PDP_TYPE_PPP,
33 QSER_APN_PDP_TYPE_IPV6,
34 QSER_APN_PDP_TYPE_IPV4V6,
35} qser_apn_pdp_type_e;
36
37typedef enum {
38 QSER_APN_AUTH_PROTO_DEFAULT = 0,
39 QSER_APN_AUTH_PROTO_NONE,
40 QSER_APN_AUTH_PROTO_PAP,
41 QSER_APN_AUTH_PROTO_CHAP,
42 QSER_APN_AUTH_PROTO_PAP_CHAP,
43} qser_apn_auth_proto_e;
44
45#define QSER_APN_MAX_LIST 8
liuyangcbdb4972024-05-30 20:19:53 +080046#define QSER_APN_NAME_SIZE 150+1
47#define QSER_APN_USERNAME_SIZE 127+1
48#define QSER_APN_PASSWORD_SIZE 127+1
b.liu4e243dc2023-11-27 11:20:00 +080049
50struct v4_address_status {
51 struct in_addr ip; /*!< Public IPv4 address. */
52 struct in_addr gateway; /*!< Public IPv4 gateway. */
53 struct in_addr pri_dns; /*!< Primary Domain Name Service IP address. */
54 struct in_addr sec_dns; /*!< Secondary Domain Name Service IP address. */
55};
56
57struct v6_address_status {
58 struct in6_addr ip; /*!< Public IPv6 address. */
59 struct in6_addr gateway; /*!< Public IPv6 gateway. */
60 struct in6_addr pri_dns; /*!< Primary Domain Name Service IPv6 address. */
61 struct in6_addr sec_dns; /*!< Secondary Domain Name Service IPv6 address. */
62};
63
64typedef struct {
65 char profile_idx; /*!< UMTS/CMDA profile ID. */
66 char name[16]; /*!< Interface Name. */
67 qser_data_call_ip_family_e ip_family; /*!< IP version. */
68 qser_data_call_state_e state; /*!< The dial status. */
69 qser_data_call_error_e err; /*!< The Reason code after data call disconnected. */
wangyouqiang805b0f92024-04-07 17:06:13 +080070 struct v4_address_status v4; /*!< IPv4 information. */
71 struct v6_address_status v6; /*!< IPv6 information. */
b.liu4e243dc2023-11-27 11:20:00 +080072} qser_data_call_state_s;
73
74/*
75 *!< Client callback function used to post event indications.
76 */
77typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
78
79typedef struct {
80 char profile_idx; /*!< UMTS/CMDA profile ID. */
81 bool reconnect; /*!< Whether to re-dial after disconnecting the network. */
82 qser_data_call_ip_family_e ip_family; /*!< IP version. */
83 char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
84 char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
85} qser_data_call_s;
86
87struct pkt_stats {
88 unsigned long pkts_tx; /*!< Number of packets transmitted. */
89 unsigned long pkts_rx; /*!< Number of packets received. */
90 long long bytes_tx; /*!< Number of bytes transmitted. */
91 long long bytes_rx; /*!< Number of bytes received. */
92 unsigned long pkts_dropped_tx; /*!< Number of transmit packets dropped. */
93 unsigned long pkts_dropped_rx; /*!< Number of receive packets dropped. */
94};
95
96struct v4_info {
97 char name[16]; /*!< Interface Name. */
98 qser_data_call_state_e state; /*!< The dial status. */
99 bool reconnect; /*!< re-dial flag. */
100 struct v4_address_status addr; /*!< IPv4 IP Address information. */
101 struct pkt_stats stats; /*!< IPv4 statics */
102};
103
104struct v6_info {
105 char name[16]; /*!< Interface Name. */
106 qser_data_call_state_e state; /*!< The dial status. */
107 bool reconnect; /*!< re-dial flag. */
108 struct v6_address_status addr; /*!< IPv6 IP Address information. */
109 struct pkt_stats stats; /*!< IPv6 statics */
110};
111
112typedef struct {
113 char profile_idx; /*!< UMTS/CDMA profile ID. */
114 qser_data_call_ip_family_e ip_family; /*!< IP version. */
115 struct v4_info v4; /*!< IPv4 information */
116 struct v6_info v6; /*!< IPv6 information */
117} qser_data_call_info_s;
118
119typedef struct {
wangyouqiang84179c82024-01-05 15:42:55 +0800120 unsigned char profile_idx; /*!< UMTS/CDMA profile ID. range: 0 - 7*/
b.liu4e243dc2023-11-27 11:20:00 +0800121 qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload
122 exchanged over the airlink when the packet data session is
123 established with this profile. */
124 qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
125 char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
126 and external packet data network. */
127 char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
128 char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
129 char apn_type[QSER_APN_NAME_SIZE];
130} qser_apn_info_s;
131
132typedef struct {
133 qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload
134 exchanged over the airlink when the packet data session is
135 established with this profile. */
136 qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
137 char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
138 and external packet data network. */
139 char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
140 char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
141 char apn_type[QSER_APN_NAME_SIZE];
142} qser_apn_add_s;
143
144typedef struct {
145 int cnt;
146 qser_apn_info_s apn[QSER_APN_MAX_LIST];
147} qser_apn_info_list_s;
148
149
150/**
151 * Initialization data call module, and callback function registered.
152 *
153 * @param [in] evt_cb callback fucntion
154 *
155 * @return
156 * On success, 0 is returned. On error, -1 is returned.
157 *
158 */
159extern int qser_data_call_init(qser_data_call_evt_cb_t evt_cb);
160
161/**
162 * Destroy data call module, and unregister callback funciton
163 *
164 * @param
165 * None
166 *
167 * @return
168 * On success, 0 is returned. On error, -1 is returned.
169 *
170 */
171extern void qser_data_call_destroy(void);
172
173/**
174 * Starts a data call. If profile index is zero, it will call CDMA profile.
175 *
176 * @param [in] data_call The data call parameters
177 * @param [out] error Error code returned by data call
178 *
179 * @return
180 * On success, 0 is returned. On error, -1 is returned.
181 *
182 */
183extern int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
184
185/**
wangyouqiange2498f12024-01-06 17:55:36 +0800186 * Starts a data call. If profile index is zero, it will call CDMA profile.
187 *
188 * @param [in] data_call The data call parameters
189 * @param [out] error Error code returned by data call
190 *
191 * @return
192 * On success, 0 is returned. On error, -1 is returned.
193 *
194 */
195extern int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err);
196
197/**
b.liu4e243dc2023-11-27 11:20:00 +0800198 * Stop a data call.
199 *
200 * @param [in] profile_idx UMTS/CDMA profile ID
201 * @param [in] ip_family IP Version
202 * @param [out] error Error code returned by data call
203 *
204 * @return
205 * On success, 0 is returned. On error, -1 is returned.
206 *
207 */
208extern int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err);
209
210/**
211 * Get a data call information.
212 *
213 * @param [in] profile_idx UMTS/CDMA profile ID
214 * @param [in] ip_family IP Version
215 * @param [out] info The Data Call information
216 * @param [out] error Error code returned by data call
217 *
218 * @return
219 * On success, 0 is returned. On error, -1 is returned.
220 *
221 */
222extern int qser_data_call_info_get(char profile_idx,
223 qser_data_call_ip_family_e ip_family,
224 qser_data_call_info_s *info,
225 qser_data_call_error_e *err);
226
227/**
228 * Changes the settings in a configured profile.
229 *
230 * @param [in] apn the profile information.
231 *
232 * @return
233 * On success, 0 is returned. On error, -1 is returned, such apn not exist.
234 *
235 */
236extern int qser_apn_set(qser_apn_info_s *apn);
237
238/**
239 * Retrieves the settings from a configured profile.
240 *
241 * @param [in] profile_idx UMTS/CDMA profile ID
242 * @param [out] apn the profile information.
243 *
244 * @return
245 * On success, 0 is returned. On error, -1 is returned.
246 *
247 */
248extern int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn);
249
250/**
251 * Retrieves the settings from a configured profile.
252 *
253 * @param [in] apn the profile information.
254 * @param [out] profile_idx UMTS/CDMA profile ID
255 *
256 * @return
257 * On success, 0 is returned. On error, -1 is returned.
258 *
259 */
260extern int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx);
261
262/**
263 * Delete a configured profile.
264 *
265 * @param [in] profile_idx UMTS/CDMA profile ID
266 *
267 * @return
268 * On success, 0 is returned. On error, -1 is returned.
269 *
270 */
271extern int qser_apn_del(unsigned char profile_idx);
272
273/**
274 * Retrieves the settings from a configured profile list.
275 *
276 * @param [out] apn_list the profile list information.
277 *
278 * @return
279 * On success, 0 is returned. On error, -1 is returned.
280 *
281 */
282extern int qser_apn_get_list(qser_apn_info_list_s *apn_list);
283#ifdef __cplusplus
284}
285#endif
286#endif
287