blob: cb2ad0b8884ffc8631dd80c2e0c50b7e4988a546 [file] [log] [blame]
lhf81a46f2022-02-13 23:57:37 -08001#include <stdio.h>
2#include <sys/types.h>
3#include <sys/socket.h>
4#include <arpa/inet.h>
5#include <fcntl.h>
6#include <string.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <binder/Parcel.h>
10#include <log/log.h>
11#include "lynq_data.h"
12#include <cutils/jstring.h>
13#include <pthread.h>
14#include "liblog/lynq_deflog.h"
15#include <sys/time.h>
rjw0cdacbc2022-06-22 10:51:07 +080016#include <include/lynq_uci.h>
rjw747deea2022-07-01 18:25:30 +080017#include <errno.h>
rjw7ee7bb42023-01-18 11:34:28 +080018#include <vector>
19#include "lynq_data_urc.h"
20
lhf81a46f2022-02-13 23:57:37 -080021#define LYNQ_SERVICE_PORT 8088
lh8d290112023-10-22 20:53:06 -070022#define LYNQ_RIL_FWK_IP "127.0.0.1"
23
lhf81a46f2022-02-13 23:57:37 -080024#define LYNQ_REC_BUF 8192
25#define LYNQ_REQUEST_PARAM_BUF 8192
26#define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
27#define USER_LOG_TAG "LYNQ_DATA"
28
rjw0cdacbc2022-06-22 10:51:07 +080029#define LYNQ_DATA_UCI_BUF 258
Hong_Liu25edfe72023-06-16 01:13:42 -070030#define LYNQ_DATA_TIME_OUT 1000*120
xy.hef5d74f12023-10-23 06:48:52 -070031#define TELEPHONY_RESTART 10
Hong_Liu7163bbe2023-06-04 03:03:44 -070032
rjw61fcae32022-08-18 14:03:39 +080033
lhf81a46f2022-02-13 23:57:37 -080034using ::android::Parcel;
35typedef struct{
36 int uToken;
37 int request;
38 int paramLen;
39 char param[LYNQ_REQUEST_PARAM_BUF];
40}lynq_client_t;
lh13586612022-01-11 21:58:58 -080041typedef enum{
42 LYNQ_E_CARDSTATE_ERROR=8000,
43 /* The voice service state is out of service*/
44 LYNQ_E_STATE_OUT_OF_SERVICE=8001,
45 /* The voice service state is EMERGENCY_ONLY*/
46 LYNQ_E_STATE_EMERGENCY_ONLY=8002,
47 /* The radio power is power off*/
48 LYNQ_E_STATE_POWER_OFF=8003,
49 LYNQ_E_TIME_OUT=8004,
50 /*create or open sms DB fail */
51 LYNQ_E_SMS_DB_FAIL=8005,
52 /*Failed to execute sql statement*/
53 LYNQ_E_SMS_SQL_FAIL = 8006,
54 LYNQ_E_SMS_NOT_FIND = 8007,
Hong_Liu25edfe72023-06-16 01:13:42 -070055 LYNQ_E_GET_RESP_FAIL = 8008,
56 LYNQ_E_NOT_THIS_APN = 8087,
57 LYNQ_E_NOT_ANY_APN = 8088,
58 LYNQ_E_MD_NOT_READY = 8089,
lh13586612022-01-11 21:58:58 -080059 /* The logic conflict*/
60 LYNQ_E_CONFLICT=9000,
61 /*Null anomaly*/
62 LYNQ_E_NULL_ANONALY=9001
lhf81a46f2022-02-13 23:57:37 -080063}LYNQ_E;
64
lha62e0882023-10-31 05:17:11 -070065typedef enum {
66 PDN_IDLE,
67 PDN_CONNECTING,
68 PDN_CONNECTED,
69 PDN_DISCONNECTING,
70 PDN_DISCONNECTED,
71 PDN_RETRYING,
72 PDN_FAILED,
73 PDN_SCANNING,
74 PDN_TIMEOUT_CANCEL,
75} RIL_Data_Call_PdnState;
76
lhf81a46f2022-02-13 23:57:37 -080077int lynq_client_sockfd = 0;
78int Global_uToken = 0;
Hong_Liu7e1b85e2023-05-16 05:51:57 -070079struct sockaddr_in lynq_data_socket_server_addr;
80int lynq_data_socket_server_addr_len;
rjw7ee7bb42023-01-18 11:34:28 +080081
lhf81a46f2022-02-13 23:57:37 -080082int lynq_data_call_change_id = -1;
xy.hef5d74f12023-10-23 06:48:52 -070083int lynq_telephony_restart_g = 0;
lhf81a46f2022-02-13 23:57:37 -080084pthread_t lynq_data_tid =-1;
85static pthread_mutex_t s_data_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
xy.hefe801322024-07-16 18:29:19 +080086//xy.he modified started @20240716
87static pthread_cond_t s_data_call_state_change_cond;
88//xy.he modified ended @20240716
rjw7ee7bb42023-01-18 11:34:28 +080089
Hong_Liu25edfe72023-06-16 01:13:42 -070090static pthread_mutex_t s_data_call_deactived_mutex = PTHREAD_MUTEX_INITIALIZER;
xy.hefe801322024-07-16 18:29:19 +080091//xy.he modified started @20240716
92static pthread_cond_t s_data_call_deactived_cond;
93//xy.he modified ended @20240716
Hong_Liu25edfe72023-06-16 01:13:42 -070094
95
rjw20006d12022-04-21 16:29:04 +080096static pthread_mutex_t s_lynq_apn_change_mutex = PTHREAD_MUTEX_INITIALIZER;
xy.hefe801322024-07-16 18:29:19 +080097//xy.he modified started @20240716
98static pthread_cond_t s_lynq_apn_change_cond;
99//xy.he modified ended @20240716
rjw7ee7bb42023-01-18 11:34:28 +0800100static pthread_mutex_t s_lynq_urc_vector_mutex = PTHREAD_MUTEX_INITIALIZER;
101static pthread_cond_t s_lynq_urc_vector_cond = PTHREAD_COND_INITIALIZER;
rjwed00d042022-05-25 09:18:16 +0800102/**g_lynq_data_sendto_mutex
103* @brief mark data send request mutex
104*/
105static pthread_mutex_t g_lynq_data_sendto_mutex;
rjwf9ec3832023-04-12 10:59:15 +0800106/*This value data the state of the wait*/
rjwc3d6e582023-03-28 17:19:11 +0800107static int data_waiting_status = 0;
rjwf9ec3832023-04-12 10:59:15 +0800108/*The value indicates that 8085 error occurs in data*/
rjwc63abb42023-03-31 18:22:42 +0800109static int data_invaild_error = 0;
rjwf9ec3832023-04-12 10:59:15 +0800110/*This value ensure the data call timing is correct*/
111static int data_timelimit = 0;
rjwc63abb42023-03-31 18:22:42 +0800112
rjw22947c22022-03-15 09:21:29 +0800113/**g_lynq_data_init_flag
114* @brief mark data initialization state
115* 0:deinit status
116* 1:init state
117*/
118static int g_lynq_data_init_flag = 0;
rjw20006d12022-04-21 16:29:04 +0800119/**g_lynq_apn_result
120* @brief temp of apn result info
121*/
122char g_lynq_apn_result[1024] = {};
lha62e0882023-10-31 05:17:11 -0700123int g_data_call_timeout_value = LYNQ_DATA_TIME_OUT;
rjw747deea2022-07-01 18:25:30 +0800124
rjw7ee7bb42023-01-18 11:34:28 +0800125static std::vector<int> s_data_urc_wait_list;
126
rjw20006d12022-04-21 16:29:04 +0800127typedef struct
128{
lhf81a46f2022-02-13 23:57:37 -0800129 char apn[LYNQ_APN_MAX_LEN];
130 char apnType[LYNQ_APN_TYPE_MAX_LEN];
131 char ifaceName[LYNQ_IFACE_NAME_MAX_LEN];
132 int hasUsed;
133 int hasTimeout;
Hong_Liudc46d412023-05-18 13:36:26 -0700134 int status;
135 char statusApnType[LYNQ_APN_TYPE_MAX_LEN];
lhf81a46f2022-02-13 23:57:37 -0800136}lynq_apn_t;
137lynq_apn_t lynq_apn_table[LYNQ_APN_CHANNEL_MAX] = {};
138lynq_data_call_response_v11_t lynq_data_call_lists[LYNQ_APN_CHANNEL_MAX] = {};
139int lynq_data_call = 0;
lhf81a46f2022-02-13 23:57:37 -0800140
xy.hef5d74f12023-10-23 06:48:52 -0700141int radio_switch(int status);
142
lhf81a46f2022-02-13 23:57:37 -0800143int getLynqApnID(char apnType[])
144{
145 int ret = 0;
rjwc63abb42023-03-31 18:22:42 +0800146 int len = 0;
lhf81a46f2022-02-13 23:57:37 -0800147 for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
148 {
Hong_Liudc46d412023-05-18 13:36:26 -0700149 len = strlen(apnType);
Hong_Liu6149f182023-05-12 02:15:14 -0700150 LYINFLOG("apn_table[%d].apnType:%s,input apntype:%s,len:%d",ret,lynq_apn_table[ret].apnType,apnType,len);
rjwc63abb42023-03-31 18:22:42 +0800151 if(strncmp(lynq_apn_table[ret].apnType,apnType,len)==0)
lh13586612022-01-11 21:58:58 -0800152 {
lhf81a46f2022-02-13 23:57:37 -0800153 return ret;
154 }
155 }
156 return -1;
157}
rjw7ee7bb42023-01-18 11:34:28 +0800158
Hong_Liudc46d412023-05-18 13:36:26 -0700159int getDeactApnID(char apnType[])
160{
161 int ret = 0;
162 int len = 0;
163 for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
164 {
165 len = strlen(apnType);
166 LYINFLOG("apn_table[%d].apnType:%s,input apntype:%s,len:%d",ret,lynq_apn_table[ret].apnType,apnType,len);
167 if(strncmp(lynq_apn_table[ret].statusApnType,apnType,len)==0)
168 {
169 return ret;
170 }
171 }
172 return -1;
173}
174
lhf81a46f2022-02-13 23:57:37 -0800175void updateApnTable(lynq_apn_t *apn_table,char apn[],char apntype[],char ifaceName[])
176{
177 LYDBGLOG("[updateApnTable] apn:%s,apntype:%s,ifaceName:%s",apn,apntype,ifaceName);
178 if(apn_table==NULL)
179 {
180 LYERRLOG("apn_table is null");
181 return;
182 }
183 memcpy(apn_table->apn,apn,strlen(apn)+1);
184 memcpy(apn_table->apnType,apntype,strlen(apntype)+1);
185 memcpy(apn_table->ifaceName,ifaceName,strlen(ifaceName)+1);
186 apn_table->hasTimeout = 0;
187 apn_table->hasUsed = 1;
188 return;
189}
rjw7ee7bb42023-01-18 11:34:28 +0800190
lhf81a46f2022-02-13 23:57:37 -0800191void cleanOnceApnTable(int apnId)
192{
Hong_Liudc46d412023-05-18 13:36:26 -0700193 LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
lhf81a46f2022-02-13 23:57:37 -0800194 if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
195 {
196 LYERRLOG("apn id is invalid!!!");
197 return;
198 }
199 lynq_apn_table[apnId].hasTimeout = 0;
200 lynq_apn_table[apnId].hasUsed = 0;
Hong_Liudc46d412023-05-18 13:36:26 -0700201 memcpy(lynq_apn_table[apnId].statusApnType,lynq_apn_table[apnId].apnType,strlen(lynq_apn_table[apnId].apnType));
lhf81a46f2022-02-13 23:57:37 -0800202 bzero(lynq_apn_table[apnId].apn,LYNQ_APN_MAX_LEN);
Hong_Liudc46d412023-05-18 13:36:26 -0700203 bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);
lhf81a46f2022-02-13 23:57:37 -0800204 bzero(lynq_apn_table[apnId].ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
Hong_Liudc46d412023-05-18 13:36:26 -0700205 lynq_apn_table[apnId].status = 32;
lhf81a46f2022-02-13 23:57:37 -0800206 return;
207}
Hong_Liudc46d412023-05-18 13:36:26 -0700208void cleanDeactApn(int apnId)
209{
210 LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
211 if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
212 {
213 LYERRLOG("apn id is invalid!!!");
214 return;
215 }
216 lynq_apn_table[apnId].status = 0;
217 bzero(lynq_apn_table[apnId].statusApnType,LYNQ_APN_TYPE_MAX_LEN);
218}
219
220void updateDeactApn(int apnId,int pdnState)
221{
222 LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
223 if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
224 {
225 LYERRLOG("apn id is invalid!!!");
226 return;
227 }
228 lynq_apn_table[apnId].status = pdnState;
229}
230
231
lhf81a46f2022-02-13 23:57:37 -0800232int getUnusedElement()
233{
Hong_Liudc46d412023-05-18 13:36:26 -0700234 if (lynq_apn_table == NULL)
235 {
236 LYERRLOG("get UnusedElemnt apn_table is null");
237 return -1;
238 }
lhf81a46f2022-02-13 23:57:37 -0800239 for(int i=0;i < LYNQ_APN_CHANNEL_MAX; i++)
240 {
241 if(lynq_apn_table[i].hasUsed!=1)
242 {
243 return i;
244 }
245 }
rjwc63abb42023-03-31 18:22:42 +0800246 LYERRLOG("None of get unused Element");
lhf81a46f2022-02-13 23:57:37 -0800247 return -1;
248}
249int updateApn(char apnType[])
250{
251 int ret = 0;
252 ret = getUnusedElement();
Hong_Liu55668712023-05-16 21:49:17 -0700253 if(ret >= 0)
Hong_Liu7e1b85e2023-05-16 05:51:57 -0700254 {
255 memcpy(lynq_apn_table[ret].apnType,apnType,strlen(apnType)+1);
256 lynq_apn_table[ret].hasUsed = 1;
257 }
lhf81a46f2022-02-13 23:57:37 -0800258 return ret;
259}
Hong_Liu55c62f52023-08-24 19:05:50 -0700260//@return
261//other:this apn has been used in apn table
262//-1:this apn not has been used in apn table
263int check_used_apn(char apnType[])
264{
265 LYINFLOG("check_used_apn.apnType:%s",apnType);
266 int ret = 0;
267 int len = 0;
268 for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
269 {
270 len = strlen(apnType);
271 if(strncmp(lynq_apn_table[ret].apnType,apnType,len)==0)
272 {
273 LYINFLOG("check_used_apn.apnType:%s in apn table",apnType);
274 return ret;
275 }
276 }
277 return -1;
278}
279int get_handle(char apnType[])
280{
281 int call_id = 0;
282 call_id = check_used_apn(apnType);
283 if(call_id == -1)
284 {
285 call_id = updateApn(apnType);
286 }
287 LYINFLOG("handle:%d",call_id);
288 return call_id;
289}
rjw1309e232022-07-22 09:54:06 +0800290
291int handleCheck(int handle)
292{
Hong_Liu7163bbe2023-06-04 03:03:44 -0700293 if ((handle >= 0) && (handle <= 6))
rjw1309e232022-07-22 09:54:06 +0800294 {
Hong_Liu7163bbe2023-06-04 03:03:44 -0700295 if (lynq_apn_table[handle].hasUsed == 1)
296 {
297 return 0;
298 }
rjw1309e232022-07-22 09:54:06 +0800299 return -1;
300 }
Hong_Liu7163bbe2023-06-04 03:03:44 -0700301 return -1;
rjw1309e232022-07-22 09:54:06 +0800302}
rjw20006d12022-04-21 16:29:04 +0800303int waitApnResult()
304{
305 int ret = 0;
306 LYINFLOG("start wait apn result!!!");
307 int sec = 0;
308 int usec = 0;
xy.hefe801322024-07-16 18:29:19 +0800309 //xy.he modified started @20240716
rjw20006d12022-04-21 16:29:04 +0800310 struct timespec timeout;
xy.hefe801322024-07-16 18:29:19 +0800311 struct timespec now;
rjw20006d12022-04-21 16:29:04 +0800312 sec = 20000 / 1000;
313 usec = 20000 % 1000;
xy.hefe801322024-07-16 18:29:19 +0800314 clock_gettime(CLOCK_MONOTONIC, &now);
rjw20006d12022-04-21 16:29:04 +0800315 timeout.tv_sec = now.tv_sec + sec;
xy.hefe801322024-07-16 18:29:19 +0800316 timeout.tv_nsec = now.tv_nsec + usec * 1000000;
317 //xy.he modified ended @20240716
rjw20006d12022-04-21 16:29:04 +0800318 pthread_mutex_lock(&s_lynq_apn_change_mutex);
319 ret = pthread_cond_timedwait(&s_lynq_apn_change_cond, &s_lynq_apn_change_mutex, &timeout);
320 pthread_mutex_unlock(&s_lynq_apn_change_mutex);
321 return ret;
322}
323
324void sendSignalApnChange()
325{
326 LYINFLOG("start send Signal Apn Change");
327 pthread_mutex_lock(&s_lynq_apn_change_mutex);
328 pthread_cond_signal(&s_lynq_apn_change_cond);
329 pthread_mutex_unlock(&s_lynq_apn_change_mutex);
330 return;
331}
lhf81a46f2022-02-13 23:57:37 -0800332
333int waitPdnChange()
334{
335 int ret = 0;
rjw7ee7bb42023-01-18 11:34:28 +0800336 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
337 ret = pthread_cond_wait(&s_lynq_urc_vector_cond,&s_lynq_urc_vector_mutex);
338 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
lhf81a46f2022-02-13 23:57:37 -0800339 return ret;
340}
341int waitDataCallstateChange(int mtime)
342{
343 int ret = 0;
344 int sec = 0;
345 int usec = 0;
xy.hefe801322024-07-16 18:29:19 +0800346 //xy.he modified started @20240716
lhf81a46f2022-02-13 23:57:37 -0800347 struct timespec timeout;
xy.hefe801322024-07-16 18:29:19 +0800348 struct timespec now;
349 sec = mtime / 1000;
350 usec = mtime % 1000;
351 clock_gettime(CLOCK_MONOTONIC, &now);
352 timeout.tv_sec = now.tv_sec + sec;
353 timeout.tv_nsec = now.tv_nsec + usec * 1000000;
354 //xy.he modified ended @20240716
lhf81a46f2022-02-13 23:57:37 -0800355 pthread_mutex_lock(&s_data_call_state_change_mutex);
356 ret = pthread_cond_timedwait(&s_data_call_state_change_cond,&s_data_call_state_change_mutex,&timeout);
357 pthread_mutex_unlock(&s_data_call_state_change_mutex);
358 return ret;
359}
360void sendSignalDataCallStateChange()
361{
362 pthread_mutex_lock(&s_data_call_state_change_mutex);
363 pthread_cond_signal(&s_data_call_state_change_cond);
364 pthread_mutex_unlock(&s_data_call_state_change_mutex);
365 return;
366}
Hong_Liu25edfe72023-06-16 01:13:42 -0700367int waitDeactived(int mtime)
368{
369 int ret = 0;
370 int sec = 0;
371 int usec = 0;
xy.hefe801322024-07-16 18:29:19 +0800372 //xy.he modified started @20240716
Hong_Liu25edfe72023-06-16 01:13:42 -0700373 struct timespec timeout;
xy.hefe801322024-07-16 18:29:19 +0800374 struct timespec now;
375 sec = mtime / 1000;
376 usec = mtime % 1000;
377 clock_gettime(CLOCK_MONOTONIC, &now);
378 timeout.tv_sec = now.tv_sec + sec;
379 timeout.tv_nsec = now.tv_nsec + usec * 1000000;
380 //xy.he modified ended @20240716
Hong_Liu25edfe72023-06-16 01:13:42 -0700381 pthread_mutex_lock(&s_data_call_deactived_mutex);
382 ret = pthread_cond_timedwait(&s_data_call_deactived_cond,&s_data_call_deactived_mutex,&timeout);
383 pthread_mutex_unlock(&s_data_call_deactived_mutex);
384 return ret;
385}
386void sendSignalDeactvied()
387{
388 pthread_mutex_lock(&s_data_call_deactived_mutex);
389 pthread_cond_signal(&s_data_call_deactived_cond);
390 pthread_mutex_unlock(&s_data_call_deactived_mutex);
391 return;
392}
393
lhf81a46f2022-02-13 23:57:37 -0800394void sendSignalPdnChange()
395{
rjw7ee7bb42023-01-18 11:34:28 +0800396 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
397 pthread_cond_signal(&s_lynq_urc_vector_cond);
398 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
lhf81a46f2022-02-13 23:57:37 -0800399 return;
400}
401
402int get_response(int sockfd,Parcel &p)
403{
404 int len = 0;
405 char recvline[LYNQ_REC_BUF];
406 bzero(recvline,LYNQ_REC_BUF);
407 /* receive data from server */
Hong_Liu7e1b85e2023-05-16 05:51:57 -0700408 len = recvfrom(sockfd,recvline,LYNQ_REC_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,(socklen_t *)&lynq_data_socket_server_addr_len);
409 //len = read(sockfd, recvline, LYNQ_REC_BUF);
rjw08528682022-07-04 21:28:02 +0800410 if(len == -1)
lhf81a46f2022-02-13 23:57:37 -0800411 {
Hong_Liu7e1b85e2023-05-16 05:51:57 -0700412 LYERRLOG("get_response fail,errno:%d",errno);
lhf81a46f2022-02-13 23:57:37 -0800413 return -1;
414 }
415 if (recvline != NULL) {
416 p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
417 p.setDataPosition(0);
418 }
419 return 0;
420}
Hong_Liu25edfe72023-06-16 01:13:42 -0700421/**@brief get utoken in range 0 to 10000
422* @return utoken
423*/
424int get_utoken()
lhf81a46f2022-02-13 23:57:37 -0800425{
Hong_Liu25edfe72023-06-16 01:13:42 -0700426 return (Global_uToken++)%10000;/*0-10000*/
427}
428/**@brief wait response with expected token and write msg to parcel in some time
429* @param fd [IN]: socket fd
430* @param p [OUT]: quote the parcel,if return success need delete p.
431* @param token [IN]: the expected token for the response msg
432* @return
433* 0:success
434* other:failure
435*/
436int wait_response(int sockfd,Parcel *& p,int utoken)
437{
438 int len = 0;
439 int flag = 1;
440 int count = 0;
441 int in_utoken = -1;
442 int resp_type = -1;
443 Parcel *temp = NULL;
444 char recvline[LYNQ_REC_BUF];
445 //Sometimes the socket is abnormal, causing the socket buffer to store the response of the last request.
446 //Here it does not return until the response corresponding to the request is read.
447 while(flag && (count < 20))//why?
lhf81a46f2022-02-13 23:57:37 -0800448 {
Hong_Liu25edfe72023-06-16 01:13:42 -0700449 bzero(recvline,LYNQ_REC_BUF);
450 count++;
451 LYINFLOG("wait_response,count:%d",count);
452 len = recvfrom(sockfd,recvline,LYNQ_REC_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,(socklen_t *)&lynq_data_socket_server_addr_len);
453 if(len == -1)
454 {
455 LYERRLOG("wait_response fail,errno:%d",errno);
456 return LYNQ_E_GET_RESP_FAIL;
457 }
458 if (len != 0)
459 {
460 temp = new Parcel;
461 int i = 0;
462 while((NULL == temp) && (i < 100))
463 {
464 usleep(1000);
465 temp = new Parcel;
466 i++;
467 }
468 if((i >= 100) || (NULL == temp))
469 {
470 LYERRLOG("wait_response i:%d",i);
471 return LYNQ_E_GET_RESP_FAIL;
472 }
473 temp->setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
474 temp->setDataPosition(0);
475 temp->readInt32(&resp_type);
476 temp->readInt32(&in_utoken);
477 LYINFLOG("[%s]in_utoken:%d,utoken:%d",__FUNCTION__,in_utoken,utoken);
478 if (in_utoken != utoken)
479 {
480 delete temp;
481 temp = NULL;
482 in_utoken = 0;
483 continue;
484 }
485 temp->setDataPosition(0);
486 p = temp;
487 flag = 0;
488 return 0;
489 }
490 else
491 {
492 LYERRLOG("recvline is null,errno:%d",errno);
493 return LYNQ_E_GET_RESP_FAIL;
494 }
495 }
496 return LYNQ_E_GET_RESP_FAIL;
497}
498
499int JumpHeader(Parcel *p,int *resp_type,int *utoken,int *request,int *slot_id,int *error)
500{
501 if(NULL == p)
502 {
503 LYERRLOG("JumpHeader is null");
504 return -1;
505 }
506 if(p->dataAvail() > 0)
507 {
508 p->readInt32(resp_type);
509 p->readInt32(utoken);
510 p->readInt32(request);
511 p->readInt32(slot_id);
512 p->readInt32(error);
lhf81a46f2022-02-13 23:57:37 -0800513 return 0;
514 }
515 else
516 {
517 return -1;
518 }
519}
Hong_Liu25edfe72023-06-16 01:13:42 -0700520void free_parcel(Parcel *p)
521{
522 if(p)
523 {
524 delete p;
525 p = NULL;
526 }
527}
lhf81a46f2022-02-13 23:57:37 -0800528int send_request(int sockfd,lynq_client_t *client_tmp)
529{
530 int ret=0;
lh8d290112023-10-22 20:53:06 -0700531 ret = sendto(sockfd,client_tmp,LYQN_SEDN_BUF,0,(struct sockaddr *)&lynq_data_socket_server_addr,lynq_data_socket_server_addr_len);
lhf81a46f2022-02-13 23:57:37 -0800532 if(ret==-1)
533 {
lh8d290112023-10-22 20:53:06 -0700534 LYERRLOG("%s:errno code:%d",__FUNCTION__,errno);
lhf81a46f2022-02-13 23:57:37 -0800535 return -1;
536 }
537 return 0;
538}
539static char *strdupReadString(Parcel &p) {
540 size_t stringlen;
541 const char16_t *s16;
542 s16 = p.readString16Inplace(&stringlen);
543 return strndup16to8(s16, stringlen);
544}
545static char *strdupReadString_p(Parcel *p) {
546 size_t stringlen;
547 const char16_t *s16;
548 s16 = p->readString16Inplace(&stringlen);
549 return strndup16to8(s16, stringlen);
550}
551
lhf81a46f2022-02-13 23:57:37 -0800552/*Warren add for T800 platform 2021/11/19 start*/
553int lynq_socket_client_start()
554{
lh8d290112023-10-22 20:53:06 -0700555 int ret;
556 struct timeval timeOut;
557 struct sockaddr_in liblynq_data_socket;
rjw747deea2022-07-01 18:25:30 +0800558
lh8d290112023-10-22 20:53:06 -0700559 ret = 0;
rjwa59bf312022-07-05 11:50:31 +0800560 timeOut.tv_sec = 30;
rjw747deea2022-07-01 18:25:30 +0800561 timeOut.tv_usec = 0;
lh8d290112023-10-22 20:53:06 -0700562 bzero(&liblynq_data_socket, sizeof(liblynq_data_socket));
563 bzero(&lynq_data_socket_server_addr, sizeof(lynq_data_socket_server_addr));
564
565 //set this lib socket config
566 liblynq_data_socket.sin_family = AF_INET;
567 liblynq_data_socket.sin_addr.s_addr = inet_addr(LYNQ_RIL_FWK_IP);
rjw747deea2022-07-01 18:25:30 +0800568
lh8d290112023-10-22 20:53:06 -0700569 //set ril service socket config
570 lynq_data_socket_server_addr.sin_family = AF_INET;
571 lynq_data_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
572 lynq_data_socket_server_addr.sin_addr.s_addr = inet_addr(LYNQ_RIL_FWK_IP);
573 lynq_data_socket_server_addr_len = sizeof(lynq_data_socket_server_addr);
574
575 lynq_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
576 ret = bind(lynq_client_sockfd, (struct sockaddr *)&liblynq_data_socket, sizeof(liblynq_data_socket));
577 if (-1 == ret)
578 {
579 LYERRLOG("liblynq_data_socket bind fail,errno:%d",errno);
580 return -1;
581 }
rjw747deea2022-07-01 18:25:30 +0800582 if (setsockopt(lynq_client_sockfd, SOL_SOCKET, SO_RCVTIMEO, &timeOut, sizeof(timeOut)) < 0)
583 {
lh8d290112023-10-22 20:53:06 -0700584 LYERRLOG("time out setting failed,errno:%d",errno);
lhf81a46f2022-02-13 23:57:37 -0800585 return -1;
586 }
587 return 0;
588}
rjw7ee7bb42023-01-18 11:34:28 +0800589
590bool is_support_urc(int urc_id)
lhf81a46f2022-02-13 23:57:37 -0800591{
rjw7ee7bb42023-01-18 11:34:28 +0800592 switch(urc_id)
593 {
594 case LYNQ_URC_DATA_CALL_STATUS_IND:
595
596 case LYNQ_URC_MODIFY_APNDB:
597 case LYNQ_URC_RESET_APNDB:
xy.hef5d74f12023-10-23 06:48:52 -0700598 case LYNQ_TELEPHONY_RESTART:
rjw7ee7bb42023-01-18 11:34:28 +0800599 return true;
600 default:
601 return false;
602 }
603}
604
rjwc63abb42023-03-31 18:22:42 +0800605int printf_apn_table()
606{
607 int ret = 0;
Hong_Liu6149f182023-05-12 02:15:14 -0700608 if (lynq_apn_table == NULL)
609 {
610 LYERRLOG("apn table is null");
611 return -1;
612 }
rjwc63abb42023-03-31 18:22:42 +0800613 for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
614 {
Hong_Liudc46d412023-05-18 13:36:26 -0700615 LYINFLOG("[%s][%d] apn=%s ;apntype=%s ;ifname=%s ;hasTimeout = %d ; hasUsed = %d,status = %d,statusDeactApn = %s",__FUNCTION__,ret, \
rjwc63abb42023-03-31 18:22:42 +0800616 lynq_apn_table[ret].apn,lynq_apn_table[ret].apnType,lynq_apn_table[ret].ifaceName, \
Hong_Liudc46d412023-05-18 13:36:26 -0700617 lynq_apn_table[ret].hasTimeout,lynq_apn_table[ret].hasUsed,lynq_apn_table[ret].status,lynq_apn_table[ret].statusApnType);
rjwc63abb42023-03-31 18:22:42 +0800618 }
619 return 0;
620}
621
Hong_Liu6149f182023-05-12 02:15:14 -0700622void printf_apn_table_debug(const char *fun,int line)
623{
624 LYINFLOG("[%s][%d]apn_table msg",fun,line);
625 printf_apn_table();
626}
rjwc63abb42023-03-31 18:22:42 +0800627
rjw7ee7bb42023-01-18 11:34:28 +0800628void urc_msg_process(Parcel *p)
629{
630 int len;
631 int resp_type;
632 int urcid;
633 int slot_id;
rjwf9ec3832023-04-12 10:59:15 +0800634 int check_count = 0;
Hong_Liudc46d412023-05-18 13:36:26 -0700635 static int apnId=-1;
rjw7ee7bb42023-01-18 11:34:28 +0800636
637 int pdnState = 0;
lhf81a46f2022-02-13 23:57:37 -0800638 char apn[LYNQ_APN_MAX_LEN];
639 char apnType[LYNQ_APN_TYPE_MAX_LEN];
lhf81a46f2022-02-13 23:57:37 -0800640 char ifaceName[LYNQ_IFACE_NAME_MAX_LEN];
lhf81a46f2022-02-13 23:57:37 -0800641 char *urc_msg = NULL;
rjw7ee7bb42023-01-18 11:34:28 +0800642
643 int size = p->dataSize();
644 p->readInt32(&resp_type);
645 p->readInt32(&urcid);
646 p->readInt32(&slot_id);
647 LYINFLOG("data lib recv urc:resp_type=%d,urcid=%d,slot_id=%d,size=%d\n",resp_type,urcid,slot_id,size);
648 switch(urcid)
lhf81a46f2022-02-13 23:57:37 -0800649 {
rjw7ee7bb42023-01-18 11:34:28 +0800650 case LYNQ_URC_DATA_CALL_STATUS_IND:
651 p->readInt32(&pdnState);
652 bzero(apn,LYNQ_APN_MAX_LEN);
653 bzero(apnType,LYNQ_APN_TYPE_MAX_LEN);
654 bzero(ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
lha62e0882023-10-31 05:17:11 -0700655 if(pdnState != RIL_Data_Call_PdnState::PDN_DISCONNECTED)//PDN_DISCONNECTED
lhf81a46f2022-02-13 23:57:37 -0800656 {
rjw20006d12022-04-21 16:29:04 +0800657 urc_msg = strdupReadString_p(p);
rjw7ee7bb42023-01-18 11:34:28 +0800658 int len = strlen(urc_msg);
Hong_Liu6149f182023-05-12 02:15:14 -0700659 if((len < LYNQ_APN_MAX_LEN-1) && (len > 0))
rjw20006d12022-04-21 16:29:04 +0800660 {
rjw7ee7bb42023-01-18 11:34:28 +0800661 memcpy(apn,urc_msg,len+1);
rjw20006d12022-04-21 16:29:04 +0800662 }
Hong_Liu6149f182023-05-12 02:15:14 -0700663 free(urc_msg);
rjw7ee7bb42023-01-18 11:34:28 +0800664 urc_msg = strdupReadString_p(p);
665 len = strlen(urc_msg);
Hong_Liu6149f182023-05-12 02:15:14 -0700666 if((len < LYNQ_APN_TYPE_MAX_LEN-1) && (len > 0))
rjw7ee7bb42023-01-18 11:34:28 +0800667 {
668 memcpy(apnType,urc_msg,len+1);
669 }
Hong_Liu6149f182023-05-12 02:15:14 -0700670 free(urc_msg);
rjw7ee7bb42023-01-18 11:34:28 +0800671 urc_msg = strdupReadString_p(p);
672 len = strlen(urc_msg);
Hong_Liu6149f182023-05-12 02:15:14 -0700673 if((len < LYNQ_IFACE_NAME_MAX_LEN-1) && (len > 0))
rjw7ee7bb42023-01-18 11:34:28 +0800674 {
675 memcpy(ifaceName,urc_msg,strlen(urc_msg)+1);
676 }
Hong_Liu6149f182023-05-12 02:15:14 -0700677 free(urc_msg);
rjw7ee7bb42023-01-18 11:34:28 +0800678 //sendSignalDataCallStateChange();
Hong_Liudc46d412023-05-18 13:36:26 -0700679 apnId = getLynqApnID(apnType);
rjw7ee7bb42023-01-18 11:34:28 +0800680 if(apnId >= 0)
681 {
Hong_Liudc46d412023-05-18 13:36:26 -0700682 LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
rjw7ee7bb42023-01-18 11:34:28 +0800683 if(lynq_apn_table[apnId].hasTimeout==1)
684 {
rjwc63abb42023-03-31 18:22:42 +0800685 /*whether timeout?,real or not,*/
686 printf_apn_table();
rjw7ee7bb42023-01-18 11:34:28 +0800687 LYERRLOG("apn:%s has time out,deacive this apn",lynq_apn_table[apnId].apn);
rjw3938f262023-03-08 16:09:28 +0800688 if (NULL != lynq_apn_table[apnId].apn && NULL != lynq_apn_table[apnId].apnType && strlen(lynq_apn_table[apnId].apn)>0)
rjw7ee7bb42023-01-18 11:34:28 +0800689 {
690 LYERRLOG("deactive this time out APN");
691 lynq_deactive_data_call(&apnId);
692 }
rjwc63abb42023-03-31 18:22:42 +0800693 else
rjw7ee7bb42023-01-18 11:34:28 +0800694 {
rjwc63abb42023-03-31 18:22:42 +0800695 /*if apn lose,update apn and deactive all apn*/
696 LYERRLOG("this table is invalid update APN table");
rjw7ee7bb42023-01-18 11:34:28 +0800697 }
698 break;
699 }
rjwacdb2152023-02-07 14:12:49 +0800700 updateApnTable(&lynq_apn_table[apnId],apn,apnType,ifaceName);
Hong_Liu6149f182023-05-12 02:15:14 -0700701 printf_apn_table_debug(__FUNCTION__,__LINE__);
rjw7ee7bb42023-01-18 11:34:28 +0800702 }
703 /*To be completed*/
rjw20006d12022-04-21 16:29:04 +0800704 else
705 {
Hong_Liu6149f182023-05-12 02:15:14 -0700706 data_invaild_error = 1;
Hong_Liudc46d412023-05-18 13:36:26 -0700707 printf_apn_table_debug(__FUNCTION__,__LINE__);
708 apnId = getDeactApnID(apnType);
709 if(apnId < 0)
710 {
711 LYERRLOG("[%d]invalid apnId:%d",__LINE__,apnId);
712 break;
713 }
714 LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
715 updateDeactApn(apnId,pdnState);
716 printf_apn_table_debug(__FUNCTION__,__LINE__);
rjw20006d12022-04-21 16:29:04 +0800717 }
rjw7ee7bb42023-01-18 11:34:28 +0800718 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
719 s_data_urc_wait_list.push_back(apnId);
720 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
721 lynq_data_call_change_id = apnId;
rjwc3d6e582023-03-28 17:19:11 +0800722 sendSignalPdnChange();
rjw7ee7bb42023-01-18 11:34:28 +0800723 LYDBGLOG("data call state:%d",lynq_data_call);
724 if(lynq_data_call==1)
725 {
rjwf9ec3832023-04-12 10:59:15 +0800726 while (data_timelimit == 0)
727 {
728 LYINFLOG("client not ready to wait");
729 for (check_count = 0;check_count < 500;check_count++)
730 {
731 /*wait 10ms*/
732 usleep(10*1000);
733 }
734 LYERRLOG("client still without res");
735 break;
736 }
lha62e0882023-10-31 05:17:11 -0700737 if(pdnState == RIL_Data_Call_PdnState::PDN_TIMEOUT_CANCEL)
738 {
739 lynq_data_call = LYNQ_E_TIME_OUT;
740 }
741 else
742 {
743 lynq_data_call = 0;
744 }
rjw7ee7bb42023-01-18 11:34:28 +0800745 sendSignalDataCallStateChange();
rjwf9ec3832023-04-12 10:59:15 +0800746 data_timelimit = 0;
rjw7ee7bb42023-01-18 11:34:28 +0800747 }
Hong_Liu6149f182023-05-12 02:15:14 -0700748 printf_apn_table_debug(__FUNCTION__,__LINE__);
rjw20006d12022-04-21 16:29:04 +0800749 }
rjw7ee7bb42023-01-18 11:34:28 +0800750 else
rjw20006d12022-04-21 16:29:04 +0800751 {
rjw7ee7bb42023-01-18 11:34:28 +0800752 urc_msg = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -0700753 free(urc_msg);
754 urc_msg = strdupReadString_p(p);
rjw7ee7bb42023-01-18 11:34:28 +0800755 len = strlen(urc_msg);
756 if(len < LYNQ_APN_TYPE_MAX_LEN-1)
757 {
758 memcpy(apnType,urc_msg,len+1);
759 }
Hong_Liu6149f182023-05-12 02:15:14 -0700760 free(urc_msg);
rjw7ee7bb42023-01-18 11:34:28 +0800761 LYDBGLOG("[data thread_urc_recv] apntype:%s",apnType);
Hong_Liudc46d412023-05-18 13:36:26 -0700762 apnId = getLynqApnID(apnType);
rjw7ee7bb42023-01-18 11:34:28 +0800763 if(apnId >= 0)
764 {
Hong_Liu8d77acf2023-08-30 02:11:09 -0700765 LYINFLOG("[%d]URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",__LINE__,apnType,ifaceName,apn,pdnState,apnId);
Hong_Liudc46d412023-05-18 13:36:26 -0700766 lynq_data_call_change_id = apnId;
767 //bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);//async clean
768 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
769 s_data_urc_wait_list.push_back(apnId);
770 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
771 sendSignalPdnChange();
772 }
773 else
774 {
775 apnId = getDeactApnID(apnType);
776 if(apnId < 0)
777 {
778 LYERRLOG("[%d]invalid apnId:%d",__LINE__,apnId);
779 break;
780 }
Hong_Liu8d77acf2023-08-30 02:11:09 -0700781 LYINFLOG("[%d]URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",__LINE__,apnType,ifaceName,apn,pdnState,apnId);
Hong_Liudc46d412023-05-18 13:36:26 -0700782 cleanDeactApn(apnId);
rjw7ee7bb42023-01-18 11:34:28 +0800783 lynq_data_call_change_id = apnId;
784 bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);//async clean
rjw3938f262023-03-08 16:09:28 +0800785 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
786 s_data_urc_wait_list.push_back(apnId);
787 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
Hong_Liu25edfe72023-06-16 01:13:42 -0700788 sendSignalDeactvied();
rjwc3d6e582023-03-28 17:19:11 +0800789 sendSignalPdnChange();
Hong_Liudc46d412023-05-18 13:36:26 -0700790 printf_apn_table_debug(__FUNCTION__,__LINE__);
rjw7ee7bb42023-01-18 11:34:28 +0800791 }
rjw7ee7bb42023-01-18 11:34:28 +0800792 LYDBGLOG("data call state:%d",lynq_data_call);
793 if(lynq_data_call==1)
794 {
rjwf9ec3832023-04-12 10:59:15 +0800795 while (data_timelimit == 0)
796 {
797 LYINFLOG("client not ready to wait");
798 for (check_count = 0;check_count < 500;check_count++)
799 {
800 /*wait 10ms*/
801 usleep(10*1000);
802 }
803 LYERRLOG("client still without res");
804 break;
805 }
rjw7ee7bb42023-01-18 11:34:28 +0800806 sendSignalDataCallStateChange();
807 lynq_data_call = 0;
rjwf9ec3832023-04-12 10:59:15 +0800808 data_timelimit = 0;
rjw7ee7bb42023-01-18 11:34:28 +0800809 }
Hong_Liu6149f182023-05-12 02:15:14 -0700810 printf_apn_table_debug(__FUNCTION__,__LINE__);
rjw7ee7bb42023-01-18 11:34:28 +0800811 }
812 break;
813 case LYNQ_URC_MODIFY_APNDB:
814 urc_msg = strdupReadString_p(p);
815 if (NULL == urc_msg)
816 {
817 LYERRLOG("error apn msg");
818 }
819 else
820 {
821 bzero(g_lynq_apn_result, 1024);
822 strcpy(g_lynq_apn_result, urc_msg);
823 sendSignalApnChange();
824 }
Hong_Liu6149f182023-05-12 02:15:14 -0700825 free(urc_msg);
rjw7ee7bb42023-01-18 11:34:28 +0800826 break;
827 case LYNQ_URC_RESET_APNDB:
828 {
rjw20006d12022-04-21 16:29:04 +0800829 urc_msg = strdupReadString_p(p);
830 if (NULL == urc_msg)
831 {
832 LYERRLOG("error apn msg");
833 }
834 else
835 {
836 bzero(g_lynq_apn_result, 1024);
837 strcpy(g_lynq_apn_result, urc_msg);
838 sendSignalApnChange();
839 }
Hong_Liu6149f182023-05-12 02:15:14 -0700840 free(urc_msg);
xy.heac05ee02023-11-29 14:36:31 +0800841 break;
rjw20006d12022-04-21 16:29:04 +0800842 }
xy.hef5d74f12023-10-23 06:48:52 -0700843 case LYNQ_TELEPHONY_RESTART:
844 {
845 if(slot_id == 0)
846 {
847 RLOGI("data has received telephony has restart");
848 RLOGI("handle set to 10");
849 lynq_telephony_restart_g = 1;
850 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
851 s_data_urc_wait_list.push_back(TELEPHONY_RESTART);
852 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
xy.hef5d74f12023-10-23 06:48:52 -0700853 sendSignalPdnChange();
854 }
xy.heac05ee02023-11-29 14:36:31 +0800855 break;
xy.hef5d74f12023-10-23 06:48:52 -0700856 }
rjw7ee7bb42023-01-18 11:34:28 +0800857 default:
858 break;
lhf81a46f2022-02-13 23:57:37 -0800859 }
rjw7ee7bb42023-01-18 11:34:28 +0800860
lhf81a46f2022-02-13 23:57:37 -0800861}
rjw7ee7bb42023-01-18 11:34:28 +0800862
rjw7ee7bb42023-01-18 11:34:28 +0800863int create_urc_vector_signal_thread()
864{
865 int ret;
rjw7ee7bb42023-01-18 11:34:28 +0800866 pthread_mutex_init(&s_lynq_urc_vector_mutex,NULL);
rjw7ee7bb42023-01-18 11:34:28 +0800867 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
868 s_data_urc_wait_list.clear();
869 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
lhf81a46f2022-02-13 23:57:37 -0800870 return 0;
871}
Hong_Liu25edfe72023-06-16 01:13:42 -0700872int get_imsi();
Hong_Liu7d9ac8d2023-07-24 00:40:31 -0700873int check_apn_status();
xy.hef5d74f12023-10-23 06:48:52 -0700874
lha62e0882023-10-31 05:17:11 -0700875int get_timeout_value();
lhf81a46f2022-02-13 23:57:37 -0800876int lynq_init_data(int uToken)
877{
q.huangf6a9ddc2023-12-08 20:23:56 +0800878 LYLOGSET(LOG_INFO);
879 LYLOGEINIT(USER_LOG_TAG);
q.huang78c21ff2023-12-13 20:46:43 +0800880 LYERRLOG("%s start, parameter is %d", __func__,uToken);
xy.hefe801322024-07-16 18:29:19 +0800881 //xy.he modified started @20240716
882 pthread_condattr_t attr;
883 pthread_condattr_init(&attr);
884
885 pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
886 pthread_cond_init(&s_lynq_apn_change_cond,&attr);
887 pthread_cond_init(&s_data_call_state_change_cond,&attr);
888 pthread_cond_init(&s_data_call_deactived_cond,&attr);
889 //xy.he modified ended @20240716
890
q.huangf6a9ddc2023-12-08 20:23:56 +0800891
rjw22947c22022-03-15 09:21:29 +0800892 if (g_lynq_data_init_flag == 1)
893 {
894 LYERRLOG("init twice is not allowed");
895 return -1;
896 }
897 g_lynq_data_init_flag = 1;
lhf81a46f2022-02-13 23:57:37 -0800898 int result = 0;
899 Global_uToken = uToken;
q.huangf6a9ddc2023-12-08 20:23:56 +0800900
lha62e0882023-10-31 05:17:11 -0700901 int ret = get_timeout_value();
902 if(ret >= 30000)
903 {
904 g_data_call_timeout_value = ret;
905 }
906 else
907 {
908 LYERRLOG("timeout must greater or equal to 30s!!!");
909 }
lhf81a46f2022-02-13 23:57:37 -0800910 result = lynq_socket_client_start();
rjwed00d042022-05-25 09:18:16 +0800911 pthread_mutex_init(&g_lynq_data_sendto_mutex, NULL);
lhf81a46f2022-02-13 23:57:37 -0800912 if(result!=0)
913 {
914 LYERRLOG("init socket client fail!!!");
915 return -1;
916 }
rjw7ee7bb42023-01-18 11:34:28 +0800917 result = lynq_init_data_urc_thread();
918 if(result!=0)
919 {
920 LYERRLOG("init socket urc fail!!!");
921 return -1;
922 }
923
924 result = create_urc_vector_signal_thread();
lhf81a46f2022-02-13 23:57:37 -0800925 if(result!=0)
926 {
927 LYERRLOG("init socket urc fail!!!");
928 return -1;
929 }
930 memset(lynq_apn_table,0,sizeof(lynq_apn_table));
Hong_Liu7d9ac8d2023-07-24 00:40:31 -0700931 LYINFLOG("[%s] radio on/off solution 20230724",__FUNCTION__);
Hong_Liu25edfe72023-06-16 01:13:42 -0700932 int count = 0;
Hong_Liu7d9ac8d2023-07-24 00:40:31 -0700933 while(count < 2)//try recover the network within 10s.
934 {
935 result = check_apn_status();
936 if(result==0)
937 {
938 break;
939 }
940 radio_switch(0);
941 sleep(1);
942 radio_switch(1);
943 sleep(3);
944 count++;
945 }
946 LYINFLOG("[%s] count is %d",__FUNCTION__,count);
947 if(result!=0)
948 {
949 LYDBGLOG("lynq init call fail!!!");
950 return LYNQ_E_MD_NOT_READY;//
951 }
952 /* old
Hong_Liu25edfe72023-06-16 01:13:42 -0700953 while(count < 10)
954 {
955 result = get_imsi();
956 if(result==0)
957 {
958 break;
959 }
960 sleep(1);
961 count++;
962 }
963 LYINFLOG("[%s] count is %d",__FUNCTION__,count);
964 if(result!=0)
965 {
966 LYDBGLOG("lynq init call fail!!!");
967 return LYNQ_E_MD_NOT_READY;//
968 }
Hong_Liu7d9ac8d2023-07-24 00:40:31 -0700969 */
q.huangf6a9ddc2023-12-08 20:23:56 +0800970 LYERRLOG("%s end suc", __func__);
lhf81a46f2022-02-13 23:57:37 -0800971 return 0;
972
973}
974int lynq_deinit_data()
975{
q.huangf6a9ddc2023-12-08 20:23:56 +0800976 LYERRLOG("%s start", __func__);
977
978 int ret = -1;
rjw22947c22022-03-15 09:21:29 +0800979 if (g_lynq_data_init_flag == 0)
980 {
981 LYERRLOG("deinit twice is not allowed");
982 return ret;
983 }
984 g_lynq_data_init_flag = 0;
lhf81a46f2022-02-13 23:57:37 -0800985 for(int i =0;i<LYNQ_APN_CHANNEL_MAX;i++)
986 {
987 if(strlen(lynq_apn_table[i].apnType)!=0)
988 {
989 lynq_deactive_data_call(&i);
990 }
991 }
992 if(lynq_client_sockfd>0)
993 {
994 close(lynq_client_sockfd);
995 }
rjw7ee7bb42023-01-18 11:34:28 +0800996 ret = lynq_deinit_data_urc_thread();
rjweb65a2f2023-02-01 16:43:23 +0800997 if (ret != 0)
rjw22947c22022-03-15 09:21:29 +0800998 {
rjw7ee7bb42023-01-18 11:34:28 +0800999 LYERRLOG("lynq_deinit_data_urc_thread fail");
1000 return ret;
rjw22947c22022-03-15 09:21:29 +08001001 }
rjwc3d6e582023-03-28 17:19:11 +08001002 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
1003 s_data_urc_wait_list.clear();
1004 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
q.huangf6a9ddc2023-12-08 20:23:56 +08001005 LYERRLOG("%s end suc", __func__);
lhf81a46f2022-02-13 23:57:37 -08001006 return 0;
1007}
1008int lynq_setup_data_call(int *handle)
1009{
Hong_Liue54db8c2023-04-21 02:37:23 -07001010 int error = -1;
lha62e0882023-10-31 05:17:11 -07001011 if (g_lynq_data_init_flag == 0)
1012 {
1013 LYERRLOG("[%s][%d]Invalid operation",__FUNCTION__,__LINE__);
1014 return error;
1015 }
Hong_Liue54db8c2023-04-21 02:37:23 -07001016 #ifdef GSW_RIL_CFG //becuase gsw not have connman,data can not be triggered by connman.
1017 LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__);
Hong_Liue9879152023-04-25 20:40:26 -07001018 error = lynq_setup_data_call_sp(handle,NULL,"default",NULL,NULL,NULL,NULL,NULL);
Hong_Liue54db8c2023-04-21 02:37:23 -07001019 #else
Hong_Liu25edfe72023-06-16 01:13:42 -07001020 Parcel *p = NULL;
lhf81a46f2022-02-13 23:57:37 -08001021 lynq_client_t client;
1022 int resp_type = -1;
1023 int request = -1;
1024 int slot_id = -1;
lhf81a46f2022-02-13 23:57:37 -08001025 int lynq_data_call_id = 0;
1026 if(handle==NULL)
1027 {
1028 LYERRLOG("handle is null!!!");
1029 return LYNQ_E_NULL_ANONALY;
1030 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001031 client.uToken = get_utoken();
lhf81a46f2022-02-13 23:57:37 -08001032 client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
1033 client.paramLen = 0;
1034 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
1035 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
Hong_Liu55c62f52023-08-24 19:05:50 -07001036 lynq_data_call_id = get_handle("default");
rjwc63abb42023-03-31 18:22:42 +08001037 if (lynq_data_call_id < 0)
1038 {
1039 LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001040 return LYNQ_E_NULL_ANONALY+1;
rjwc63abb42023-03-31 18:22:42 +08001041 }
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001042 *handle = lynq_data_call_id;//T8TSK-211 (2023/5/16) why? If it times out, the client application will also try to reconnect.
1043 //Reconnection needs to be deactivated first, and deactivation needs to know which apn to activate.
rjw733b9832023-04-03 10:20:08 +08001044 lynq_data_call = 1;
rjwed00d042022-05-25 09:18:16 +08001045 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001046 if(send_request(lynq_client_sockfd,&client)==-1)
1047 {
1048 LYERRLOG("send request fail");
1049 perror("[LYNQ_DATA] send request fail:");
Hong_Liu25edfe72023-06-16 01:13:42 -07001050 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001051 return LYNQ_E_NULL_ANONALY+2;
lhf81a46f2022-02-13 23:57:37 -08001052 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001053 //get_response(lynq_client_sockfd,p);
1054 error = wait_response(lynq_client_sockfd,p,client.uToken);
1055 if(error!=0)
1056 {
1057 LYERRLOG("wait_response fail,ret:%d",error);
1058 printf_apn_table_debug(__FUNCTION__,__LINE__);
1059 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
1060 return error;
1061 }
rjwed00d042022-05-25 09:18:16 +08001062 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liuaa7f4b32023-07-19 07:51:25 -07001063 JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
Hong_Liu25edfe72023-06-16 01:13:42 -07001064 free_parcel(p);
lhf81a46f2022-02-13 23:57:37 -08001065 LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
lhf81a46f2022-02-13 23:57:37 -08001066 if(error==0)
1067 {
rjwf9ec3832023-04-12 10:59:15 +08001068 data_timelimit = 1;
lha62e0882023-10-31 05:17:11 -07001069 if (waitDataCallstateChange(g_data_call_timeout_value) == ETIMEDOUT)
lhf81a46f2022-02-13 23:57:37 -08001070 {
1071 error = LYNQ_E_TIME_OUT;
1072 LYERRLOG("timeout:wait data Call state fail!!!");
1073 lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
Hong_Liu6149f182023-05-12 02:15:14 -07001074 if (data_invaild_error == 1)
1075 {
1076 data_invaild_error = 0;
1077 LYERRLOG("urc apn info error!!!");
1078 return 8085;
1079 }
1080 printf_apn_table_debug(__FUNCTION__,__LINE__);
lhf81a46f2022-02-13 23:57:37 -08001081 return error;
1082 }
lha62e0882023-10-31 05:17:11 -07001083 if(lynq_data_call == LYNQ_E_TIME_OUT)
1084 {
1085 error = LYNQ_E_TIME_OUT;
1086 LYERRLOG("PDN_TIMEOUT_CANCLE:wait data Call state fail!!!");
1087 printf_apn_table_debug(__FUNCTION__,__LINE__);
1088 return error;
1089 }
lhf81a46f2022-02-13 23:57:37 -08001090 }
Hong_Liu6149f182023-05-12 02:15:14 -07001091 printf_apn_table_debug(__FUNCTION__,__LINE__);
Hong_Liue54db8c2023-04-21 02:37:23 -07001092 #endif //GSW_RIL_CFG
lhf81a46f2022-02-13 23:57:37 -08001093 return error;
1094}
rjw7ee7bb42023-01-18 11:34:28 +08001095
xy.hefb1ab522024-01-17 13:48:45 +08001096void deactiveAfterTimeout(int apnId)
1097{
1098 LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
1099 cleanDeactApn(apnId);
1100 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
1101 s_data_urc_wait_list.push_back(apnId);
1102 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
1103 sendSignalPdnChange();
1104}
lhf81a46f2022-02-13 23:57:37 -08001105int lynq_deactive_data_call(int *handle)
1106{
Hong_Liu25edfe72023-06-16 01:13:42 -07001107 Parcel *p = NULL;
lhf81a46f2022-02-13 23:57:37 -08001108 lynq_client_t client;
1109 int resp_type = -1;
1110 int request = -1;
1111 int slot_id = -1;
1112 int error = -1;
1113 int lynq_data_call_id = -1;
rjw1309e232022-07-22 09:54:06 +08001114 int ret = 0;
lha62e0882023-10-31 05:17:11 -07001115 if (g_lynq_data_init_flag == 0)
1116 {
1117 LYERRLOG("[%s][%d]Invalid operation",__FUNCTION__,__LINE__);
1118 return error;
1119 }
lhf81a46f2022-02-13 23:57:37 -08001120 if(handle==NULL)
1121 {
1122 LYERRLOG("handle is null!!!");
1123 return -1;
1124 }
rjw1309e232022-07-22 09:54:06 +08001125 ret = handleCheck(*handle);
1126 if (ret != 0)
1127 {
1128 LYERRLOG("incomming handle is invalid");
1129 return -1;
1130 }
1131 lynq_data_call_id = *handle;
Hong_Liu25edfe72023-06-16 01:13:42 -07001132 client.uToken = get_utoken();
lhf81a46f2022-02-13 23:57:37 -08001133 client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL
Hong_Liue3d35262023-05-04 00:20:12 -07001134 client.paramLen = 0;
1135 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
1136 #ifdef GSW_RIL_CFG
1137 client.paramLen = 1;
1138 sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType);
1139 #else
1140 if(strcmp(lynq_apn_table[lynq_data_call_id].apnType,"default")!=0)
lh13586612022-01-11 21:58:58 -08001141 {
lhf81a46f2022-02-13 23:57:37 -08001142 client.paramLen = 1;
lhf81a46f2022-02-13 23:57:37 -08001143 sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType);
1144 }
Hong_Liue3d35262023-05-04 00:20:12 -07001145 #endif //GSW_RIL_CFG
lhf81a46f2022-02-13 23:57:37 -08001146 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
rjwed00d042022-05-25 09:18:16 +08001147 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001148 if(send_request(lynq_client_sockfd,&client)==-1)
1149 {
1150 LYERRLOG("send request fail");
1151 perror("[LYNQ_DATA] send request fail:");
Hong_Liu25edfe72023-06-16 01:13:42 -07001152 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001153 return -1;
1154 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001155 //get_response(lynq_client_sockfd,p);
1156 error = wait_response(lynq_client_sockfd,p,client.uToken);
1157 if(error!=0)
1158 {
1159 LYERRLOG("wait_response fail,ret:%d",error);
1160 printf_apn_table_debug(__FUNCTION__,__LINE__);
1161 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
1162 return error;
1163 }
rjwed00d042022-05-25 09:18:16 +08001164 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu25edfe72023-06-16 01:13:42 -07001165 JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
1166 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
lhf81a46f2022-02-13 23:57:37 -08001167 cleanOnceApnTable(lynq_data_call_id);
Hong_Liu6149f182023-05-12 02:15:14 -07001168 printf_apn_table_debug(__FUNCTION__,__LINE__);
Hong_Liu25edfe72023-06-16 01:13:42 -07001169 if(error==0)
1170 {
1171 if(waitDeactived(20000)==ETIMEDOUT)
1172 {
1173 error = LYNQ_E_TIME_OUT;
1174 LYERRLOG("[lynq_deactive_data_call] timeout:wait data Call state fail!!!");
xy.hefb1ab522024-01-17 13:48:45 +08001175 deactiveAfterTimeout(lynq_data_call_id);
Hong_Liu25edfe72023-06-16 01:13:42 -07001176 printf_apn_table_debug(__FUNCTION__,__LINE__);
1177 }
1178 }
1179 free_parcel(p);
lhf81a46f2022-02-13 23:57:37 -08001180 return error;
1181}
1182int lynq_setup_data_call_sp(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol)
1183{
Hong_Liu25edfe72023-06-16 01:13:42 -07001184 Parcel *p = NULL;
lhf81a46f2022-02-13 23:57:37 -08001185 lynq_client_t client;
1186 int resp_type = -1;
1187 int request = -1;
1188 int slot_id = -1;
1189 int error = -1;
lhf81a46f2022-02-13 23:57:37 -08001190 int lynq_data_call_id = -1;
1191 char *argv[10] = {};
lha62e0882023-10-31 05:17:11 -07001192 if (g_lynq_data_init_flag == 0)
1193 {
1194 LYERRLOG("[%s][%d]Invalid operation",__FUNCTION__,__LINE__);
1195 return error;
1196 }
Hong_Liue54db8c2023-04-21 02:37:23 -07001197 #ifdef GSW_RIL_CFG
1198 LYINFLOG("[%s][%d]",__FUNCTION__,__LINE__);
1199 if(handle==NULL||apnType==NULL)
1200 {
1201 LYERRLOG("handle or apntype is null!!!");
1202 return -1;
1203 }
1204 #else
lhf81a46f2022-02-13 23:57:37 -08001205 if(handle==NULL||apn==NULL||apnType==NULL)
1206 {
1207 LYERRLOG("handle ,apn or apntype is null!!!");
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001208 return LYNQ_E_NULL_ANONALY;
lhf81a46f2022-02-13 23:57:37 -08001209 }
Hong_Liue54db8c2023-04-21 02:37:23 -07001210 #endif //GSW_RIL_CFG
lhf81a46f2022-02-13 23:57:37 -08001211 if(user==NULL)
1212 {
1213 argv[1] = "null";
1214 }
1215 else
1216 {
1217 argv[1] = user;
lh13586612022-01-11 21:58:58 -08001218 }
1219 if(password==NULL)
1220 {
lhf81a46f2022-02-13 23:57:37 -08001221 argv[2] = "null";
lh13586612022-01-11 21:58:58 -08001222 }
1223 else
1224 {
lhf81a46f2022-02-13 23:57:37 -08001225 argv[2] = password;
lh13586612022-01-11 21:58:58 -08001226 }
1227 if(authType==NULL)
1228 {
lhf81a46f2022-02-13 23:57:37 -08001229 argv[3] = "null";
lh13586612022-01-11 21:58:58 -08001230 }
1231 else
1232 {
lhf81a46f2022-02-13 23:57:37 -08001233 argv[3] = authType;
lh13586612022-01-11 21:58:58 -08001234 }
1235 if(normalProtocol==NULL)
1236 {
lhf81a46f2022-02-13 23:57:37 -08001237 argv[4] = "null";
lh13586612022-01-11 21:58:58 -08001238 }
1239 else
1240 {
lhf81a46f2022-02-13 23:57:37 -08001241 argv[4] = normalProtocol;
lh13586612022-01-11 21:58:58 -08001242 }
1243 if(roamingProtocol==NULL)
1244 {
lhf81a46f2022-02-13 23:57:37 -08001245 argv[5] = "null";
lh13586612022-01-11 21:58:58 -08001246 }
1247 else
1248 {
lhf81a46f2022-02-13 23:57:37 -08001249 argv[5] = roamingProtocol;
1250 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001251 client.uToken = get_utoken();
lhf81a46f2022-02-13 23:57:37 -08001252 client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
1253 client.paramLen = 7;
1254 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
Hong_Liue54db8c2023-04-21 02:37:23 -07001255 #ifdef GSW_RIL_CFG
1256 if(NULL == apn)
1257 {
1258 sprintf(client.param,"null %s %s %s %s %s %s",apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
1259 }
1260 else
1261 {
1262 sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
1263 }
1264 #else
lhf81a46f2022-02-13 23:57:37 -08001265 sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
Hong_Liue54db8c2023-04-21 02:37:23 -07001266 #endif //GSW_RIL_CFG
lhf81a46f2022-02-13 23:57:37 -08001267 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
Hong_Liu55c62f52023-08-24 19:05:50 -07001268 lynq_data_call_id = get_handle(apnType);
rjwc63abb42023-03-31 18:22:42 +08001269 if (lynq_data_call_id < 0)
1270 {
1271 LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001272 return LYNQ_E_NULL_ANONALY+1;
rjwc63abb42023-03-31 18:22:42 +08001273 }
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001274 *handle = lynq_data_call_id;//T8TSK-211 (2023/5/16)
rjw733b9832023-04-03 10:20:08 +08001275 lynq_data_call = 1;
rjwed00d042022-05-25 09:18:16 +08001276 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001277 if(send_request(lynq_client_sockfd,&client)==-1)
1278 {
1279 LYERRLOG("send request fail");
1280 perror("[LYNQ_DATA] send request fail:");
Hong_Liu25edfe72023-06-16 01:13:42 -07001281 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001282 return LYNQ_E_NULL_ANONALY+2;
lhf81a46f2022-02-13 23:57:37 -08001283 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001284 //get_response(lynq_client_sockfd,p);
1285 error = wait_response(lynq_client_sockfd,p,client.uToken);
1286 if(error!=0)
1287 {
1288 LYERRLOG("wait_response fail,ret:%d",error);
1289 printf_apn_table_debug(__FUNCTION__,__LINE__);
1290 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
1291 return error;
1292 }
rjwed00d042022-05-25 09:18:16 +08001293 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu25edfe72023-06-16 01:13:42 -07001294 JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error);
1295 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
1296 free_parcel(p);
lhf81a46f2022-02-13 23:57:37 -08001297 if(error==0)
1298 {
Hong_Liu7e1b85e2023-05-16 05:51:57 -07001299 data_timelimit = 1;
lha62e0882023-10-31 05:17:11 -07001300 if(waitDataCallstateChange(g_data_call_timeout_value)==ETIMEDOUT)
lhf81a46f2022-02-13 23:57:37 -08001301 {
1302 error = LYNQ_E_TIME_OUT;
1303 LYERRLOG("timeout:wait data Call state fail!!!");
1304 lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
Hong_Liu6149f182023-05-12 02:15:14 -07001305 if (data_invaild_error == 1)
1306 {
1307 data_invaild_error = 0;
1308 LYERRLOG("urc apn info error!!!");
1309 return 8085;
1310 }
1311 printf_apn_table_debug(__FUNCTION__,__LINE__);
lhf81a46f2022-02-13 23:57:37 -08001312 return error;
1313 }
lha62e0882023-10-31 05:17:11 -07001314 if(lynq_data_call == LYNQ_E_TIME_OUT)
1315 {
1316 error = LYNQ_E_TIME_OUT;
1317 LYERRLOG("PDN_TIMEOUT_CANCLE:wait data Call state fail!!!");
1318 printf_apn_table_debug(__FUNCTION__,__LINE__);
1319 return error;
1320 }
lhf81a46f2022-02-13 23:57:37 -08001321 }
Hong_Liu6149f182023-05-12 02:15:14 -07001322 printf_apn_table_debug(__FUNCTION__,__LINE__);
lhf81a46f2022-02-13 23:57:37 -08001323 return error;
1324}
1325/*
1326int lynq_deactive_data_call_sp(int *handle,char *apnType)
1327{
1328 Parcel p;
1329 lynq_client_t client;
1330 int resp_type = -1;
1331 int request = -1;
1332 int slot_id = -1;
1333 int error = -1;
1334 if(handle==NULL||apnType==NULL)
1335 {
1336 LYERRLOG("handle is null!!!");
1337 return -1;
1338 }
1339 client.uToken = Global_uToken;
1340 client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL
1341 client.paramLen = 1;
1342 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
1343 sprintf(client.param,"%s",apnType);
1344 LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
1345 if(send_request(lynq_client_sockfd,&client)==-1)
1346 {
1347 LYERRLOG("send request fail");
1348 perror("[LYNQ_DATA] send request fail:");
1349 return -1;
1350 }
1351 get_response(lynq_client_sockfd,p);
rjwfa532972022-09-16 13:39:41 +08001352 JumpHeader(p,&resp_type,&request,&slot_id,&error);
lhf81a46f2022-02-13 23:57:37 -08001353 LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
1354 return error;
1355}
1356*/
1357int getDataCallLists(lynq_data_call_response_v11_t dataCallList[LYNQ_APN_CHANNEL_MAX],int *realNum)
1358{
Hong_Liu25edfe72023-06-16 01:13:42 -07001359 Parcel *p = NULL;
lhf81a46f2022-02-13 23:57:37 -08001360 lynq_client_t client;
1361 int resp_type = -1;
q.huang7de1d662022-09-13 14:19:24 +08001362 int token;
Hong_Liu25edfe72023-06-16 01:13:42 -07001363 int request = -1;
lhf81a46f2022-02-13 23:57:37 -08001364 int slot_id = -1;
1365 int error = -1;
1366 int version =0;
1367 int num = 0;
lhf81a46f2022-02-13 23:57:37 -08001368 char *temp_char = NULL;
1369 if(dataCallList==NULL)
1370 {
1371 LYERRLOG("dataCallList is null!!!");
1372 return -1;
1373 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001374 client.uToken = get_utoken();;
lhf81a46f2022-02-13 23:57:37 -08001375 client.request = 57;//RIL_REQUEST_DATA_CALL_LIST
1376 client.paramLen = 0;
1377 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
1378 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
rjwed00d042022-05-25 09:18:16 +08001379 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001380 if(send_request(lynq_client_sockfd,&client)==-1)
1381 {
1382 LYERRLOG("send request fail");
1383 perror("[LYNQ_DATA] send request fail:");
Hong_Liu25edfe72023-06-16 01:13:42 -07001384 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
lhf81a46f2022-02-13 23:57:37 -08001385 return -1;
1386 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001387 //get_response(lynq_client_sockfd,p);
1388 error = wait_response(lynq_client_sockfd,p,client.uToken);
1389 if(error!=0)
1390 {
1391 LYERRLOG("wait_response fail,ret:%d",error);
1392 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
1393 return error;
1394 }
rjwed00d042022-05-25 09:18:16 +08001395 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu25edfe72023-06-16 01:13:42 -07001396 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
rjwfa532972022-09-16 13:39:41 +08001397 {
Hong_Liu25edfe72023-06-16 01:13:42 -07001398 LYERRLOG("JumpHeader fail");
rjwfa532972022-09-16 13:39:41 +08001399 return -1;
1400 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001401 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
1402 p->readInt32(&version);
lhf81a46f2022-02-13 23:57:37 -08001403 if(version==11)
1404 {
Hong_Liu25edfe72023-06-16 01:13:42 -07001405 p->readInt32(&num);
lhf81a46f2022-02-13 23:57:37 -08001406 *realNum = num;
1407 for (int i = 0; i < num; i++)
1408 {
Hong_Liu25edfe72023-06-16 01:13:42 -07001409 p->readInt32(&dataCallList[i].status);
1410 p->readInt32(&dataCallList[i].suggestedRetryTime);
1411 p->readInt32(&dataCallList[i].cid);
1412 p->readInt32(&dataCallList[i].active);
1413 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001414 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1415 if(temp_char)
1416 {
1417 memcpy(dataCallList[i].type,temp_char,strlen(temp_char)+1);
1418 free(temp_char);
1419 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001420 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001421 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1422 if(temp_char)
1423 {
1424 memcpy(dataCallList[i].ifname,temp_char,strlen(temp_char)+1);
1425 free(temp_char);
1426 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001427 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001428 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1429 if(temp_char)
1430 {
1431 memcpy(dataCallList[i].addresses,temp_char,strlen(temp_char)+1);
1432 free(temp_char);
1433 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001434 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001435 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1436 if(temp_char)
1437 {
1438 memcpy(dataCallList[i].dnses,temp_char,strlen(temp_char)+1);
1439 free(temp_char);
1440 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001441 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001442 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1443 if(temp_char)
1444 {
1445 memcpy(dataCallList[i].gateways,temp_char,strlen(temp_char)+1);
1446 free(temp_char);
1447 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001448 temp_char = strdupReadString_p(p);
Hong_Liu6149f182023-05-12 02:15:14 -07001449 LYINFLOG("[%s][%d]%s",__FUNCTION__,__LINE__,temp_char);
1450 if(temp_char)
1451 {
1452 memcpy(dataCallList[i].pcscf,temp_char,strlen(temp_char)+1);
1453 free(temp_char);
1454 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001455 p->readInt32(&dataCallList[i].mtu);
lhf81a46f2022-02-13 23:57:37 -08001456 }
1457 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001458 free_parcel(p);
lhf81a46f2022-02-13 23:57:37 -08001459 return error;
1460}
Hong_Liu7163bbe2023-06-04 03:03:44 -07001461
1462int lynq_get_apn_msg(int handle,lynq_apn_msg_t *apn_msg)
1463{
1464 LYINFLOG("[lynq_get_apn_msg] enter,handle:%d",handle);
1465 if((handle < 0) || (handle > 6) || (NULL == apn_msg))
1466 {
1467 LYERRLOG("handle value error,or apn_msg is null");
1468 return LYNQ_E_NULL_ANONALY;
1469 }
1470 apn_msg->handle = handle;
1471 if(apn_msg->apn!=NULL)
1472 {
1473 memcpy(apn_msg->apn,lynq_apn_table[handle].apn,LYNQ_APN_MAX_LEN);
1474 }
1475 if(apn_msg->apnType!=NULL)
1476 {
1477 memcpy(apn_msg->apnType,lynq_apn_table[handle].apnType,LYNQ_APN_TYPE_MAX_LEN);
1478 }
1479 return 0;
1480}
1481
lhf81a46f2022-02-13 23:57:37 -08001482int lynq_get_data_call_list(int *handle,lynq_data_call_response_v11_t *dataCallList)
1483{
1484 lynq_data_call_response_v11_t interDataCallList[LYNQ_APN_CHANNEL_MAX]={};
1485 int number = 0;
1486 int lynq_data_call_id = 0;
1487 int error = 0;
lha62e0882023-10-31 05:17:11 -07001488 if (g_lynq_data_init_flag == 0)
1489 {
1490 LYERRLOG("[%s][%d]Invalid operation",__FUNCTION__,__LINE__);
1491 return -1;
1492 }
lhf81a46f2022-02-13 23:57:37 -08001493 lynq_data_call_id = *handle;
Hong_Liu7163bbe2023-06-04 03:03:44 -07001494 if((handle==NULL) || (dataCallList==NULL))
lhf81a46f2022-02-13 23:57:37 -08001495 {
Hong_Liu7163bbe2023-06-04 03:03:44 -07001496 LYERRLOG("[lynq_get_data_call_list] handle or datacalllist is NULL");
lhf81a46f2022-02-13 23:57:37 -08001497 return LYNQ_E_NULL_ANONALY;
1498 }
Hong_Liu7163bbe2023-06-04 03:03:44 -07001499 if ((*handle < 0) || (*handle > 6))
rjw3938f262023-03-08 16:09:28 +08001500 {
Hong_Liu7163bbe2023-06-04 03:03:44 -07001501 LYERRLOG("[lynq_get_data_call_list] handle value error");
1502 return LYNQ_E_NULL_ANONALY;
rjw3938f262023-03-08 16:09:28 +08001503 }
Hong_Liu7163bbe2023-06-04 03:03:44 -07001504 LYINFLOG("[lynq_get_data_call_list] incoming handle value: %d",*handle);
lhf81a46f2022-02-13 23:57:37 -08001505 memset(interDataCallList,0,sizeof(interDataCallList));
1506 error = getDataCallLists(interDataCallList,&number);
1507 if(error == 0)
1508 {
1509 for(int i = 0;i < number;i++)
1510 {
1511 if(strcmp(interDataCallList[i].ifname,lynq_apn_table[lynq_data_call_id].ifaceName)==0)
1512 {
1513 dataCallList->active = interDataCallList[i].active;
1514 dataCallList->suggestedRetryTime = interDataCallList[i].suggestedRetryTime;
1515 dataCallList->cid = interDataCallList[i].cid;
1516 dataCallList->status = interDataCallList[i].status;
1517 dataCallList->mtu = interDataCallList[i].mtu;
1518 memcpy(dataCallList->addresses,interDataCallList[i].addresses,sizeof(interDataCallList[i].addresses));
1519 memcpy(dataCallList->ifname,interDataCallList[i].ifname,sizeof(interDataCallList[i].ifname));
1520 memcpy(dataCallList->dnses,interDataCallList[i].dnses,sizeof(interDataCallList[i].dnses));
1521 memcpy(dataCallList->type,interDataCallList[i].type,sizeof(interDataCallList[i].type));
1522 memcpy(dataCallList->gateways,interDataCallList[i].gateways,sizeof(interDataCallList[i].gateways));
1523 memcpy(dataCallList->pcscf,interDataCallList[i].pcscf,sizeof(interDataCallList[i].pcscf));
1524 LYDBGLOG("ifname:%s,addr:%s",dataCallList->ifname,dataCallList->addresses);
1525 }
1526 }
1527 }
1528 return error;
1529}
1530int lynq_wait_data_call_state_change(int *handle)
1531{
rjwc3d6e582023-03-28 17:19:11 +08001532 if (data_waiting_status == 1)
1533 {
1534 LYDBGLOG("some thread is waiting");
1535 return -3;
1536 }
1537 LYDBGLOG("is empty :%d",s_data_urc_wait_list.empty());
1538 if (s_data_urc_wait_list.empty())
1539 {
1540 LYDBGLOG("start wait");
1541 data_waiting_status = 1;
1542 waitPdnChange();
1543 }
1544 data_waiting_status = 0;
rjw7ee7bb42023-01-18 11:34:28 +08001545 std::vector<int>::iterator iter;
rjw7ee7bb42023-01-18 11:34:28 +08001546
1547 pthread_mutex_lock(&s_lynq_urc_vector_mutex);
1548 iter = s_data_urc_wait_list.begin();
rjwc3d6e582023-03-28 17:19:11 +08001549 if (iter != s_data_urc_wait_list.end())
1550 {
1551 *handle = *iter;
1552 }
rjw7ee7bb42023-01-18 11:34:28 +08001553 s_data_urc_wait_list.erase(iter);
1554 pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
1555
Hong_Liudc46d412023-05-18 13:36:26 -07001556 LYINFLOG("lynq_wait_data_call_state_change handle:%d",*handle);
lhf81a46f2022-02-13 23:57:37 -08001557 return 0;
1558}
1559/*Warren add for T800 platform 2021/11/19 end*/
rjw20006d12022-04-21 16:29:04 +08001560
1561/*Typethree add for T800 platform 2022/04/21 start*/
rjw61fcae32022-08-18 14:03:39 +08001562
1563int insert_apn_char(char *agc, char *id,char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier)
rjw20006d12022-04-21 16:29:04 +08001564{
1565 char strtmp[10][32];
rjw61fcae32022-08-18 14:03:39 +08001566 if (id == NULL)
rjw0cdacbc2022-06-22 10:51:07 +08001567 {
rjw61fcae32022-08-18 14:03:39 +08001568 sprintf(strtmp[0], "id=;");
rjw0cdacbc2022-06-22 10:51:07 +08001569 }
rjw61fcae32022-08-18 14:03:39 +08001570 else
rjw0cdacbc2022-06-22 10:51:07 +08001571 {
rjw61fcae32022-08-18 14:03:39 +08001572 sprintf(strtmp[0], "id=%s;", id);
rjw0cdacbc2022-06-22 10:51:07 +08001573 }
rjw20006d12022-04-21 16:29:04 +08001574 if (mcc == NULL)
1575 {
1576 sprintf(strtmp[1], "mcc=;");
1577 }
1578 else
1579 {
1580 sprintf(strtmp[1], "mcc=%s;", mcc);
1581 }
1582 if (mnc == NULL)
1583 {
rjw61fcae32022-08-18 14:03:39 +08001584 sprintf(strtmp[2], "mnc=;");
rjw20006d12022-04-21 16:29:04 +08001585 }
1586 else
1587 {
1588 sprintf(strtmp[2], "mnc=%s;", mnc);
1589 }
1590 if (apn == NULL)
1591 {
1592 sprintf(strtmp[3], "apn=;");
1593 }
1594 else
1595 {
1596 sprintf(strtmp[3], "apn=%s;", apn);
1597 }
1598 if (apntype == NULL)
1599 {
1600 sprintf(strtmp[4], "apntype=;");
1601 }
1602 else
1603 {
1604 sprintf(strtmp[4], "apntype=%s;", apntype);
1605 }
1606 if (user == NULL)
1607 {
1608 sprintf(strtmp[5], "user=;");
1609 }
1610 else
1611 {
1612 sprintf(strtmp[5], "user=%s;", user);
1613 }
1614 if (password == NULL)
1615 {
1616 sprintf(strtmp[6], "password=;");
1617 }
1618 else
1619 {
1620 sprintf(strtmp[6], "password=%s;", password);
1621 }
1622 if (normalprotocol == NULL)
1623 {
xy.he602890e2024-08-08 16:07:12 +08001624 sprintf(strtmp[7], "protocol=;");
rjw20006d12022-04-21 16:29:04 +08001625 }
1626 else
1627 {
xy.he602890e2024-08-08 16:07:12 +08001628 sprintf(strtmp[7], "protocol=%s;", normalprotocol);
rjw20006d12022-04-21 16:29:04 +08001629 }
1630 if (roamingprotocol == NULL)
1631 {
xy.he602890e2024-08-08 16:07:12 +08001632 sprintf(strtmp[8], "roaming_protocol=;");
rjw20006d12022-04-21 16:29:04 +08001633 }
1634 else
1635 {
xy.he602890e2024-08-08 16:07:12 +08001636 sprintf(strtmp[8], "roaming_protocol=%s;", roamingprotocol);
rjw20006d12022-04-21 16:29:04 +08001637 }
1638 if (carrier == NULL)
1639 {
1640 sprintf(strtmp[9], "carrier=;");
1641 }
1642 else
1643 {
1644 sprintf(strtmp[9], "carrier=%s;", carrier);
1645 }
rjw61fcae32022-08-18 14:03:39 +08001646 sprintf(agc, "%s%s%s%s%s%s%s%s%s%s",strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]);
rjw0cdacbc2022-06-22 10:51:07 +08001647
rjw20006d12022-04-21 16:29:04 +08001648 return 0;
1649}
1650
1651int modify_apn_char(char *agc, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier)
1652{
1653 char strtmp[10][32];
1654 if (id == NULL)
1655 {
1656 sprintf(strtmp[0], "id=;");
1657 }
1658 else
1659 {
1660 sprintf(strtmp[0], "id=%s;", id);
1661 }
1662 if (mcc == NULL)
1663 {
1664 sprintf(strtmp[1], "mcc=;");
1665 }
1666 else
1667 {
1668 sprintf(strtmp[1], "mcc=%s;", mcc);
1669 }
1670 if (mnc == NULL)
1671 {
1672 sprintf(strtmp[2], "mnc=;");
1673 }
1674 else
1675 {
1676 sprintf(strtmp[2], "mnc=%s;", mnc);
1677 }
1678 if (apn == NULL)
1679 {
1680 sprintf(strtmp[3], "apn=;");
1681 }
1682 else
1683 {
1684 sprintf(strtmp[3], "apn=%s;", apn);
1685 }
1686 if (apntype == NULL)
1687 {
1688 sprintf(strtmp[4], "apntype=;");
1689 }
1690 else
1691 {
1692 sprintf(strtmp[4], "apntype=%s;", apntype);
1693 }
1694 if (user == NULL)
1695 {
1696 sprintf(strtmp[5], "user=;");
1697 }
1698 else
1699 {
1700 sprintf(strtmp[5], "user=%s;", user);
1701 }
1702 if (password == NULL)
1703 {
1704 sprintf(strtmp[6], "password=;");
1705 }
1706 else
1707 {
1708 sprintf(strtmp[6], "password=%s;", password);
1709 }
1710 if (normalprotocol == NULL)
1711 {
xy.he602890e2024-08-08 16:07:12 +08001712 sprintf(strtmp[7], "protocol=;");
rjw20006d12022-04-21 16:29:04 +08001713 }
1714 else
1715 {
xy.he602890e2024-08-08 16:07:12 +08001716 sprintf(strtmp[7], "protocol=%s;", normalprotocol);
rjw20006d12022-04-21 16:29:04 +08001717 }
1718 if (roamingprotocol == NULL)
1719 {
xy.he602890e2024-08-08 16:07:12 +08001720 sprintf(strtmp[8], "roaming_protocol=;");
rjw20006d12022-04-21 16:29:04 +08001721 }
1722 else
1723 {
xy.he602890e2024-08-08 16:07:12 +08001724 sprintf(strtmp[8], "roaming_protocol=%s;", roamingprotocol);
rjw20006d12022-04-21 16:29:04 +08001725 }
1726 if (carrier == NULL)
1727 {
1728 sprintf(strtmp[9], "carrier=;");
1729 }
1730 else
1731 {
1732 sprintf(strtmp[9], "carrier=%s;", carrier);
1733 }
1734 sprintf(agc, "%s%s%s%s%s%s%s%s%s%s", strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]);
1735 return 0;
1736}
1737
rjwaf4b1612022-06-13 17:26:01 +08001738
1739int query_apn_char(char *agc, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier)
1740{
1741 char strtmp[10][32];
1742 if (id == NULL)
1743 {
1744 sprintf(strtmp[0], "");
1745 }
1746 else
1747 {
1748 sprintf(strtmp[0], "id=%s;", id);
1749 }
1750 if (mcc == NULL)
1751 {
1752 sprintf(strtmp[1], "");
1753 }
1754 else
1755 {
1756 sprintf(strtmp[1], "mcc=%s;", mcc);
1757 }
1758 if (mnc == NULL)
1759 {
1760 sprintf(strtmp[2], "");
1761 }
1762 else
1763 {
1764 sprintf(strtmp[2], "mnc=%s;", mnc);
1765 }
1766 if (apn == NULL)
1767 {
1768 sprintf(strtmp[3], "");
1769 }
1770 else
1771 {
1772 sprintf(strtmp[3], "apn=%s;", apn);
1773 }
1774 if (apntype == NULL)
1775 {
1776 sprintf(strtmp[4], "");
1777 }
1778 else
1779 {
1780 sprintf(strtmp[4], "apntype=%s;", apntype);
1781 }
1782 if (user == NULL)
1783 {
1784 sprintf(strtmp[5], "");
1785 }
1786 else
1787 {
1788 sprintf(strtmp[5], "user=%s;", user);
1789 }
1790 if (password == NULL)
1791 {
1792 sprintf(strtmp[6], "");
1793 }
1794 else
1795 {
1796 sprintf(strtmp[6], "password=%s;", password);
1797 }
1798 if (normalprotocol == NULL)
1799 {
1800 sprintf(strtmp[7], "");
1801 }
1802 else
1803 {
1804 sprintf(strtmp[7], "normalprotocol=%s;", normalprotocol);
1805 }
1806 if (roamingprotocol == NULL)
1807 {
1808 sprintf(strtmp[8], "");
1809 }
1810 else
1811 {
1812 sprintf(strtmp[8], "roamingprotocol=%s;", roamingprotocol);
1813 }
1814 if (carrier == NULL)
1815 {
1816 sprintf(strtmp[9], "");
1817 }
1818 else
1819 {
1820 sprintf(strtmp[9], "carrier=%s;", carrier);
1821 }
1822 sprintf(agc, "%s%s%s%s%s%s%s%s%s%s", strtmp[0], strtmp[1], strtmp[2], strtmp[3], strtmp[4], strtmp[5], strtmp[6], strtmp[7], strtmp[8], strtmp[9]);
1823 return 0;
1824}
1825
rjw20006d12022-04-21 16:29:04 +08001826static char *lynqStrdupReadString(Parcel &p)
1827{
1828 size_t stringlen;
1829 const char16_t *s16;
1830
1831 s16 = p.readString16Inplace(&stringlen);
1832 return strndup16to8(s16, stringlen);
1833}
Hong_Liu7163bbe2023-06-04 03:03:44 -07001834int get_imsi()
1835{
Hong_Liu25edfe72023-06-16 01:13:42 -07001836 Parcel *p =NULL;
Hong_Liu7163bbe2023-06-04 03:03:44 -07001837 lynq_client_t client;
1838 int resp_type = -1;
1839 int token;
1840 int request = -1;
1841 int slot_id = -1;
1842 int error = -1;
1843 int version =0;
1844 int num = 0;
1845 char *temp_char = NULL;
1846 char mccmnc[32] = {0};
1847 char mccmnckey[64] = {0};
Hong_Liu25edfe72023-06-16 01:13:42 -07001848 client.uToken = get_utoken();
Hong_Liu7163bbe2023-06-04 03:03:44 -07001849 client.request = 11;//RIL_REQUEST_GET_IMSI 11
1850 client.paramLen = 0;
1851 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
1852 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
1853 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
1854 if(send_request(lynq_client_sockfd,&client)==-1)
1855 {
1856 LYERRLOG("send request fail");
1857 perror("[LYNQ_DATA] send request fail:");
Hong_Liu25edfe72023-06-16 01:13:42 -07001858 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu7163bbe2023-06-04 03:03:44 -07001859 return -1;
1860 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001861 //get_response(lynq_client_sockfd,p);
1862 error = wait_response(lynq_client_sockfd,p,client.uToken);
1863 if(error!=0)
Hong_Liu7163bbe2023-06-04 03:03:44 -07001864 {
Hong_Liu25edfe72023-06-16 01:13:42 -07001865 LYERRLOG("wait_response fail,ret:%d",error);
1866 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
Hong_Liu7163bbe2023-06-04 03:03:44 -07001867 return error;
1868 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001869 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
1870 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
Hong_Liu7163bbe2023-06-04 03:03:44 -07001871 {
Hong_Liu25edfe72023-06-16 01:13:42 -07001872 LYERRLOG("JumpHeader fail");
Hong_Liu7163bbe2023-06-04 03:03:44 -07001873 return -1;
1874 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001875 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
1876 if(error == 0)
1877 {
1878 char * test = strdupReadString_p(p);
1879 memcpy(mccmnc, test,5);
1880 mccmnc[5]='\0';
1881 free(test);
1882 sprintf(mccmnckey,"uci set radio_property.property.vendor_ril_data_gsm_mcc_mnc0=%s",mccmnc);
1883 system(mccmnckey);
1884 system("uci commit");
1885 }
1886 free_parcel(p);
1887 return error;
Hong_Liu7163bbe2023-06-04 03:03:44 -07001888}
rjw20006d12022-04-21 16:29:04 +08001889int lynq_modify_apn_db(const int cmd, char *id, char *mcc, char *mnc, char *apn, char *apntype, char *user, char *password, char *normalprotocol, char *roamingprotocol, char *carrier, char *out)
1890{
1891 if (NULL == id && NULL == mcc && NULL == mnc && NULL == apn && NULL == apntype && NULL == user && NULL == password && NULL == normalprotocol && NULL == roamingprotocol && NULL == carrier)
1892 {
1893 LYERRLOG("There are no valid parameters");
1894 return -1;
1895 }
1896 lynq_client_t client;
1897 char argc[512];
Hong_Liu7163bbe2023-06-04 03:03:44 -07001898 int res = -1;
xy.he2a7fc1d2024-05-24 17:32:48 +08001899 //xy.he@20240524 modify for T8TSK-338 start
1900 int password_input = 0;
1901 if(NULL != password && strcmp(password,"")!=0)
1902 {
1903 password_input = 1;
1904 }
1905 //xy.he@20240524 modify for T8TSK-338 end
rjw20006d12022-04-21 16:29:04 +08001906 if (cmd == 0) // insert apn db
1907 {
rjw61fcae32022-08-18 14:03:39 +08001908 res = insert_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier);
Hong_Liu25edfe72023-06-16 01:13:42 -07001909 client.uToken = get_utoken();
rjw20006d12022-04-21 16:29:04 +08001910 client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN
1911 client.paramLen = 2;
1912 bzero(client.param, LYNQ_REQUEST_PARAM_BUF);
1913 sprintf(client.param, "%d %s", cmd, argc);
1914 }
rjw61fcae32022-08-18 14:03:39 +08001915 else if (cmd == 1) //delete apn db
rjw20006d12022-04-21 16:29:04 +08001916 {
1917 if (NULL == id)
1918 {
1919 LYERRLOG("id is NULL!!!please input id: ");
1920 }
1921 sprintf(argc, "id=%s", id);
Hong_Liu25edfe72023-06-16 01:13:42 -07001922 client.uToken = get_utoken();
rjw20006d12022-04-21 16:29:04 +08001923 client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN
1924 client.paramLen = 2;
1925 bzero(client.param, LYNQ_REQUEST_PARAM_BUF);
1926 sprintf(client.param, "%d %s", cmd, argc);
1927 }
rjw61fcae32022-08-18 14:03:39 +08001928 else if (cmd == 2) //query apn db
rjw20006d12022-04-21 16:29:04 +08001929 {
rjwaf4b1612022-06-13 17:26:01 +08001930 query_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier);
Hong_Liu25edfe72023-06-16 01:13:42 -07001931 client.uToken = get_utoken();
rjw20006d12022-04-21 16:29:04 +08001932 client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN
1933 client.paramLen = 2;
1934 bzero(client.param, LYNQ_REQUEST_PARAM_BUF);
1935 sprintf(client.param, "%d %s", cmd, argc);
1936 }
rjw61fcae32022-08-18 14:03:39 +08001937 else if (cmd == 3) //modify apn db
rjw20006d12022-04-21 16:29:04 +08001938 {
1939 modify_apn_char(argc, id, mcc, mnc, apn, apntype, user, password, normalprotocol, roamingprotocol, carrier);
Hong_Liu25edfe72023-06-16 01:13:42 -07001940 client.uToken = get_utoken();
rjw20006d12022-04-21 16:29:04 +08001941 client.request = 2000 + 193; // RIL_REQUEST_MODIFY_APN
1942 client.paramLen = 2;
1943 bzero(client.param, LYNQ_REQUEST_PARAM_BUF);
1944 sprintf(client.param, "%d %s", cmd, argc);
1945 }
1946 else
1947 {
1948 LYERRLOG("incoming command is invalid");
1949 return -1;
1950 }
xy.he2a7fc1d2024-05-24 17:32:48 +08001951 //xy.he@20240524 modify for T8TSK-338 start
1952 if(password_input == 1)
1953 {
1954 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=(has got)",client.uToken,client.request,client.paramLen);
1955 //endoding apn arguments
1956 encode_data_log(client.param,6);
1957 }
1958
1959 else
1960 {
1961 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
1962 }
1963 //xy.he@20240524 modify for T8TSK-338 end
rjwed00d042022-05-25 09:18:16 +08001964 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08001965 if(send_request(lynq_client_sockfd,&client)==-1)
1966 {
1967 LYERRLOG("send request fail");
Hong_Liu25edfe72023-06-16 01:13:42 -07001968 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08001969 return -1;
1970 }
rjwed00d042022-05-25 09:18:16 +08001971 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08001972 waitApnResult();
rjw3bcbbf12022-04-22 16:47:18 +08001973 strcpy(out, g_lynq_apn_result);
xy.he2a7fc1d2024-05-24 17:32:48 +08001974 //xy.he@20240524 modify for T8TSK-338 start
1975 if(strstr(out,"password") != NULL)
1976 {
1977 LYINFLOG(">>>>>output info:(has got)");
1978 encode_data_log(client.param,6);
1979 }
1980 //xy.he@20240524 modify for T8TSK-338 end
rjw20006d12022-04-21 16:29:04 +08001981 return 0;
1982}
1983
1984int lynq_reset_apn(char *result)
1985{
rjw20006d12022-04-21 16:29:04 +08001986 lynq_client_t client;
rjw3bcbbf12022-04-22 16:47:18 +08001987 if (NULL == result)
1988 {
1989 LYERRLOG("incoming paramters error");
1990 }
Hong_Liu25edfe72023-06-16 01:13:42 -07001991 client.uToken = get_utoken();
rjw20006d12022-04-21 16:29:04 +08001992 client.request = 2000 + 194;
1993 client.paramLen = 0;
1994 bzero(client.param, LYNQ_REQUEST_PARAM_BUF);
1995 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s", client.uToken, client.request, client.paramLen, client.param);
rjwed00d042022-05-25 09:18:16 +08001996 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08001997 if (send_request(lynq_client_sockfd, &client) == -1)
1998 {
1999 LYERRLOG("send request fail");
Hong_Liu25edfe72023-06-16 01:13:42 -07002000 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08002001 return -1;
2002 }
rjwed00d042022-05-25 09:18:16 +08002003 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
rjw20006d12022-04-21 16:29:04 +08002004 waitApnResult();
2005 strcpy(result, g_lynq_apn_result);
2006 LYINFLOG(">>>>>result:%s",result);
2007 return 0;
2008}
2009
rjw3bcbbf12022-04-22 16:47:18 +08002010/*Typethree add for T800 platform 2022/04/21 end*/
Hong_Liu7d9ac8d2023-07-24 00:40:31 -07002011static int exec_cmd(const char *str_cmd, char * str_cmd_ret, size_t max_len) {
2012 FILE *fp;
2013 //printf("to exec cmd:%s\n", str_cmd);
2014 if((fp=popen(str_cmd,"r"))==NULL)
2015 {
2016 perror("popen error!");
2017 return -1;
2018 }
2019 if((fread(str_cmd_ret,max_len,1,fp))<0)
2020 {
2021 perror("fread fail!");
2022 fclose(fp);
2023 return -1;
2024 }
2025 fclose(fp);
2026 return 0;
2027}
2028int check_apn_status()
2029{
2030 LYINFLOG("check_apn_status enter");
2031 int ret = -1;
2032 char cmd_ret[8] ={0};//get mccmnc
2033 const char *cmd = "uci get radio_property.property.vendor_ril_data_gsm_mcc_mnc0";
2034 const char *empty_str = ":empty";
2035 ret = exec_cmd(cmd,cmd_ret,8);
2036 if(ret==0)
2037 {
2038 if(strlen(cmd_ret)==0)
2039 {
2040 LYERRLOG("not have mccmnc config in uci ram");
2041 return 1;
2042 }
2043 if(strncmp(cmd_ret,empty_str,strlen(empty_str))==0)
2044 {
2045 LYERRLOG("mccmnc is empty");
2046 return 2;
2047 }
2048 LYINFLOG("mccmnc is %s",cmd_ret);
2049 return 0;
2050 }
2051 else
2052 {
2053 LYERRLOG("exec cmd fail");
2054 return -1;
2055 }
2056 return 0;
2057}
lha62e0882023-10-31 05:17:11 -07002058int get_timeout_value()
2059{
2060 LYINFLOG("get_timeout_value enter");
2061 int ret = -1;
2062 char timeout_value[8] ={0};//get get_timeout_value
2063 ret = lynq_get_value("lynq_uci","data_call","timeout",timeout_value);
2064 if(ret == 0)
2065 {
2066 LYINFLOG("data_call.timeout is %s",timeout_value);
2067 return atoi(timeout_value);
2068 }
2069 else
2070 {
2071 LYERRLOG("get_timeout_value");
2072 return -1;
2073 }
2074}
2075
Hong_Liu7d9ac8d2023-07-24 00:40:31 -07002076int radio_switch(int status)
2077{
2078 Parcel *p =NULL;
2079 lynq_client_t client;
2080 int resp_type = -1;
2081 int token;
2082 int request = -1;
2083 int slot_id = -1;
2084 int error = -1;
2085 int version =0;
2086 int num = 0;
2087 char *temp_char = NULL;
2088 char mccmnc[32] = {0};
2089 char mccmnckey[64] = {0};
2090 client.uToken = get_utoken();
2091 client.request = 59;//RIL_REQUEST_OEM_HOOK_RAW 59
2092 client.paramLen = 1;
2093 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
2094 sprintf(client.param,"AT+CFUN=%d",status);
2095 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
2096 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
2097 if(send_request(lynq_client_sockfd,&client)==-1)
2098 {
2099 LYERRLOG("send request fail");
2100 perror("[LYNQ_DATA] send request fail:");
2101 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2102 return -1;
2103 }
2104 //get_response(lynq_client_sockfd,p);
2105 error = wait_response(lynq_client_sockfd,p,client.uToken);
2106 if(error!=0)
2107 {
2108 LYERRLOG("wait_response fail,ret:%d",error);
2109 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2110 return error;
2111 }
2112 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2113 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
2114 {
2115 LYERRLOG("JumpHeader fail");
2116 return -1;
2117 }
2118 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
2119 free_parcel(p);
2120 return error;
2121}
xy.he2a7fc1d2024-05-24 17:32:48 +08002122
2123//xy.he@20240524 modify for T8TSK-338 end
2124void string_to_hex(unsigned char *Buff, unsigned int BuffLen, char *OutputStr)
2125{
2126 int i = 0;
2127 char TempBuff[512*2 + 1] = {0};
2128 char strBuff[512*2 + 1] = {0};
2129
2130 if (BuffLen > 512)
2131 {
2132 RLOGD("BuffLen is too long");
2133 return;
2134 }
2135
2136 for(i = 0; i < BuffLen; i++)
2137 {
2138 sprintf(TempBuff,"%02X",(unsigned char)Buff[i]);
2139 strncat(strBuff,TempBuff,BuffLen*2);
2140 }
2141
2142 strncpy(OutputStr,strBuff,BuffLen*2);
2143 return;
2144
2145}
2146
2147void encode_data_log(char input_str[], int n)
2148{
2149 char c;
2150 int i;
2151 char str[512*2 + 1] = {0};
2152
2153 string_to_hex((unsigned char *)input_str, strlen(input_str), str);
2154
2155 for(i = 0; i < strlen(str); i++)
2156 {
2157 c = str[i];
2158 if(c>=' ' && c<='z')
2159 {
2160 if (c + n%90 <= 'z')
2161 {
2162 str[i] = (char)(c + n%90); //encode
2163 }
2164 else
2165 { //After encoding, the space beyond the end reaches ‘z’, and the cycle starts from the beginning.
2166 str[i] = (char)(c + n%90 - 90); //encode
2167 }
2168 }
2169 else
2170 {
2171 str[i] = c; //not encode
2172 }
2173
2174 }
2175
2176
2177 RLOGD("encode_data_log: %s", str);
2178
2179}
2180
2181void decode_data_log(char str[], int n)
2182{
2183 char c;
2184 int i;
2185 for(i = 0; i < strlen(str); i++)
2186 {
2187 c = str[i];
2188
2189 if(c>=' ' && c<='z')
2190 {
2191 if (c - n%90 >= ' ')
2192 {
2193 str[i] = (char)(c - n%90); //decode
2194 }
2195 else
2196 { //After decoding, the space beyond the end reaches ‘z’, and the cycle starts from the beginning.
2197 str[i] = (char)(c - n%90 + 90); //decode
2198 }
2199 }
2200 else
2201 {
2202 str[i] = c; //not decode
2203 }
2204 }
2205
2206 RLOGD("decode_data_log: %s", str);
2207}
xy.heb23b0532024-07-16 14:10:05 +08002208//xy.he@20240524 modify for T8TSK-338 end
2209
2210
2211int lynq_set_ip_filter(int cid)
2212{
2213 Parcel *p =NULL;
2214 lynq_client_t client;
2215 int resp_type = -1;
2216 int token;
2217 int request = -1;
2218 int slot_id = -1;
2219 int error = -1;
2220 int version =0;
2221 int num = 0;
2222
2223 client.uToken = get_utoken();
2224 client.request = LYNQ_SET_IP_TUPLE_FILTER;//RIL_REQUEST_SET_IP_TUPLE_FILTER 2195
2225 client.paramLen = 1;
2226 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
2227 sprintf(client.param,"%d",(cid / 100));
2228 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
2229 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
2230 if(send_request(lynq_client_sockfd,&client)==-1)
2231 {
2232 LYERRLOG("send request fail");
2233 perror("[LYNQ_DATA] send request fail:");
2234 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2235 return -1;
2236 }
2237 //get_response(lynq_client_sockfd,p);
2238 error = wait_response(lynq_client_sockfd,p,client.uToken);
2239 if(error!=0)
2240 {
2241 LYERRLOG("wait_response fail,ret:%d",error);
2242 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2243 return error;
2244 }
2245 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2246 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
2247 {
2248 LYERRLOG("JumpHeader fail");
2249 return -1;
2250 }
2251 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
2252 free_parcel(p);
2253 return error;
2254}
2255
2256int lynq_set_ip_filter_mode(int cid,int operation)
2257{
2258 Parcel *p =NULL;
2259 lynq_client_t client;
2260 int resp_type = -1;
2261 int token;
2262 int request = -1;
2263 int slot_id = -1;
2264 int error = -1;
2265 int version =0;
2266 int num = 0;
2267
2268 client.uToken = get_utoken();
2269 client.request = LYNQ_SET_IP_TUPLE_FILTER_MODE;//RIL_REQUEST_SET_IP_TUPLE_FILTER_MODE 2196
2270 client.paramLen = 2;
2271 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
2272 sprintf(client.param,"%d %d",(cid / 100),operation);
2273
2274 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
2275 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
2276 if(send_request(lynq_client_sockfd,&client)==-1)
2277 {
2278 LYERRLOG("send request fail");
2279 perror("[LYNQ_DATA] send request fail:");
2280 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2281 return -1;
2282 }
2283 //get_response(lynq_client_sockfd,p);
2284 error = wait_response(lynq_client_sockfd,p,client.uToken);
2285 if(error!=0)
2286 {
2287 LYERRLOG("wait_response fail,ret:%d",error);
2288 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2289 return error;
2290 }
2291 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2292 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
2293 {
2294 LYERRLOG("JumpHeader fail");
2295 return -1;
2296 }
2297 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
2298 free_parcel(p);
2299 return error;
2300
2301
2302}
2303
2304int lynq_get_ip_filter(int cid,int *filter_count, int *filter_mode)
2305{
2306 Parcel *p =NULL;
2307 lynq_client_t client;
2308 int resp_type = -1;
2309 int token;
2310 int request = -1;
2311 int slot_id = -1;
2312 int error = -1;
2313 int version =0;
2314 int num = 0;
2315
2316 client.uToken = get_utoken();
2317 client.request = LYNQ_GET_IP_TUPLE_FILTER;//RIL_REQUEST_GET_IP_TUPLE_FILTER 2197
2318 client.paramLen = 1;
2319 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
2320 sprintf(client.param,"%d",(cid / 100));
2321
2322 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
2323 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
2324 if(send_request(lynq_client_sockfd,&client)==-1)
2325 {
2326 LYERRLOG("send request fail");
2327 perror("[LYNQ_DATA] send request fail:");
2328 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2329 return -1;
2330 }
2331 //get_response(lynq_client_sockfd,p);
2332 error = wait_response(lynq_client_sockfd,p,client.uToken);
2333 if(error!=0)
2334 {
2335 LYERRLOG("wait_response fail,ret:%d",error);
2336 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2337 return error;
2338 }
2339 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2340 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
2341 {
2342 LYERRLOG("JumpHeader fail");
2343 return -1;
2344 }
2345 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
2346 if(error == 0)
2347 {
2348 p->readInt32(filter_count);
2349 p->readInt32(filter_mode);
2350 }
2351 free_parcel(p);
2352 return error;
2353
2354
2355}
2356
2357int lynq_del_ip_filter(int cid)
2358{
2359 Parcel *p =NULL;
2360 lynq_client_t client;
2361 int resp_type = -1;
2362 int token;
2363 int request = -1;
2364 int slot_id = -1;
2365 int error = -1;
2366 int version =0;
2367 int num = 0;
2368
2369 client.uToken = get_utoken();
2370 client.request = LYNQ_DEL_IP_TUPLE_FILTER;//RIL_REQUEST_DEL_IP_TUPLE_FILTER 2198
2371 client.paramLen = 1;
2372 bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
2373 sprintf(client.param,"%d",(cid / 100));
2374
2375 LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
2376 pthread_mutex_lock(&g_lynq_data_sendto_mutex);
2377 if(send_request(lynq_client_sockfd,&client)==-1)
2378 {
2379 LYERRLOG("send request fail");
2380 perror("[LYNQ_DATA] send request fail:");
2381 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2382 return -1;
2383 }
2384 //get_response(lynq_client_sockfd,p);
2385 error = wait_response(lynq_client_sockfd,p,client.uToken);
2386 if(error!=0)
2387 {
2388 LYERRLOG("wait_response fail,ret:%d",error);
2389 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2390 return error;
2391 }
2392 pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
2393 if(JumpHeader(p,&resp_type,&client.uToken,&request,&slot_id,&error)!=0)
2394 {
2395 LYERRLOG("JumpHeader fail");
2396 return -1;
2397 }
2398 LYINFLOG("resp_type=%d,uToken=%d,request=%d,slot_id=%d,error_code=%d",resp_type,client.uToken,request,slot_id,error);
2399 free_parcel(p);
2400 return error;
2401
2402
xy.hefe801322024-07-16 18:29:19 +08002403}