#include "QMIThread.h"
extern char *strndup (const char *__string, size_t __n);
int qmiclientId[QMUX_TYPE_WDS_ADMIN + 1]; //GobiNet use fd to indicate client ID, so type of qmiclientId must be int
static UINT WdsConnectionIPv4Handle = 0;
static int s_is_cdma = 0;
static int s_hdr_personality = 0; // 0x01-HRPD, 0x02-eHRPD
static char *qstrcpy(char *to, const char *from) { //no __strcpy_chk
char *save = to;
for (; (*to = *from) != '\0'; ++from, ++to);
return(save);
}
static int s_9x07 = 0;
typedef USHORT (*CUSTOMQMUX)(PQMUX_MSG pMUXMsg, void *arg);
// To retrieve the ith (Index) TLV
PQMI_TLV_HDR GetTLV (PQCQMUX_MSG_HDR pQMUXMsgHdr, int TLVType) {
int TLVFind = 0;
USHORT Length = le16_to_cpu(pQMUXMsgHdr->Length);
PQMI_TLV_HDR pTLVHdr = (PQMI_TLV_HDR)(pQMUXMsgHdr + 1);
while (Length >= sizeof(QMI_TLV_HDR)) {
TLVFind++;
if (TLVType > 0x1000) {
if ((TLVFind + 0x1000) == TLVType)
return pTLVHdr;
} else if (pTLVHdr->TLVType == TLVType) {
return pTLVHdr;
}
Length -= (le16_to_cpu((pTLVHdr->TLVLength)) + sizeof(QMI_TLV_HDR));
pTLVHdr = (PQMI_TLV_HDR)(((UCHAR *)pTLVHdr) + le16_to_cpu(pTLVHdr->TLVLength) + sizeof(QMI_TLV_HDR));
}
return NULL;
}
static USHORT GetQMUXTransactionId(void) {
static int TransactionId = 0;
if (++TransactionId > 0xFFFF)
TransactionId = 1;
return TransactionId;
}
static PQCQMIMSG ComposeQMUXMsg(UCHAR QMIType, USHORT Type, CUSTOMQMUX customQmuxMsgFunction, void *arg) {
UCHAR QMIBuf[WDM_DEFAULT_BUFSIZE];
PQCQMIMSG pRequest = (PQCQMIMSG)QMIBuf;
int Length;
memset(QMIBuf, 0x00, sizeof(QMIBuf));
pRequest->QMIHdr.IFType = USB_CTL_MSG_TYPE_QMI;
pRequest->QMIHdr.CtlFlags = 0x00;
pRequest->QMIHdr.QMIType = QMIType;
pRequest->QMIHdr.ClientId = qmiclientId[pRequest->QMIHdr.QMIType] & 0xFF;
if (pRequest->QMIHdr.ClientId == 0) {
dbg_time("QMIType %d has no clientID", pRequest->QMIHdr.QMIType);
return NULL;
}
pRequest->MUXMsg.QMUXHdr.CtlFlags = QMUX_CTL_FLAG_SINGLE_MSG | QMUX_CTL_FLAG_TYPE_CMD;
pRequest->MUXMsg.QMUXHdr.TransactionId = cpu_to_le16(GetQMUXTransactionId());
pRequest->MUXMsg.QMUXMsgHdr.Type = cpu_to_le16(Type);
if (customQmuxMsgFunction)
pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(customQmuxMsgFunction(&pRequest->MUXMsg, arg) - sizeof(QCQMUX_MSG_HDR));
else
pRequest->MUXMsg.QMUXMsgHdr.Length = cpu_to_le16(0x0000);
pRequest->QMIHdr.Length = cpu_to_le16(le16_to_cpu(pRequest->MUXMsg.QMUXMsgHdr.Length) + sizeof(QCQMUX_MSG_HDR) + sizeof(QCQMUX_HDR)
+ sizeof(QCQMI_HDR) - 1);
Length = le16_to_cpu(pRequest->QMIHdr.Length) + 1;
pRequest = (PQCQMIMSG)malloc(Length);
if (pRequest == NULL) {
dbg_time("%s fail to malloc", __func__);
} else {
memcpy(pRequest, QMIBuf, Length);
}
return pRequest;
}
#if 0
static USHORT NasSetEventReportReq(PQMUX_MSG pMUXMsg, void *arg) {
pMUXMsg->SetEventReportReq.TLVType = 0x10;
pMUXMsg->SetEventReportReq.TLVLength = 0x04;
pMUXMsg->SetEventReportReq.ReportSigStrength = 0x00;
pMUXMsg->SetEventReportReq.NumTresholds = 2;
pMUXMsg->SetEventReportReq.TresholdList[0] = -113;
pMUXMsg->SetEventReportReq.TresholdList[1] = -50;
return sizeof(QMINAS_SET_EVENT_REPORT_REQ_MSG);
}
static USHORT WdsSetEventReportReq(PQMUX_MSG pMUXMsg, void *arg) {
pMUXMsg->EventReportReq.TLVType = 0x10; // 0x10 -- current channel rate indicator
pMUXMsg->EventReportReq.TLVLength = 0x0001; // 1
pMUXMsg->EventReportReq.Mode = 0x00; // 0-do not report; 1-report when rate changes
pMUXMsg->EventReportReq.TLV2Type = 0x11; // 0x11
pMUXMsg->EventReportReq.TLV2Length = 0x0005; // 5
pMUXMsg->EventReportReq.StatsPeriod = 0x00; // seconds between reports; 0-do not report
pMUXMsg->EventReportReq.StatsMask = 0x000000ff; //
pMUXMsg->EventReportReq.TLV3Type = 0x12; // 0x12 -- current data bearer indicator
pMUXMsg->EventReportReq.TLV3Length = 0x0001; // 1
pMUXMsg->EventReportReq.Mode3 = 0x01; // 0-do not report; 1-report when changes
pMUXMsg->EventReportReq.TLV4Type = 0x13; // 0x13 -- dormancy status indicator
pMUXMsg->EventReportReq.TLV4Length = 0x0001; // 1
pMUXMsg->EventReportReq.DormancyStatus = 0x00; // 0-do not report; 1-report when changes
return sizeof(QMIWDS_SET_EVENT_REPORT_REQ_MSG);
}
static USHORT DmsSetEventReportReq(PQMUX_MSG pMUXMsg) {
PPIN_STATUS pPinState = (PPIN_STATUS)(&pMUXMsg->DmsSetEventReportReq + 1);
PUIM_STATE pUimState = (PUIM_STATE)(pPinState + 1);
// Pin State
pPinState->TLVType = 0x12;
pPinState->TLVLength = 0x01;
pPinState->ReportPinState = 0x01;
// UIM State
pUimState->TLVType = 0x15;
pUimState->TLVLength = 0x01;
pUimState->UIMState = 0x01;
return sizeof(QMIDMS_SET_EVENT_REPORT_REQ_MSG) + sizeof(PIN_STATUS) + sizeof(UIM_STATE);
}
#endif
static USHORT WdsStartNwInterfaceReq(PQMUX_MSG pMUXMsg, void *arg) {
PQMIWDS_TECHNOLOGY_PREFERECE pTechPref;
PQMIWDS_AUTH_PREFERENCE pAuthPref;
PQMIWDS_USERNAME pUserName;
PQMIWDS_PASSWD pPasswd;
PQMIWDS_APNNAME pApnName;
PQMIWDS_IP_FAMILY_TLV pIpFamily;
USHORT TLVLength = 0;
UCHAR *pTLV;
PROFILE_T *profile = (PROFILE_T *)arg;
pTLV = (UCHAR *)(&pMUXMsg->StartNwInterfaceReq + 1);
pMUXMsg->StartNwInterfaceReq.Length = 0;
// Set technology Preferece
pTechPref = (PQMIWDS_TECHNOLOGY_PREFERECE)(pTLV + TLVLength);
pTechPref->TLVType = 0x30;
pTechPref->TLVLength = cpu_to_le16(0x01);
if (s_is_cdma == 0)
pTechPref->TechPreference = 0x01;
else
pTechPref->TechPreference = 0x02;
TLVLength +=(le16_to_cpu(pTechPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
// Set APN Name
if (profile->apn) {
pApnName = (PQMIWDS_APNNAME)(pTLV + TLVLength);
pApnName->TLVType = 0x14;
pApnName->TLVLength = cpu_to_le16(strlen(profile->apn));
qstrcpy((char *)&pApnName->ApnName, profile->apn);
TLVLength +=(le16_to_cpu(pApnName->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
}
// Set User Name
if (profile->user) {
pUserName = (PQMIWDS_USERNAME)(pTLV + TLVLength);
pUserName->TLVType = 0x17;
pUserName->TLVLength = cpu_to_le16(strlen(profile->user));
qstrcpy((char *)&pUserName->UserName, profile->user);
TLVLength += (le16_to_cpu(pUserName->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
}
// Set Password
if (profile->password) {
pPasswd = (PQMIWDS_PASSWD)(pTLV + TLVLength);
pPasswd->TLVType = 0x18;
pPasswd->TLVLength = cpu_to_le16(strlen(profile->password));
qstrcpy((char *)&pPasswd->Passwd, profile->password);
TLVLength +=(le16_to_cpu(pPasswd->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
}
// Set Auth Protocol
if (profile->user && profile->password) {
pAuthPref = (PQMIWDS_AUTH_PREFERENCE)(pTLV + TLVLength);
pAuthPref->TLVType = 0x16;
pAuthPref->TLVLength = cpu_to_le16(0x01);
pAuthPref->AuthPreference = profile->auth; // 0 ~ None, 1 ~ Pap, 2 ~ Chap, 3 ~ MsChapV2
TLVLength +=(le16_to_cpu(pAuthPref->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
}
// Add IP Family Preference
pIpFamily = (PQMIWDS_IP_FAMILY_TLV)(pTLV + TLVLength);
pIpFamily->TLVType = 0x19;
pIpFamily->TLVLength = cpu_to_le16(0x01);
pIpFamily->IpFamily = profile->IPType;
TLVLength += (le16_to_cpu(pIpFamily->TLVLength) + sizeof(QCQMICTL_TLV_HDR));
//Set Profile Index
if (profile->pdp) {
PQMIWDS_PROFILE_IDENTIFIER pProfileIndex = (PQMIWDS_PROFILE_IDENTIFIER)(pTLV + TLVLe
Quectel_Linux_ConnectManager_SR01A01V21.
5星 · 超过95%的资源 需积分: 13 90 浏览量
2017-10-23
18:49:19
上传
评论 1
收藏 51KB ZIP 举报
「已注销」
- 粉丝: 5
- 资源: 2
最新资源
- 111111111111111111
- 咪视界.apk
- C语言期末大作业之实现成语连连看.zip
- C语言期末大作业之实现扫雷游戏.zip
- C语言期末大作业之图书信息管理系统实现-基于Dev-C++实现.zip
- tensorflow-rocm-2.13.1.600-cp39-cp39-manylinux2014-x86-64.whl
- tensorflow-gpu-2.7.0-cp39-cp39-manylinux2010-x86-64.whl
- C语言期末大作业之图书信息管理系统实现-基于VivualStudio实现.zip
- tensorflow-gpu-2.7.0-cp38-cp38-manylinux2010-x86-64.whl
- 电子科大 电路分析与模拟电路 实验报告.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈