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 | |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame^] | 606 | int apn_xml_handle_clean() |
| 607 | { |
| 608 | int node_num = 0; |
| 609 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
| 610 | xmlNodePtr node = NULL; |
| 611 | xmlNodePtr modify_node = NULL; |
| 612 | xmlChar *temp_char; |
| 613 | char temp_buff[12]; |
| 614 | |
| 615 | if(NULL == apn_table_xml_pdoc) |
| 616 | { |
| 617 | LYERRLOG("open xml file error"); |
| 618 | goto FAILED; |
| 619 | } |
| 620 | |
| 621 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
| 622 | if (NULL == node) |
| 623 | { |
| 624 | LYERRLOG("xmlDocGetRootElement() error"); |
| 625 | goto FAILED; |
| 626 | } |
| 627 | modify_node = node->xmlChildrenNode; |
| 628 | if(modify_node != NULL) |
| 629 | { |
| 630 | modify_node = modify_node->next; |
| 631 | } |
| 632 | else |
| 633 | { |
| 634 | LYERRLOG("modify_node is null\n"); |
| 635 | goto FAILED; |
| 636 | } |
| 637 | while (modify_node != NULL) |
| 638 | { |
| 639 | temp_char = xmlGetProp(modify_node, "handle"); |
| 640 | if (temp_char == NULL) |
| 641 | { |
| 642 | modify_node = modify_node->next; |
| 643 | continue; |
| 644 | } |
| 645 | bzero(temp_buff,12); |
| 646 | snprintf(temp_buff,sizeof(temp_buff),"%d",default_handle); |
| 647 | xmlSetProp(modify_node,BAD_CAST"handle",(xmlChar *)temp_buff); |
| 648 | modify_node = modify_node->next; |
| 649 | } |
| 650 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 651 | return RESULT_OK; |
| 652 | |
| 653 | FAILED: |
| 654 | // if (apn_table_xml_pdoc) |
| 655 | // { |
| 656 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 657 | // } |
| 658 | return RESULT_ERROR; |
| 659 | } |
| 660 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 661 | int apn_xml_add(qser_apn_add_s *apn,unsigned char *apn_num) |
| 662 | { |
| 663 | int node_num = 0; |
| 664 | char temp_buff[12]; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 665 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 666 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 667 | xmlNodePtr node = NULL; |
| 668 | xmlNodePtr tmp_node = NULL; |
| 669 | xmlNodePtr sum_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 670 | |
| 671 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 672 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 673 | { |
| 674 | LYERRLOG("open xml file error"); |
| 675 | goto FAILED; |
| 676 | } |
| 677 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 678 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 679 | if (NULL == node) |
| 680 | { |
| 681 | LYERRLOG("xmlDocGetRootElement() error"); |
| 682 | goto FAILED; |
| 683 | } |
| 684 | sum_node = node->xmlChildrenNode; |
| 685 | sum_node = sum_node->next; |
| 686 | while (sum_node != NULL) |
| 687 | { |
| 688 | if (xmlGetProp(sum_node, "profile_idx") == NULL) //Null Node |
| 689 | { |
| 690 | sum_node = sum_node->next; |
| 691 | continue; |
| 692 | } |
xf.li | f7c68e3 | 2023-10-10 23:18:42 -0700 | [diff] [blame] | 693 | else if(strcmp((char *)xmlGetProp(sum_node, "apn_type"), apn->apn_type) == 0) |
| 694 | { |
| 695 | LYERRLOG("apntype already exists\n"); |
| 696 | goto FAILED; |
| 697 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 698 | node_num++; |
| 699 | sum_node = sum_node->next; |
| 700 | } |
xf.li | 3f891cb | 2023-08-23 23:11:24 -0700 | [diff] [blame] | 701 | LYINFLOG("apn_num = %d ",node_num); |
| 702 | if(node_num >= QSER_APN_MAX_LIST) |
| 703 | { |
| 704 | LYERRLOG("apn num reached the max"); |
| 705 | goto FAILED; |
| 706 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 707 | tmp_node = xmlNewNode(NULL,BAD_CAST"apn"); |
| 708 | *apn_num = node_num; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 709 | bzero(temp_buff,12); |
| 710 | snprintf(temp_buff,sizeof(temp_buff),"%d",*apn_num); |
| 711 | xmlNewProp(tmp_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 712 | bzero(temp_buff,12); |
| 713 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type); |
| 714 | xmlNewProp(tmp_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff); |
| 715 | bzero(temp_buff,12); |
| 716 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto); |
| 717 | xmlNewProp(tmp_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff); |
| 718 | xmlNewProp(tmp_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name); |
| 719 | xmlNewProp(tmp_node,BAD_CAST"username",(xmlChar *)apn->username); |
| 720 | xmlNewProp(tmp_node,BAD_CAST"password",(xmlChar *)apn->password); |
| 721 | xmlNewProp(tmp_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type); |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 722 | bzero(temp_buff,12); |
| 723 | snprintf(temp_buff,sizeof(temp_buff),"%d",default_handle); |
| 724 | xmlNewProp(tmp_node,BAD_CAST"handle",(xmlChar *)temp_buff); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 725 | xmlAddChild(node,tmp_node); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 726 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 727 | |
| 728 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 729 | return RESULT_OK; |
| 730 | |
| 731 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 732 | /* if (apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 733 | { |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 734 | xmlFreeDoc(apn_table_xml_pdoc); |
| 735 | }*/ |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 736 | return RESULT_ERROR; |
| 737 | } |
| 738 | |
| 739 | int apn_xml_delete(unsigned char profile_idx) |
| 740 | { |
| 741 | int node_num = 0; |
| 742 | char temp_buff[12]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 743 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 744 | xmlNodePtr node = NULL; |
| 745 | xmlNodePtr modify_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 746 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 747 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 748 | { |
| 749 | LYERRLOG("open xml file error"); |
| 750 | goto FAILED; |
| 751 | } |
| 752 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 753 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 754 | if (NULL == node) |
| 755 | { |
| 756 | LYERRLOG("xmlDocGetRootElement() error"); |
| 757 | goto FAILED; |
| 758 | } |
| 759 | modify_node = node->xmlChildrenNode; |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 760 | if(modify_node != NULL) |
| 761 | { |
| 762 | modify_node = modify_node->next; |
| 763 | } |
| 764 | else |
| 765 | { |
| 766 | LYERRLOG("modify_node is null\n"); |
| 767 | goto FAILED; |
| 768 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 769 | for (node_num=0 ;node_num<(int)profile_idx ; node_num++) |
| 770 | { |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 771 | if(modify_node == NULL) |
| 772 | { |
| 773 | LYERRLOG("modify_node is null\n"); |
| 774 | goto FAILED; |
| 775 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 776 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 777 | { |
| 778 | modify_node = modify_node->next; |
| 779 | node_num--; |
| 780 | continue; |
| 781 | } |
| 782 | modify_node = modify_node->next; |
| 783 | } |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 784 | if(modify_node == NULL) |
| 785 | { |
| 786 | LYERRLOG("modify_node is null\n"); |
| 787 | goto FAILED; |
| 788 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 789 | xmlUnlinkNode(modify_node); |
| 790 | xmlFreeNode(modify_node); |
| 791 | modify_node = NULL; |
| 792 | node_num = 0; |
| 793 | modify_node = node->xmlChildrenNode; |
| 794 | modify_node = modify_node->next; |
| 795 | while (modify_node != NULL) |
| 796 | { |
| 797 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 798 | { |
| 799 | modify_node = modify_node->next; |
| 800 | continue; |
| 801 | } |
| 802 | bzero(temp_buff,12); |
| 803 | snprintf(temp_buff,sizeof(temp_buff),"%d",node_num); |
| 804 | xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 805 | modify_node = modify_node->next; |
| 806 | node_num++; |
| 807 | } |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 808 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 809 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 810 | return RESULT_OK; |
| 811 | |
| 812 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 813 | // if (apn_table_xml_pdoc) |
| 814 | // { |
| 815 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 816 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 817 | return RESULT_ERROR; |
| 818 | } |
| 819 | |
| 820 | int apn_xml_modify(qser_apn_info_s *apn) |
| 821 | { |
| 822 | int node_num = 0; |
| 823 | char temp_buff[12]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 824 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 825 | xmlNodePtr node = NULL; |
| 826 | xmlNodePtr modify_node = NULL; |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 827 | xmlNodePtr check_node = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 828 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 829 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 830 | { |
| 831 | LYERRLOG("open xml file error"); |
| 832 | goto FAILED; |
| 833 | } |
| 834 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 835 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 836 | if (NULL == node) |
| 837 | { |
| 838 | LYERRLOG("xmlDocGetRootElement() error"); |
| 839 | goto FAILED; |
| 840 | } |
| 841 | modify_node = node->xmlChildrenNode; |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 842 | if(modify_node != NULL) |
| 843 | { |
| 844 | modify_node = modify_node->next; |
| 845 | } |
| 846 | else |
| 847 | { |
| 848 | LYERRLOG("modify_node is null\n"); |
| 849 | goto FAILED; |
| 850 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 851 | //check apn_type |
| 852 | check_node = modify_node; |
| 853 | while (check_node != NULL) |
| 854 | { |
| 855 | if (xmlGetProp(check_node, "profile_idx") == NULL) //Null Node |
| 856 | { |
| 857 | check_node = check_node->next; |
| 858 | continue; |
| 859 | } |
| 860 | else if(strcmp((char *)xmlGetProp(check_node, "apn_type"), apn->apn_type) == 0) |
| 861 | { |
| 862 | LYERRLOG("apntype already exists\n"); |
| 863 | goto FAILED; |
| 864 | } |
| 865 | check_node = check_node->next; |
| 866 | } |
| 867 | //check apn_type end |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 868 | for (node_num=0; node_num<(int)apn->profile_idx;node_num++) |
| 869 | { |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 870 | if(modify_node == NULL) |
| 871 | { |
| 872 | LYERRLOG("modify_node is null\n"); |
| 873 | goto FAILED; |
| 874 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 875 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 876 | { |
| 877 | modify_node = modify_node->next; |
| 878 | node_num--; |
| 879 | continue; |
| 880 | } |
| 881 | modify_node = modify_node->next; |
| 882 | } |
xf.li | fb8bf04 | 2023-12-13 18:09:49 -0800 | [diff] [blame] | 883 | if(modify_node == NULL) |
| 884 | { |
| 885 | LYERRLOG("modify_node is null\n"); |
| 886 | goto FAILED; |
| 887 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 888 | bzero(temp_buff,12); |
| 889 | snprintf(temp_buff,sizeof(temp_buff),"%d",node_num); |
| 890 | xmlSetProp(modify_node,BAD_CAST"profile_idx",(xmlChar *)temp_buff); |
| 891 | bzero(temp_buff,12); |
| 892 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->pdp_type); |
| 893 | xmlSetProp(modify_node,BAD_CAST"pdp_type",(xmlChar *)temp_buff); |
| 894 | bzero(temp_buff,12); |
| 895 | snprintf(temp_buff,sizeof(temp_buff),"%d",apn->auth_proto); |
| 896 | xmlSetProp(modify_node,BAD_CAST"auth_proto",(xmlChar *)temp_buff); |
| 897 | xmlSetProp(modify_node,BAD_CAST"apn_name",(xmlChar *)apn->apn_name); |
| 898 | xmlSetProp(modify_node,BAD_CAST"username",(xmlChar *)apn->username); |
| 899 | xmlSetProp(modify_node,BAD_CAST"password",(xmlChar *)apn->password); |
| 900 | xmlSetProp(modify_node,BAD_CAST"apn_type",(xmlChar *)apn->apn_type); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 901 | xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 902 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 903 | return RESULT_OK; |
| 904 | |
| 905 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 906 | // if (apn_table_xml_pdoc) |
| 907 | // { |
| 908 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 909 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 910 | return RESULT_ERROR; |
| 911 | } |
| 912 | |
| 913 | |
| 914 | int apn_xml_query(unsigned char profile_idx,qser_apn_info_s *apn) |
| 915 | { |
| 916 | int node_num = 0; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 917 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 918 | xmlNodePtr node = NULL; |
| 919 | xmlNodePtr modify_node = NULL; |
| 920 | unsigned char temp = NULL; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 921 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 922 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 923 | { |
| 924 | LYERRLOG("open xml file error"); |
| 925 | goto FAILED; |
| 926 | } |
| 927 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 928 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 929 | if (NULL == node) |
| 930 | { |
| 931 | LYERRLOG("xmlDocGetRootElement() error"); |
| 932 | goto FAILED; |
| 933 | } |
| 934 | modify_node = node->xmlChildrenNode; |
xf.li | bf9df4c | 2023-07-02 02:42:35 -0700 | [diff] [blame] | 935 | if(modify_node != NULL) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 936 | { |
xf.li | bf9df4c | 2023-07-02 02:42:35 -0700 | [diff] [blame] | 937 | modify_node = modify_node->next; |
| 938 | } |
| 939 | else |
| 940 | { |
| 941 | LYERRLOG("modify_node is null\n"); |
| 942 | goto FAILED; |
| 943 | } |
| 944 | LYINFLOG("profile_idx is %d\n", (int)profile_idx); |
| 945 | for (node_num = 0;(node_num<(int)profile_idx);node_num++) |
| 946 | { |
| 947 | if(modify_node == NULL) |
| 948 | { |
| 949 | LYERRLOG("modify_node is null\n"); |
| 950 | goto FAILED; |
| 951 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 952 | if (xmlGetProp(modify_node, "profile_idx") == NULL) //Null Node |
| 953 | { |
| 954 | modify_node = modify_node->next; |
| 955 | node_num--; |
| 956 | continue; |
| 957 | } |
| 958 | modify_node = modify_node->next; |
xf.li | 029a9e7 | 2023-11-04 02:29:45 -0700 | [diff] [blame] | 959 | } |
| 960 | if(modify_node == NULL) |
| 961 | { |
| 962 | LYERRLOG("modify_node is null\n"); |
| 963 | goto FAILED; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 964 | } |
| 965 | apn->profile_idx = (unsigned char)atoi(xmlGetProp(modify_node, "profile_idx")); |
| 966 | apn->pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type")); |
| 967 | 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] | 968 | strncpy(apn->apn_name,(char *)xmlGetProp(modify_node, "apn_name"), QSER_APN_NAME_SIZE); |
| 969 | strncpy(apn->username,(char *)xmlGetProp(modify_node, "username"), QSER_APN_USERNAME_SIZE); |
| 970 | strncpy(apn->password,(char *)xmlGetProp(modify_node, "password"), QSER_APN_PASSWORD_SIZE); |
| 971 | 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] | 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 | int apn_xml_query_list(qser_apn_info_list_s *apn_list) |
| 985 | { |
| 986 | int node_num = 0; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 987 | //xmlDocPtr apn_table_xml_pdoc = NULL; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 988 | xmlNodePtr node = NULL; |
| 989 | xmlNodePtr modify_node = NULL; |
| 990 | xmlChar *temp_char; |
| 991 | char temp[64]; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 992 | // apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 993 | if(NULL == apn_table_xml_pdoc) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 994 | { |
| 995 | LYERRLOG("open xml file error"); |
| 996 | goto FAILED; |
| 997 | } |
| 998 | |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 999 | node = xmlDocGetRootElement(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1000 | if (NULL == node) |
| 1001 | { |
| 1002 | LYERRLOG("xmlDocGetRootElement() error"); |
| 1003 | goto FAILED; |
| 1004 | } |
| 1005 | modify_node = node->xmlChildrenNode; |
| 1006 | modify_node = modify_node->next; |
| 1007 | while (modify_node != NULL) |
| 1008 | { |
| 1009 | temp_char = xmlGetProp(modify_node, "profile_idx"); |
| 1010 | if (temp_char == NULL) |
| 1011 | { |
| 1012 | modify_node = modify_node->next; |
| 1013 | continue; |
| 1014 | } |
| 1015 | sprintf(temp,"%s",temp_char); |
| 1016 | apn_list->apn[node_num].profile_idx = (unsigned char)atoi(temp); |
| 1017 | apn_list->apn[node_num].pdp_type = (qser_apn_pdp_type_e)atoi(xmlGetProp(modify_node, "pdp_type")); |
| 1018 | 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] | 1019 | strncpy(apn_list->apn[node_num].apn_name,(char *)xmlGetProp(modify_node, "apn_name"), QSER_APN_NAME_SIZE); |
| 1020 | strncpy(apn_list->apn[node_num].username,(char *)xmlGetProp(modify_node, "username"), QSER_APN_USERNAME_SIZE); |
| 1021 | strncpy(apn_list->apn[node_num].password,(char *)xmlGetProp(modify_node, "password"), QSER_APN_PASSWORD_SIZE); |
| 1022 | 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] | 1023 | node_num ++; |
| 1024 | modify_node = modify_node->next; |
| 1025 | } |
| 1026 | apn_list->cnt = node_num; |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1027 | // xmlSaveFormatFileEnc(data_xml_path, apn_table_xml_pdoc, "UTF-8", 1); |
| 1028 | // xmlFreeDoc(apn_table_xml_pdoc); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1029 | return RESULT_OK; |
| 1030 | |
| 1031 | FAILED: |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1032 | // if (apn_table_xml_pdoc) |
| 1033 | // { |
| 1034 | // xmlFreeDoc(apn_table_xml_pdoc); |
| 1035 | // } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1036 | return RESULT_ERROR; |
| 1037 | } |
| 1038 | |
| 1039 | void judge_pdp_type(qser_apn_pdp_type_e pdp_type,char *out_pdp_type) |
| 1040 | { |
| 1041 | switch (pdp_type) |
| 1042 | { |
| 1043 | case QSER_APN_PDP_TYPE_IPV4: |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 1044 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1045 | strcpy(out_pdp_type,"IP"); |
| 1046 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1047 | strcpy(out_pdp_type,"IPV4"); |
xf.li | 9e27f3d | 2023-11-30 00:43:13 -0800 | [diff] [blame] | 1048 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1049 | break; |
| 1050 | case QSER_APN_PDP_TYPE_PPP: |
| 1051 | strcpy(out_pdp_type,"PPP"); |
| 1052 | break; |
| 1053 | case QSER_APN_PDP_TYPE_IPV6: |
| 1054 | strcpy(out_pdp_type,"IPV6"); |
| 1055 | break; |
| 1056 | case QSER_APN_PDP_TYPE_IPV4V6: |
| 1057 | strcpy(out_pdp_type,"IPV4V6"); |
| 1058 | break; |
| 1059 | default: |
| 1060 | strcpy(out_pdp_type,"NULL"); |
| 1061 | break; |
| 1062 | } |
| 1063 | return; |
| 1064 | } |
| 1065 | void judge_authtype(qser_apn_auth_proto_e auth_proto,char *out_proto) |
| 1066 | { |
| 1067 | switch (auth_proto) |
| 1068 | { |
| 1069 | case QSER_APN_AUTH_PROTO_DEFAULT: |
| 1070 | strcpy(out_proto,"NULL;authType=0"); |
| 1071 | break; |
| 1072 | case QSER_APN_AUTH_PROTO_NONE: |
| 1073 | strcpy(out_proto,"NULL;authType=1"); |
| 1074 | break; |
| 1075 | case QSER_APN_AUTH_PROTO_PAP: |
| 1076 | strcpy(out_proto,"NULL;authType=2"); |
| 1077 | break; |
| 1078 | case QSER_APN_AUTH_PROTO_CHAP: |
| 1079 | strcpy(out_proto,"NULL;authtype=3"); |
| 1080 | break; |
| 1081 | case QSER_APN_AUTH_PROTO_PAP_CHAP: |
| 1082 | strcpy(out_proto,"NULL;authtype=4"); |
| 1083 | break; |
| 1084 | default: |
| 1085 | strcpy(out_proto,"NULL;authType=NULL"); |
| 1086 | break; |
| 1087 | } |
| 1088 | return ; |
| 1089 | } |
| 1090 | |
| 1091 | int data_call_handle_get(const char profile_idx,int *handle) |
| 1092 | { |
| 1093 | int num = LYNQ_APN_CHANNEL_MAX; |
| 1094 | int table_num = 0; |
| 1095 | lynq_apn_info **apn_table = NULL; |
| 1096 | qser_apn_info_s apn; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1097 | int ret = 0; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1098 | apn_table = (lynq_apn_info **)malloc(sizeof(lynq_apn_info *)*LYNQ_APN_CHANNEL_MAX); |
| 1099 | if (NULL == apn_table) |
| 1100 | { |
| 1101 | LYERRLOG("malloc apn_table fail "); |
| 1102 | return RESULT_ERROR; |
| 1103 | } |
| 1104 | for(int i =0;i<10;i++) |
| 1105 | { |
| 1106 | apn_table[i] = (lynq_apn_info*)malloc(sizeof(lynq_apn_info)); |
| 1107 | if (apn_table[i]==NULL) |
| 1108 | { |
| 1109 | for (int n=0;n<i;n++) |
| 1110 | { |
| 1111 | free(apn_table[n]); |
| 1112 | } |
| 1113 | return RESULT_ERROR; |
| 1114 | } |
| 1115 | memset(apn_table[i],0,sizeof(lynq_apn_info)); |
| 1116 | } |
| 1117 | lynq_get_apn_table(&table_num,apn_table); |
| 1118 | memset(&apn,0,sizeof(qser_apn_info_s)); |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1119 | ret = apn_xml_query(profile_idx,&apn); |
| 1120 | if (ret < 0) |
| 1121 | { |
| 1122 | LYERRLOG("apn_xml_query error"); |
| 1123 | return ret; |
| 1124 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1125 | for (int j = 0;j < table_num;j++) |
| 1126 | { |
| 1127 | if (strcmp(apn.apn_type,apn_table[j]->apnType) == 0) |
| 1128 | { |
| 1129 | *handle = apn_table[j]->index; |
| 1130 | LYINFLOG("apn_table->index:%d,handle:%d ",apn_table[j]->index,*handle); |
| 1131 | break; |
| 1132 | } |
| 1133 | } |
| 1134 | |
| 1135 | for (int i = 0; i < LYNQ_APN_CHANNEL_MAX; i++) |
| 1136 | { |
| 1137 | if (apn_table[i]!=NULL) |
| 1138 | { |
| 1139 | free(apn_table[i]); |
| 1140 | apn_table[i]=NULL; |
| 1141 | } |
| 1142 | } |
| 1143 | free(apn_table); |
| 1144 | apn_table=NULL; |
| 1145 | LYINFLOG("data_call_handle_get end"); |
| 1146 | return RESULT_OK; |
| 1147 | } |
| 1148 | |
| 1149 | void *thread_wait_cb_status(void) |
| 1150 | { |
| 1151 | int handle = -1; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1152 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1153 | int default_handle = LYNQ_APN_CHANNEL_MAX + 1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1154 | lynq_data_call_response_v11_t data_urc_info = {0}; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1155 | qser_data_call_state_s data_cb_state; |
| 1156 | while (s_qser_data_cb_thread_status) |
| 1157 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1158 | ret = lynq_wait_data_call_state_change(&handle); |
| 1159 | LYINFLOG("ret = %d, wait data call state change end!!!\n", ret); |
| 1160 | if(s_qser_data_cb_thread_status == 0) |
| 1161 | { |
| 1162 | return NULL; |
| 1163 | } |
| 1164 | else if(ret < 0) |
| 1165 | { |
| 1166 | continue; |
| 1167 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1168 | LYINFLOG("[thread_wait_cb_status]: handle = %d", handle); |
| 1169 | memset(&data_urc_info, 0, sizeof(data_urc_info)); |
| 1170 | memset(&data_cb_state, 0, sizeof(data_cb_state)); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1171 | lynq_get_data_call_list(&handle,&data_urc_info); |
| 1172 | /*compare paramter*/ |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1173 | //data_cb_state.profile_idx = (char)handle; |
| 1174 | apn_xml_handle_get_profile(handle, &data_cb_state.profile_idx); |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1175 | 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", |
| 1176 | data_urc_info.status, data_urc_info.suggestedRetryTime, data_urc_info.cid, data_urc_info.active, |
| 1177 | data_urc_info.type, data_urc_info.ifname, data_urc_info.addresses, data_urc_info.dnses, data_urc_info.gateways, data_urc_info.pcscf, |
| 1178 | data_urc_info.mtu); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1179 | 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] | 1180 | 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] | 1181 | { |
| 1182 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4; |
| 1183 | } |
| 1184 | else if (!strcmp(data_urc_info.type,"IPV6")) |
| 1185 | { |
| 1186 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV6; |
| 1187 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1188 | else if (!strcmp(data_urc_info.type,"IPV4V6")) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1189 | { |
| 1190 | data_cb_state.ip_family = QSER_DATA_CALL_TYPE_IPV4V6; |
| 1191 | } |
| 1192 | else |
| 1193 | { |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1194 | LYERRLOG("unknow data call type: %s", data_urc_info.type); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1195 | } |
| 1196 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1197 | if (data_urc_info.active != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1198 | { |
| 1199 | data_cb_state.state = QSER_DATA_CALL_CONNECTED; |
| 1200 | } |
| 1201 | else |
| 1202 | { |
| 1203 | data_cb_state.state = QSER_DATA_CALL_DISCONNECTED; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1204 | ret = apn_xml_handle_set(data_cb_state.profile_idx, default_handle); |
| 1205 | if(ret != 0) |
| 1206 | { |
| 1207 | LYERRLOG("handle set error"); |
| 1208 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1209 | } |
| 1210 | if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4) |
| 1211 | { |
| 1212 | lynq_ipv4_aton_urc(&data_urc_info,&data_cb_state); |
| 1213 | } |
| 1214 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV6) |
| 1215 | { |
| 1216 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1217 | } |
| 1218 | else if (data_cb_state.ip_family == QSER_DATA_CALL_TYPE_IPV4V6) |
| 1219 | { |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1220 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1221 | lynq_ipv4v6_inet_pton_urc(&data_urc_info,&data_cb_state); |
| 1222 | #else |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1223 | lynq_ipv6_inet_pton_urc(&data_urc_info,&data_cb_state); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1224 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1225 | } |
| 1226 | else |
| 1227 | { |
| 1228 | LYERRLOG("unknow ip_family"); |
| 1229 | continue; |
| 1230 | } |
| 1231 | if (s_data_call_cb != NULL) |
| 1232 | { |
| 1233 | s_data_call_cb(&data_cb_state); |
| 1234 | } |
| 1235 | } |
| 1236 | return NULL; |
| 1237 | } |
| 1238 | |
| 1239 | int qser_cb_pthread_create() |
| 1240 | { |
| 1241 | int ret; |
| 1242 | s_qser_data_cb_thread_status = 1; |
| 1243 | ret = pthread_create(&s_cb_tid,NULL,thread_wait_cb_status,NULL); |
| 1244 | if (ret < 0) |
| 1245 | { |
| 1246 | LYERRLOG("pthread create fail"); |
| 1247 | s_qser_data_cb_thread_status = 0; |
| 1248 | return RESULT_ERROR; |
| 1249 | } |
| 1250 | return RESULT_OK; |
| 1251 | } |
| 1252 | |
| 1253 | void qser_cb_pthread_cancel() |
| 1254 | { |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1255 | s_qser_data_cb_thread_status = 0; |
| 1256 | if (s_cb_tid != -1) |
| 1257 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1258 | lynq_release_wait_data_call(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1259 | } |
| 1260 | return; |
| 1261 | } |
xf.li | 7b0bfd0 | 2023-08-03 01:11:52 -0700 | [diff] [blame] | 1262 | int check_xml_file(const char *file) |
| 1263 | { |
| 1264 | /* Check for existence */ |
| 1265 | if((access(file, F_OK)) == -1) |
| 1266 | { |
| 1267 | LYERRLOG("no such xml file.\n"); |
| 1268 | system("cp /data/lynq_qser_data_apn.xml /mnt/userdata/"); |
| 1269 | } |
| 1270 | |
| 1271 | if((access(file, F_OK)) == -1) |
| 1272 | { |
| 1273 | LYERRLOG("error copy xml file.\n"); |
| 1274 | return -1; |
| 1275 | } |
| 1276 | return RESULT_OK; |
| 1277 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1278 | |
| 1279 | int qser_data_call_init(qser_data_call_evt_cb_t evt_cb) |
| 1280 | { |
| 1281 | int ret = 0; |
| 1282 | int utoken = 0; |
| 1283 | if (NULL == evt_cb) |
| 1284 | { |
| 1285 | LYERRLOG("init incoming paramters error"); |
| 1286 | return RESULT_ERROR; |
| 1287 | } |
xf.li | 7b0bfd0 | 2023-08-03 01:11:52 -0700 | [diff] [blame] | 1288 | |
| 1289 | ret = check_xml_file(data_xml_path); |
| 1290 | if (ret != RESULT_OK) |
| 1291 | { |
| 1292 | LYERRLOG("check xml file error"); |
| 1293 | return RESULT_ERROR; |
| 1294 | } |
| 1295 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1296 | s_data_call_cb = evt_cb; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1297 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1298 | ret = lynq_init_data(utoken); |
| 1299 | if (ret != RESULT_OK) |
| 1300 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1301 | //qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1302 | s_data_call_cb = NULL; |
| 1303 | return RESULT_ERROR; |
| 1304 | } |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1305 | qser_cb_pthread_create(); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1306 | apn_table_xml_pdoc = xmlReadFile(data_xml_path ,"UTF-8",XML_PARSE_RECOVER); |
| 1307 | if(NULL == apn_table_xml_pdoc) |
| 1308 | { |
| 1309 | LYERRLOG("open xml file error"); |
| 1310 | return RESULT_ERROR; |
| 1311 | } |
xf.li | 63b87e8 | 2024-01-04 00:43:35 -0800 | [diff] [blame^] | 1312 | ret = apn_xml_handle_clean(); |
| 1313 | if(ret != RESULT_OK) |
| 1314 | { |
| 1315 | LYERRLOG("clean handle error"); |
| 1316 | return RESULT_ERROR; |
| 1317 | } |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1318 | g_lynq_qser_data_init_flag = 1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1319 | return RESULT_OK; |
| 1320 | } |
| 1321 | |
| 1322 | void qser_data_call_destroy(void) |
| 1323 | { |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1324 | LYINFLOG("[%s] start [%d]",__FUNCTION__,__LINE__); |
xf.li | e3f55f4 | 2023-12-01 22:47:33 -0800 | [diff] [blame] | 1325 | if(apn_table_xml_pdoc) |
| 1326 | { |
| 1327 | xmlFreeDoc(apn_table_xml_pdoc); |
| 1328 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1329 | lynq_deinit_data(); |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1330 | qser_cb_pthread_cancel(); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1331 | s_data_call_cb = NULL; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1332 | g_lynq_qser_data_init_flag = 0; |
xf.li | 6b0d850 | 2023-09-04 18:49:12 -0700 | [diff] [blame] | 1333 | LYINFLOG("[%s] end [%d]",__FUNCTION__,__LINE__); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1334 | return ; |
| 1335 | } |
| 1336 | |
| 1337 | int qser_data_call_start(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1338 | { |
| 1339 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1340 | int error = -1; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1341 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1342 | if(g_lynq_qser_data_init_flag == 0) |
| 1343 | { |
| 1344 | if(err != NULL) |
| 1345 | { |
| 1346 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1347 | } |
| 1348 | return LYNQ_E_NO_INIT; |
| 1349 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1350 | if (NULL == data_call || NULL == err) |
| 1351 | { |
| 1352 | LYERRLOG("call start incoming paramters error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1353 | if(err != NULL) |
| 1354 | { |
| 1355 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1356 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1357 | return ret; |
| 1358 | } |
| 1359 | if (data_call->profile_idx == 0) |
| 1360 | { |
| 1361 | ret = lynq_setup_data_call(&handle); |
| 1362 | } |
| 1363 | else |
| 1364 | { |
| 1365 | char pdptype[16]; |
| 1366 | qser_apn_info_s apn_info; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1367 | ret = qser_apn_get(data_call->profile_idx,&apn_info); |
| 1368 | if (ret != 0) |
| 1369 | { |
| 1370 | LYERRLOG("qser_apn_get error"); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1371 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | 0fc2650 | 2023-09-16 02:10:17 -0700 | [diff] [blame] | 1372 | return ret; |
| 1373 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1374 | judge_pdp_type(apn_info.pdp_type,pdptype); |
| 1375 | ret = lynq_setup_data_call_sp(&handle,apn_info.apn_name,apn_info.apn_type,apn_info.username,apn_info.password,NULL,pdptype,pdptype); |
| 1376 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1377 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1378 | { |
| 1379 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1380 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1381 | else |
| 1382 | { |
| 1383 | error = apn_xml_handle_set(data_call->profile_idx, handle); |
| 1384 | if(error != 0) |
| 1385 | { |
| 1386 | LYERRLOG("handle set error"); |
| 1387 | } |
| 1388 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1389 | return ret; |
| 1390 | } |
| 1391 | |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1392 | int qser_data_call_start_async(qser_data_call_s *data_call, qser_data_call_error_e *err) |
| 1393 | { |
| 1394 | int ret = -1; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1395 | int error = -1; |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1396 | int handle = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1397 | if(g_lynq_qser_data_init_flag == 0) |
| 1398 | { |
| 1399 | if(err != NULL) |
| 1400 | { |
| 1401 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1402 | } |
| 1403 | return LYNQ_E_NO_INIT; |
| 1404 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1405 | if (NULL == data_call || NULL == err) |
| 1406 | { |
| 1407 | LYERRLOG("call start incoming paramters error"); |
| 1408 | if(err != NULL) |
| 1409 | { |
| 1410 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1411 | } |
| 1412 | return ret; |
| 1413 | } |
| 1414 | if (data_call->profile_idx == 0) |
| 1415 | { |
| 1416 | ret = lynq_setup_data_call_sp_t106_async(&handle,"default","default",NULL,NULL,NULL,NULL,NULL); |
| 1417 | } |
| 1418 | else |
| 1419 | { |
| 1420 | char pdptype[16]; |
| 1421 | qser_apn_info_s apn_info; |
| 1422 | ret = qser_apn_get(data_call->profile_idx,&apn_info); |
| 1423 | if (ret != 0) |
| 1424 | { |
| 1425 | LYERRLOG("qser_apn_get error"); |
| 1426 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1427 | return ret; |
| 1428 | } |
| 1429 | judge_pdp_type(apn_info.pdp_type,pdptype); |
| 1430 | 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); |
| 1431 | } |
| 1432 | if (ret != 0) |
| 1433 | { |
| 1434 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1435 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1436 | else |
| 1437 | { |
| 1438 | error = apn_xml_handle_set(data_call->profile_idx, handle); |
| 1439 | if(error != 0) |
| 1440 | { |
| 1441 | LYERRLOG("handle set error"); |
| 1442 | } |
| 1443 | } |
xf.li | 8535bc0 | 2023-12-12 23:28:35 -0800 | [diff] [blame] | 1444 | return ret; |
| 1445 | } |
| 1446 | |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1447 | int qser_data_call_stop(char profile_idx, qser_data_call_ip_family_e ip_family, qser_data_call_error_e *err) |
| 1448 | { |
| 1449 | int ret = 0; |
| 1450 | int handle = -1; |
| 1451 | |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1452 | if(g_lynq_qser_data_init_flag == 0) |
| 1453 | { |
| 1454 | if(err != NULL) |
| 1455 | { |
| 1456 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1457 | } |
| 1458 | return LYNQ_E_NO_INIT; |
| 1459 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1460 | if (NULL == err) |
| 1461 | { |
| 1462 | LYERRLOG("call stop incoming paramters error"); |
| 1463 | return ret; |
| 1464 | } |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1465 | ret = data_call_handle_get(profile_idx,&handle); |
| 1466 | if(ret != 0) |
| 1467 | { |
| 1468 | LYERRLOG("datacall handle get error"); |
| 1469 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
| 1470 | return ret; |
| 1471 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1472 | ret = lynq_deactive_data_call(&handle); |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1473 | if (ret != 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1474 | { |
| 1475 | *err = QSER_DATA_CALL_ERROR_INVALID_PARAMS; |
xf.li | c12b370 | 2023-11-22 22:39:01 -0800 | [diff] [blame] | 1476 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1477 | } |
xy.he | e2daacc | 2023-09-18 00:57:51 -0700 | [diff] [blame] | 1478 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1479 | } |
| 1480 | 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) |
| 1481 | { |
| 1482 | int ret = 0; |
| 1483 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1484 | if(g_lynq_qser_data_init_flag == 0) |
| 1485 | { |
| 1486 | if(err != NULL) |
| 1487 | { |
| 1488 | *err = QSER_DATA_CALL_ERROR_NO_INIT; |
| 1489 | } |
| 1490 | return LYNQ_E_NO_INIT; |
| 1491 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1492 | lynq_data_call_response_v11_t data_call_info; |
| 1493 | data_call_handle_get(profile_idx,&handle); |
| 1494 | ret = lynq_get_data_call_list(&handle,&data_call_info); |
| 1495 | if (ret == 0) |
| 1496 | { |
| 1497 | info->profile_idx = profile_idx; |
| 1498 | info->ip_family = ip_family; |
xf.li | 157f7e9 | 2023-10-19 23:22:46 -0700 | [diff] [blame] | 1499 | 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] | 1500 | { |
| 1501 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1502 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1503 | LYINFLOG("[IPV4]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1504 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
| 1505 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1506 | else if (strncmp(data_call_info.type,"IPV6", strlen("IPV6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1507 | { |
| 1508 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1509 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1510 | LYINFLOG("[IPV6]addresses:%s,gateways:%s,dnses:%s",data_call_info.addresses,data_call_info.gateways,data_call_info.dnses); |
| 1511 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
| 1512 | } |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1513 | else if (strncmp(data_call_info.type,"IPV4V6", strlen("IPV4V6") + 1) == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1514 | { |
| 1515 | strcpy(info->v4.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1516 | datacall_ipv4_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1517 | 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] | 1518 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1519 | lynq_ipv4_aton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1520 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1521 | strcpy(info->v6.name,data_call_info.ifname); |
xf.li | b5dc063 | 2023-11-30 18:20:35 -0800 | [diff] [blame] | 1522 | datacall_ipv6_status_judge(data_call_info.active,info); |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1523 | 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] | 1524 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1525 | lynq_ipv6_inet_pton_getinfo(&data_call_info,info); |
xf.li | 3c0a475 | 2023-09-03 20:46:19 -0700 | [diff] [blame] | 1526 | #endif |
| 1527 | #ifdef MOBILETEK_TARGET_PLATFORM_T106 |
| 1528 | lynq_ipv4v6_inet_pton_getinfo(&data_call_info,info); |
| 1529 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1530 | } |
| 1531 | else |
| 1532 | { |
| 1533 | LYERRLOG("useless qser_data_call_ip_family_e"); |
| 1534 | } |
| 1535 | } |
| 1536 | return ret; |
| 1537 | } |
| 1538 | int qser_apn_set(qser_apn_info_s *apn) |
| 1539 | { |
| 1540 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1541 | int handle = -1; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1542 | if(g_lynq_qser_data_init_flag == 0) |
| 1543 | { |
| 1544 | return LYNQ_E_NO_INIT; |
| 1545 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1546 | if (NULL == apn || apn->profile_idx == 0) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1547 | { |
| 1548 | LYERRLOG("apn set incoming paramters error"); |
| 1549 | return RESULT_ERROR; |
| 1550 | } |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1551 | ret = apn_xml_handle_get(apn->profile_idx, &handle); |
| 1552 | if(ret != 0) |
| 1553 | { |
| 1554 | LYERRLOG("handle set error"); |
| 1555 | } |
| 1556 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1557 | { |
| 1558 | LYERRLOG("It has setup datacall"); |
| 1559 | return RESULT_ERROR; |
| 1560 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1561 | ret = apn_xml_modify(apn); |
| 1562 | if (ret < 0) |
| 1563 | { |
| 1564 | LYERRLOG("apn_xml_modify error"); |
| 1565 | return ret; |
| 1566 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1567 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1568 | int apn_id = 0; |
| 1569 | char tmp_id[12]; |
| 1570 | char *outinfo = NULL; |
| 1571 | char normalprotocol[16]; |
| 1572 | char authtype[32]; |
| 1573 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1574 | bzero(tmp_id,12); |
| 1575 | bzero(outinfo,512); |
| 1576 | apn_id = apn->profile_idx + apndb_offset; |
| 1577 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1578 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1579 | judge_authtype(apn->auth_proto,authtype); |
| 1580 | lynq_modify_apn_db(3,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1581 | LYINFLOG("[output]:%s",outinfo); |
| 1582 | free(outinfo); |
| 1583 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1584 | #endif |
| 1585 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1586 | } |
| 1587 | |
| 1588 | int qser_apn_get(unsigned char profile_idx, qser_apn_info_s *apn) |
| 1589 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1590 | if(g_lynq_qser_data_init_flag == 0) |
| 1591 | { |
| 1592 | return LYNQ_E_NO_INIT; |
| 1593 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1594 | if (profile_idx < 0 || profile_idx > 24 || NULL == apn) |
| 1595 | { |
| 1596 | LYERRLOG("apn get incoming paramters error"); |
| 1597 | return RESULT_ERROR; |
| 1598 | } |
| 1599 | int ret = 0; |
| 1600 | ret = apn_xml_query(profile_idx,apn); |
| 1601 | if (ret < 0) |
| 1602 | { |
| 1603 | LYERRLOG("apn_xml_query error"); |
| 1604 | return ret; |
| 1605 | } |
| 1606 | return ret; |
| 1607 | } |
| 1608 | |
| 1609 | int qser_apn_add(qser_apn_add_s *apn, unsigned char *profile_idx) |
| 1610 | { |
| 1611 | int ret = 0; |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1612 | if(g_lynq_qser_data_init_flag == 0) |
| 1613 | { |
| 1614 | return LYNQ_E_NO_INIT; |
| 1615 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1616 | if (NULL == apn || NULL == profile_idx) |
| 1617 | { |
| 1618 | LYERRLOG("apn add incoming paramters error"); |
| 1619 | return RESULT_ERROR; |
| 1620 | } |
| 1621 | ret = apn_xml_add(apn,profile_idx); |
| 1622 | if (ret < 0) |
| 1623 | { |
| 1624 | LYERRLOG("apn_xml_add error"); |
| 1625 | return ret; |
| 1626 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1627 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1628 | int apn_id = 0; |
| 1629 | char tmp_id[12]; |
| 1630 | char *outinfo = NULL; |
| 1631 | char normalprotocol[16]; |
| 1632 | char authtype[32]; |
| 1633 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1634 | bzero(tmp_id,12); |
| 1635 | bzero(outinfo,512); |
| 1636 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1637 | judge_pdp_type(apn->pdp_type,normalprotocol); |
| 1638 | judge_authtype(apn->auth_proto,authtype); |
| 1639 | lynq_modify_apn_db(0,tmp_id,NULL,NULL,apn->apn_name,apn->apn_type,apn->username,apn->password,normalprotocol,normalprotocol,authtype,outinfo); |
| 1640 | LYINFLOG("[output]:%s",outinfo); |
| 1641 | free(outinfo); |
| 1642 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1643 | #endif |
| 1644 | return ret; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1645 | } |
| 1646 | |
| 1647 | int qser_apn_del(unsigned char profile_idx) |
| 1648 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1649 | if(g_lynq_qser_data_init_flag == 0) |
| 1650 | { |
| 1651 | return LYNQ_E_NO_INIT; |
| 1652 | } |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1653 | if (profile_idx <= 0 || profile_idx > QSER_APN_MAX_LIST) |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1654 | { |
| 1655 | LYERRLOG("apn del incoming paramters error"); |
xf.li | 4b18fa6 | 2023-12-19 19:38:10 -0800 | [diff] [blame] | 1656 | return RESULT_ERROR; |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1657 | } |
| 1658 | int ret = 0; |
xf.li | 0fd6acf | 2023-12-20 18:16:34 -0800 | [diff] [blame] | 1659 | int handle = -1; |
| 1660 | ret = apn_xml_handle_get(profile_idx, &handle); |
| 1661 | if(ret != 0) |
| 1662 | { |
| 1663 | LYERRLOG("handle set error"); |
| 1664 | } |
| 1665 | if(handle >= 0 && handle < LYNQ_APN_CHANNEL_MAX) |
| 1666 | { |
| 1667 | LYERRLOG("It has setup datacall"); |
| 1668 | return RESULT_ERROR; |
| 1669 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1670 | ret = apn_xml_delete(profile_idx); |
| 1671 | if (ret < 0) |
| 1672 | { |
| 1673 | LYERRLOG("apn_xml_delete error"); |
| 1674 | return ret; |
| 1675 | } |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1676 | #ifndef MOBILETEK_TARGET_PLATFORM_T106 |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1677 | int apn_id = 0; |
| 1678 | char tmp_id[12]; |
| 1679 | char *outinfo = NULL; |
| 1680 | outinfo = (char *)malloc(sizeof(char)*512); |
| 1681 | bzero(tmp_id,12); |
| 1682 | bzero(outinfo,512); |
| 1683 | apn_id = profile_idx+apndb_offset; |
| 1684 | snprintf(tmp_id,sizeof(tmp_id),"%d",apn_id); |
| 1685 | lynq_modify_apn_db(1,tmp_id,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,outinfo); |
| 1686 | LYINFLOG("[output]:%s",outinfo); |
| 1687 | free(outinfo); |
| 1688 | outinfo = NULL; |
xf.li | 6c7e397 | 2023-10-27 20:01:59 -0700 | [diff] [blame] | 1689 | #endif |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1690 | return ret; |
| 1691 | } |
| 1692 | |
| 1693 | int qser_apn_get_list(qser_apn_info_list_s *apn_list) |
| 1694 | { |
xf.li | b33d486 | 2023-12-13 00:40:37 -0800 | [diff] [blame] | 1695 | if(g_lynq_qser_data_init_flag == 0) |
| 1696 | { |
| 1697 | return LYNQ_E_NO_INIT; |
| 1698 | } |
xf.li | 2fc8455 | 2023-06-23 05:26:47 -0700 | [diff] [blame] | 1699 | if (NULL == apn_list) |
| 1700 | { |
| 1701 | LYERRLOG("apn_list incoming paramters error"); |
| 1702 | return RESULT_ERROR; |
| 1703 | } |
| 1704 | int ret = 0; |
| 1705 | ret = apn_xml_query_list(apn_list); |
| 1706 | if (ret < 0) |
| 1707 | { |
| 1708 | LYERRLOG("apn_xml_query_list error"); |
| 1709 | return ret; |
| 1710 | } |
| 1711 | return ret; |
xf.li | 3f891cb | 2023-08-23 23:11:24 -0700 | [diff] [blame] | 1712 | } |
you.chen | 21c62b7 | 2023-09-08 09:41:11 +0800 | [diff] [blame] | 1713 | |
| 1714 | DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_DATA) |
| 1715 | |