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