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> |
| 12 | #include <libxml/tree.h> |
| 13 | #include <libxml/parser.h> |
| 14 | #include "lynq-qser-data.h" |
| 15 | |
| 16 | #define USER_LOG_TAG "LYNQ_QSER_DATA" |
| 17 | |
| 18 | #define RESULT_OK (0) |
| 19 | #define RESULT_ERROR (-1) |
| 20 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 21 | typedef enum{ |
| 22 | LYNQ_E_NO_INIT=9002 |
| 23 | }LYNQ_E; |
| 24 | |
| 25 | static int g_lynq_qser_data_init_flag = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 26 | static pthread_t s_cb_tid = -1; |
| 27 | static int s_qser_data_cb_thread_status = 0; |
| 28 | static pthread_mutex_t s_qser_data_cb_mutex = PTHREAD_MUTEX_INITIALIZER; |
| 29 | static pthread_cond_t s_qser_data_cb_cond = PTHREAD_COND_INITIALIZER; |
| 30 | |
xf.li | 807fd13 | 2023-07-02 02:45:36 -0700 | [diff] [blame] | 31 | #define data_xml_path "/mnt/userdata/lynq_qser_data_apn.xml" |
xf.li | 7b0bfd0 | 2023-08-03 01:11:52 -0700 | [diff] [blame] | 32 | #define COPY_XML_RETRY_TIMES 3 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 33 | |
| 34 | static qser_data_call_evt_cb_t s_data_call_cb = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 35 | static xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 36 | const int apndb_offset = 683; |
| 37 | |
| 38 | void lynq_ipv4_aton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 39 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 40 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 41 | char *tmp_char = NULL; |
| 42 | char *addresses = NULL; |
| 43 | char *dnses = NULL; |
| 44 | const char addresses_separator[2] = "/"; |
| 45 | const char dnses_separator[2] = " "; |
| 46 | |
| 47 | addresses = libdata->addresses; |
| 48 | dnses = libdata->dnses; |
| 49 | //get addresses |
| 50 | tmp_char = strsep(&addresses, addresses_separator); |
| 51 | if(tmp_char != NULL) |
| 52 | { |
| 53 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 54 | inet_aton(tmp_char,&(data_res->v4.ip)); |
| 55 | } |
| 56 | |
| 57 | //get dnses |
| 58 | tmp_char = strsep(&dnses, dnses_separator); |
| 59 | if(tmp_char != NULL) |
| 60 | { |
| 61 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 62 | inet_aton(tmp_char,&(data_res->v4.pri_dns)); |
| 63 | } |
| 64 | tmp_char = strsep(&dnses, dnses_separator); |
| 65 | if(tmp_char != NULL) |
| 66 | { |
| 67 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 68 | inet_aton(tmp_char, &(data_res->v4.sec_dns)); |
| 69 | } |
| 70 | //get gateway |
| 71 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 72 | |
| 73 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 74 | inet_aton(libdata->addresses,&(data_res->v4.ip)); |
| 75 | inet_aton(libdata->gateways,&(data_res->v4.gateway)); |
| 76 | inet_aton(libdata->dnses,&(data_res->v4.pri_dns)); |
| 77 | inet_aton(libdata->dnses,&(data_res->v4.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 78 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 79 | return ; |
| 80 | } |
| 81 | |
| 82 | void lynq_ipv6_inet_pton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 83 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 84 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 85 | char *tmp_char = NULL; |
| 86 | char *addresses = NULL; |
| 87 | char *dnses = NULL; |
| 88 | const char addresses_separator[2] = "/"; |
| 89 | const char dnses_separator[2] = " "; |
| 90 | |
| 91 | addresses = libdata->addresses; |
| 92 | dnses = libdata->dnses; |
| 93 | //get addresses |
| 94 | tmp_char = strsep(&addresses, addresses_separator); |
| 95 | if(tmp_char != NULL) |
| 96 | { |
| 97 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 98 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.ip)); |
| 99 | } |
| 100 | //get dnses |
| 101 | tmp_char = strsep(&dnses, dnses_separator); |
| 102 | if(tmp_char != NULL) |
| 103 | { |
| 104 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 105 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.pri_dns)); |
| 106 | } |
| 107 | tmp_char = strsep(&dnses, dnses_separator); |
| 108 | if(tmp_char != NULL) |
| 109 | { |
| 110 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 111 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.sec_dns)); |
| 112 | } |
| 113 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 114 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 115 | inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.ip)); |
| 116 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 117 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.pri_dns)); |
| 118 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 119 | #endif |
| 120 | |
| 121 | return ; |
| 122 | } |
| 123 | |
| 124 | void lynq_ipv4v6_inet_pton_urc(lynq_data_call_response_v11_t *libdata,qser_data_call_state_s *data_res) |
| 125 | { |
| 126 | char *tmp_char = NULL; |
| 127 | char *addresses = NULL; |
| 128 | char *dnses = NULL; |
| 129 | const char addresses_separator[2] = "/"; |
| 130 | const char dnses_separator[2] = " "; |
| 131 | |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 132 | char buf_ip[64] = {0}; |
| 133 | char buf_gateway[64] = {0}; |
| 134 | char buf_pri_dns[64] = {0}; |
| 135 | char buf_sec_dns[64] = {0}; |
| 136 | |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 137 | addresses = libdata->addresses; |
| 138 | dnses = libdata->dnses; |
| 139 | //get addresses |
| 140 | tmp_char = strsep(&addresses, addresses_separator); |
| 141 | if(tmp_char != NULL) |
| 142 | { |
| 143 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 144 | inet_aton(tmp_char,&(data_res->v4.ip)); |
| 145 | } |
| 146 | tmp_char = strsep(&addresses, addresses_separator); |
| 147 | if(tmp_char != NULL) |
| 148 | { |
| 149 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 150 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.ip)); |
| 151 | } |
| 152 | //get dnses |
| 153 | tmp_char = strsep(&dnses, dnses_separator); |
| 154 | if(tmp_char != NULL) |
| 155 | { |
| 156 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 157 | inet_aton(tmp_char,&(data_res->v4.pri_dns)); |
| 158 | } |
| 159 | tmp_char = strsep(&dnses, dnses_separator); |
| 160 | if(tmp_char != NULL) |
| 161 | { |
| 162 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 163 | inet_aton(tmp_char, &(data_res->v4.sec_dns)); |
| 164 | } |
| 165 | tmp_char = strsep(&dnses, dnses_separator); |
| 166 | if(tmp_char != NULL) |
| 167 | { |
| 168 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 169 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.pri_dns)); |
| 170 | } |
| 171 | tmp_char = strsep(&dnses, dnses_separator); |
| 172 | if(tmp_char != NULL) |
| 173 | { |
| 174 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 175 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.sec_dns)); |
| 176 | } |
| 177 | //get gateway |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 178 | inet_aton(libdata->gateways,&(data_res->v4.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 179 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.gateway)); |
| 180 | |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 181 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.ip)); |
| 182 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.pri_dns)); |
| 183 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.sec_dns)); |
| 184 | |
| 185 | inet_ntop(AF_INET6, &(data_res->v6.ip), buf_ip, sizeof(buf_ip)); |
| 186 | inet_ntop(AF_INET6, &(data_res->v6.gateway), buf_gateway, sizeof(buf_gateway)); |
| 187 | inet_ntop(AF_INET6, &(data_res->v6.pri_dns), buf_pri_dns, sizeof(buf_pri_dns)); |
| 188 | inet_ntop(AF_INET6, &(data_res->v6.sec_dns), buf_sec_dns, sizeof(buf_sec_dns)); |
| 189 | LYINFLOG("v6.ip=%s, v6.gateway=%s, v6.pri_dns=%s, v6.sec_dns=%s\n" |
| 190 | , buf_ip, buf_gateway, buf_pri_dns, buf_sec_dns); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 191 | return ; |
| 192 | } |
| 193 | |
| 194 | void lynq_ipv4_aton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 195 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 196 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 197 | char *tmp_char = NULL; |
| 198 | char *addresses = NULL; |
| 199 | char *dnses = NULL; |
| 200 | const char addresses_separator[2] = "/"; |
| 201 | const char dnses_separator[2] = " "; |
| 202 | |
| 203 | addresses = libdata->addresses; |
| 204 | dnses = libdata->dnses; |
| 205 | //get addresses |
| 206 | tmp_char = strsep(&addresses, addresses_separator); |
| 207 | if(tmp_char != NULL) |
| 208 | { |
| 209 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 210 | inet_aton(tmp_char,&(data_res->v4.addr.ip)); |
| 211 | } |
| 212 | //get dnses |
| 213 | tmp_char = strsep(&dnses, dnses_separator); |
| 214 | if(tmp_char != NULL) |
| 215 | { |
| 216 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 217 | inet_aton(tmp_char,&(data_res->v4.addr.pri_dns)); |
| 218 | } |
| 219 | tmp_char = strsep(&dnses, dnses_separator); |
| 220 | if(tmp_char != NULL) |
| 221 | { |
| 222 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 223 | inet_aton(tmp_char, &(data_res->v4.addr.sec_dns)); |
| 224 | } |
| 225 | //get gateway |
| 226 | LYINFLOG("ipv4 gateways = %s", libdata->gateways); |
| 227 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
| 228 | |
| 229 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.addr.ip)); |
| 230 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.addr.pri_dns)); |
| 231 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.addr.sec_dns)); |
| 232 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 233 | inet_aton(libdata->addresses,&(data_res->v4.addr.ip)); |
| 234 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
| 235 | inet_aton(libdata->dnses,&(data_res->v4.addr.pri_dns)); |
| 236 | inet_aton(libdata->dnses,&(data_res->v4.addr.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 237 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 238 | data_res->v4.stats.pkts_tx = 0; |
| 239 | data_res->v4.stats.pkts_rx = 0; |
| 240 | data_res->v4.stats.bytes_tx = 0; |
| 241 | data_res->v4.stats.bytes_rx = 0; |
| 242 | data_res->v4.stats.pkts_dropped_tx = 0; |
| 243 | data_res->v4.stats.pkts_dropped_rx = 0; |
| 244 | return ; |
| 245 | } |
| 246 | |
| 247 | void lynq_ipv6_inet_pton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 248 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 249 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 250 | char *tmp_char = NULL; |
| 251 | char *addresses = NULL; |
| 252 | char *dnses = NULL; |
| 253 | const char addresses_separator[2] = "/"; |
| 254 | const char dnses_separator[2] = " "; |
| 255 | |
| 256 | addresses = libdata->addresses; |
| 257 | dnses = libdata->dnses; |
| 258 | //get addresses |
| 259 | tmp_char = strsep(&addresses, addresses_separator); |
| 260 | if(tmp_char != NULL) |
| 261 | { |
| 262 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 263 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.ip)); |
| 264 | } |
| 265 | //get dnses |
| 266 | tmp_char = strsep(&dnses, dnses_separator); |
| 267 | if(tmp_char != NULL) |
| 268 | { |
| 269 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 270 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.pri_dns)); |
| 271 | } |
| 272 | tmp_char = strsep(&dnses, dnses_separator); |
| 273 | if(tmp_char != NULL) |
| 274 | { |
| 275 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 276 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.sec_dns)); |
| 277 | } |
| 278 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 279 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 280 | inet_pton(AF_INET6,libdata->addresses,&(data_res->v6.addr.ip)); |
| 281 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 282 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.pri_dns)); |
| 283 | inet_pton(AF_INET6,libdata->dnses,&(data_res->v6.addr.sec_dns)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 284 | #endif |
| 285 | data_res->v6.stats.pkts_tx = 0; |
| 286 | data_res->v6.stats.pkts_rx = 0; |
| 287 | data_res->v6.stats.bytes_tx = 0; |
| 288 | data_res->v6.stats.bytes_rx = 0; |
| 289 | data_res->v6.stats.pkts_dropped_tx = 0; |
| 290 | data_res->v6.stats.pkts_dropped_rx = 0; |
| 291 | return ; |
| 292 | } |
| 293 | void lynq_ipv4v6_inet_pton_getinfo(lynq_data_call_response_v11_t *libdata,qser_data_call_info_s *data_res) |
| 294 | { |
| 295 | char *tmp_char = NULL; |
| 296 | char *addresses = NULL; |
| 297 | char *dnses = NULL; |
| 298 | const char addresses_separator[2] = "/"; |
| 299 | const char dnses_separator[2] = " "; |
| 300 | |
| 301 | char buf_ip[64] = {0}; |
| 302 | char buf_gateway[64] = {0}; |
| 303 | char buf_pri_dns[64] = {0}; |
| 304 | char buf_sec_dns[64] = {0}; |
| 305 | |
| 306 | addresses = libdata->addresses; |
| 307 | dnses = libdata->dnses; |
| 308 | //get addresses |
| 309 | tmp_char = strsep(&addresses, addresses_separator); |
| 310 | if(tmp_char != NULL) |
| 311 | { |
| 312 | LYINFLOG("ipv4 addresses = %s", tmp_char); |
| 313 | inet_aton(tmp_char,&(data_res->v4.addr.ip)); |
| 314 | } |
| 315 | tmp_char = strsep(&addresses, addresses_separator); |
| 316 | if(tmp_char != NULL) |
| 317 | { |
| 318 | LYINFLOG("ipv6 addresses = %s", tmp_char); |
| 319 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.ip)); |
| 320 | } |
| 321 | //get dnses |
| 322 | tmp_char = strsep(&dnses, dnses_separator); |
| 323 | if(tmp_char != NULL) |
| 324 | { |
| 325 | LYINFLOG("ipv4 pri_dns = %s", tmp_char); |
| 326 | inet_aton(tmp_char,&(data_res->v4.addr.pri_dns)); |
| 327 | } |
| 328 | tmp_char = strsep(&dnses, dnses_separator); |
| 329 | if(tmp_char != NULL) |
| 330 | { |
| 331 | LYINFLOG("ipv4 sec_dns = %s", tmp_char); |
| 332 | inet_aton(tmp_char, &(data_res->v4.addr.sec_dns)); |
| 333 | } |
| 334 | tmp_char = strsep(&dnses, dnses_separator); |
| 335 | if(tmp_char != NULL) |
| 336 | { |
| 337 | LYINFLOG("ipv6 pri_dns = %s", tmp_char); |
| 338 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.pri_dns)); |
| 339 | } |
| 340 | tmp_char = strsep(&dnses, dnses_separator); |
| 341 | if(tmp_char != NULL) |
| 342 | { |
| 343 | LYINFLOG("ipv6 sec_dns = %s", tmp_char); |
| 344 | inet_pton(AF_INET6, tmp_char, &(data_res->v6.addr.sec_dns)); |
| 345 | } |
| 346 | //get gateway |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 347 | inet_aton(libdata->gateways,&(data_res->v4.addr.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 348 | inet_pton(AF_INET6,libdata->gateways,&(data_res->v6.addr.gateway)); |
| 349 | |
| 350 | LYINFLOG("v4.ip=%s", inet_ntoa(data_res->v4.addr.ip)); |
xf.li | 03baf1f | 2023-12-19 21:30:38 -0800 | [diff] [blame] | 351 | LYINFLOG("ipv4 gateways = %s", inet_ntoa(data_res->v4.addr.gateway)); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 352 | LYINFLOG("v4.pri_dns=%s", inet_ntoa(data_res->v4.addr.pri_dns)); |
| 353 | LYINFLOG("v4.sec_dns=%s", inet_ntoa(data_res->v4.addr.sec_dns)); |
| 354 | |
| 355 | inet_ntop(AF_INET6, &(data_res->v6.addr.ip), buf_ip, sizeof(buf_ip)); |
| 356 | inet_ntop(AF_INET6, &(data_res->v6.addr.gateway), buf_gateway, sizeof(buf_gateway)); |
| 357 | inet_ntop(AF_INET6, &(data_res->v6.addr.pri_dns), buf_pri_dns, sizeof(buf_pri_dns)); |
| 358 | inet_ntop(AF_INET6, &(data_res->v6.addr.sec_dns), buf_sec_dns, sizeof(buf_sec_dns)); |
| 359 | LYINFLOG("v6.ip=%s, v6.gateway=%s, v6.pri_dns=%s, v6.sec_dns=%s\n" |
| 360 | , buf_ip, buf_gateway, buf_pri_dns, buf_sec_dns); |
| 361 | data_res->v4.stats.pkts_tx = 0; |
| 362 | data_res->v4.stats.pkts_rx = 0; |
| 363 | data_res->v4.stats.bytes_tx = 0; |
| 364 | data_res->v4.stats.bytes_rx = 0; |
| 365 | data_res->v4.stats.pkts_dropped_tx = 0; |
| 366 | data_res->v4.stats.pkts_dropped_rx = 0; |
| 367 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 368 | data_res->v6.stats.pkts_tx = 0; |
| 369 | data_res->v6.stats.pkts_rx = 0; |
| 370 | data_res->v6.stats.bytes_tx = 0; |
| 371 | data_res->v6.stats.bytes_rx = 0; |
| 372 | data_res->v6.stats.pkts_dropped_tx = 0; |
| 373 | data_res->v6.stats.pkts_dropped_rx = 0; |
| 374 | return ; |
| 375 | } |
| 376 | |
| 377 | void datacall_ipv4_status_judge(int state,qser_data_call_info_s *data_res) |
| 378 | { |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 379 | if(state != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 380 | { |
| 381 | data_res->v4.state = QSER_DATA_CALL_CONNECTED; |
| 382 | data_res->v4.reconnect = 1; |
| 383 | } |
| 384 | else |
| 385 | { |
| 386 | data_res->v4.state = QSER_DATA_CALL_DISCONNECTED; |
| 387 | data_res->v4.reconnect = 0; |
| 388 | } |
| 389 | return ; |
| 390 | } |
| 391 | |
| 392 | void datacall_ipv6_status_judge(int state,qser_data_call_info_s *data_res) |
| 393 | { |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 394 | if(state != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 395 | { |
| 396 | data_res->v6.state = QSER_DATA_CALL_CONNECTED; |
| 397 | data_res->v6.reconnect = 1; |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | data_res->v6.state = QSER_DATA_CALL_DISCONNECTED; |
| 402 | data_res->v6.reconnect = 0; |
| 403 | } |
| 404 | return ; |
| 405 | } |
| 406 | |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 407 | int apn_xml_handle_get_profile(int handle, unsigned char *profile_idx) |
| 408 | { |
| 409 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
| 410 | xmlNodePtr node = NULL; |
| 411 | xmlNodePtr modify_node = NULL; |
| 412 | unsigned char temp = NULL; |
| 413 | //apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 414 | if(NULL == apn_table_xml_pdoc) |
| 415 | { |
| 416 | LYERRLOG("open xml file error"); |
| 417 | goto FAILED; |
| 418 | } |
| 419 | |
| 420 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
| 421 | if (NULL == node) |
| 422 | { |
| 423 | LYERRLOG("xmlDocGetRootElement() error"); |
| 424 | goto FAILED; |
| 425 | } |
| 426 | modify_node = node->xmlChildrenNode; |
| 427 | if(modify_node != NULL) |
| 428 | { |
| 429 | modify_node = modify_node->next; |
| 430 | } |
| 431 | else |
| 432 | { |
| 433 | LYERRLOG("modify_node is null\n"); |
| 434 | goto FAILED; |
| 435 | } |
| 436 | for (;;) |
| 437 | { |
| 438 | if(modify_node == NULL) |
| 439 | { |
| 440 | LYERRLOG("modify_node is null\n"); |
| 441 | goto FAILED; |
| 442 | } |
| 443 | if (xmlGetProp(modify_node, "handle") == NULL) //Null Node |
| 444 | { |
| 445 | modify_node = modify_node->next; |
| 446 | continue; |
| 447 | } |
| 448 | else if((int)atoi(xmlGetProp(modify_node, "handle")) == handle) |
| 449 | { |
| 450 | break; |
| 451 | } |
| 452 | modify_node = modify_node->next; |
| 453 | } |
| 454 | if(modify_node == NULL) |
| 455 | { |
| 456 | LYERRLOG("modify_node is null\n"); |
| 457 | goto FAILED; |
| 458 | } |
| 459 | *profile_idx = (unsigned char)atoi(xmlGetProp(modify_node, "profile_idx")); |
| 460 | //xmlFreeDoc(apn_table_xml_pdoc); |
| 461 | return RESULT_OK; |
| 462 | |
| 463 | FAILED: |
| 464 | // if (apn_table_xml_pdoc) |
| 465 | // { |
| 466 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 467 | // } |
| 468 | return RESULT_ERROR; |
| 469 | } |
| 470 | int apn_xml_handle_set(unsigned char profile_idx, int handle) |
| 471 | { |
| 472 | int node_num = 0; |
| 473 | char temp_buff[12]; |
| 474 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
| 475 | xmlNodePtr node = NULL; |
| 476 | xmlNodePtr modify_node = NULL; |
| 477 | xmlNodePtr check_node = NULL; |
| 478 | //apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 479 | if(NULL == apn_table_xml_pdoc) |
| 480 | { |
| 481 | LYERRLOG("open xml file error"); |
| 482 | goto FAILED; |
| 483 | } |
| 484 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
| 485 | if (NULL == node) |
| 486 | { |
| 487 | LYERRLOG("xmlDocGetRootElement() error"); |
| 488 | goto FAILED; |
| 489 | } |
| 490 | modify_node = node->xmlChildrenNode; |
| 491 | if(modify_node != NULL) |
| 492 | { |
| 493 | modify_node = modify_node->next; |
| 494 | } |
| 495 | else |
| 496 | { |
| 497 | LYERRLOG("modify_node is null\n"); |
| 498 | goto FAILED; |
| 499 | } |
| 500 | for (;;) |
| 501 | { |
| 502 | if(modify_node == NULL) |
| 503 | { |
| 504 | LYERRLOG("modify_node is null\n"); |
| 505 | goto FAILED; |
| 506 | } |
| 507 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 508 | { |
| 509 | modify_node = modify_node->next; |
| 510 | node_num--; |
| 511 | continue; |
| 512 | } |
| 513 | else if((int)atoi(xmlGetProp(modify_node, "profile_idx")) == (int)profile_idx) |
| 514 | { |
| 515 | break; |
| 516 | } |
| 517 | modify_node = modify_node->next; |
| 518 | } |
| 519 | if(modify_node == NULL) |
| 520 | { |
| 521 | LYERRLOG("modify_node is null\n"); |
| 522 | goto FAILED; |
| 523 | } |
| 524 | bzero(temp_buff,12); |
| 525 | snprintf(temp_buff,sizeof(temp_buff),"%d",handle); |
| 526 | xmlSetProp(modify_node,BAD_CAST"handle",(xmlChar *)temp_buff); |
| 527 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 528 | //xmlFreeDoc(apn_table_xml_pdoc); |
| 529 | return RESULT_OK; |
| 530 | |
| 531 | FAILED: |
| 532 | // if (apn_table_xml_pdoc) |
| 533 | // { |
| 534 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 535 | // } |
| 536 | return RESULT_ERROR; |
| 537 | } |
| 538 | int apn_xml_handle_get(unsigned char profile_idx, int *handle) |
| 539 | { |
| 540 | int node_num = 0; |
| 541 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
| 542 | xmlNodePtr node = NULL; |
| 543 | xmlNodePtr modify_node = NULL; |
| 544 | unsigned char temp = NULL; |
| 545 | //apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 546 | if(NULL == apn_table_xml_pdoc) |
| 547 | { |
| 548 | LYERRLOG("open xml file error"); |
| 549 | goto FAILED; |
| 550 | } |
| 551 | |
| 552 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
| 553 | if (NULL == node) |
| 554 | { |
| 555 | LYERRLOG("xmlDocGetRootElement() error"); |
| 556 | goto FAILED; |
| 557 | } |
| 558 | modify_node = node->xmlChildrenNode; |
| 559 | if(modify_node != NULL) |
| 560 | { |
| 561 | modify_node = modify_node->next; |
| 562 | } |
| 563 | else |
| 564 | { |
| 565 | LYERRLOG("modify_node is null\n"); |
| 566 | goto FAILED; |
| 567 | } |
| 568 | LYINFLOG("profile_idx is %d\n", (int)profile_idx); |
| 569 | for (;;) |
| 570 | { |
| 571 | if(modify_node == NULL) |
| 572 | { |
| 573 | LYERRLOG("modify_node is null\n"); |
| 574 | goto FAILED; |
| 575 | } |
| 576 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 577 | { |
| 578 | modify_node = modify_node->next; |
| 579 | node_num--; |
| 580 | continue; |
| 581 | } |
| 582 | else if((int)atoi(xmlGetProp(modify_node, "profile_idx")) == (int)profile_idx) |
| 583 | { |
| 584 | break; |
| 585 | } |
| 586 | modify_node = modify_node->next; |
| 587 | } |
| 588 | if(modify_node == NULL) |
| 589 | { |
| 590 | LYERRLOG("modify_node is null\n"); |
| 591 | goto FAILED; |
| 592 | } |
| 593 | *handle = (int)atoi(xmlGetProp(modify_node, "handle")); |
| 594 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 595 | //xmlFreeDoc(apn_table_xml_pdoc); |
| 596 | return RESULT_OK; |
| 597 | |
| 598 | FAILED: |
| 599 | // if (apn_table_xml_pdoc) |
| 600 | // { |
| 601 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 602 | // } |
| 603 | return RESULT_ERROR; |
| 604 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 605 | |
| 606 | int apn_xml_add(qser_apn_add_s *apn,unsigned char *apn_num) |
| 607 | { |
| 608 | int node_num = 0; |
| 609 | char temp_buff[12]; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 610 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 611 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 612 | xmlNodePtr node = NULL; |
| 613 | xmlNodePtr tmp_node = NULL; |
| 614 | xmlNodePtr sum_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 615 | |
| 616 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 617 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 618 | { |
| 619 | LYERRLOG("open xml file error"); |
| 620 | goto FAILED; |
| 621 | } |
| 622 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 623 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 624 | if (NULL == node) |
| 625 | { |
| 626 | LYERRLOG("xmlDocGetRootElement() error"); |
| 627 | goto FAILED; |
| 628 | } |
| 629 | sum_node = node->xmlChildrenNode; |
| 630 | sum_node = sum_node->next; |
| 631 | while (sum_node != NULL) |
| 632 | { |
| 633 | if (xmlGetProp(sum_node, "profile_idx") == NULL) //Null Node |
| 634 | { |
| 635 | sum_node = sum_node->next; |
| 636 | continue; |
| 637 | } |
xf.li | f7c68e3 | 2023-10-10 23:18:42 -0700 | [diff] [blame] | 638 | else if(strcmp((char *)xmlGetProp(sum_node, "apn_type"), apn->apn_type) == 0) |
| 639 | { |
| 640 | LYERRLOG("apntype already exists\n"); |
| 641 | goto FAILED; |
| 642 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 643 | node_num++; |
| 644 | sum_node = sum_node->next; |
| 645 | } |
xf.li | 3f891cb | 2023-08-23 23:11:24 -0700 | [diff] [blame] | 646 | LYINFLOG("apn_num = %d ",node_num); |
| 647 | if(node_num >= QSER_APN_MAX_LIST) |
| 648 | { |
| 649 | LYERRLOG("apn num reached the max"); |
| 650 | goto FAILED; |
| 651 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 652 | tmp_node = xmlNewNode(NULL,BAD_CAST"apn"); |
| 653 | *apn_num = node_num; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 654 | bzero(temp_buff,12); |
| 655 | snprintf(temp_buff,sizeof(temp_buff),"%d",*apn_num); |
| 656 | xmlNewProp(tmp_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 657 | bzero(temp_buff,12); |
| 658 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type); |
| 659 | xmlNewProp(tmp_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff); |
| 660 | bzero(temp_buff,12); |
| 661 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto); |
| 662 | xmlNewProp(tmp_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff); |
| 663 | xmlNewProp(tmp_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name); |
| 664 | xmlNewProp(tmp_node,BAD_CAST"username",(xmlChar *)apn->username); |
| 665 | xmlNewProp(tmp_node,BAD_CAST"password",(xmlChar *)apn->password); |
| 666 | xmlNewProp(tmp_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 667 | bzero(temp_buff,12); |
| 668 | snprintf(temp_buff,sizeof(temp_buff),"%d",default_handle); |
| 669 | xmlNewProp(tmp_node,BAD_CAST"handle",(xmlChar *)temp_buff); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 670 | xmlAddChild(node,tmp_node); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 671 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 672 | |
| 673 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 674 | return RESULT_OK; |
| 675 | |
| 676 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 677 | /* if (apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 678 | { |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 679 | xmlFreeDoc(apn_table_xml_pdoc); |
| 680 | }*/ |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 681 | return RESULT_ERROR; |
| 682 | } |
| 683 | |
| 684 | int apn_xml_delete(unsigned char profile_idx) |
| 685 | { |
| 686 | int node_num = 0; |
| 687 | char temp_buff[12]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 688 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 689 | xmlNodePtr node = NULL; |
| 690 | xmlNodePtr modify_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 691 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 692 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 693 | { |
| 694 | LYERRLOG("open xml file error"); |
| 695 | goto FAILED; |
| 696 | } |
| 697 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 698 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 699 | if (NULL == node) |
| 700 | { |
| 701 | LYERRLOG("xmlDocGetRootElement() error"); |
| 702 | goto FAILED; |
| 703 | } |
| 704 | modify_node = node->xmlChildrenNode; |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 705 | if(modify_node != NULL) |
| 706 | { |
| 707 | modify_node = modify_node->next; |
| 708 | } |
| 709 | else |
| 710 | { |
| 711 | LYERRLOG("modify_node is null\n"); |
| 712 | goto FAILED; |
| 713 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 714 | for (node_num=0 ;node_num<(int)profile_idx ; node_num++) |
| 715 | { |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 716 | if(modify_node == NULL) |
| 717 | { |
| 718 | LYERRLOG("modify_node is null\n"); |
| 719 | goto FAILED; |
| 720 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 721 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 722 | { |
| 723 | modify_node = modify_node->next; |
| 724 | node_num--; |
| 725 | continue; |
| 726 | } |
| 727 | modify_node = modify_node->next; |
| 728 | } |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 729 | if(modify_node == NULL) |
| 730 | { |
| 731 | LYERRLOG("modify_node is null\n"); |
| 732 | goto FAILED; |
| 733 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 734 | xmlUnlinkNode(modify_node); |
| 735 | xmlFreeNode(modify_node); |
| 736 | modify_node = NULL; |
| 737 | node_num = 0; |
| 738 | modify_node = node->xmlChildrenNode; |
| 739 | modify_node = modify_node->next; |
| 740 | while (modify_node != NULL) |
| 741 | { |
| 742 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 743 | { |
| 744 | modify_node = modify_node->next; |
| 745 | continue; |
| 746 | } |
| 747 | bzero(temp_buff,12); |
| 748 | snprintf(temp_buff,sizeof(temp_buff),"%d",node_num); |
| 749 | xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 750 | modify_node = modify_node->next; |
| 751 | node_num++; |
| 752 | } |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 753 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 754 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 755 | return RESULT_OK; |
| 756 | |
| 757 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 758 | // if (apn_table_xml_pdoc) |
| 759 | // { |
| 760 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 761 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 762 | return RESULT_ERROR; |
| 763 | } |
| 764 | |
| 765 | int apn_xml_modify(qser_apn_info_s *apn) |
| 766 | { |
| 767 | int node_num = 0; |
| 768 | char temp_buff[12]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 769 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 770 | xmlNodePtr node = NULL; |
| 771 | xmlNodePtr modify_node = NULL; |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 772 | xmlNodePtr check_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 773 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 774 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 775 | { |
| 776 | LYERRLOG("open xml file error"); |
| 777 | goto FAILED; |
| 778 | } |
| 779 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 780 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 781 | if (NULL == node) |
| 782 | { |
| 783 | LYERRLOG("xmlDocGetRootElement() error"); |
| 784 | goto FAILED; |
| 785 | } |
| 786 | modify_node = node->xmlChildrenNode; |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 787 | if(modify_node != NULL) |
| 788 | { |
| 789 | modify_node = modify_node->next; |
| 790 | } |
| 791 | else |
| 792 | { |
| 793 | LYERRLOG("modify_node is null\n"); |
| 794 | goto FAILED; |
| 795 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 796 | //check apn_type |
| 797 | check_node = modify_node; |
| 798 | while (check_node != NULL) |
| 799 | { |
| 800 | if (xmlGetProp(check_node, "profile_idx") == NULL) //Null Node |
| 801 | { |
| 802 | check_node = check_node->next; |
| 803 | continue; |
| 804 | } |
| 805 | else if(strcmp((char *)xmlGetProp(check_node, "apn_type"), apn->apn_type) == 0) |
| 806 | { |
| 807 | LYERRLOG("apntype already exists\n"); |
| 808 | goto FAILED; |
| 809 | } |
| 810 | check_node = check_node->next; |
| 811 | } |
| 812 | //check apn_type end |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 813 | for (node_num=0; node_num<(int)apn->profile_idx;node_num++) |
| 814 | { |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 815 | if(modify_node == NULL) |
| 816 | { |
| 817 | LYERRLOG("modify_node is null\n"); |
| 818 | goto FAILED; |
| 819 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 820 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 821 | { |
| 822 | modify_node = modify_node->next; |
| 823 | node_num--; |
| 824 | continue; |
| 825 | } |
| 826 | modify_node = modify_node->next; |
| 827 | } |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 828 | if(modify_node == NULL) |
| 829 | { |
| 830 | LYERRLOG("modify_node is null\n"); |
| 831 | goto FAILED; |
| 832 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 833 | bzero(temp_buff,12); |
| 834 | snprintf(temp_buff,sizeof(temp_buff),"%d",node_num); |
| 835 | xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 836 | bzero(temp_buff,12); |
| 837 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type); |
| 838 | xmlSetProp(modify_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff); |
| 839 | bzero(temp_buff,12); |
| 840 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto); |
| 841 | xmlSetProp(modify_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff); |
| 842 | xmlSetProp(modify_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name); |
| 843 | xmlSetProp(modify_node,BAD_CAST"username",(xmlChar *)apn->username); |
| 844 | xmlSetProp(modify_node,BAD_CAST"password",(xmlChar *)apn->password); |
| 845 | xmlSetProp(modify_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 846 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 847 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 848 | return RESULT_OK; |
| 849 | |
| 850 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 851 | // if (apn_table_xml_pdoc) |
| 852 | // { |
| 853 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 854 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 855 | return RESULT_ERROR; |
| 856 | } |
| 857 | |
| 858 | |
| 859 | int apn_xml_query(unsigned char profile_idx,qser_apn_info_s *apn) |
| 860 | { |
| 861 | int node_num = 0; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 862 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 863 | xmlNodePtr node = NULL; |
| 864 | xmlNodePtr modify_node = NULL; |
| 865 | unsigned char temp = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 866 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 867 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 868 | { |
| 869 | LYERRLOG("open xml file error"); |
| 870 | goto FAILED; |
| 871 | } |
| 872 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 873 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 874 | if (NULL == node) |
| 875 | { |
| 876 | LYERRLOG("xmlDocGetRootElement() error"); |
| 877 | goto FAILED; |
| 878 | } |
| 879 | modify_node = node->xmlChildrenNode; |
xf.li | bf9df4c | 2023-07-02 02:42:35 -0700 | [diff] [blame] | 880 | if(modify_node != NULL) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 881 | { |
xf.li | bf9df4c | 2023-07-02 02:42:35 -0700 | [diff] [blame] | 882 | modify_node = modify_node->next; |
| 883 | } |
| 884 | else |
| 885 | { |
| 886 | LYERRLOG("modify_node is null\n"); |
| 887 | goto FAILED; |
| 888 | } |
| 889 | LYINFLOG("profile_idx is %d\n", (int)profile_idx); |
| 890 | for (node_num = 0;(node_num<(int)profile_idx);node_num++) |
| 891 | { |
| 892 | if(modify_node == NULL) |
| 893 | { |
| 894 | LYERRLOG("modify_node is null\n"); |
| 895 | goto FAILED; |
| 896 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 897 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 898 | { |
| 899 | modify_node = modify_node->next; |
| 900 | node_num--; |
| 901 | continue; |
| 902 | } |
| 903 | modify_node = modify_node->next; |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 904 | } |
| 905 | if(modify_node == NULL) |
| 906 | { |
| 907 | LYERRLOG("modify_node is null\n"); |
| 908 | goto FAILED; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 909 | } |
| 910 | apn->profile_idx = (unsigned char)atoi(xmlGetProp(modify_node, "profile_idx")); |
| 911 | apn->pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type")); |
| 912 | apn->auth_proto = (qser_apn_auth_proto_e)atoi(xmlGetProp(modify_node, "auth_proto")); |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 913 | strncpy(apn->apn_name,(char *)xmlGetProp(modify_node, "apn_name"), QSER_APN_NAME_SIZE); |
| 914 | strncpy(apn->username,(char *)xmlGetProp(modify_node, "username"), QSER_APN_USERNAME_SIZE); |
| 915 | strncpy(apn->password,(char *)xmlGetProp(modify_node, "password"), QSER_APN_PASSWORD_SIZE); |
| 916 | strncpy(apn->apn_type,(char *)xmlGetProp(modify_node, "apn_type"), QSER_APN_NAME_SIZE); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 917 | // xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 918 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 919 | return RESULT_OK; |
| 920 | |
| 921 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 922 | // if (apn_table_xml_pdoc) |
| 923 | // { |
| 924 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 925 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 926 | return RESULT_ERROR; |
| 927 | } |
| 928 | |
| 929 | int apn_xml_query_list(qser_apn_info_list_s *apn_list) |
| 930 | { |
| 931 | int node_num = 0; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 932 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 933 | xmlNodePtr node = NULL; |
| 934 | xmlNodePtr modify_node = NULL; |
| 935 | xmlChar *temp_char; |
| 936 | char temp[64]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 937 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 938 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 939 | { |
| 940 | LYERRLOG("open xml file error"); |
| 941 | goto FAILED; |
| 942 | } |
| 943 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 944 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 945 | if (NULL == node) |
| 946 | { |
| 947 | LYERRLOG("xmlDocGetRootElement() error"); |
| 948 | goto FAILED; |
| 949 | } |
| 950 | modify_node = node->xmlChildrenNode; |
| 951 | modify_node = modify_node->next; |
| 952 | while (modify_node != NULL) |
| 953 | { |
| 954 | temp_char = xmlGetProp(modify_node, "profile_idx"); |
| 955 | if (temp_char == NULL) |
| 956 | { |
| 957 | modify_node = modify_node->next; |
| 958 | continue; |
| 959 | } |
| 960 | sprintf(temp,"%s",temp_char); |
| 961 | apn_list->apn[node_num].profile_idx = (unsigned char)atoi(temp); |
| 962 | apn_list->apn[node_num].pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type")); |
| 963 | apn_list->apn[node_num].auth_proto = (qser_apn_auth_proto_e)atoi(xmlGetProp(modify_node, "auth_proto")); |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 964 | strncpy(apn_list->apn[node_num].apn_name,(char *)xmlGetProp(modify_node, "apn_name"), QSER_APN_NAME_SIZE); |
| 965 | strncpy(apn_list->apn[node_num].username,(char *)xmlGetProp(modify_node, "username"), QSER_APN_USERNAME_SIZE); |
| 966 | strncpy(apn_list->apn[node_num].password,(char *)xmlGetProp(modify_node, "password"), QSER_APN_PASSWORD_SIZE); |
| 967 | strncpy(apn_list->apn[node_num].apn_type,(char *)xmlGetProp(modify_node, "apn_type"), QSER_APN_NAME_SIZE); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 968 | node_num ++; |
| 969 | modify_node = modify_node->next; |
| 970 | } |
| 971 | apn_list->cnt = node_num; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 972 | // xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 973 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 974 | return RESULT_OK; |
| 975 | |
| 976 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 977 | // if (apn_table_xml_pdoc) |
| 978 | // { |
| 979 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 980 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 981 | return RESULT_ERROR; |
| 982 | } |
| 983 | |
| 984 | void judge_pdp_type(qser_apn_pdp_type_e pdp_type,char *out_pdp_type) |
| 985 | { |
| 986 | switch (pdp_type) |
| 987 | { |
| 988 | case QSER_APN_PDP_TYPE_IPV4: |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 989 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 990 | strcpy(out_pdp_type,"IP"); |
| 991 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 992 | strcpy(out_pdp_type,"IPV4"); |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 993 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 994 | break; |
| 995 | case QSER_APN_PDP_TYPE_PPP: |
| 996 | strcpy(out_pdp_type,"PPP"); |
| 997 | break; |
| 998 | case QSER_APN_PDP_TYPE_IPV6: |
| 999 | strcpy(out_pdp_type,"IPV6"); |
| 1000 | break; |
| 1001 | case QSER_APN_PDP_TYPE_IPV4V6: |
| 1002 | strcpy(out_pdp_type,"IPV4V6"); |
| 1003 | break; |
| 1004 | default: |
| 1005 | strcpy(out_pdp_type,"NULL"); |
| 1006 | break; |
| 1007 | } |
| 1008 | return; |
| 1009 | } |
| 1010 | void judge_authtype(qser_apn_auth_proto_e auth_proto,char *out_proto) |
| 1011 | { |
| 1012 | switch (auth_proto) |
| 1013 | { |
| 1014 | case QSER_APN_AUTH_PROTO_DEFAULT: |
| 1015 | strcpy(out_proto,"NULL;authType=0"); |
| 1016 | break; |
| 1017 | case QSER_APN_AUTH_PROTO_NONE: |
| 1018 | strcpy(out_proto,"NULL;authType=1"); |
| 1019 | break; |
| 1020 | case QSER_APN_AUTH_PROTO_PAP: |
| 1021 | strcpy(out_proto,"NULL;authType=2"); |
| 1022 | break; |
| 1023 | case QSER_APN_AUTH_PROTO_CHAP: |
| 1024 | strcpy(out_proto,"NULL;authtype=3"); |
| 1025 | break; |
| 1026 | case QSER_APN_AUTH_PROTO_PAP_CHAP: |
| 1027 | strcpy(out_proto,"NULL;authtype=4"); |
| 1028 | break; |
| 1029 | default: |
| 1030 | strcpy(out_proto,"NULL;authType=NULL"); |
| 1031 | break; |
| 1032 | } |
| 1033 | return ; |
| 1034 | } |
| 1035 | |
| 1036 | int data_call_handle_get(const char profile_idx,int *handle) |
| 1037 | { |
| 1038 | int num = LYNQ_APN_CHANNEL_MAX; |
| 1039 | int table_num = 0; |
| 1040 | lynq_apn_info **apn_table = NULL; |
| 1041 | qser_apn_info_s apn; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1042 | int ret = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1043 | apn_table = (lynq_apn_info **)malloc(sizeof(lynq_apn_info *)*LYNQ_APN_CHANNEL_MAX); |
| 1044 | if (NULL == apn_table) |
| 1045 | { |
| 1046 | LYERRLOG("malloc apn_table fail "); |
| 1047 | return RESULT_ERROR; |
| 1048 | } |
| 1049 | for(int i =0;i<10;i++) |
| 1050 | { |
| 1051 | apn_table[i] = (lynq_apn_info*)malloc(sizeof(lynq_apn_info)); |
| 1052 | if (apn_table[i]==NULL) |
| 1053 | { |
| 1054 | for (int n=0;n<i;n++) |
| 1055 | { |
| 1056 | free(apn_table[n]); |
| 1057 | } |
| 1058 | return RESULT_ERROR; |
| 1059 | } |
| 1060 | memset(apn_table[i],0,sizeof(lynq_apn_info)); |
| 1061 | } |
| 1062 | lynq_get_apn_table(&table_num,apn_table); |
| 1063 | memset(&apn,0,sizeof(qser_apn_info_s)); |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1064 | ret = apn_xml_query(profile_idx,&apn); |
| 1065 | if (ret < 0) |
| 1066 | { |
| 1067 | LYERRLOG("apn_xml_query error"); |
| 1068 | return ret; |
| 1069 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1070 | for (int j = 0;j < table_num;j++) |
| 1071 | { |
| 1072 | if (strcmp(apn.apn_type,apn_table[j]->apnType) == 0) |
| 1073 | { |
| 1074 | *handle = apn_table[j]->index; |
| 1075 | LYINFLOG("apn_table->index:%d,handle:%d ",apn_table[j]->index,*handle); |
| 1076 | break; |
| 1077 | } |
| 1078 | } |
| 1079 | |
| 1080 | for (int i = 0; i < LYNQ_APN_CHANNEL_MAX; i++) |
| 1081 | { |
| 1082 | if (apn_table[i]!=NULL) |
| 1083 | { |
| 1084 | free(apn_table[i]); |
| 1085 | apn_table[i]=NULL; |
| 1086 | } |
| 1087 | } |
| 1088 | free(apn_table); |
| 1089 | apn_table=NULL; |
| 1090 | LYINFLOG("data_call_handle_get end"); |
| 1091 | return RESULT_OK; |
| 1092 | } |
| 1093 | |
| 1094 | void *thread_wait_cb_status(void) |
| 1095 | { |
| 1096 | int handle = -1; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1097 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1098 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1099 | lynq_data_call_response_v11_t data_urc_info = {0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1100 | qser_data_call_state_s data_cb_state; |
| 1101 | while (s_qser_data_cb_thread_status) |
| 1102 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1103 | ret = lynq_wait_data_call_state_change(&handle); |
| 1104 | LYINFLOG("ret = %d, wait data call state change end!!!\n", ret); |
| 1105 | if(s_qser_data_cb_thread_status == 0) |
| 1106 | { |
| 1107 | return NULL; |
| 1108 | } |
| 1109 | else if(ret < 0) |
| 1110 | { |
| 1111 | continue; |
| 1112 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1113 | LYINFLOG("[thread_wait_cb_status]: handle = %d", handle); |
| 1114 | memset(&data_urc_info, 0, sizeof(data_urc_info)); |
| 1115 | memset(&data_cb_state, 0, sizeof(data_cb_state)); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1116 | lynq_get_data_call_list(&handle,&data_urc_info); |
| 1117 | /*compare paramter*/ |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1118 | //data_cb_state.profile_idx = (char)handle; |
| 1119 | apn_xml_handle_get_profile(handle, &data_cb_state.profile_idx); |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1120 | 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", |
| 1121 | data_urc_info.status, data_urc_info.suggestedRetryTime, data_urc_info.cid, data_urc_info.active, |
| 1122 | data_urc_info.type, data_urc_info.ifname, data_urc_info.addresses, data_urc_info.dnses, data_urc_info.gateways, data_urc_info.pcscf, |
| 1123 | data_urc_info.mtu); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1124 | 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] | 1125 | 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] | 1126 | { |
| 1127 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4; |
| 1128 | } |
| 1129 | else if (!strcmp(data_urc_info.type,"IPV6")) |
| 1130 | { |
| 1131 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV6; |
| 1132 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1133 | else if (!strcmp(data_urc_info.type,"IPV4V6")) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1134 | { |
| 1135 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4V6; |
| 1136 | } |
| 1137 | else |
| 1138 | { |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1139 | LYERRLOG("unknow data call type: %s", data_urc_info.type); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1140 | } |
| 1141 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1142 | if (data_urc_info.active != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1143 | { |
| 1144 | data_cb_state.state = QSER_DATA_CALL_CONNECTED; |
| 1145 | } |
| 1146 | else |
| 1147 | { |
| 1148 | data_cb_state.state = QSER_DATA_CALL_DISCONNECTED; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1149 | ret = apn_xml_handle_set(data_cb_state.profile_idx, default_handle); |
| 1150 | if(ret != 0) |
| 1151 | { |
| 1152 | LYERRLOG("handle set error"); |
| 1153 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1154 | } |
| 1155 | if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4) |
| 1156 | { |
| 1157 | lynq_ipv4_aton_urc(&data_urc_info,&data_cb_state); |
| 1158 | } |
| 1159 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV6) |
| 1160 | { |
| 1161 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1162 | } |
| 1163 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4V6) |
| 1164 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1165 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1166 | lynq_ipv4v6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1167 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1168 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1169 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1170 | } |
| 1171 | else |
| 1172 | { |
| 1173 | LYERRLOG("unknow ip_family"); |
| 1174 | continue; |
| 1175 | } |
| 1176 | if (s_data_call_cb != NULL) |
| 1177 | { |
| 1178 | s_data_call_cb(&data_cb_state); |
| 1179 | } |
| 1180 | } |
| 1181 | return NULL; |
| 1182 | } |
| 1183 | |
| 1184 | int qser_cb_pthread_create() |
| 1185 | { |
| 1186 | int ret; |
| 1187 | s_qser_data_cb_thread_status = 1; |
| 1188 | ret = pthread_create(&s_cb_tid,NULL,thread_wait_cb_status,NULL); |
| 1189 | if (ret < 0) |
| 1190 | { |
| 1191 | LYERRLOG("pthread create fail"); |
| 1192 | s_qser_data_cb_thread_status = 0; |
| 1193 | return RESULT_ERROR; |
| 1194 | } |
| 1195 | return RESULT_OK; |
| 1196 | } |
| 1197 | |
| 1198 | void qser_cb_pthread_cancel() |
| 1199 | { |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1200 | s_qser_data_cb_thread_status = 0; |
| 1201 | if (s_cb_tid != -1) |
| 1202 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1203 | lynq_release_wait_data_call(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1204 | } |
| 1205 | return; |
| 1206 | } |
xf.li | 7b0bfd0 | 2023-08-03 01:11:52 -0700 | [diff] [blame] | 1207 | int check_xml_file(const char *file) |
| 1208 | { |
| 1209 | /* Check for existence */ |
| 1210 | if((access(file, F_OK)) == -1) |
| 1211 | { |
| 1212 | LYERRLOG("no such xml file.\n"); |
| 1213 | system("cp /data/lynq_qser_data_apn.xml /mnt/userdata/"); |
| 1214 | } |
| 1215 | |
| 1216 | if((access(file, F_OK)) == -1) |
| 1217 | { |
| 1218 | LYERRLOG("error copy xml file.\n"); |
| 1219 | return -1; |
| 1220 | } |
| 1221 | return RESULT_OK; |
| 1222 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1223 | |
| 1224 | int qser_data_call_init(qser_data_call_evt_cb_t evt_cb) |
| 1225 | { |
| 1226 | int ret = 0; |
| 1227 | int utoken = 0; |
| 1228 | if (NULL == evt_cb) |
| 1229 | { |
| 1230 | LYERRLOG("init incoming paramters error"); |
| 1231 | return RESULT_ERROR; |
| 1232 | } |
xf.li | 7b0bfd0 | 2023-08-03 01:11:52 -0700 | [diff] [blame] | 1233 | |
| 1234 | ret = check_xml_file(data_xml_path); |
| 1235 | if (ret != RESULT_OK) |
| 1236 | { |
| 1237 | LYERRLOG("check xml file error"); |
| 1238 | return RESULT_ERROR; |
| 1239 | } |
| 1240 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1241 | s_data_call_cb = evt_cb; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1242 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1243 | ret = lynq_init_data(utoken); |
| 1244 | if (ret != RESULT_OK) |
| 1245 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1246 | //qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1247 | s_data_call_cb = NULL; |
| 1248 | return RESULT_ERROR; |
| 1249 | } |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1250 | qser_cb_pthread_create(); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1251 | apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 1252 | if(NULL == apn_table_xml_pdoc) |
| 1253 | { |
| 1254 | LYERRLOG("open xml file error"); |
| 1255 | return RESULT_ERROR; |
| 1256 | } |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1257 | g_lynq_qser_data_init_flag = 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1258 | return RESULT_OK; |
| 1259 | } |
| 1260 | |
| 1261 | void qser_data_call_destroy(void) |
| 1262 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1263 | LYINFLOG("[%s] start [%d]",__FUNCTION__,__LINE__); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1264 | if(apn_table_xml_pdoc) |
| 1265 | { |
| 1266 | xmlFreeDoc(apn_table_xml_pdoc); |
| 1267 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1268 | lynq_deinit_data(); |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1269 | qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1270 | s_data_call_cb = NULL; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1271 | g_lynq_qser_data_init_flag = 0; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1272 | LYINFLOG("[%s] end [%d]",__FUNCTION__,__LINE__); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1273 | return ; |
| 1274 | } |
| 1275 | |
| 1276 | int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1277 | { |
| 1278 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1279 | int error = -1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1280 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1281 | if(g_lynq_qser_data_init_flag == 0) |
| 1282 | { |
| 1283 | if(err != NULL) |
| 1284 | { |
| 1285 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1286 | } |
| 1287 | return LYNQ_E_NO_INIT; |
| 1288 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1289 | if (NULL == data_call || NULL == err) |
| 1290 | { |
| 1291 | LYERRLOG("call start incoming paramters error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1292 | if(err != NULL) |
| 1293 | { |
| 1294 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1295 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1296 | return ret; |
| 1297 | } |
| 1298 | if (data_call->profile_idx == 0) |
| 1299 | { |
| 1300 | ret = lynq_setup_data_call(&handle); |
| 1301 | } |
| 1302 | else |
| 1303 | { |
| 1304 | char pdptype[16]; |
| 1305 | qser_apn_info_s apn_info; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1306 | ret = qser_apn_get(data_call->profile_idx,&apn_info); |
| 1307 | if (ret != 0) |
| 1308 | { |
| 1309 | LYERRLOG("qser_apn_get error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1310 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1311 | return ret; |
| 1312 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1313 | judge_pdp_type(apn_info.pdp_type,pdptype); |
| 1314 | ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype); |
| 1315 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1316 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1317 | { |
| 1318 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1319 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1320 | else |
| 1321 | { |
| 1322 | error = apn_xml_handle_set(data_call->profile_idx, handle); |
| 1323 | if(error != 0) |
| 1324 | { |
| 1325 | LYERRLOG("handle set error"); |
| 1326 | } |
| 1327 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1328 | return ret; |
| 1329 | } |
| 1330 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1331 | int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1332 | { |
| 1333 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1334 | int error = -1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1335 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1336 | if(g_lynq_qser_data_init_flag == 0) |
| 1337 | { |
| 1338 | if(err != NULL) |
| 1339 | { |
| 1340 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1341 | } |
| 1342 | return LYNQ_E_NO_INIT; |
| 1343 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1344 | if (NULL == data_call || NULL == err) |
| 1345 | { |
| 1346 | LYERRLOG("call start incoming paramters error"); |
| 1347 | if(err != NULL) |
| 1348 | { |
| 1349 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1350 | } |
| 1351 | return ret; |
| 1352 | } |
| 1353 | if (data_call->profile_idx == 0) |
| 1354 | { |
| 1355 | ret = lynq_setup_data_call_sp_t106_async(&handle,"default","default",NULL,NULL,NULL,NULL,NULL); |
| 1356 | } |
| 1357 | else |
| 1358 | { |
| 1359 | char pdptype[16]; |
| 1360 | qser_apn_info_s apn_info; |
| 1361 | ret = qser_apn_get(data_call->profile_idx,&apn_info); |
| 1362 | if (ret != 0) |
| 1363 | { |
| 1364 | LYERRLOG("qser_apn_get error"); |
| 1365 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1366 | return ret; |
| 1367 | } |
| 1368 | judge_pdp_type(apn_info.pdp_type,pdptype); |
| 1369 | ret = lynq_setup_data_call_sp_t106_async(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype); |
| 1370 | } |
| 1371 | if (ret != 0) |
| 1372 | { |
| 1373 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1374 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1375 | else |
| 1376 | { |
| 1377 | error = apn_xml_handle_set(data_call->profile_idx, handle); |
| 1378 | if(error != 0) |
| 1379 | { |
| 1380 | LYERRLOG("handle set error"); |
| 1381 | } |
| 1382 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1383 | return ret; |
| 1384 | } |
| 1385 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1386 | int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err) |
| 1387 | { |
| 1388 | int ret = 0; |
| 1389 | int handle = -1; |
| 1390 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1391 | if(g_lynq_qser_data_init_flag == 0) |
| 1392 | { |
| 1393 | if(err != NULL) |
| 1394 | { |
| 1395 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1396 | } |
| 1397 | return LYNQ_E_NO_INIT; |
| 1398 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1399 | if (NULL == err) |
| 1400 | { |
| 1401 | LYERRLOG("call stop incoming paramters error"); |
| 1402 | return ret; |
| 1403 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1404 | ret = data_call_handle_get(profile_idx,&handle); |
| 1405 | if(ret != 0) |
| 1406 | { |
| 1407 | LYERRLOG("datacall handle get error"); |
| 1408 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1409 | return ret; |
| 1410 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1411 | ret = lynq_deactive_data_call(&handle); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1412 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1413 | { |
| 1414 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1415 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1416 | } |
xy.he | e2daacc | 2023-09-18 00:57:51 -0700 | [diff] [blame] | 1417 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1418 | } |
| 1419 | 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) |
| 1420 | { |
| 1421 | int ret = 0; |
| 1422 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1423 | if(g_lynq_qser_data_init_flag == 0) |
| 1424 | { |
| 1425 | if(err != NULL) |
| 1426 | { |
| 1427 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1428 | } |
| 1429 | return LYNQ_E_NO_INIT; |
| 1430 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1431 | lynq_data_call_response_v11_t data_call_info; |
| 1432 | data_call_handle_get(profile_idx,&handle); |
| 1433 | ret = lynq_get_data_call_list(&handle,&data_call_info); |
| 1434 | if (ret == 0) |
| 1435 | { |
| 1436 | info->profile_idx = profile_idx; |
| 1437 | info->ip_family = ip_family; |
xf.li | 157f7e9 | 2023-10-19 23:22:46 -0700 | [diff] [blame] | 1438 | 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] | 1439 | { |
| 1440 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1441 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1442 | LYINFLOG("[IPV4]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1443 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
| 1444 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1445 | else if (strncmp(data_call_info.type,"IPV6", strlen("IPV6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1446 | { |
| 1447 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1448 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1449 | LYINFLOG("[IPV6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1450 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
| 1451 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1452 | else if (strncmp(data_call_info.type,"IPV4V6", strlen("IPV4V6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1453 | { |
| 1454 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1455 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1456 | 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] | 1457 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1458 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1459 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1460 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1461 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1462 | 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] | 1463 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1464 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1465 | #endif |
| 1466 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1467 | lynq_ipv4v6_inet_pton_getinfo(&data_call_info,info); |
| 1468 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1469 | } |
| 1470 | else |
| 1471 | { |
| 1472 | LYERRLOG("useless qser_data_call_ip_family_e"); |
| 1473 | } |
| 1474 | } |
| 1475 | return ret; |
| 1476 | } |
| 1477 | int qser_apn_set(qser_apn_info_s *apn) |
| 1478 | { |
| 1479 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1480 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1481 | if(g_lynq_qser_data_init_flag == 0) |
| 1482 | { |
| 1483 | return LYNQ_E_NO_INIT; |
| 1484 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1485 | if (NULL == apn || apn->profile_idx == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1486 | { |
| 1487 | LYERRLOG("apn set incoming paramters error"); |
| 1488 | return RESULT_ERROR; |
| 1489 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1490 | ret = apn_xml_handle_get(apn->profile_idx, &handle); |
| 1491 | if(ret != 0) |
| 1492 | { |
| 1493 | LYERRLOG("handle set error"); |
| 1494 | } |
| 1495 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1496 | { |
| 1497 | LYERRLOG("It has setup datacall"); |
| 1498 | return RESULT_ERROR; |
| 1499 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1500 | ret = apn_xml_modify(apn); |
| 1501 | if (ret < 0) |
| 1502 | { |
| 1503 | LYERRLOG("apn_xml_modify error"); |
| 1504 | return ret; |
| 1505 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1506 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1507 | int apn_id = 0; |
| 1508 | char tmp_id[12]; |
| 1509 | char *outinfo = NULL; |
| 1510 | char normalprotocol[16]; |
| 1511 | char authtype[32]; |
| 1512 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1513 | bzero(tmp_id,12); |
| 1514 | bzero(outinfo,512); |
| 1515 | apn_id = apn->profile_idx + apndb_offset; |
| 1516 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1517 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1518 | judge_authtype(apn->auth_proto,authtype); |
| 1519 | lynq_modify_apn_db(3,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1520 | LYINFLOG("[output]:%s",outinfo); |
| 1521 | free(outinfo); |
| 1522 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1523 | #endif |
| 1524 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1525 | } |
| 1526 | |
| 1527 | int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn) |
| 1528 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1529 | if(g_lynq_qser_data_init_flag == 0) |
| 1530 | { |
| 1531 | return LYNQ_E_NO_INIT; |
| 1532 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1533 | if (profile_idx < 0 || profile_idx > 24 || NULL == apn) |
| 1534 | { |
| 1535 | LYERRLOG("apn get incoming paramters error"); |
| 1536 | return RESULT_ERROR; |
| 1537 | } |
| 1538 | int ret = 0; |
| 1539 | ret = apn_xml_query(profile_idx,apn); |
| 1540 | if (ret < 0) |
| 1541 | { |
| 1542 | LYERRLOG("apn_xml_query error"); |
| 1543 | return ret; |
| 1544 | } |
| 1545 | return ret; |
| 1546 | } |
| 1547 | |
| 1548 | int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx) |
| 1549 | { |
| 1550 | int ret = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1551 | if(g_lynq_qser_data_init_flag == 0) |
| 1552 | { |
| 1553 | return LYNQ_E_NO_INIT; |
| 1554 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1555 | if (NULL == apn || NULL == profile_idx) |
| 1556 | { |
| 1557 | LYERRLOG("apn add incoming paramters error"); |
| 1558 | return RESULT_ERROR; |
| 1559 | } |
| 1560 | ret = apn_xml_add(apn,profile_idx); |
| 1561 | if (ret < 0) |
| 1562 | { |
| 1563 | LYERRLOG("apn_xml_add error"); |
| 1564 | return ret; |
| 1565 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1566 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1567 | int apn_id = 0; |
| 1568 | char tmp_id[12]; |
| 1569 | char *outinfo = NULL; |
| 1570 | char normalprotocol[16]; |
| 1571 | char authtype[32]; |
| 1572 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1573 | bzero(tmp_id,12); |
| 1574 | bzero(outinfo,512); |
| 1575 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1576 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1577 | judge_authtype(apn->auth_proto,authtype); |
| 1578 | lynq_modify_apn_db(0,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1579 | LYINFLOG("[output]:%s",outinfo); |
| 1580 | free(outinfo); |
| 1581 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1582 | #endif |
| 1583 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1584 | } |
| 1585 | |
| 1586 | int qser_apn_del(unsigned char profile_idx) |
| 1587 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1588 | if(g_lynq_qser_data_init_flag == 0) |
| 1589 | { |
| 1590 | return LYNQ_E_NO_INIT; |
| 1591 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1592 | if (profile_idx <= 0 || profile_idx > QSER_APN_MAX_LIST) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1593 | { |
| 1594 | LYERRLOG("apn del incoming paramters error"); |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1595 | return RESULT_ERROR; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1596 | } |
| 1597 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1598 | int handle = -1; |
| 1599 | ret = apn_xml_handle_get(profile_idx, &handle); |
| 1600 | if(ret != 0) |
| 1601 | { |
| 1602 | LYERRLOG("handle set error"); |
| 1603 | } |
| 1604 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1605 | { |
| 1606 | LYERRLOG("It has setup datacall"); |
| 1607 | return RESULT_ERROR; |
| 1608 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1609 | ret = apn_xml_delete(profile_idx); |
| 1610 | if (ret < 0) |
| 1611 | { |
| 1612 | LYERRLOG("apn_xml_delete error"); |
| 1613 | return ret; |
| 1614 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1615 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1616 | int apn_id = 0; |
| 1617 | char tmp_id[12]; |
| 1618 | char *outinfo = NULL; |
| 1619 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1620 | bzero(tmp_id,12); |
| 1621 | bzero(outinfo,512); |
| 1622 | apn_id = profile_idx+apndb_offset; |
| 1623 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1624 | lynq_modify_apn_db(1,tmp_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,outinfo); |
| 1625 | LYINFLOG("[output]:%s",outinfo); |
| 1626 | free(outinfo); |
| 1627 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1628 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1629 | return ret; |
| 1630 | } |
| 1631 | |
| 1632 | int qser_apn_get_list(qser_apn_info_list_s *apn_list) |
| 1633 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1634 | if(g_lynq_qser_data_init_flag == 0) |
| 1635 | { |
| 1636 | return LYNQ_E_NO_INIT; |
| 1637 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1638 | if (NULL == apn_list) |
| 1639 | { |
| 1640 | LYERRLOG("apn_list incoming paramters error"); |
| 1641 | return RESULT_ERROR; |
| 1642 | } |
| 1643 | int ret = 0; |
| 1644 | ret = apn_xml_query_list(apn_list); |
| 1645 | if (ret < 0) |
| 1646 | { |
| 1647 | LYERRLOG("apn_xml_query_list error"); |
| 1648 | return ret; |
| 1649 | } |
| 1650 | return ret; |
xf.li | 3f891cb | 2023-08-23 23:11:24 -0700 | [diff] [blame] | 1651 | } |
you.chen | 21c62b7 | 2023-09-08 09:41:11 +0800 | [diff] [blame] | 1652 | |
| 1653 | DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_DATA) |
| 1654 | |