| #include <stdio.h>
|
| #include <sys/types.h>
|
| #include <sys/socket.h>
|
| #include <arpa/inet.h>
|
| #include <fcntl.h>
|
| #include <string.h>
|
| #include <stdlib.h>
|
| #include <unistd.h>
|
| #include <binder/Parcel.h>
|
| #include <log/log.h>
|
| #include "lynq_data.h"
|
| #include <cutils/jstring.h>
|
| #include <pthread.h>
|
| #include "liblog/lynq_deflog.h"
|
| #include <sys/time.h>
|
| #define LYNQ_SERVICE_PORT 8088
|
| #define LYNQ_URC_SERVICE_PORT 8086
|
| #define LYNQ_REC_BUF 8192
|
| #define LYNQ_REQUEST_PARAM_BUF 8192
|
| #define LYQN_SEDN_BUF 1024*8+sizeof(int)*3
|
| #define USER_LOG_TAG "LYNQ_DATA"
|
|
|
| using ::android::Parcel;
|
| typedef struct{
|
| int uToken;
|
| int request;
|
| int paramLen;
|
| char param[LYNQ_REQUEST_PARAM_BUF];
|
| }lynq_client_t;
|
| typedef enum{ |
| LYNQ_E_CARDSTATE_ERROR=8000, |
| /* The voice service state is out of service*/ |
| LYNQ_E_STATE_OUT_OF_SERVICE=8001, |
| /* The voice service state is EMERGENCY_ONLY*/ |
| LYNQ_E_STATE_EMERGENCY_ONLY=8002, |
| /* The radio power is power off*/ |
| LYNQ_E_STATE_POWER_OFF=8003, |
| LYNQ_E_TIME_OUT=8004, |
| /*create or open sms DB fail */ |
| LYNQ_E_SMS_DB_FAIL=8005, |
| /*Failed to execute sql statement*/ |
| LYNQ_E_SMS_SQL_FAIL = 8006, |
| LYNQ_E_SMS_NOT_FIND = 8007, |
| /* The logic conflict*/ |
| LYNQ_E_CONFLICT=9000, |
| /*Null anomaly*/ |
| LYNQ_E_NULL_ANONALY=9001 |
| }LYNQ_E;
|
|
|
| int lynq_client_sockfd = 0;
|
| int Global_uToken = 0;
|
| bool urc_recive_status = 1;
|
| int lynq_data_call_change_id = -1;
|
| static pthread_mutex_t s_data_call_state_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| static pthread_cond_t s_data_call_state_change_cond = PTHREAD_COND_INITIALIZER;
|
| static pthread_mutex_t s_pdn_change_mutex = PTHREAD_MUTEX_INITIALIZER;
|
| static pthread_cond_t s_pdn_change_cond = PTHREAD_COND_INITIALIZER;
|
|
|
| typedef struct{
|
| char apn[LYNQ_APN_MAX_LEN];
|
| char apnType[LYNQ_APN_TYPE_MAX_LEN];
|
| char ifaceName[LYNQ_IFACE_NAME_MAX_LEN];
|
| int hasUsed;
|
| int hasTimeout;
|
| }lynq_apn_t;
|
| lynq_apn_t lynq_apn_table[LYNQ_APN_CHANNEL_MAX] = {};
|
| lynq_data_call_response_v11_t lynq_data_call_lists[LYNQ_APN_CHANNEL_MAX] = {};
|
| int lynq_data_call = 0;
|
|
|
| int getLynqApnID(char apnType[])
|
| {
|
| int ret = 0;
|
| for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
|
| {
|
| if(strcmp(lynq_apn_table[ret].apnType,apnType)==0)
|
| {
|
| return ret;
|
| }
|
| }
|
| return -1;
|
| }
|
| void updateApnTable(lynq_apn_t *apn_table,char apn[],char apntype[],char ifaceName[])
|
| {
|
| if(apn_table==NULL)
|
| {
|
| LYERRLOG("apn_table is null");
|
| return;
|
| }
|
| memcpy(apn_table->apn,apn,strlen(apn)+1);
|
| memcpy(apn_table->apnType,apntype,strlen(apntype)+1);
|
| memcpy(apn_table->ifaceName,ifaceName,strlen(ifaceName)+1);
|
| apn_table->hasTimeout = 0;
|
| apn_table->hasUsed = 1;
|
| return;
|
| }
|
| void cleanOnceApnTable(int apnId)
|
| {
|
| if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
|
| {
|
| LYERRLOG("apn id is invalid!!!");
|
| return;
|
| }
|
| lynq_apn_table[apnId].hasTimeout = 0;
|
| lynq_apn_table[apnId].hasUsed = 0;
|
| bzero(lynq_apn_table[apnId].apn,LYNQ_APN_MAX_LEN);
|
| bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);
|
| bzero(lynq_apn_table[apnId].ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
|
| return;
|
| }
|
| int getUnusedElement()
|
| {
|
| for(int i=0;i < LYNQ_APN_CHANNEL_MAX; i++)
|
| {
|
| if(lynq_apn_table[i].hasUsed!=1)
|
| {
|
| return i;
|
| }
|
| }
|
| return -1;
|
| }
|
| int updateApn(char apnType[])
|
| {
|
| int ret = 0;
|
| ret = getUnusedElement();
|
| memcpy(lynq_apn_table[ret].apnType,apnType,strlen(apnType)+1);
|
| lynq_apn_table[ret].hasUsed = 1;
|
| return ret;
|
| }
|
|
|
| int waitPdnChange()
|
| {
|
| int ret = 0;
|
| pthread_mutex_lock(&s_pdn_change_mutex);
|
| ret = pthread_cond_wait(&s_pdn_change_cond,&s_pdn_change_mutex);
|
| pthread_mutex_unlock(&s_pdn_change_mutex);
|
| return ret;
|
| }
|
| int waitDataCallstateChange(int mtime)
|
| {
|
| int ret = 0;
|
| int sec = 0;
|
| int usec = 0;
|
| struct timeval now;
|
| struct timespec timeout;
|
| gettimeofday(&now,NULL);
|
| sec = mtime/1000;
|
| usec = mtime%1000;
|
| timeout.tv_sec = now.tv_sec+sec;
|
| timeout.tv_nsec = now.tv_usec*1000+usec*1000000;
|
| pthread_mutex_lock(&s_data_call_state_change_mutex);
|
| ret = pthread_cond_timedwait(&s_data_call_state_change_cond,&s_data_call_state_change_mutex,&timeout);
|
| pthread_mutex_unlock(&s_data_call_state_change_mutex);
|
| return ret;
|
| }
|
| void sendSignalDataCallStateChange()
|
| {
|
| pthread_mutex_lock(&s_data_call_state_change_mutex);
|
| pthread_cond_signal(&s_data_call_state_change_cond);
|
| pthread_mutex_unlock(&s_data_call_state_change_mutex);
|
| return;
|
| }
|
| void sendSignalPdnChange()
|
| {
|
| pthread_mutex_lock(&s_pdn_change_mutex);
|
| pthread_cond_signal(&s_pdn_change_cond);
|
| pthread_mutex_unlock(&s_pdn_change_mutex);
|
| return;
|
| }
|
|
|
| int get_response(int sockfd,Parcel &p)
|
| {
|
| int len = 0;
|
| char recvline[LYNQ_REC_BUF];
|
| bzero(recvline,LYNQ_REC_BUF);
|
| /* receive data from server */
|
| len = read(sockfd, recvline, LYNQ_REC_BUF);
|
| if(len == -1)
|
| {
|
| perror("read error");
|
| return -1;
|
| }
|
| printf("===>n=%d\n",len);
|
| if (recvline != NULL) {
|
| p.setData((uint8_t *)recvline,len); // p.setData((uint8_t *) buffer, buflen);
|
| p.setDataPosition(0);
|
| }
|
| return 0;
|
| }
|
| int JumpHeader(Parcel &p,int *resp_type,int *request,int *slot_id,int *error)
|
| {
|
| if(p.dataAvail() > 0)
|
| {
|
| p.readInt32(resp_type);
|
| p.readInt32(request);
|
| p.readInt32(slot_id);
|
| p.readInt32(error);
|
| return 0;
|
| }
|
| else
|
| {
|
| return -1;
|
| }
|
| }
|
| int send_request(int sockfd,lynq_client_t *client_tmp)
|
| {
|
| int ret=0;
|
| ret = write(sockfd, client_tmp, LYQN_SEDN_BUF);
|
| if(ret==-1)
|
| {
|
| perror("write error");
|
| return -1;
|
| }
|
| return 0;
|
| }
|
| static char *strdupReadString(Parcel &p) {
|
| size_t stringlen; |
| const char16_t *s16;
|
| s16 = p.readString16Inplace(&stringlen);
|
| return strndup16to8(s16, stringlen); |
| }
|
| static char *strdupReadString_p(Parcel *p) {
|
| size_t stringlen; |
| const char16_t *s16;
|
| s16 = p->readString16Inplace(&stringlen);
|
| return strndup16to8(s16, stringlen); |
| }
|
|
|
|
|
| /*Warren add for T800 platform 2021/11/19 start*/
|
| int lynq_socket_client_start()
|
| {
|
| struct sockaddr_in lynq_socket_server_addr;
|
| /* init lynq_socket_server_addr */
|
| bzero(&lynq_socket_server_addr, sizeof(lynq_socket_server_addr));
|
| lynq_socket_server_addr.sin_family = AF_INET;
|
| lynq_socket_server_addr.sin_port = htons(LYNQ_SERVICE_PORT);
|
| lynq_socket_server_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| /*
|
| if(inet_pton(AF_INET,"127.0.0.1", &lynq_socket_server_addr.sin_addr) <= 0)
|
| {
|
| printf("[%s] is not a valid IPaddress\n", argv[1]);
|
| exit(1);
|
| }
|
| */
|
| lynq_client_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
| if(connect(lynq_client_sockfd, (struct sockaddr *)&lynq_socket_server_addr, sizeof(lynq_socket_server_addr)) == -1)
|
| {
|
| perror("connect error");
|
| return -1;
|
| }
|
| return 0;
|
| }
|
| void *thread_urc_recv(void *parg)
|
| { |
| int socket_fd = (int64_t)parg;
|
| int len=0;
|
| socklen_t addr_len=0;
|
| uint8_t *dataLength = NULL;
|
| char urc_data[LYNQ_REC_BUF];
|
| char apn[LYNQ_APN_MAX_LEN];
|
| char apnType[LYNQ_APN_TYPE_MAX_LEN];
|
| int pdnState = 0;
|
| char ifaceName[LYNQ_IFACE_NAME_MAX_LEN];
|
| int slot_id = -1;
|
| int resp_type = -1;
|
| int urcid = -1;
|
| char *urc_msg = NULL;
|
| Parcel *p = NULL;
|
| struct sockaddr_in dest_addr;
|
| LYINFLOG("thread_urc_recv in running....\n");
|
| while(urc_recive_status)
|
| {
|
| bzero(urc_data,LYNQ_REC_BUF);
|
| //get data msg
|
| len = recvfrom(socket_fd,urc_data,LYNQ_REC_BUF,0,(struct sockaddr *)&dest_addr,&addr_len);
|
| if(len <= 0)
|
| { |
| perror("thread_urc_recv step2 fail:");
|
| break; |
| }
|
| LYDBGLOG("=====>urc data len<=====:%d\n",len);
|
| p = new Parcel();
|
| if(p==NULL)
|
| {
|
| RLOGD("new parcel failure!!!");
|
| break;
|
| }
|
| p->setData((uint8_t *)urc_data,len); // p.setData((uint8_t *) buffer, buflen);
|
| p->setDataPosition(0);
|
| if(p->dataAvail() > 0)
|
| {
|
| p->readInt32(&resp_type);
|
| p->readInt32(&urcid);
|
| p->readInt32(&slot_id);
|
| //LYDBGLOG("*******Warren test*******:resp_type=%d,urcid=%d,slot_id=%d\n",resp_type,urcid,slot_id);
|
| switch (urcid)
|
| {
|
| case 9003://LYNQ_URC_DATA_CALL_STATUS_IND
|
| {
|
| LYINFLOG("**************:resp_type=%d,urcid=%d,slot_id=%d\n",resp_type,urcid,slot_id);
|
| p->readInt32(&pdnState);
|
| bzero(apn,LYNQ_APN_MAX_LEN);
|
| bzero(apnType,LYNQ_APN_TYPE_MAX_LEN);
|
| bzero(ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
|
| if(pdnState!=4)//PDN_DISCONNECTED
|
| {
|
| urc_msg = strdupReadString_p(p);
|
| int len = strlen(urc_msg);
|
| if(len < LYNQ_APN_MAX_LEN-1)
|
| {
|
| memcpy(apn,urc_msg,len+1);
|
| }
|
| urc_msg = strdupReadString_p(p);
|
| len = strlen(urc_msg);
|
| if(len < LYNQ_APN_TYPE_MAX_LEN-1)
|
| {
|
| memcpy(apnType,urc_msg,len+1);
|
| }
|
| urc_msg = strdupReadString_p(p);
|
| len = strlen(urc_msg);
|
| if(len < LYNQ_IFACE_NAME_MAX_LEN-1)
|
| {
|
| memcpy(ifaceName,urc_msg,strlen(urc_msg)+1);
|
| }
|
| //sendSignalDataCallStateChange();
|
| }
|
| int apnId = getLynqApnID(apnType);
|
| if(lynq_apn_table[apnId].hasTimeout==1)
|
| {
|
| LYERRLOG("apn:%s has time out",lynq_apn_table[apnId].apn);
|
| lynq_deactive_data_call(&apnId);
|
| continue;
|
| }
|
| updateApnTable(&lynq_apn_table[apnId], apn,apnType,ifaceName);
|
| sendSignalPdnChange();
|
| lynq_data_call_change_id = apnId;
|
| if(lynq_data_call==1)
|
| {
|
| sendSignalDataCallStateChange();
|
| lynq_data_call = 0;
|
| }
|
| /*
|
| if(dataCb!=NULL)
|
| {
|
| (*dataCb)(apn,apnType,pdnState,ifaceName);
|
| }
|
| */
|
| break;
|
| }
|
| default:
|
| break;
|
| }
|
| }
|
| delete p;
|
| p = NULL;
|
| }
|
| close(socket_fd);
|
| }
|
| int lynq_socket_urc_start()
|
| {
|
| int socket_fd=0;
|
| int rt=0;
|
| int len=0;
|
| int on=1;
|
| struct sockaddr_in urc_local_addr;
|
| pthread_t tid;
|
| pthread_attr_t attr;
|
| socket_fd = socket(AF_INET,SOCK_DGRAM,0); |
| printf("test 001\n"); |
| if(socket_fd < 0) |
| { |
| perror("creaet socket for udp fail");
|
| return -1; |
| }
|
| urc_local_addr.sin_family = AF_INET;
|
| urc_local_addr.sin_port = htons(LYNQ_URC_SERVICE_PORT);
|
| urc_local_addr.sin_addr.s_addr = htons(INADDR_ANY);
|
| /* Set socket to allow reuse of address and port, SO_REUSEADDR value is 2*/
|
| rt = setsockopt(socket_fd,SOL_SOCKET,SO_REUSEADDR,&on,sizeof on); |
| if(rt<0) |
| { |
| perror("SO_REUSEADDR fail\n");
|
| return -1;
|
| }
|
| rt = bind(socket_fd ,(struct sockaddr*)&urc_local_addr, sizeof(urc_local_addr));
|
| if (rt == -1) |
| { |
| perror("bind failed");
|
| return -1; |
| }
|
| pthread_attr_init(&attr);
|
| pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
| rt = pthread_create(&tid,&attr,thread_urc_recv,(void *)socket_fd);
|
| if(rt < 0)
|
| {
|
| printf("urc loop failure!!!\n");
|
| return -1;
|
| }
|
| printf("urc loop success!!!\n");
|
| return 0;
|
| }
|
| void lynq_call_state_change_test(int soc_id)
|
| {
|
| printf("call state change,sim:%d\n",soc_id);
|
| }
|
| void lynq_data_call_state_cb_test(char apn[LYNQ_APN_MAX_LEN],char apnType[LYNQ_APN_TYPE_MAX_LEN],int pdnState,char ifaceName[LYNQ_IFACE_NAME_MAX_LEN])
|
| {
|
| printf("data state change,apn=%s,apntype=%s,pdnstate=%d,ifacename=%s:%d\n",apn,apnType,pdnState,ifaceName);
|
| }
|
|
|
| int lynq_init_data(int uToken)
|
| {
|
| int result = 0;
|
| Global_uToken = uToken;
|
| LYLOGSET(LOG_INFO);
|
| LYLOGEINIT(USER_LOG_TAG);
|
| result = lynq_socket_client_start();
|
| if(result!=0)
|
| {
|
| LYERRLOG("init socket client fail!!!");
|
| return -1;
|
| }
|
| result = lynq_socket_urc_start();
|
| if(result!=0)
|
| {
|
| LYERRLOG("init socket urc fail!!!");
|
| return -1;
|
| }
|
| memset(lynq_apn_table,0,sizeof(lynq_apn_table));
|
| LYDBGLOG("lynq init call success!!!");
|
| return 0;
|
|
|
| }
|
| int lynq_deinit_data()
|
| {
|
| close(lynq_client_sockfd);
|
| for(int i =0;i<LYNQ_APN_CHANNEL_MAX;i++)
|
| {
|
| if(lynq_apn_table[i].apnType!=NULL)
|
| {
|
| lynq_deactive_data_call(&i);
|
| }
|
| }
|
| urc_recive_status = 0;
|
| return 0;
|
| }
|
| int lynq_setup_data_call(int *handle)
|
| {
|
| Parcel p;
|
| lynq_client_t client;
|
| int resp_type = -1;
|
| int request = -1;
|
| int slot_id = -1;
|
| int error = -1;
|
| char iface = NULL;
|
| int lynq_data_call_id = 0;
|
| if(handle==NULL)
|
| {
|
| LYERRLOG("handle is null!!!");
|
| return LYNQ_E_NULL_ANONALY;
|
| }
|
| client.uToken = Global_uToken;
|
| client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
|
| client.paramLen = 0;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
| if(send_request(lynq_client_sockfd,&client)==-1)
|
| {
|
| LYERRLOG("send request fail");
|
| perror("[LYNQ_DATA] send request fail:");
|
| return -1;
|
| }
|
| get_response(lynq_client_sockfd,p);
|
| JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| lynq_data_call_id = updateApn("default");
|
| lynq_data_call = 1;
|
| if(error==0)
|
| {
|
| if(waitDataCallstateChange(1000)==ETIMEDOUT)//1000ms
|
| {
|
| error = LYNQ_E_TIME_OUT;
|
| LYERRLOG("timeout:wait data Call state fail!!!");
|
| lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
|
| return error;
|
| }
|
| *handle = lynq_data_call_id;
|
| }
|
| return error;
|
| }
|
| int lynq_deactive_data_call(int *handle)
|
| {
|
| Parcel p;
|
| lynq_client_t client;
|
| int resp_type = -1;
|
| int request = -1;
|
| int slot_id = -1;
|
| int error = -1;
|
| int lynq_data_call_id = -1;
|
| lynq_data_call_id = *handle;
|
| if(handle==NULL)
|
| {
|
| LYERRLOG("handle is null!!!");
|
| return -1;
|
| }
|
| client.uToken = Global_uToken;
|
| client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL
|
| if(strcmp(lynq_apn_table[lynq_data_call_id].apnType,"default")==0)
|
| {
|
| client.paramLen = 0;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| }
|
| else
|
| {
|
| client.paramLen = 1;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| sprintf(client.param,"%s",lynq_apn_table[lynq_data_call_id].apnType);
|
| }
|
| LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
| if(send_request(lynq_client_sockfd,&client)==-1)
|
| {
|
| LYERRLOG("send request fail");
|
| perror("[LYNQ_DATA] send request fail:");
|
| return -1;
|
| }
|
| get_response(lynq_client_sockfd,p);
|
| JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| cleanOnceApnTable(lynq_data_call_id);
|
| return error;
|
| }
|
| int lynq_setup_data_call_sp(int *handle,char *apn,char *apnType,char *user,char *password,char *authType,char *normalProtocol,char *roamingProtocol)
|
| {
|
| Parcel p;
|
| lynq_client_t client;
|
| int resp_type = -1;
|
| int request = -1;
|
| int slot_id = -1;
|
| int error = -1;
|
| char iface = NULL;
|
| int lynq_data_call_id = -1;
|
| char *argv[10] = {};
|
| if(handle==NULL||apn==NULL||apnType==NULL)
|
| {
|
| LYERRLOG("handle ,apn or apntype is null!!!");
|
| return -1;
|
| }
|
| if(user==NULL)
|
| { |
| argv[1] = "null";
|
| } |
| else |
| { |
| argv[1] = user;
|
| } |
| if(password==NULL) |
| { |
| argv[2] = "null";
|
| } |
| else |
| { |
| argv[2] = password;
|
| } |
| if(authType==NULL) |
| { |
| argv[3] = "null";
|
| } |
| else |
| { |
| argv[3] = authType;
|
| } |
| if(normalProtocol==NULL) |
| { |
| argv[4] = "null";
|
| } |
| else |
| { |
| argv[4] = normalProtocol;
|
| } |
| if(roamingProtocol==NULL) |
| { |
| argv[5] = "null";
|
| } |
| else |
| { |
| argv[5] = roamingProtocol;
|
| }
|
| client.uToken = Global_uToken;
|
| client.request = 27;//RIL_REQUEST_SETUP_DATA_CALL
|
| client.paramLen = 7;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
|
| LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
| if(send_request(lynq_client_sockfd,&client)==-1)
|
| {
|
| LYERRLOG("send request fail");
|
| perror("[LYNQ_DATA] send request fail:");
|
| return -1;
|
| }
|
| get_response(lynq_client_sockfd,p);
|
| JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| lynq_data_call_id = updateApn(apnType);
|
| if(error==0)
|
| {
|
| if(waitDataCallstateChange(1000)==ETIMEDOUT)//1000ms
|
| {
|
| error = LYNQ_E_TIME_OUT;
|
| LYERRLOG("timeout:wait data Call state fail!!!");
|
| lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
|
| return error;
|
| }
|
| *handle = lynq_data_call_id;
|
| }
|
| return error;
|
| }
|
| /*
|
| int lynq_deactive_data_call_sp(int *handle,char *apnType)
|
| {
|
| Parcel p;
|
| lynq_client_t client;
|
| int resp_type = -1;
|
| int request = -1;
|
| int slot_id = -1;
|
| int error = -1;
|
| if(handle==NULL||apnType==NULL)
|
| {
|
| LYERRLOG("handle is null!!!");
|
| return -1;
|
| }
|
| client.uToken = Global_uToken;
|
| client.request = 41;//RIL_REQUEST_DEACTIVATE_DATA_CALL
|
| client.paramLen = 1;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| sprintf(client.param,"%s",apnType);
|
| LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
| if(send_request(lynq_client_sockfd,&client)==-1)
|
| {
|
| LYERRLOG("send request fail");
|
| perror("[LYNQ_DATA] send request fail:");
|
| return -1;
|
| }
|
| get_response(lynq_client_sockfd,p);
|
| JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| return error;
|
| }
|
| */
|
| int getDataCallLists(lynq_data_call_response_v11_t dataCallList[LYNQ_APN_CHANNEL_MAX],int *realNum)
|
| {
|
| Parcel p;
|
| lynq_client_t client;
|
| int resp_type = -1;
|
| int request = -1;
|
| int slot_id = -1;
|
| int error = -1;
|
| int version =0;
|
| int num = 0;
|
| int temp_int =0;
|
| char *temp_char = NULL;
|
| if(dataCallList==NULL)
|
| {
|
| LYERRLOG("dataCallList is null!!!");
|
| return -1;
|
| }
|
| client.uToken = Global_uToken;
|
| client.request = 57;//RIL_REQUEST_DATA_CALL_LIST
|
| client.paramLen = 0;
|
| bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
|
| LYERRLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
|
| if(send_request(lynq_client_sockfd,&client)==-1)
|
| {
|
| LYERRLOG("send request fail");
|
| perror("[LYNQ_DATA] send request fail:");
|
| return -1;
|
| }
|
| get_response(lynq_client_sockfd,p);
|
| JumpHeader(p,&resp_type,&request,&slot_id,&error);
|
| LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
|
| p.readInt32(&version);
|
| if(version==11)
|
| {
|
| p.readInt32(&num);
|
| *realNum = num;
|
| for (int i = 0; i < num; i++)
|
| {
|
| p.readInt32(&dataCallList[i].status);
|
| p.readInt32(&dataCallList[i].suggestedRetryTime);
|
| p.readInt32(&dataCallList[i].cid);
|
| p.readInt32(&dataCallList[i].active);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].type,temp_char,strlen(temp_char)+1);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].ifname,temp_char,strlen(temp_char)+1);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].addresses,temp_char,strlen(temp_char)+1);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].dnses,temp_char,strlen(temp_char)+1);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].gateways,temp_char,strlen(temp_char)+1);
|
| temp_char = strdupReadString(p);
|
| memcpy(dataCallList[i].pcscf,temp_char,strlen(temp_char)+1);
|
| p.readInt32(&dataCallList[i].mtu);
|
| }
|
| }
|
| return error;
|
| }
|
| int lynq_get_data_call_list(int *handle,lynq_data_call_response_v11_t dataCallList)
|
| {
|
| lynq_data_call_response_v11_t interDataCallList[LYNQ_APN_CHANNEL_MAX]={};
|
| int number = 0;
|
| int lynq_data_call_id = 0;
|
| int error = 0;
|
| lynq_data_call_id = *handle;
|
| if(handle==NULL)
|
| {
|
| LYERRLOG("handle is NULL");
|
| return LYNQ_E_NULL_ANONALY;
|
| }
|
| memset(interDataCallList,0,sizeof(interDataCallList));
|
| error = getDataCallLists(interDataCallList,&number);
|
| if(error == 0)
|
| {
|
| for(int i = 0;i < number;i++)
|
| {
|
| if(strcmp(interDataCallList[i].ifname,lynq_apn_table[lynq_data_call_id].ifaceName)==0)
|
| {
|
| dataCallList.active = interDataCallList[i].active;
|
| dataCallList.suggestedRetryTime = interDataCallList[i].suggestedRetryTime;
|
| dataCallList.cid = interDataCallList[i].cid;
|
| dataCallList.status = interDataCallList[i].status;
|
| dataCallList.mtu = interDataCallList[i].mtu;
|
| memcpy(dataCallList.addresses,interDataCallList[i].addresses,sizeof(interDataCallList[i].addresses));
|
| memcpy(dataCallList.ifname,interDataCallList[i].ifname,sizeof(interDataCallList[i].ifname));
|
| memcpy(dataCallList.dnses,interDataCallList[i].dnses,sizeof(interDataCallList[i].dnses));
|
| memcpy(dataCallList.type,interDataCallList[i].type,sizeof(interDataCallList[i].type));
|
| memcpy(dataCallList.gateways,interDataCallList[i].gateways,sizeof(interDataCallList[i].gateways));
|
| memcpy(dataCallList.pcscf,interDataCallList[i].pcscf,sizeof(interDataCallList[i].pcscf));
|
| }
|
| }
|
| }
|
| return error;
|
| }
|
| int lynq_wait_data_call_state_change(int *handle)
|
| {
|
| waitPdnChange();
|
| *handle = lynq_data_call_change_id;
|
| LYINFLOG("lynq data call id:%d",lynq_data_call_change_id);
|
| return 0;
|
| }
|
| #if 0
|
| int main(int argc,char **argv)
|
| {
|
| int n = 0;
|
| n = lynq_init_call(lynq_call_state_change_test,2222);
|
| if(n<0)
|
| {
|
| printf("lynq init call fail!!!\n");
|
| return -1;
|
| }
|
| printf("lynq call init success!!!\n");
|
| char phoneNum[LYNQ_PHONE_NUMBER_MAX];
|
| sprintf(phoneNum,"18180053406 0",strlen("18180053406 0")+1);
|
| lynq_call(phoneNum);
|
| while(1)
|
| {
|
| sleep(1);
|
| }
|
| return 0;
|
| }
|
| #endif
|
| /*Warren add for T800 platform 2021/11/19 end*/
|