blob: ba4711f1888d69772230d6f10e128ba0e036a2a5 [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
46#define QSER_APN_NAME_SIZE 150
47#define QSER_APN_USERNAME_SIZE 127
48#define QSER_APN_PASSWORD_SIZE 127
49
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. */
70 union {
71 struct v4_address_status v4; /*!< IPv4 information. */
72 struct v6_address_status v6; /*!< IPv6 information. */
73 };
74} qser_data_call_state_s;
75
76/*
77 *!< Client callback function used to post event indications.
78 */
79typedef void (*qser_data_call_evt_cb_t)(qser_data_call_state_s *state);
80
81typedef struct {
82 char profile_idx; /*!< UMTS/CMDA profile ID. */
83 bool reconnect; /*!< Whether to re-dial after disconnecting the network. */
84 qser_data_call_ip_family_e ip_family; /*!< IP version. */
85 char cdma_username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
86 char cdma_password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
87} qser_data_call_s;
88
89struct pkt_stats {
90 unsigned long pkts_tx; /*!< Number of packets transmitted. */
91 unsigned long pkts_rx; /*!< Number of packets received. */
92 long long bytes_tx; /*!< Number of bytes transmitted. */
93 long long bytes_rx; /*!< Number of bytes received. */
94 unsigned long pkts_dropped_tx; /*!< Number of transmit packets dropped. */
95 unsigned long pkts_dropped_rx; /*!< Number of receive packets dropped. */
96};
97
98struct v4_info {
99 char name[16]; /*!< Interface Name. */
100 qser_data_call_state_e state; /*!< The dial status. */
101 bool reconnect; /*!< re-dial flag. */
102 struct v4_address_status addr; /*!< IPv4 IP Address information. */
103 struct pkt_stats stats; /*!< IPv4 statics */
104};
105
106struct v6_info {
107 char name[16]; /*!< Interface Name. */
108 qser_data_call_state_e state; /*!< The dial status. */
109 bool reconnect; /*!< re-dial flag. */
110 struct v6_address_status addr; /*!< IPv6 IP Address information. */
111 struct pkt_stats stats; /*!< IPv6 statics */
112};
113
114typedef struct {
115 char profile_idx; /*!< UMTS/CDMA profile ID. */
116 qser_data_call_ip_family_e ip_family; /*!< IP version. */
117 struct v4_info v4; /*!< IPv4 information */
118 struct v6_info v6; /*!< IPv6 information */
119} qser_data_call_info_s;
120
121typedef struct {
wangyouqiang84179c82024-01-05 15:42:55 +0800122 unsigned char profile_idx; /*!< UMTS/CDMA profile ID. range: 0 - 7*/
b.liu4e243dc2023-11-27 11:20:00 +0800123 qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload
124 exchanged over the airlink when the packet data session is
125 established with this profile. */
126 qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
127 char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
128 and external packet data network. */
129 char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
130 char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
131 char apn_type[QSER_APN_NAME_SIZE];
132} qser_apn_info_s;
133
134typedef struct {
135 qser_apn_pdp_type_e pdp_type; /*!< Packet Data Protocol (PDP) type specifies the type of data payload
136 exchanged over the airlink when the packet data session is
137 established with this profile. */
138 qser_apn_auth_proto_e auth_proto; /*!< Authentication Protocol. */
139 char apn_name[QSER_APN_NAME_SIZE]; /*!< A string parameter that is a logical name used to select the GGSN
140 and external packet data network. */
141 char username[QSER_APN_USERNAME_SIZE]; /*!< Username used during data network authentication. */
142 char password[QSER_APN_PASSWORD_SIZE]; /*!< Password to be used during data network authentication. */
143 char apn_type[QSER_APN_NAME_SIZE];
144} qser_apn_add_s;
145
146typedef struct {
147 int cnt;
148 qser_apn_info_s apn[QSER_APN_MAX_LIST];
149} qser_apn_info_list_s;
150
151
152/**
153 * Initialization data call module, and callback function registered.
154 *
155 * @param [in] evt_cb callback fucntion
156 *
157 * @return
158 * On success, 0 is returned. On error, -1 is returned.
159 *
160 */
161extern int qser_data_call_init(qser_data_call_evt_cb_t evt_cb);
162
163/**
164 * Destroy data call module, and unregister callback funciton
165 *
166 * @param
167 * None
168 *
169 * @return
170 * On success, 0 is returned. On error, -1 is returned.
171 *
172 */
173extern void qser_data_call_destroy(void);
174
175/**
176 * Starts a data call. If profile index is zero, it will call CDMA profile.
177 *
178 * @param [in] data_call The data call parameters
179 * @param [out] error Error code returned by data call
180 *
181 * @return
182 * On success, 0 is returned. On error, -1 is returned.
183 *
184 */
185extern int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err);
186
187/**
wangyouqiange2498f12024-01-06 17:55:36 +0800188 * Starts a data call. If profile index is zero, it will call CDMA profile.
189 *
190 * @param [in] data_call The data call parameters
191 * @param [out] error Error code returned by data call
192 *
193 * @return
194 * On success, 0 is returned. On error, -1 is returned.
195 *
196 */
197extern int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err);
198
199/**
b.liu4e243dc2023-11-27 11:20:00 +0800200 * Stop a data call.
201 *
202 * @param [in] profile_idx UMTS/CDMA profile ID
203 * @param [in] ip_family IP Version
204 * @param [out] error Error code returned by data call
205 *
206 * @return
207 * On success, 0 is returned. On error, -1 is returned.
208 *
209 */
210extern int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err);
211
212/**
213 * Get a data call information.
214 *
215 * @param [in] profile_idx UMTS/CDMA profile ID
216 * @param [in] ip_family IP Version
217 * @param [out] info The Data Call information
218 * @param [out] error Error code returned by data call
219 *
220 * @return
221 * On success, 0 is returned. On error, -1 is returned.
222 *
223 */
224extern int qser_data_call_info_get(char profile_idx,
225 qser_data_call_ip_family_e ip_family,
226 qser_data_call_info_s *info,
227 qser_data_call_error_e *err);
228
229/**
230 * Changes the settings in a configured profile.
231 *
232 * @param [in] apn the profile information.
233 *
234 * @return
235 * On success, 0 is returned. On error, -1 is returned, such apn not exist.
236 *
237 */
238extern int qser_apn_set(qser_apn_info_s *apn);
239
240/**
241 * Retrieves the settings from a configured profile.
242 *
243 * @param [in] profile_idx UMTS/CDMA profile ID
244 * @param [out] apn the profile information.
245 *
246 * @return
247 * On success, 0 is returned. On error, -1 is returned.
248 *
249 */
250extern int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn);
251
252/**
253 * Retrieves the settings from a configured profile.
254 *
255 * @param [in] apn the profile information.
256 * @param [out] profile_idx UMTS/CDMA profile ID
257 *
258 * @return
259 * On success, 0 is returned. On error, -1 is returned.
260 *
261 */
262extern int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx);
263
264/**
265 * Delete a configured profile.
266 *
267 * @param [in] profile_idx UMTS/CDMA profile ID
268 *
269 * @return
270 * On success, 0 is returned. On error, -1 is returned.
271 *
272 */
273extern int qser_apn_del(unsigned char profile_idx);
274
275/**
276 * Retrieves the settings from a configured profile list.
277 *
278 * @param [out] apn_list the profile list information.
279 *
280 * @return
281 * On success, 0 is returned. On error, -1 is returned.
282 *
283 */
284extern int qser_apn_get_list(qser_apn_info_list_s *apn_list);
285#ifdef __cplusplus
286}
287#endif
288#endif
289