xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdint.h> |
| 3 | #include <sys/types.h> |
| 4 | #include <arpa/inet.h> |
| 5 | #include <string.h> |
| 6 | #include <stdlib.h> |
| 7 | #include <unistd.h> |
| 8 | #include <log/log.h> |
| 9 | #include <libdata/lynq_data.h> |
| 10 | #include <liblog/lynq_deflog.h> |
| 11 | #include <pthread.h> |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 12 | #include <sqlite3.h> |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 13 | #include "lynq-qser-data.h" |
| 14 | |
| 15 | #define USER_LOG_TAG "LYNQ_QSER_DATA" |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 16 | #define APN_DB_PATH "/mnt/userdata/apn.db" |
| 17 | #define APN_DB_READED 0 |
| 18 | #define APN_DB_ERR 1 |
| 19 | #define APN_DB_CREATE 2 |
xf.li | 1bbfc7d | 2024-07-15 23:50:41 -0700 | [diff] [blame] | 20 | #define APN_TABLE_CREATE 3 |
| 21 | #define APN_TABLE_NEED_CREATE 4 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 22 | #define RESULT_OK (0) |
| 23 | #define RESULT_ERROR (-1) |
| 24 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 25 | typedef enum{ |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 26 | LYNQ_E_NO_INIT=9002, |
| 27 | LYNQ_E_APN_DB_FAIL=9003 |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 28 | }LYNQ_E; |
| 29 | |
| 30 | static int g_lynq_qser_data_init_flag = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 31 | static pthread_t s_cb_tid = -1; |
| 32 | static int s_qser_data_cb_thread_status = 0; |
| 33 | static pthread_mutex_t s_qser_data_cb_mutex = PTHREAD_MUTEX_INITIALIZER; |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 34 | static pthread_mutex_t s_qser_data_database_mutex = PTHREAD_MUTEX_INITIALIZER; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 35 | static pthread_cond_t s_qser_data_cb_cond = PTHREAD_COND_INITIALIZER; |
| 36 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 37 | |
| 38 | static qser_data_call_evt_cb_t s_data_call_cb = NULL; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 39 | static sqlite3* apnDb; |
| 40 | qser_apn_add_s default_apn = {QSER_APN_PDP_TYPE_IPV4V6, QSER_APN_AUTH_PROTO_DEFAULT, "default", "NULL", "NULL", "default"}; |
| 41 | int apn_indexs[LYNQ_APN_CHANNEL_MAX]={0}; |
| 42 | int next_index = 0; |
| 43 | int apn_count = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 44 | const int apndb_offset = 683; |
| 45 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 46 | static int init_apn_db(); |
| 47 | static int create_apn_db(char *path); |
| 48 | static int create_apn_table(char*path); |
| 49 | static int has_apn_db_created(char *path,sqlite3* apnDb_l); |
| 50 | static int apn_db_handle_clean(); |
| 51 | |
| 52 | static int lynq_apn_callback(void *data, int argc, char **argv, char **azColName); |
| 53 | static int lynq_check_index(unsigned char index); |
| 54 | static int apn_db_handle_get_profile_cb(void *data, int argc, char **argv, char **azColName); |
| 55 | static int apn_db_handle_get_profile(int handle, unsigned char *profile_idx); |
| 56 | static int apn_db_handle_set(unsigned char profile_idx, int handle); |
| 57 | static int apn_db_handle_get_cb(void *data, int argc, char **argv, char **azColName); |
| 58 | static int apn_db_handle_get(unsigned char profile_idx, int *handle); |
| 59 | |
| 60 | static int find_unuse_apn_index(char *path); |
| 61 | static int apn_db_add(int profile_id, qser_apn_add_s *apn); |
| 62 | static int apn_db_delete(unsigned char profile_idx); |
| 63 | static int apn_db_modify(qser_apn_info_s *apn); |
| 64 | static int lynq_apn_db_query_cb(void *data, int argc, char **argv, char **azColName); |
| 65 | static int apn_db_query(unsigned char profile_idx,qser_apn_info_s *apn); |
| 66 | static int apn_db_query_list_cb(void *data, int argc, char **argv, char **azColName); |
| 67 | static int apn_db_query_list(qser_apn_info_list_s *apn_list); |
| 68 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 69 | void lynq_ipv4_aton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 70 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 71 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 72 | char *tmp_char = NULL; |
| 73 | char *addresses = NULL; |
| 74 | char *dnses = NULL; |
| 75 | const char addresses_separator[2] = "/"; |
| 76 | const char dnses_separator[2] = " "; |
| 77 | |
| 78 | addresses = libdata->addresses; |
| 79 | dnses = libdata->dnses; |
| 80 | //get addresses |
| 81 | tmp_char = strsep(&addresses, addresses_separator); |
| 82 | if(tmp_char != NULL) |
| 83 | { |
| 84 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 85 | inet_aton(tmp_char,&(data_res->v4.ip)); |
| 86 | } |
| 87 | |
| 88 | //get dnses |
| 89 | tmp_char = strsep(&dnses, dnses_separator); |
| 90 | if(tmp_char != NULL) |
| 91 | { |
| 92 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 93 | inet_aton(tmp_char,&(data_res->v4.pri_dns)); |
| 94 | } |
| 95 | tmp_char = strsep(&dnses, dnses_separator); |
| 96 | if(tmp_char != NULL) |
| 97 | { |
| 98 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 99 | inet_aton(tmp_char, &(data_res->v4.sec_dns)); |
| 100 | } |
| 101 | //get gateway |
| 102 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 103 | |
| 104 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 105 | inet_aton(libdata->addresses,&(data_res->v4.ip)); |
| 106 | inet_aton(libdata->gateways,&(data_res->v4.gateway)); |
| 107 | inet_aton(libdata->dnses,&(data_res->v4.pri_dns)); |
| 108 | inet_aton(libdata->dnses,&(data_res->v4.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 109 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 110 | return ; |
| 111 | } |
| 112 | |
| 113 | void lynq_ipv6_inet_pton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 114 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 115 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 116 | char *tmp_char = NULL; |
| 117 | char *addresses = NULL; |
| 118 | char *dnses = NULL; |
| 119 | const char addresses_separator[2] = "/"; |
| 120 | const char dnses_separator[2] = " "; |
| 121 | |
| 122 | addresses = libdata->addresses; |
| 123 | dnses = libdata->dnses; |
| 124 | //get addresses |
| 125 | tmp_char = strsep(&addresses, addresses_separator); |
| 126 | if(tmp_char != NULL) |
| 127 | { |
| 128 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 129 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.ip)); |
| 130 | } |
| 131 | //get dnses |
| 132 | tmp_char = strsep(&dnses, dnses_separator); |
| 133 | if(tmp_char != NULL) |
| 134 | { |
| 135 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 136 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.pri_dns)); |
| 137 | } |
| 138 | tmp_char = strsep(&dnses, dnses_separator); |
| 139 | if(tmp_char != NULL) |
| 140 | { |
| 141 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 142 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.sec_dns)); |
| 143 | } |
| 144 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 145 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 146 | inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.ip)); |
| 147 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 148 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.pri_dns)); |
| 149 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 150 | #endif |
| 151 | |
| 152 | return ; |
| 153 | } |
| 154 | |
| 155 | void lynq_ipv4v6_inet_pton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 156 | { |
| 157 | char *tmp_char = NULL; |
| 158 | char *addresses = NULL; |
| 159 | char *dnses = NULL; |
| 160 | const char addresses_separator[2] = "/"; |
| 161 | const char dnses_separator[2] = " "; |
| 162 | |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 163 | char buf_ip[64] = {0}; |
| 164 | char buf_gateway[64] = {0}; |
| 165 | char buf_pri_dns[64] = {0}; |
| 166 | char buf_sec_dns[64] = {0}; |
| 167 | |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 168 | addresses = libdata->addresses; |
| 169 | dnses = libdata->dnses; |
| 170 | //get addresses |
| 171 | tmp_char = strsep(&addresses, addresses_separator); |
| 172 | if(tmp_char != NULL) |
| 173 | { |
| 174 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 175 | inet_aton(tmp_char,&(data_res->v4.ip)); |
| 176 | } |
| 177 | tmp_char = strsep(&addresses, addresses_separator); |
| 178 | if(tmp_char != NULL) |
| 179 | { |
| 180 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 181 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.ip)); |
| 182 | } |
| 183 | //get dnses |
| 184 | tmp_char = strsep(&dnses, dnses_separator); |
| 185 | if(tmp_char != NULL) |
| 186 | { |
| 187 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 188 | inet_aton(tmp_char,&(data_res->v4.pri_dns)); |
| 189 | } |
| 190 | tmp_char = strsep(&dnses, dnses_separator); |
| 191 | if(tmp_char != NULL) |
| 192 | { |
| 193 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 194 | inet_aton(tmp_char, &(data_res->v4.sec_dns)); |
| 195 | } |
| 196 | tmp_char = strsep(&dnses, dnses_separator); |
| 197 | if(tmp_char != NULL) |
| 198 | { |
| 199 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 200 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.pri_dns)); |
| 201 | } |
| 202 | tmp_char = strsep(&dnses, dnses_separator); |
| 203 | if(tmp_char != NULL) |
| 204 | { |
| 205 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 206 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.sec_dns)); |
| 207 | } |
| 208 | //get gateway |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 209 | inet_aton(libdata->gateways,&(data_res->v4.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 210 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 211 | |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 212 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.ip)); |
| 213 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.pri_dns)); |
| 214 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.sec_dns)); |
| 215 | |
| 216 | inet_ntop(AF_INET6, &(data_res->v6.ip), buf_ip, sizeof(buf_ip)); |
| 217 | inet_ntop(AF_INET6, &(data_res->v6.gateway), buf_gateway, sizeof(buf_gateway)); |
| 218 | inet_ntop(AF_INET6, &(data_res->v6.pri_dns), buf_pri_dns, sizeof(buf_pri_dns)); |
| 219 | inet_ntop(AF_INET6, &(data_res->v6.sec_dns), buf_sec_dns, sizeof(buf_sec_dns)); |
| 220 | LYINFLOG("v6.ip=%s, v6.gateway=%s, v6.pri_dns=%s, v6.sec_dns=%s\n" |
| 221 | , buf_ip, buf_gateway, buf_pri_dns, buf_sec_dns); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 222 | return ; |
| 223 | } |
| 224 | |
| 225 | void lynq_ipv4_aton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 226 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 227 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 228 | char *tmp_char = NULL; |
| 229 | char *addresses = NULL; |
| 230 | char *dnses = NULL; |
| 231 | const char addresses_separator[2] = "/"; |
| 232 | const char dnses_separator[2] = " "; |
| 233 | |
| 234 | addresses = libdata->addresses; |
| 235 | dnses = libdata->dnses; |
| 236 | //get addresses |
| 237 | tmp_char = strsep(&addresses, addresses_separator); |
| 238 | if(tmp_char != NULL) |
| 239 | { |
| 240 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 241 | inet_aton(tmp_char,&(data_res->v4.addr.ip)); |
| 242 | } |
| 243 | //get dnses |
| 244 | tmp_char = strsep(&dnses, dnses_separator); |
| 245 | if(tmp_char != NULL) |
| 246 | { |
| 247 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 248 | inet_aton(tmp_char,&(data_res->v4.addr.pri_dns)); |
| 249 | } |
| 250 | tmp_char = strsep(&dnses, dnses_separator); |
| 251 | if(tmp_char != NULL) |
| 252 | { |
| 253 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 254 | inet_aton(tmp_char, &(data_res->v4.addr.sec_dns)); |
| 255 | } |
| 256 | //get gateway |
| 257 | LYINFLOG("ipv4 gateways = %s", libdata->gateways); |
| 258 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
| 259 | |
| 260 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.addr.ip)); |
| 261 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.addr.pri_dns)); |
| 262 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.addr.sec_dns)); |
| 263 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 264 | inet_aton(libdata->addresses,&(data_res->v4.addr.ip)); |
| 265 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
| 266 | inet_aton(libdata->dnses,&(data_res->v4.addr.pri_dns)); |
| 267 | inet_aton(libdata->dnses,&(data_res->v4.addr.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 268 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 269 | data_res->v4.stats.pkts_tx = 0; |
| 270 | data_res->v4.stats.pkts_rx = 0; |
| 271 | data_res->v4.stats.bytes_tx = 0; |
| 272 | data_res->v4.stats.bytes_rx = 0; |
| 273 | data_res->v4.stats.pkts_dropped_tx = 0; |
| 274 | data_res->v4.stats.pkts_dropped_rx = 0; |
| 275 | return ; |
| 276 | } |
| 277 | |
| 278 | void lynq_ipv6_inet_pton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 279 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 280 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 281 | char *tmp_char = NULL; |
| 282 | char *addresses = NULL; |
| 283 | char *dnses = NULL; |
| 284 | const char addresses_separator[2] = "/"; |
| 285 | const char dnses_separator[2] = " "; |
| 286 | |
| 287 | addresses = libdata->addresses; |
| 288 | dnses = libdata->dnses; |
| 289 | //get addresses |
| 290 | tmp_char = strsep(&addresses, addresses_separator); |
| 291 | if(tmp_char != NULL) |
| 292 | { |
| 293 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 294 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.ip)); |
| 295 | } |
| 296 | //get dnses |
| 297 | tmp_char = strsep(&dnses, dnses_separator); |
| 298 | if(tmp_char != NULL) |
| 299 | { |
| 300 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 301 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.pri_dns)); |
| 302 | } |
| 303 | tmp_char = strsep(&dnses, dnses_separator); |
| 304 | if(tmp_char != NULL) |
| 305 | { |
| 306 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 307 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.sec_dns)); |
| 308 | } |
| 309 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 310 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 311 | inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.addr.ip)); |
| 312 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 313 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.pri_dns)); |
| 314 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 315 | #endif |
| 316 | data_res->v6.stats.pkts_tx = 0; |
| 317 | data_res->v6.stats.pkts_rx = 0; |
| 318 | data_res->v6.stats.bytes_tx = 0; |
| 319 | data_res->v6.stats.bytes_rx = 0; |
| 320 | data_res->v6.stats.pkts_dropped_tx = 0; |
| 321 | data_res->v6.stats.pkts_dropped_rx = 0; |
| 322 | return ; |
| 323 | } |
| 324 | void lynq_ipv4v6_inet_pton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 325 | { |
| 326 | char *tmp_char = NULL; |
| 327 | char *addresses = NULL; |
| 328 | char *dnses = NULL; |
| 329 | const char addresses_separator[2] = "/"; |
| 330 | const char dnses_separator[2] = " "; |
| 331 | |
| 332 | char buf_ip[64] = {0}; |
| 333 | char buf_gateway[64] = {0}; |
| 334 | char buf_pri_dns[64] = {0}; |
| 335 | char buf_sec_dns[64] = {0}; |
| 336 | |
| 337 | addresses = libdata->addresses; |
| 338 | dnses = libdata->dnses; |
| 339 | //get addresses |
| 340 | tmp_char = strsep(&addresses, addresses_separator); |
| 341 | if(tmp_char != NULL) |
| 342 | { |
| 343 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 344 | inet_aton(tmp_char,&(data_res->v4.addr.ip)); |
| 345 | } |
| 346 | tmp_char = strsep(&addresses, addresses_separator); |
| 347 | if(tmp_char != NULL) |
| 348 | { |
| 349 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 350 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.ip)); |
| 351 | } |
| 352 | //get dnses |
| 353 | tmp_char = strsep(&dnses, dnses_separator); |
| 354 | if(tmp_char != NULL) |
| 355 | { |
| 356 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 357 | inet_aton(tmp_char,&(data_res->v4.addr.pri_dns)); |
| 358 | } |
| 359 | tmp_char = strsep(&dnses, dnses_separator); |
| 360 | if(tmp_char != NULL) |
| 361 | { |
| 362 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 363 | inet_aton(tmp_char, &(data_res->v4.addr.sec_dns)); |
| 364 | } |
| 365 | tmp_char = strsep(&dnses, dnses_separator); |
| 366 | if(tmp_char != NULL) |
| 367 | { |
| 368 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 369 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.pri_dns)); |
| 370 | } |
| 371 | tmp_char = strsep(&dnses, dnses_separator); |
| 372 | if(tmp_char != NULL) |
| 373 | { |
| 374 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 375 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.sec_dns)); |
| 376 | } |
| 377 | //get gateway |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 378 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 379 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 380 | |
| 381 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.addr.ip)); |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 382 | LYINFLOG("ipv4 gateways = %s", inet_ntoa(data_res->v4.addr.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 383 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.addr.pri_dns)); |
| 384 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.addr.sec_dns)); |
| 385 | |
| 386 | inet_ntop(AF_INET6, &(data_res->v6.addr.ip), buf_ip, sizeof(buf_ip)); |
| 387 | inet_ntop(AF_INET6, &(data_res->v6.addr.gateway), buf_gateway, sizeof(buf_gateway)); |
| 388 | inet_ntop(AF_INET6, &(data_res->v6.addr.pri_dns), buf_pri_dns, sizeof(buf_pri_dns)); |
| 389 | inet_ntop(AF_INET6, &(data_res->v6.addr.sec_dns), buf_sec_dns, sizeof(buf_sec_dns)); |
| 390 | LYINFLOG("v6.ip=%s, v6.gateway=%s, v6.pri_dns=%s, v6.sec_dns=%s\n" |
| 391 | , buf_ip, buf_gateway, buf_pri_dns, buf_sec_dns); |
| 392 | data_res->v4.stats.pkts_tx = 0; |
| 393 | data_res->v4.stats.pkts_rx = 0; |
| 394 | data_res->v4.stats.bytes_tx = 0; |
| 395 | data_res->v4.stats.bytes_rx = 0; |
| 396 | data_res->v4.stats.pkts_dropped_tx = 0; |
| 397 | data_res->v4.stats.pkts_dropped_rx = 0; |
| 398 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 399 | data_res->v6.stats.pkts_tx = 0; |
| 400 | data_res->v6.stats.pkts_rx = 0; |
| 401 | data_res->v6.stats.bytes_tx = 0; |
| 402 | data_res->v6.stats.bytes_rx = 0; |
| 403 | data_res->v6.stats.pkts_dropped_tx = 0; |
| 404 | data_res->v6.stats.pkts_dropped_rx = 0; |
| 405 | return ; |
| 406 | } |
| 407 | |
| 408 | void datacall_ipv4_status_judge(int state,qser_data_call_info_s *data_res) |
| 409 | { |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 410 | if(state != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 411 | { |
| 412 | data_res->v4.state = QSER_DATA_CALL_CONNECTED; |
| 413 | data_res->v4.reconnect = 1; |
| 414 | } |
| 415 | else |
| 416 | { |
| 417 | data_res->v4.state = QSER_DATA_CALL_DISCONNECTED; |
| 418 | data_res->v4.reconnect = 0; |
| 419 | } |
| 420 | return ; |
| 421 | } |
| 422 | |
| 423 | void datacall_ipv6_status_judge(int state,qser_data_call_info_s *data_res) |
| 424 | { |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 425 | if(state != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 426 | { |
| 427 | data_res->v6.state = QSER_DATA_CALL_CONNECTED; |
| 428 | data_res->v6.reconnect = 1; |
| 429 | } |
| 430 | else |
| 431 | { |
| 432 | data_res->v6.state = QSER_DATA_CALL_DISCONNECTED; |
| 433 | data_res->v6.reconnect = 0; |
| 434 | } |
| 435 | return ; |
| 436 | } |
| 437 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 438 | // ****************apn DB start****************** |
| 439 | static int apn_db_handle_get_profile_cb(void *data, int argc, char **argv, char **azColName) |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 440 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 441 | if(data==NULL) |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 442 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 443 | return 1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 444 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 445 | int *temp = (int *)data; |
| 446 | for(int i=0; i<argc; i++){ |
| 447 | LYINFLOG("[%s]%s = %s", __FUNCTION__,azColName[i], argv[i] ? argv[i] : "NULL"); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 448 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 449 | *temp = atoi(argv[0]); |
| 450 | return 0; |
| 451 | } |
| 452 | static int apn_db_handle_get_profile(int handle, unsigned char *profile_idx) |
| 453 | { |
| 454 | char *zErrMsg = 0; |
| 455 | int rc; |
| 456 | int idx = 0; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 457 | char sql[128]={0}; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 458 | |
| 459 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 460 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 461 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 462 | if( rc ) |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 463 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 464 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 465 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 466 | return LYNQ_E_APN_DB_FAIL; |
| 467 | } |
| 468 | |
| 469 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 470 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 471 | sprintf(sql,"SELECT ID from LYNQAPN WHERE HANDLE=%d", handle); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 472 | LYINFLOG("sql: %s\n", sql); |
| 473 | /* Execute SQL statement */ |
| 474 | rc = sqlite3_exec(apnDb, sql, apn_db_handle_get_profile_cb, &idx, &zErrMsg); |
| 475 | if( rc != SQLITE_OK ) |
| 476 | { |
| 477 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 478 | sqlite3_free(zErrMsg); |
| 479 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 480 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 481 | return LYNQ_E_APN_DB_FAIL; |
| 482 | }; |
| 483 | *profile_idx = (unsigned char)idx; |
| 484 | LYINFLOG("get idx %d successfully\n", *profile_idx); |
| 485 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 486 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 487 | return 0; |
| 488 | } |
| 489 | static int lynq_apn_callback(void *data, int argc, char **argv, char **azColName){ |
| 490 | int i; |
| 491 | |
| 492 | apn_indexs[atoi(argv[0])] = atoi(argv[0]); |
| 493 | LYINFLOG("apn_indexs[%d] is %d", atoi(argv[0]), apn_indexs[atoi(argv[0])]); |
| 494 | |
| 495 | for(i=0; i<argc; i++){ |
| 496 | LYINFLOG("%s = %s", azColName[i], argv[i] ? argv[i] : "NULL"); |
| 497 | } |
| 498 | return 0; |
| 499 | } |
| 500 | /** |
| 501 | * @brief Check whether the ID exists in the database |
| 502 | * |
| 503 | * @param index |
| 504 | * @return int |
| 505 | * find:turn 1 |
| 506 | * not find:turn 0 |
| 507 | */ |
| 508 | static int lynq_check_index(unsigned char index) |
| 509 | { |
| 510 | memset(apn_indexs,0,sizeof(apn_indexs)); |
| 511 | next_index = 0; |
| 512 | char *zErrMsg = 0; |
| 513 | int rc; |
| 514 | char sql[128]={0}; |
| 515 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 516 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 517 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 518 | if( rc ) |
| 519 | { |
| 520 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 521 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 522 | return LYNQ_E_APN_DB_FAIL; |
| 523 | } |
| 524 | sprintf(sql,"%s", "SELECT * from LYNQAPN"); |
| 525 | rc = sqlite3_exec(apnDb, sql, lynq_apn_callback, NULL, &zErrMsg); |
| 526 | if( rc != SQLITE_OK ) |
| 527 | { |
| 528 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 529 | sqlite3_free(zErrMsg); |
| 530 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 531 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 532 | return LYNQ_E_APN_DB_FAIL; |
| 533 | } |
| 534 | //for(int cnt = 0; cnt < next_index;cnt++) |
| 535 | for(int cnt = 0; cnt <= QSER_APN_MAX_LIST; cnt++) |
| 536 | { |
| 537 | if(index == apn_indexs[cnt]) |
| 538 | { |
| 539 | LYINFLOG("index = apn_index\n"); |
| 540 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 541 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 542 | return 1; |
| 543 | } |
| 544 | } |
| 545 | LYINFLOG("cant find the index %d\n", index); |
| 546 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 547 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
| 548 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 549 | return 0; |
| 550 | } |
| 551 | |
| 552 | static int apn_db_handle_set(unsigned char profile_idx, int handle) |
| 553 | { |
| 554 | char *zErrMsg = 0; |
| 555 | int rc; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 556 | char sql[128]={0}; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 557 | if(!lynq_check_index(profile_idx)) |
| 558 | { |
| 559 | return LYNQ_E_APN_DB_FAIL; |
| 560 | } |
| 561 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 562 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 563 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 564 | if( rc ) |
| 565 | { |
| 566 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 567 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 568 | return LYNQ_E_APN_DB_FAIL; |
| 569 | } |
| 570 | |
| 571 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 572 | /* Create SQL statement */ |
| 573 | //sql = "SELECT * from LYNQAPN"; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 574 | sprintf(sql,"UPDATE LYNQAPN SET HANDLE=%d WHERE ID=%d", handle, (int)profile_idx); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 575 | LYINFLOG("sql: %s\n", sql); |
| 576 | /* Execute SQL statement */ |
| 577 | rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg); |
| 578 | if( rc != SQLITE_OK ) |
| 579 | { |
| 580 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 581 | sqlite3_free(zErrMsg); |
| 582 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 583 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 584 | return LYNQ_E_APN_DB_FAIL; |
| 585 | } |
| 586 | LYINFLOG("update apn %d successfully\n", profile_idx); |
| 587 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 588 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 589 | return 0; |
| 590 | } |
| 591 | static int apn_db_handle_get_cb(void *data, int argc, char **argv, char **azColName) |
| 592 | { |
| 593 | if(data==NULL) |
| 594 | { |
| 595 | return 1; |
| 596 | } |
| 597 | int *temp = (int *)data; |
| 598 | for(int i=0; i<argc; i++){ |
| 599 | LYINFLOG("[%s]%s = %s", __FUNCTION__,azColName[i], argv[i] ? argv[i] : "NULL"); |
| 600 | } |
| 601 | *temp = atoi(argv[0]); |
| 602 | LYINFLOG("The handle is %d\n", *temp); |
| 603 | return 0; |
| 604 | } |
| 605 | static int apn_db_handle_get(unsigned char profile_idx, int *handle) |
| 606 | { |
| 607 | char *zErrMsg = 0; |
| 608 | int rc; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 609 | char sql[128]={0}; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 610 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 611 | if(!lynq_check_index(profile_idx)) |
| 612 | { |
| 613 | return LYNQ_E_APN_DB_FAIL; |
| 614 | } |
| 615 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 616 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 617 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 618 | if( rc ) |
| 619 | { |
| 620 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 621 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 622 | return LYNQ_E_APN_DB_FAIL; |
| 623 | } |
| 624 | |
| 625 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 626 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 627 | sprintf(sql,"SELECT HANDLE from LYNQAPN WHERE ID=%d", (int)profile_idx); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 628 | LYINFLOG("sql: %s\n", sql); |
| 629 | /* Execute SQL statement */ |
| 630 | rc = sqlite3_exec(apnDb, sql, apn_db_handle_get_cb, handle, &zErrMsg); |
| 631 | if( rc != SQLITE_OK ) |
| 632 | { |
| 633 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 634 | sqlite3_free(zErrMsg); |
| 635 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 636 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 637 | return LYNQ_E_APN_DB_FAIL; |
| 638 | } |
| 639 | LYINFLOG("get idx %d successfully\n", *handle); |
| 640 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 641 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 642 | return 0; |
| 643 | } |
| 644 | |
| 645 | static int has_apn_db_created(char *path,sqlite3* apnDb_l) |
| 646 | { |
| 647 | if (path == NULL || strlen(path) == 0) |
| 648 | { |
| 649 | LYERRLOG("initApnDb error with null path!"); |
| 650 | return APN_DB_ERR; |
| 651 | } |
| 652 | int rc = sqlite3_open_v2(path, &apnDb_l, SQLITE_OPEN_READWRITE,NULL); |
| 653 | if (rc == SQLITE_OK) |
| 654 | { |
| 655 | LYINFLOG("check init success!"); |
xf.li | b5d82bf | 2024-03-09 01:54:50 -0800 | [diff] [blame] | 656 | sqlite3_close_v2(apnDb_l); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 657 | return APN_DB_READED; |
| 658 | } |
| 659 | else |
| 660 | { |
| 661 | LYERRLOG("db has not create %s!", sqlite3_errmsg(apnDb_l)); |
| 662 | sqlite3_close_v2(apnDb_l); |
| 663 | return APN_DB_ERR; |
| 664 | } |
| 665 | } |
| 666 | static int create_apn_db(char *path) |
| 667 | { |
| 668 | if (path == NULL || strlen(path) == 0) { |
| 669 | LYERRLOG("initApnDb error with null path!"); |
| 670 | return APN_DB_ERR; |
| 671 | } |
| 672 | if(APN_DB_READED==has_apn_db_created(path,apnDb)) |
| 673 | { |
| 674 | return APN_DB_READED; |
| 675 | } |
| 676 | int rc = sqlite3_open(path, &apnDb); |
| 677 | if (rc != SQLITE_OK) { |
| 678 | LYERRLOG("initDb failed %d", sqlite3_errcode(apnDb)); |
| 679 | return APN_DB_ERR; |
| 680 | } else { |
| 681 | LYINFLOG("create db in %s", path); |
| 682 | } |
| 683 | sqlite3_close(apnDb); |
| 684 | return APN_DB_CREATE; |
| 685 | } |
| 686 | static int create_apn_table(char*path) |
| 687 | { |
| 688 | char *zErrMsg = 0; |
| 689 | int rc; |
| 690 | char *sql; |
| 691 | |
| 692 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 693 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 694 | rc = sqlite3_open(path, &apnDb); |
| 695 | if( rc ) |
| 696 | { |
| 697 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 698 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 699 | return 1; |
| 700 | } |
| 701 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 702 | /* Create SQL statement */ |
| 703 | sql = "CREATE TABLE LYNQAPN( \ |
| 704 | ID INT NOT NULL, \ |
| 705 | PDP_TYPE INT NOT NULL, \ |
| 706 | AUTH_PROTO INT NOT NULL, \ |
| 707 | APN_NAME TEXT NOT NULL, \ |
| 708 | USERNAME TEXT NOT NULL,\ |
| 709 | PASSWORD TEXT NOT NULL, \ |
| 710 | APN_TYPE TEXT PRIMARY KEY NOT NULL, \ |
| 711 | HANDLE INT NOT NULL)"; |
| 712 | /* Execute SQL statement */ |
| 713 | rc = sqlite3_exec(apnDb, sql, NULL, 0, &zErrMsg); |
| 714 | if( rc != SQLITE_OK ) |
| 715 | { |
| 716 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 717 | sqlite3_free(zErrMsg); |
| 718 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 719 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 720 | return 1; |
| 721 | } |
| 722 | LYINFLOG("Table LYNQAPN created successfully\n"); |
| 723 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 724 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 725 | return 0; |
| 726 | } |
xf.li | 1bbfc7d | 2024-07-15 23:50:41 -0700 | [diff] [blame] | 727 | check_apn_table_cb(void *data, int argc, char **argv, char **azColName) |
| 728 | { |
| 729 | if(data==NULL) |
| 730 | { |
| 731 | return 1; |
| 732 | } |
| 733 | int *temp = (int *)data; |
| 734 | for(int i=0; i<argc; i++){ |
| 735 | LYINFLOG("[%s]%s = %s", __FUNCTION__,azColName[i], argv[i] ? argv[i] : "NULL"); |
| 736 | } |
| 737 | *temp = atoi(argv[0]); |
| 738 | LYINFLOG("\nThe number is %d\n", *temp); |
| 739 | return 0; |
| 740 | } |
| 741 | int check_apn_table(char*path) |
| 742 | { |
| 743 | char *zErrMsg = 0; |
| 744 | int rc; |
| 745 | char *sql; |
| 746 | int num = -1; |
| 747 | |
| 748 | /* Open database */ |
| 749 | pthread_mutex_lock(&s_qser_data_database_mutex); |
| 750 | rc = sqlite3_open(path, &apnDb); |
| 751 | if( rc ) |
| 752 | { |
| 753 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
| 754 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
| 755 | return 1; |
| 756 | } |
| 757 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 758 | /* Create SQL statement */ |
| 759 | sql = "SELECT COUNT(*) FROM sqlite_master where type ='table' and name = 'LYNQAPN'"; |
| 760 | /* Execute SQL statement */ |
| 761 | rc = sqlite3_exec(apnDb, sql, check_apn_table_cb, &num, &zErrMsg); |
| 762 | if( rc != SQLITE_OK ) |
| 763 | { |
| 764 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 765 | sqlite3_free(zErrMsg); |
| 766 | sqlite3_close(apnDb); |
| 767 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
| 768 | return 1; |
| 769 | } |
| 770 | LYINFLOG("Table LYNQAPN check successfully\n"); |
| 771 | sqlite3_close(apnDb); |
| 772 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
| 773 | if(num <= 0) |
| 774 | { |
| 775 | LYINFLOG("No table LYNQAPN, num = %d\n", num); |
| 776 | return APN_TABLE_NEED_CREATE; |
| 777 | } |
| 778 | else |
| 779 | { |
| 780 | LYINFLOG("The table LYNQAPN exist, num = %d\n", num); |
| 781 | return APN_TABLE_CREATE; |
| 782 | } |
| 783 | |
| 784 | return 0; |
| 785 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 786 | static int init_apn_db() |
| 787 | { |
| 788 | int db_ret=0; |
xf.li | 1bbfc7d | 2024-07-15 23:50:41 -0700 | [diff] [blame] | 789 | int check_ret=0; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 790 | int table_ret=0; |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 791 | |
| 792 | pthread_mutex_init(&s_qser_data_database_mutex, NULL); |
| 793 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 794 | db_ret = create_apn_db(APN_DB_PATH); |
| 795 | if(db_ret==APN_DB_CREATE) |
| 796 | { |
| 797 | table_ret = create_apn_table(APN_DB_PATH); |
| 798 | if(table_ret!=0) |
| 799 | { |
| 800 | LYERRLOG("create apn table fail!!!"); |
| 801 | return RESULT_ERROR; |
| 802 | } |
| 803 | apn_db_add(0, &default_apn); |
| 804 | } |
| 805 | else if(db_ret==APN_DB_READED) |
| 806 | { |
xf.li | 1bbfc7d | 2024-07-15 23:50:41 -0700 | [diff] [blame] | 807 | LYINFLOG("[%s] apn db has be build!!!",__FUNCTION__); |
| 808 | check_ret = check_apn_table(APN_DB_PATH); |
| 809 | if(check_ret == APN_TABLE_NEED_CREATE) |
| 810 | { |
| 811 | table_ret = create_apn_table(APN_DB_PATH); |
| 812 | if(table_ret!=0) |
| 813 | { |
| 814 | LYERRLOG("create apn table fail!!!"); |
| 815 | return 1; |
| 816 | } |
| 817 | apn_db_add(0, &default_apn); |
| 818 | } |
| 819 | else if(check_ret == APN_TABLE_CREATE) |
| 820 | { |
| 821 | LYINFLOG("Table LYNQAPN has created"); |
| 822 | } |
| 823 | else |
| 824 | { |
| 825 | LYERRLOG("check table fail!!!, ret = %d", check_ret); |
| 826 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 827 | } |
| 828 | else |
| 829 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 830 | LYERRLOG("init apn db fail!!!"); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 831 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 832 | return RESULT_OK; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 833 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 834 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 835 | static int apn_db_handle_clean() |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 836 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 837 | char *zErrMsg = 0; |
| 838 | int rc; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 839 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 840 | char sql[128]={0}; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 841 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 842 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 843 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 844 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 845 | if( rc ) |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 846 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 847 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 848 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 849 | return LYNQ_E_APN_DB_FAIL; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 850 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 851 | |
| 852 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 853 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 854 | sprintf(sql,"UPDATE LYNQAPN SET HANDLE=%d", default_handle); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 855 | LYINFLOG("sql: %s\n", sql); |
| 856 | /* Execute SQL statement */ |
| 857 | rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg); |
| 858 | if( rc != SQLITE_OK ) |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 859 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 860 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 861 | sqlite3_free(zErrMsg); |
| 862 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 863 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 864 | return LYNQ_E_APN_DB_FAIL; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 865 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 866 | LYINFLOG("clean apn table successfully\n"); |
| 867 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 868 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 869 | return RESULT_OK; |
| 870 | } |
| 871 | |
| 872 | static int find_unuse_apn_index(char *path) |
| 873 | { |
| 874 | char *zErrMsg = 0; |
| 875 | int rc; |
| 876 | int count =1; |
| 877 | bool apn_usable = false; |
| 878 | char *sql; |
| 879 | |
| 880 | memset(apn_indexs,0,sizeof(apn_indexs)); |
| 881 | next_index = 0; |
| 882 | LYINFLOG("index = %p",apn_indexs); |
| 883 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 884 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 885 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 886 | if( rc ) |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 887 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 888 | LYERRLOG("Can't open database: %s\n", sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 889 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 890 | return -1; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 891 | } |
| 892 | else |
| 893 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 894 | LYINFLOG("Opened database successfully\n"); |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 895 | } |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 896 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 897 | /* Create SQL statement */ |
| 898 | sql = "SELECT ID from LYNQAPN"; |
| 899 | /* Execute SQL statement */ |
| 900 | rc = sqlite3_exec(apnDb, sql, lynq_apn_callback,NULL, &zErrMsg); |
| 901 | if( rc != SQLITE_OK ) |
| 902 | { |
| 903 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 904 | sqlite3_free(zErrMsg); |
xf.li | b5d82bf | 2024-03-09 01:54:50 -0800 | [diff] [blame] | 905 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 906 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 907 | return -1; |
| 908 | } |
| 909 | else |
| 910 | { |
| 911 | LYINFLOG("Operation done successfully\n"); |
| 912 | } |
| 913 | //indexs = temp_index; |
| 914 | LYINFLOG("index = %p",apn_indexs); |
| 915 | for(count;count<=QSER_APN_MAX_LIST;count++) |
| 916 | { |
| 917 | //if(apn_indexs[count-1]!=count) |
| 918 | LYINFLOG("apn_indexs[count] = %d, count = %d\n", apn_indexs[count], count); |
| 919 | if(apn_indexs[count]!=count) |
| 920 | { |
| 921 | //apn_usable=true; |
| 922 | break; |
| 923 | } |
| 924 | } |
| 925 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 926 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 927 | LYINFLOG("count is %d\n", count); |
| 928 | return count; |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 929 | } |
| 930 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 931 | static int apn_db_add(int profile_id, qser_apn_add_s *apn) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 932 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 933 | char *zErrMsg = 0; |
| 934 | int rc; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 935 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 936 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 937 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 938 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 939 | if( rc ) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 940 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 941 | LYERRLOG("[%s] Can't open database: %s",__FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 942 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 943 | return 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 944 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 945 | LYINFLOG("[%s] Opened database successfully",__FUNCTION__); |
| 946 | /* Create SQL statement */ |
| 947 | /* Execute SQL statement */ |
| 948 | LYINFLOG("the profile id is %d\n", profile_id); |
| 949 | char *sql = sqlite3_mprintf("INSERT INTO LYNQAPN VALUES('%d','%d','%d','%q','%q','%q','%q','%d')", profile_id, apn->pdp_type, apn->auth_proto, apn->apn_name, apn->username, apn->password, apn->apn_type, default_handle); |
| 950 | rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg); |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 951 | sqlite3_free(sql); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 952 | if( rc != SQLITE_OK ) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 953 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 954 | LYERRLOG( "SQL error: %s", zErrMsg); |
| 955 | sqlite3_free(zErrMsg); |
| 956 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 957 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 958 | return 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 959 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 960 | LYINFLOG("write apn to apn db successfully"); |
| 961 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 962 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 963 | return 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 964 | } |
| 965 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 966 | static int apn_db_delete(unsigned char profile_idx) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 967 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 968 | char *zErrMsg = 0; |
| 969 | int rc; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 970 | char sql[128]={0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 971 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 972 | if(!lynq_check_index(profile_idx)) |
| 973 | { |
| 974 | return LYNQ_E_APN_DB_FAIL; |
| 975 | } |
| 976 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 977 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 978 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 979 | if( rc ) |
| 980 | { |
| 981 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 982 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 983 | return LYNQ_E_APN_DB_FAIL; |
| 984 | } |
| 985 | |
| 986 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 987 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 988 | sprintf(sql,"DELETE from LYNQAPN WHERE ID=%d",(int)profile_idx); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 989 | LYINFLOG("sql: %s\n", sql); |
| 990 | /* Execute SQL statement */ |
| 991 | rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg); |
| 992 | if( rc != SQLITE_OK ) |
| 993 | { |
| 994 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 995 | sqlite3_free(zErrMsg); |
| 996 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 997 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 998 | return LYNQ_E_APN_DB_FAIL; |
| 999 | } |
| 1000 | LYINFLOG("delete apn %d successfully\n", profile_idx); |
| 1001 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1002 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1003 | return 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1006 | static int apn_db_modify(qser_apn_info_s *apn) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1007 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1008 | char *zErrMsg = 0; |
| 1009 | int rc; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1010 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1011 | if(!lynq_check_index(apn->profile_idx)) |
| 1012 | { |
| 1013 | return LYNQ_E_APN_DB_FAIL; |
| 1014 | } |
| 1015 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1016 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1017 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 1018 | if( rc ) |
| 1019 | { |
| 1020 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1021 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1022 | return LYNQ_E_APN_DB_FAIL; |
| 1023 | } |
| 1024 | |
| 1025 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 1026 | /* Create SQL statement */ |
| 1027 | char *sql = sqlite3_mprintf("UPDATE LYNQAPN set PDP_TYPE = %d, AUTH_PROTO = %d, APN_NAME = '%q', USERNAME = '%q', PASSWORD = '%q', APN_TYPE = '%q' WHERE ID=%d", apn->pdp_type, apn->auth_proto, apn->apn_name, apn->username, apn->password, apn->apn_type, apn->profile_idx); |
| 1028 | LYINFLOG("sql: %s\n", sql); |
| 1029 | /* Execute SQL statement */ |
| 1030 | rc = sqlite3_exec(apnDb, sql, NULL, NULL, &zErrMsg); |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 1031 | sqlite3_free(sql); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1032 | if( rc != SQLITE_OK ) |
| 1033 | { |
| 1034 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 1035 | sqlite3_free(zErrMsg); |
| 1036 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1037 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1038 | return LYNQ_E_APN_DB_FAIL; |
| 1039 | } |
| 1040 | LYINFLOG("set apn %d successfully\n",apn->profile_idx); |
| 1041 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1042 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1043 | return 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1044 | } |
| 1045 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1046 | static int lynq_apn_db_query_cb(void *data, int argc, char **argv, char **azColName) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1047 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1048 | if(data==NULL) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1049 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1050 | return 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1051 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1052 | qser_apn_info_s* temp = (qser_apn_info_s *)data; |
| 1053 | for(int i=0; i<argc; i++){ |
| 1054 | LYINFLOG("[%s]%s = %s", __FUNCTION__,azColName[i], argv[i] ? argv[i] : "NULL"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1055 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1056 | temp->profile_idx = atoi(argv[0]); |
| 1057 | temp->pdp_type = atoi(argv[1]); |
| 1058 | temp->auth_proto = atoi(argv[2]); |
| 1059 | memcpy(temp->apn_name,argv[3],QSER_APN_NAME_SIZE); |
| 1060 | memcpy(temp->username,argv[4],QSER_APN_USERNAME_SIZE); |
| 1061 | memcpy(temp->password,argv[5],QSER_APN_PASSWORD_SIZE); |
| 1062 | memcpy(temp->apn_type,argv[6],QSER_APN_NAME_SIZE); |
| 1063 | LYINFLOG("lynq_apn_db_query_cb: profile_idx is %d", atoi(argv[0])); |
| 1064 | return 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1065 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1066 | static int apn_db_query(unsigned char profile_idx,qser_apn_info_s *apn) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1067 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1068 | char *zErrMsg = 0; |
| 1069 | int rc; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 1070 | char sql[128]={0}; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1071 | |
| 1072 | if(!lynq_check_index(profile_idx)) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1073 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1074 | return LYNQ_E_APN_DB_FAIL; |
| 1075 | } |
| 1076 | /* Open database */ |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1077 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1078 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 1079 | if( rc ) |
| 1080 | { |
| 1081 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1082 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1083 | return LYNQ_E_APN_DB_FAIL; |
| 1084 | } |
| 1085 | |
| 1086 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 1087 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 1088 | sprintf(sql,"SELECT * from LYNQAPN WHERE ID=%d", (int)profile_idx); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1089 | LYINFLOG("sql: %s\n", sql); |
| 1090 | /* Execute SQL statement */ |
| 1091 | rc = sqlite3_exec(apnDb, sql, lynq_apn_db_query_cb, (qser_apn_info_s *)apn, &zErrMsg); |
| 1092 | if( rc != SQLITE_OK ) |
| 1093 | { |
| 1094 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 1095 | sqlite3_free(zErrMsg); |
| 1096 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1097 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1098 | return LYNQ_E_APN_DB_FAIL; |
| 1099 | } |
| 1100 | LYINFLOG("set apn %d successfully\n",apn->profile_idx); |
| 1101 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1102 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1103 | return 0; |
| 1104 | } |
| 1105 | static int apn_db_query_list_cb(void *data, int argc, char **argv, char **azColName) |
| 1106 | { |
| 1107 | int i; |
| 1108 | |
| 1109 | //apn_count++; |
| 1110 | |
| 1111 | qser_apn_info_list_s* temp = (qser_apn_info_list_s *)data; |
| 1112 | for(i=0; i<argc; i++){ |
| 1113 | LYINFLOG("%s = %s", azColName[i], argv[i] ? argv[i] : "NULL"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1114 | } |
| 1115 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1116 | temp->apn[temp->cnt].profile_idx = atoi(argv[0]); |
| 1117 | temp->apn[temp->cnt].pdp_type = atoi(argv[1]); |
| 1118 | temp->apn[temp->cnt].auth_proto = atoi(argv[2]); |
| 1119 | memcpy(temp->apn[temp->cnt].apn_name,argv[3],QSER_APN_NAME_SIZE); |
| 1120 | memcpy(temp->apn[temp->cnt].username,argv[4],QSER_APN_USERNAME_SIZE); |
| 1121 | memcpy(temp->apn[temp->cnt].password,argv[5],QSER_APN_PASSWORD_SIZE); |
| 1122 | memcpy(temp->apn[temp->cnt].apn_type,argv[6],QSER_APN_NAME_SIZE); |
| 1123 | temp->cnt++; |
| 1124 | return 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1125 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1126 | static int apn_db_query_list(qser_apn_info_list_s *apn_list) |
| 1127 | { |
| 1128 | char *zErrMsg = 0; |
| 1129 | int rc; |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 1130 | char sql[128]={0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1131 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1132 | /* Open database */ |
| 1133 | apn_count = 0; |
| 1134 | apn_list->cnt = 0; |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1135 | pthread_mutex_lock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1136 | rc = sqlite3_open(APN_DB_PATH, &apnDb); |
| 1137 | if( rc ) |
| 1138 | { |
| 1139 | LYERRLOG("[%s] Can't open database: %s\n", __FUNCTION__,sqlite3_errmsg(apnDb)); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1140 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1141 | return LYNQ_E_APN_DB_FAIL; |
| 1142 | } |
| 1143 | |
| 1144 | LYINFLOG("[%s] Opened database successfully\n",__FUNCTION__); |
| 1145 | /* Create SQL statement */ |
xf.li | ff41520 | 2024-09-19 23:08:09 -0700 | [diff] [blame] | 1146 | sprintf(sql,"SELECT * from LYNQAPN"); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1147 | LYINFLOG("sql: %s\n", sql); |
| 1148 | /* Execute SQL statement */ |
| 1149 | rc = sqlite3_exec(apnDb, sql, apn_db_query_list_cb, (qser_apn_info_list_s *)apn_list, &zErrMsg); |
| 1150 | if( rc != SQLITE_OK ) |
| 1151 | { |
| 1152 | LYERRLOG("SQL error: %s\n", zErrMsg); |
| 1153 | sqlite3_free(zErrMsg); |
| 1154 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1155 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1156 | return LYNQ_E_APN_DB_FAIL; |
| 1157 | } |
| 1158 | sqlite3_close(apnDb); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1159 | pthread_mutex_unlock(&s_qser_data_database_mutex); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1160 | return 0; |
| 1161 | } |
| 1162 | // **************apn DB end**************************** |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1163 | void judge_pdp_type(qser_apn_pdp_type_e pdp_type,char *out_pdp_type) |
| 1164 | { |
| 1165 | switch (pdp_type) |
| 1166 | { |
| 1167 | case QSER_APN_PDP_TYPE_IPV4: |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 1168 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1169 | strcpy(out_pdp_type,"IP"); |
| 1170 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1171 | strcpy(out_pdp_type,"IPV4"); |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 1172 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1173 | break; |
| 1174 | case QSER_APN_PDP_TYPE_PPP: |
| 1175 | strcpy(out_pdp_type,"PPP"); |
| 1176 | break; |
| 1177 | case QSER_APN_PDP_TYPE_IPV6: |
| 1178 | strcpy(out_pdp_type,"IPV6"); |
| 1179 | break; |
| 1180 | case QSER_APN_PDP_TYPE_IPV4V6: |
| 1181 | strcpy(out_pdp_type,"IPV4V6"); |
| 1182 | break; |
| 1183 | default: |
| 1184 | strcpy(out_pdp_type,"NULL"); |
| 1185 | break; |
| 1186 | } |
| 1187 | return; |
| 1188 | } |
| 1189 | void judge_authtype(qser_apn_auth_proto_e auth_proto,char *out_proto) |
| 1190 | { |
| 1191 | switch (auth_proto) |
| 1192 | { |
| 1193 | case QSER_APN_AUTH_PROTO_DEFAULT: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1194 | strcpy(out_proto,"0"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1195 | break; |
| 1196 | case QSER_APN_AUTH_PROTO_NONE: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1197 | strcpy(out_proto,"0"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1198 | break; |
| 1199 | case QSER_APN_AUTH_PROTO_PAP: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1200 | strcpy(out_proto,"1"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1201 | break; |
| 1202 | case QSER_APN_AUTH_PROTO_CHAP: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1203 | strcpy(out_proto,"2"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1204 | break; |
| 1205 | case QSER_APN_AUTH_PROTO_PAP_CHAP: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1206 | strcpy(out_proto,"3"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1207 | break; |
| 1208 | default: |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1209 | strcpy(out_proto,"NULL"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1210 | break; |
| 1211 | } |
| 1212 | return ; |
| 1213 | } |
| 1214 | |
| 1215 | int data_call_handle_get(const char profile_idx,int *handle) |
| 1216 | { |
| 1217 | int num = LYNQ_APN_CHANNEL_MAX; |
| 1218 | int table_num = 0; |
| 1219 | lynq_apn_info **apn_table = NULL; |
| 1220 | qser_apn_info_s apn; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1221 | int ret = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1222 | apn_table = (lynq_apn_info **)malloc(sizeof(lynq_apn_info *)*LYNQ_APN_CHANNEL_MAX); |
| 1223 | if (NULL == apn_table) |
| 1224 | { |
| 1225 | LYERRLOG("malloc apn_table fail "); |
| 1226 | return RESULT_ERROR; |
| 1227 | } |
| 1228 | for(int i =0;i<10;i++) |
| 1229 | { |
| 1230 | apn_table[i] = (lynq_apn_info*)malloc(sizeof(lynq_apn_info)); |
| 1231 | if (apn_table[i]==NULL) |
| 1232 | { |
| 1233 | for (int n=0;n<i;n++) |
| 1234 | { |
| 1235 | free(apn_table[n]); |
| 1236 | } |
| 1237 | return RESULT_ERROR; |
| 1238 | } |
| 1239 | memset(apn_table[i],0,sizeof(lynq_apn_info)); |
| 1240 | } |
| 1241 | lynq_get_apn_table(&table_num,apn_table); |
| 1242 | memset(&apn,0,sizeof(qser_apn_info_s)); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1243 | ret = apn_db_query(profile_idx,&apn); |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1244 | if (ret < 0) |
| 1245 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1246 | LYERRLOG("apn_db_query error"); |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1247 | return ret; |
| 1248 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1249 | for (int j = 0;j < table_num;j++) |
| 1250 | { |
| 1251 | if (strcmp(apn.apn_type,apn_table[j]->apnType) == 0) |
| 1252 | { |
| 1253 | *handle = apn_table[j]->index; |
| 1254 | LYINFLOG("apn_table->index:%d,handle:%d ",apn_table[j]->index,*handle); |
| 1255 | break; |
| 1256 | } |
| 1257 | } |
| 1258 | |
| 1259 | for (int i = 0; i < LYNQ_APN_CHANNEL_MAX; i++) |
| 1260 | { |
| 1261 | if (apn_table[i]!=NULL) |
| 1262 | { |
| 1263 | free(apn_table[i]); |
| 1264 | apn_table[i]=NULL; |
| 1265 | } |
| 1266 | } |
| 1267 | free(apn_table); |
| 1268 | apn_table=NULL; |
| 1269 | LYINFLOG("data_call_handle_get end"); |
| 1270 | return RESULT_OK; |
| 1271 | } |
| 1272 | |
| 1273 | void *thread_wait_cb_status(void) |
| 1274 | { |
| 1275 | int handle = -1; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1276 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1277 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1278 | lynq_data_call_response_v11_t data_urc_info = {0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1279 | qser_data_call_state_s data_cb_state; |
| 1280 | while (s_qser_data_cb_thread_status) |
| 1281 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1282 | ret = lynq_wait_data_call_state_change(&handle); |
| 1283 | LYINFLOG("ret = %d, wait data call state change end!!!\n", ret); |
| 1284 | if(s_qser_data_cb_thread_status == 0) |
| 1285 | { |
| 1286 | return NULL; |
| 1287 | } |
| 1288 | else if(ret < 0) |
| 1289 | { |
| 1290 | continue; |
| 1291 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1292 | LYINFLOG("[thread_wait_cb_status]: handle = %d", handle); |
| 1293 | memset(&data_urc_info, 0, sizeof(data_urc_info)); |
| 1294 | memset(&data_cb_state, 0, sizeof(data_cb_state)); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1295 | lynq_get_data_call_list(&handle,&data_urc_info); |
| 1296 | /*compare paramter*/ |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1297 | //data_cb_state.profile_idx = (char)handle; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1298 | apn_db_handle_get_profile(handle, &data_cb_state.profile_idx); |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1299 | LYINFLOG("[thread_wait_cb_status]: callback profile_idx is %d\n", data_cb_state.profile_idx); |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1300 | LYINFLOG("[thread_wait_cb_status]: status=%d, suggestedRetryTime=%d, cid=%d, active=%d, type=%s, ifname=%s, addresses=%s, dnses=%s, gateways=%s, pcscf=%s, mtu=%d\n", |
| 1301 | data_urc_info.status, data_urc_info.suggestedRetryTime, data_urc_info.cid, data_urc_info.active, |
| 1302 | data_urc_info.type, data_urc_info.ifname, data_urc_info.addresses, data_urc_info.dnses, data_urc_info.gateways, data_urc_info.pcscf, |
| 1303 | data_urc_info.mtu); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1304 | memcpy(data_cb_state.name,data_urc_info.ifname,strlen(data_urc_info.ifname)+1); |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 1305 | if ((strcmp(data_urc_info.type,"IPV4") == 0) || (strcmp(data_urc_info.type,"IP") == 0)) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1306 | { |
| 1307 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4; |
| 1308 | } |
| 1309 | else if (!strcmp(data_urc_info.type,"IPV6")) |
| 1310 | { |
| 1311 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV6; |
| 1312 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1313 | else if (!strcmp(data_urc_info.type,"IPV4V6")) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1314 | { |
| 1315 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4V6; |
| 1316 | } |
| 1317 | else |
| 1318 | { |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1319 | LYERRLOG("unknow data call type: %s", data_urc_info.type); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1322 | if (data_urc_info.active != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1323 | { |
| 1324 | data_cb_state.state = QSER_DATA_CALL_CONNECTED; |
| 1325 | } |
| 1326 | else |
| 1327 | { |
| 1328 | data_cb_state.state = QSER_DATA_CALL_DISCONNECTED; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1329 | ret = apn_db_handle_set(data_cb_state.profile_idx, default_handle); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1330 | if(ret != 0) |
| 1331 | { |
| 1332 | LYERRLOG("handle set error"); |
| 1333 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1334 | } |
| 1335 | if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4) |
| 1336 | { |
| 1337 | lynq_ipv4_aton_urc(&data_urc_info,&data_cb_state); |
| 1338 | } |
| 1339 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV6) |
| 1340 | { |
| 1341 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1342 | } |
| 1343 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4V6) |
| 1344 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1345 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1346 | lynq_ipv4v6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1347 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1348 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1349 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1350 | } |
| 1351 | else |
| 1352 | { |
| 1353 | LYERRLOG("unknow ip_family"); |
| 1354 | continue; |
| 1355 | } |
| 1356 | if (s_data_call_cb != NULL) |
| 1357 | { |
| 1358 | s_data_call_cb(&data_cb_state); |
| 1359 | } |
| 1360 | } |
| 1361 | return NULL; |
| 1362 | } |
| 1363 | |
| 1364 | int qser_cb_pthread_create() |
| 1365 | { |
xf.li | b5d82bf | 2024-03-09 01:54:50 -0800 | [diff] [blame] | 1366 | pthread_attr_t attr; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1367 | int ret; |
| 1368 | s_qser_data_cb_thread_status = 1; |
xf.li | b5d82bf | 2024-03-09 01:54:50 -0800 | [diff] [blame] | 1369 | |
| 1370 | pthread_attr_init(&attr); |
| 1371 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); |
| 1372 | |
| 1373 | ret = pthread_create(&s_cb_tid,&attr,thread_wait_cb_status,NULL); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1374 | if (ret < 0) |
| 1375 | { |
| 1376 | LYERRLOG("pthread create fail"); |
| 1377 | s_qser_data_cb_thread_status = 0; |
| 1378 | return RESULT_ERROR; |
| 1379 | } |
xf.li | b5d82bf | 2024-03-09 01:54:50 -0800 | [diff] [blame] | 1380 | pthread_attr_destroy(&attr); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1381 | return RESULT_OK; |
| 1382 | } |
| 1383 | |
| 1384 | void qser_cb_pthread_cancel() |
| 1385 | { |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1386 | s_qser_data_cb_thread_status = 0; |
| 1387 | if (s_cb_tid != -1) |
| 1388 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1389 | lynq_release_wait_data_call(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1390 | } |
| 1391 | return; |
| 1392 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1393 | int qser_data_call_init(qser_data_call_evt_cb_t evt_cb) |
| 1394 | { |
| 1395 | int ret = 0; |
| 1396 | int utoken = 0; |
| 1397 | if (NULL == evt_cb) |
| 1398 | { |
| 1399 | LYERRLOG("init incoming paramters error"); |
| 1400 | return RESULT_ERROR; |
| 1401 | } |
xf.li | 09b46db | 2024-03-13 19:21:18 -0700 | [diff] [blame] | 1402 | if(g_lynq_qser_data_init_flag == 1) |
| 1403 | { |
| 1404 | LYERRLOG("init twice is not allowed"); |
| 1405 | return RESULT_ERROR; |
| 1406 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1407 | ret = lynq_init_data(utoken); |
| 1408 | if (ret != RESULT_OK) |
| 1409 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1410 | //qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1411 | s_data_call_cb = NULL; |
| 1412 | return RESULT_ERROR; |
| 1413 | } |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1414 | qser_cb_pthread_create(); |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1415 | ret = init_apn_db(); |
| 1416 | if(ret != RESULT_OK) |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1417 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1418 | LYERRLOG("init apn db error"); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1419 | return RESULT_ERROR; |
| 1420 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1421 | |
| 1422 | ret = apn_db_handle_clean(); |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame] | 1423 | if(ret != RESULT_OK) |
| 1424 | { |
| 1425 | LYERRLOG("clean handle error"); |
| 1426 | return RESULT_ERROR; |
| 1427 | } |
xf.li | 09b46db | 2024-03-13 19:21:18 -0700 | [diff] [blame] | 1428 | s_data_call_cb = evt_cb; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1429 | g_lynq_qser_data_init_flag = 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1430 | return RESULT_OK; |
| 1431 | } |
| 1432 | |
| 1433 | void qser_data_call_destroy(void) |
| 1434 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1435 | LYINFLOG("[%s] start [%d]",__FUNCTION__,__LINE__); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1436 | lynq_deinit_data(); |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1437 | qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1438 | s_data_call_cb = NULL; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1439 | g_lynq_qser_data_init_flag = 0; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1440 | LYINFLOG("[%s] end [%d]",__FUNCTION__,__LINE__); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1441 | return ; |
| 1442 | } |
| 1443 | |
| 1444 | int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1445 | { |
| 1446 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1447 | int error = -1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1448 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1449 | if(g_lynq_qser_data_init_flag == 0) |
| 1450 | { |
| 1451 | if(err != NULL) |
| 1452 | { |
| 1453 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1454 | } |
| 1455 | return LYNQ_E_NO_INIT; |
| 1456 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1457 | if (NULL == data_call || NULL == err) |
| 1458 | { |
| 1459 | LYERRLOG("call start incoming paramters error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1460 | if(err != NULL) |
| 1461 | { |
| 1462 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1463 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1464 | return ret; |
| 1465 | } |
| 1466 | if (data_call->profile_idx == 0) |
| 1467 | { |
| 1468 | ret = lynq_setup_data_call(&handle); |
| 1469 | } |
| 1470 | else |
| 1471 | { |
| 1472 | char pdptype[16]; |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1473 | char auth_proto[16]; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1474 | qser_apn_info_s apn_info; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1475 | LYINFLOG("datacall->profile_idx is %d\n", data_call->profile_idx); |
| 1476 | ret = qser_apn_get((unsigned char)data_call->profile_idx,&apn_info); |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1477 | if (ret != 0) |
| 1478 | { |
| 1479 | LYERRLOG("qser_apn_get error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1480 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1481 | return ret; |
| 1482 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1483 | judge_pdp_type(apn_info.pdp_type,pdptype); |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1484 | judge_authtype(apn_info.auth_proto,auth_proto); |
| 1485 | ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,auth_proto,pdptype,pdptype); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1486 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1487 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1488 | { |
| 1489 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1490 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1491 | else |
| 1492 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1493 | error = apn_db_handle_set((unsigned char)data_call->profile_idx, handle); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1494 | if(error != 0) |
| 1495 | { |
| 1496 | LYERRLOG("handle set error"); |
| 1497 | } |
| 1498 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1499 | return ret; |
| 1500 | } |
| 1501 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1502 | int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1503 | { |
| 1504 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1505 | int error = -1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1506 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1507 | if(g_lynq_qser_data_init_flag == 0) |
| 1508 | { |
| 1509 | if(err != NULL) |
| 1510 | { |
| 1511 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1512 | } |
| 1513 | return LYNQ_E_NO_INIT; |
| 1514 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1515 | if (NULL == data_call || NULL == err) |
| 1516 | { |
| 1517 | LYERRLOG("call start incoming paramters error"); |
| 1518 | if(err != NULL) |
| 1519 | { |
| 1520 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1521 | } |
| 1522 | return ret; |
| 1523 | } |
| 1524 | if (data_call->profile_idx == 0) |
| 1525 | { |
| 1526 | ret = lynq_setup_data_call_sp_t106_async(&handle,"default","default",NULL,NULL,NULL,NULL,NULL); |
| 1527 | } |
| 1528 | else |
| 1529 | { |
| 1530 | char pdptype[16]; |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1531 | char auth_proto[16]; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1532 | qser_apn_info_s apn_info; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1533 | LYINFLOG("datacall->profile_idx is %d\n", data_call->profile_idx); |
| 1534 | ret = qser_apn_get((unsigned char)data_call->profile_idx,&apn_info); |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1535 | if (ret != 0) |
| 1536 | { |
| 1537 | LYERRLOG("qser_apn_get error"); |
| 1538 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1539 | return ret; |
| 1540 | } |
| 1541 | judge_pdp_type(apn_info.pdp_type,pdptype); |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1542 | judge_authtype(apn_info.auth_proto,auth_proto); |
| 1543 | ret = lynq_setup_data_call_sp_t106_async(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,auth_proto,pdptype,pdptype); |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1544 | } |
| 1545 | if (ret != 0) |
| 1546 | { |
| 1547 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1548 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1549 | else |
| 1550 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1551 | error = apn_db_handle_set((unsigned char)data_call->profile_idx, handle); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1552 | if(error != 0) |
| 1553 | { |
| 1554 | LYERRLOG("handle set error"); |
| 1555 | } |
| 1556 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1557 | return ret; |
| 1558 | } |
| 1559 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1560 | int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err) |
| 1561 | { |
| 1562 | int ret = 0; |
| 1563 | int handle = -1; |
| 1564 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1565 | if(g_lynq_qser_data_init_flag == 0) |
| 1566 | { |
| 1567 | if(err != NULL) |
| 1568 | { |
| 1569 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1570 | } |
| 1571 | return LYNQ_E_NO_INIT; |
| 1572 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1573 | if (NULL == err) |
| 1574 | { |
| 1575 | LYERRLOG("call stop incoming paramters error"); |
| 1576 | return ret; |
| 1577 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1578 | ret = data_call_handle_get(profile_idx,&handle); |
| 1579 | if(ret != 0) |
| 1580 | { |
| 1581 | LYERRLOG("datacall handle get error"); |
| 1582 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1583 | return ret; |
| 1584 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1585 | ret = lynq_deactive_data_call(&handle); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1586 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1587 | { |
| 1588 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1589 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1590 | } |
xy.he | e2daacc | 2023-09-18 00:57:51 -0700 | [diff] [blame] | 1591 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1592 | } |
| 1593 | int qser_data_call_info_get(char profile_idx,qser_data_call_ip_family_e ip_family,qser_data_call_info_s *info,qser_data_call_error_e *err) |
| 1594 | { |
| 1595 | int ret = 0; |
| 1596 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1597 | if(g_lynq_qser_data_init_flag == 0) |
| 1598 | { |
| 1599 | if(err != NULL) |
| 1600 | { |
| 1601 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1602 | } |
| 1603 | return LYNQ_E_NO_INIT; |
| 1604 | } |
xf.li | 4ab455d | 2024-07-30 01:21:56 -0700 | [diff] [blame] | 1605 | lynq_data_call_response_v11_t data_call_info = {0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1606 | data_call_handle_get(profile_idx,&handle); |
| 1607 | ret = lynq_get_data_call_list(&handle,&data_call_info); |
| 1608 | if (ret == 0) |
| 1609 | { |
| 1610 | info->profile_idx = profile_idx; |
| 1611 | info->ip_family = ip_family; |
xf.li | 157f7e9 | 2023-10-19 23:22:46 -0700 | [diff] [blame] | 1612 | if ((strncmp(data_call_info.type,"IPV4", strlen("IPV4") + 1) == 0) || (strncmp(data_call_info.type,"IP", strlen("IP") + 1) == 0)) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1613 | { |
xf.li | 0400b38 | 2024-06-05 19:20:36 -0700 | [diff] [blame] | 1614 | info->ip_family = QSER_DATA_CALL_TYPE_IPV4; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1615 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1616 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1617 | LYINFLOG("[IPV4]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1618 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
| 1619 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1620 | else if (strncmp(data_call_info.type,"IPV6", strlen("IPV6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1621 | { |
xf.li | 0400b38 | 2024-06-05 19:20:36 -0700 | [diff] [blame] | 1622 | info->ip_family = QSER_DATA_CALL_TYPE_IPV6; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1623 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1624 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1625 | LYINFLOG("[IPV6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1626 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
| 1627 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1628 | else if (strncmp(data_call_info.type,"IPV4V6", strlen("IPV4V6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1629 | { |
xf.li | 0400b38 | 2024-06-05 19:20:36 -0700 | [diff] [blame] | 1630 | info->ip_family = QSER_DATA_CALL_TYPE_IPV4V6; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1631 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1632 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1633 | LYINFLOG("[IPV4V6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1634 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1635 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1636 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1637 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1638 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1639 | LYINFLOG("[IPV4V6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1640 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1641 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1642 | #endif |
| 1643 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1644 | lynq_ipv4v6_inet_pton_getinfo(&data_call_info,info); |
| 1645 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1646 | } |
| 1647 | else |
| 1648 | { |
| 1649 | LYERRLOG("useless qser_data_call_ip_family_e"); |
| 1650 | } |
| 1651 | } |
| 1652 | return ret; |
| 1653 | } |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1654 | int check_pdp_type(qser_apn_pdp_type_e pdp_type) |
| 1655 | { |
| 1656 | switch (pdp_type) |
| 1657 | { |
| 1658 | case QSER_APN_PDP_TYPE_IPV4: |
| 1659 | case QSER_APN_PDP_TYPE_PPP: |
| 1660 | case QSER_APN_PDP_TYPE_IPV6: |
| 1661 | case QSER_APN_PDP_TYPE_IPV4V6: |
| 1662 | return 0; |
| 1663 | default: |
| 1664 | return -1; |
| 1665 | } |
| 1666 | } |
| 1667 | int check_auth_proto(qser_apn_auth_proto_e auth_proto) |
| 1668 | { |
| 1669 | switch (auth_proto) |
| 1670 | { |
| 1671 | case QSER_APN_AUTH_PROTO_DEFAULT: |
| 1672 | case QSER_APN_AUTH_PROTO_NONE: |
| 1673 | case QSER_APN_AUTH_PROTO_PAP: |
| 1674 | case QSER_APN_AUTH_PROTO_CHAP: |
| 1675 | case QSER_APN_AUTH_PROTO_PAP_CHAP: |
| 1676 | return 0; |
| 1677 | default: |
| 1678 | return -1; |
| 1679 | } |
| 1680 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1681 | int qser_apn_set(qser_apn_info_s *apn) |
| 1682 | { |
| 1683 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1684 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1685 | if(g_lynq_qser_data_init_flag == 0) |
| 1686 | { |
| 1687 | return LYNQ_E_NO_INIT; |
| 1688 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1689 | if (NULL == apn || apn->profile_idx == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1690 | { |
| 1691 | LYERRLOG("apn set incoming paramters error"); |
| 1692 | return RESULT_ERROR; |
| 1693 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1694 | ret = apn_db_handle_get(apn->profile_idx, &handle); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1695 | if(ret != 0) |
| 1696 | { |
| 1697 | LYERRLOG("handle set error"); |
| 1698 | } |
| 1699 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1700 | { |
| 1701 | LYERRLOG("It has setup datacall"); |
| 1702 | return RESULT_ERROR; |
| 1703 | } |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1704 | |
| 1705 | if(strlen(apn->apn_name) > QSER_APN_NAME_SIZE) |
| 1706 | { |
| 1707 | LYERRLOG("apn_name out of range\n"); |
| 1708 | return RESULT_ERROR; |
| 1709 | } |
| 1710 | if(strlen(apn->username) > QSER_APN_USERNAME_SIZE) |
| 1711 | { |
| 1712 | LYERRLOG("username out of range\n"); |
| 1713 | return RESULT_ERROR; |
| 1714 | } |
| 1715 | if(strlen(apn->password) > QSER_APN_PASSWORD_SIZE) |
| 1716 | { |
| 1717 | LYERRLOG("password out of range\n"); |
| 1718 | return RESULT_ERROR; |
| 1719 | } |
| 1720 | if(strlen(apn->apn_type) > QSER_APN_NAME_SIZE) |
| 1721 | { |
| 1722 | LYERRLOG("apn_type out of range\n"); |
| 1723 | return RESULT_ERROR; |
| 1724 | } |
| 1725 | if(check_pdp_type(apn->pdp_type) != 0) |
| 1726 | { |
| 1727 | LYERRLOG("pdp_type out of range\n"); |
| 1728 | return RESULT_ERROR; |
| 1729 | } |
| 1730 | if(check_auth_proto(apn->auth_proto) != 0) |
| 1731 | { |
| 1732 | LYERRLOG("auth_proto out of range\n"); |
| 1733 | return RESULT_ERROR; |
| 1734 | } |
| 1735 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1736 | ret = apn_db_modify(apn); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1737 | if (ret < 0) |
| 1738 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1739 | LYERRLOG("apn_db_modify error"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1740 | return ret; |
| 1741 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1742 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1743 | int apn_id = 0; |
| 1744 | char tmp_id[12]; |
| 1745 | char *outinfo = NULL; |
| 1746 | char normalprotocol[16]; |
| 1747 | char authtype[32]; |
| 1748 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1749 | bzero(tmp_id,12); |
| 1750 | bzero(outinfo,512); |
| 1751 | apn_id = apn->profile_idx + apndb_offset; |
| 1752 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1753 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1754 | judge_authtype(apn->auth_proto,authtype); |
| 1755 | lynq_modify_apn_db(3,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1756 | LYINFLOG("[output]:%s",outinfo); |
| 1757 | free(outinfo); |
| 1758 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1759 | #endif |
| 1760 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1761 | } |
| 1762 | |
| 1763 | int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn) |
| 1764 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1765 | if(g_lynq_qser_data_init_flag == 0) |
| 1766 | { |
| 1767 | return LYNQ_E_NO_INIT; |
| 1768 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1769 | if (profile_idx < 0 || profile_idx > QSER_APN_MAX_LIST || NULL == apn) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1770 | { |
| 1771 | LYERRLOG("apn get incoming paramters error"); |
| 1772 | return RESULT_ERROR; |
| 1773 | } |
| 1774 | int ret = 0; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1775 | ret = apn_db_query(profile_idx,apn); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1776 | if (ret < 0) |
| 1777 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1778 | LYERRLOG("apn_db_query error"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1779 | return ret; |
| 1780 | } |
| 1781 | return ret; |
| 1782 | } |
| 1783 | |
| 1784 | int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx) |
| 1785 | { |
| 1786 | int ret = 0; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1787 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1788 | if(g_lynq_qser_data_init_flag == 0) |
| 1789 | { |
| 1790 | return LYNQ_E_NO_INIT; |
| 1791 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1792 | if (NULL == apn || NULL == profile_idx) |
| 1793 | { |
| 1794 | LYERRLOG("apn add incoming paramters error"); |
| 1795 | return RESULT_ERROR; |
| 1796 | } |
xf.li | fb6134e | 2024-05-09 01:26:54 -0700 | [diff] [blame] | 1797 | |
| 1798 | if(strlen(apn->apn_name) > QSER_APN_NAME_SIZE) |
| 1799 | { |
| 1800 | LYERRLOG("apn_name out of range\n"); |
| 1801 | return RESULT_ERROR; |
| 1802 | } |
| 1803 | if(strlen(apn->username) > QSER_APN_USERNAME_SIZE) |
| 1804 | { |
| 1805 | LYERRLOG("username out of range\n"); |
| 1806 | return RESULT_ERROR; |
| 1807 | } |
| 1808 | if(strlen(apn->password) > QSER_APN_PASSWORD_SIZE) |
| 1809 | { |
| 1810 | LYERRLOG("password out of range\n"); |
| 1811 | return RESULT_ERROR; |
| 1812 | } |
| 1813 | if(strlen(apn->apn_type) > QSER_APN_NAME_SIZE) |
| 1814 | { |
| 1815 | LYERRLOG("apn_type out of range\n"); |
| 1816 | return RESULT_ERROR; |
| 1817 | } |
| 1818 | if(check_pdp_type(apn->pdp_type) != 0) |
| 1819 | { |
| 1820 | LYERRLOG("pdp_type out of range\n"); |
| 1821 | return RESULT_ERROR; |
| 1822 | } |
| 1823 | if(check_auth_proto(apn->auth_proto) != 0) |
| 1824 | { |
| 1825 | LYERRLOG("auth_proto out of range\n"); |
| 1826 | return RESULT_ERROR; |
| 1827 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1828 | |
| 1829 | *profile_idx = 0; |
| 1830 | *profile_idx = (unsigned char)find_unuse_apn_index(APN_DB_PATH); |
| 1831 | LYINFLOG("[%s] id = %d\n",__FUNCTION__,(int)*profile_idx); |
| 1832 | if((int)*profile_idx > 0 && (int)*profile_idx < QSER_APN_MAX_LIST) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1833 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1834 | LYINFLOG("[%s] apn full is false\n",__FUNCTION__); |
| 1835 | ret = apn_db_add((int)*profile_idx, apn); |
| 1836 | if (ret != 0) |
| 1837 | { |
| 1838 | LYERRLOG("apn_db_add error"); |
| 1839 | return RESULT_ERROR; |
| 1840 | } |
| 1841 | else |
| 1842 | { |
| 1843 | return RESULT_OK; |
| 1844 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1845 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1846 | LYERRLOG("apn storage space is full!!!"); |
| 1847 | return RESULT_ERROR; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1848 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1849 | int apn_id = 0; |
| 1850 | char tmp_id[12]; |
| 1851 | char *outinfo = NULL; |
| 1852 | char normalprotocol[16]; |
| 1853 | char authtype[32]; |
| 1854 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1855 | bzero(tmp_id,12); |
| 1856 | bzero(outinfo,512); |
| 1857 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1858 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1859 | judge_authtype(apn->auth_proto,authtype); |
| 1860 | lynq_modify_apn_db(0,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1861 | LYINFLOG("[output]:%s",outinfo); |
| 1862 | free(outinfo); |
| 1863 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1864 | #endif |
| 1865 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1866 | } |
| 1867 | |
| 1868 | int qser_apn_del(unsigned char profile_idx) |
| 1869 | { |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1870 | int ret = 0; |
| 1871 | int handle = -1; |
| 1872 | |
| 1873 | LYINFLOG("[%s] entry\n",__FUNCTION__); |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1874 | if(g_lynq_qser_data_init_flag == 0) |
| 1875 | { |
| 1876 | return LYNQ_E_NO_INIT; |
| 1877 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1878 | if (profile_idx <= 0 || profile_idx > QSER_APN_MAX_LIST) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1879 | { |
| 1880 | LYERRLOG("apn del incoming paramters error"); |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1881 | return RESULT_ERROR; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1882 | } |
xf.li | 87f6e6e | 2024-06-19 02:23:05 -0700 | [diff] [blame] | 1883 | |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1884 | ret = apn_db_handle_get(profile_idx, &handle); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1885 | if(ret != 0) |
| 1886 | { |
| 1887 | LYERRLOG("handle set error"); |
| 1888 | } |
| 1889 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1890 | { |
| 1891 | LYERRLOG("It has setup datacall"); |
| 1892 | return RESULT_ERROR; |
| 1893 | } |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1894 | ret = apn_db_delete(profile_idx); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1895 | if (ret < 0) |
| 1896 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1897 | LYERRLOG("apn_db_delete error"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1898 | return ret; |
| 1899 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1900 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1901 | int apn_id = 0; |
| 1902 | char tmp_id[12]; |
| 1903 | char *outinfo = NULL; |
| 1904 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1905 | bzero(tmp_id,12); |
| 1906 | bzero(outinfo,512); |
| 1907 | apn_id = profile_idx+apndb_offset; |
| 1908 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1909 | lynq_modify_apn_db(1,tmp_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,outinfo); |
| 1910 | LYINFLOG("[output]:%s",outinfo); |
| 1911 | free(outinfo); |
| 1912 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1913 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1914 | return ret; |
| 1915 | } |
| 1916 | |
| 1917 | int qser_apn_get_list(qser_apn_info_list_s *apn_list) |
| 1918 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1919 | if(g_lynq_qser_data_init_flag == 0) |
| 1920 | { |
| 1921 | return LYNQ_E_NO_INIT; |
| 1922 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1923 | if (NULL == apn_list) |
| 1924 | { |
| 1925 | LYERRLOG("apn_list incoming paramters error"); |
| 1926 | return RESULT_ERROR; |
| 1927 | } |
| 1928 | int ret = 0; |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1929 | ret = apn_db_query_list(apn_list); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1930 | if (ret < 0) |
| 1931 | { |
xf.li | cb6cd28 | 2024-02-21 22:06:14 -0800 | [diff] [blame] | 1932 | LYERRLOG("apn_db_query_list error"); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1933 | return ret; |
| 1934 | } |
| 1935 | return ret; |
xf.li | 3f891cb | 2023-08-23 23:11:24 -0700 | [diff] [blame] | 1936 | } |
you.chen | 21c62b7 | 2023-09-08 09:41:11 +0800 | [diff] [blame] | 1937 | |
| 1938 | DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_DATA) |
| 1939 | |