Add APDU pipe events registration for non HCI v12 compliant eSE's

Proprietary HCI v9 APDU pipe initialization is implemented with a different
control packets flow:
- _HCI v9_: **ADM_NOTIFY_PIPE_CREATED(1)** / ANY_OPEN_PIPE
- _HCI v12_: **ADM_CREATE_PIPE(2)** / ANY_OPEN_PIPE

For HCI v12 registration takes place in the response to
**ADM_CREATE_PIPE(2)**, therefore we need update
**ADM_NOTIFY_PIPE_CREATED(1)** appropriately.
This commit is contained in:
Chris Gunn 2018-07-26 18:46:42 -07:00
Родитель 2ea0b98043
Коммит 0eff4881f0
2 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -891,6 +891,10 @@ phHciNfc_ProcessPipeCreateNotifyCmd(phHciNfc_ReceiveParams_t *pReceivedParams,
tPipeCreatedNtfParams.bPipeID = ((phHciNfc_AdmNotfPipeCrCmdParams_t*)pReceivedParams->pData)->bPipeID;
tPipeCreatedNtfParams.bSourceGID = ((phHciNfc_AdmNotfPipeCrCmdParams_t*)pReceivedParams->pData)->bSourceGID;
tPipeCreatedNtfParams.bSourceHID = ((phHciNfc_AdmNotfPipeCrCmdParams_t*)pReceivedParams->pData)->bSourceHID;
PH_LOG_LIBNFC_INFO_STR(
"ADM_NOTIFY_PIPE_CREATED: Host ID = 0x%02X, Pipe ID = 0x%0X",
tPipeCreatedNtfParams.bSourceHID,
tPipeCreatedNtfParams.bPipeID);
/* Register for Cmd Open pipe for the newly created pipe */
tHciRegData.eMsgType = phHciNfc_e_HciMsgTypeCmd;
@ -912,7 +916,6 @@ phHciNfc_ProcessPipeCreateNotifyCmd(phHciNfc_ReceiveParams_t *pReceivedParams,
/* Update Session ID Based on whether Pipe request received from UICC or eSE*/
if( tPipeCreatedNtfParams.bSourceHID != phHciNfc_e_UICCHostID )
{
PH_LOG_LIBNFC_INFO_X32MSG("Gate ID = ", tPipeCreatedNtfParams.bDestGID);
/* Pipe Created Ntf from eSE*/
/* Check the Gate ID to which Pipe Request is received */
if((tPipeCreatedNtfParams.bDestGID == phHciNfc_e_ApduGateId) ||
@ -1145,6 +1148,7 @@ phHciNfc_ReceiveOpenPipeNotifyCmd(void *pContext,NFCSTATUS wStatus, void *pInfo)
}
else
{
bSendAnyOk = FALSE;
wIntStatus = phHciNfc_e_RspAnyECmdNotSupported;
}
@ -1161,11 +1165,11 @@ phHciNfc_ReceiveOpenPipeNotifyCmd(void *pContext,NFCSTATUS wStatus, void *pInfo)
/* DataLength */
tSendParams.dwLen = 0x01;
/* Send ANY_OK in response to ANY_OPEN_PIPE and register for pipe events */
wStatus = phHciNfc_CoreSend (pHciContext,&tSendParams,&phHciNfc_AnyOkCb, pHciContext);
if((NFCSTATUS_PENDING == wStatus))
{
/* Do not register for events at APDU Gate Pipe */
if(pReceivedParams->bPipeId != pHciContext->aGetHciSessionId[PHHCI_ESE_APDU_PIPE_STORAGE_INDEX])
if (pReceivedParams->bPipeId != pHciContext->aGetHciSessionId[PHHCI_ESE_APDU_PIPE_STORAGE_INDEX])
{
/* Register for Evt for the opened pipe */
tHciRegData.eMsgType = phHciNfc_e_HciMsgTypeEvent;
@ -1184,9 +1188,19 @@ phHciNfc_ReceiveOpenPipeNotifyCmd(void *pContext,NFCSTATUS wStatus, void *pInfo)
}
else
{
PH_LOG_HCI_CRIT_STR("No need to launch sequence");
PH_LOG_HCI_INFO_STR("No need to launch sequence");
}
}
else
{
PH_LOG_HCI_INFO_STR("Register for APDU pipe events.");
tHciRegData.eMsgType = phHciNfc_e_HciMsgTypeEvent;
tHciRegData.bPipeId = pReceivedParams->bPipeId;
(void)phHciNfc_RegisterCmdRspEvt(pHciContext,
&tHciRegData,
&phHciNfc_ProcessEventsOnApduPipe,
pHciContext);
}
}
}
}
@ -1214,6 +1228,8 @@ void phHciNfc_ProcessEventsOnPipe( void *pContext,NFCSTATUS wStatus, void *pInfo
/*Check for Transaction events */
if(pReceivedParams->bIns == PH_LIBNFC_INTERNAL_HCI_TRANSACTION_EVENT)
{
PH_LOG_HCI_INFO_STR("HCI event of type=EVT_TRANSACTION on pipeID=0x%02X", pReceivedParams->bPipeId);
while((bIndex+2) < pReceivedParams->wLen)
{
bTag = pReceivedParams->pData[bIndex++];
@ -1242,6 +1258,8 @@ void phHciNfc_ProcessEventsOnPipe( void *pContext,NFCSTATUS wStatus, void *pInfo
/*Check for Connectivity events */
else if(pReceivedParams->bIns == PH_LIBNFC_INTERNAL_HCI_CONNECTIVITY_EVENT)
{
PH_LOG_HCI_INFO_STR("HCI event of type=EVT_CONNECTIVITY on pipeID=0x%02X", pReceivedParams->bPipeId);
tSeEvtInfo.UiccEvtInfo.param.buffer = NULL;
tSeEvtInfo.UiccEvtInfo.param.length = 0x00;
tSeEvtInfo.UiccEvtInfo.aid.length = 0x00;

Просмотреть файл

@ -750,14 +750,14 @@ phLibNfc_HciGetSessionIdentity(void* pContext,NFCSTATUS status,void* pInfo)
if(NULL != pLibCtx->pHciContext)
{
/* Open a pipe to ADM (Admin) gate */
wStatus=phHciNfc_AnyGetParameter(
wStatus = phHciNfc_AnyGetParameter(
pLibCtx->pHciContext,
(uint8_t)phHciNfc_e_AdminGateId,
phHciNfc_e_SessionIdentityRegistryId,
(uint8_t)phHciNfc_e_HciAdminPipeId,
&phLibNfc_InternalSequence,
pContext
);
pContext);
if(NFCSTATUS_PENDING != wStatus)
{
PH_LOG_LIBNFC_CRIT_X32MSG("Failed to Get SessionIdentity, error",wStatus);
@ -918,7 +918,8 @@ phLibNfc_HciGetSessionIdentityProc(void* pContext,NFCSTATUS status,void* pInfo)
{
pHciCtx->aSEPipeList[PHHCI_ESE_APDU_PIPE_LIST_INDEX].bPipeId = pReadSessionIdentity->pData[PHHCI_ESE_APDU_PIPE_STORAGE_INDEX];
pHciCtx->aSEPipeList[PHHCI_ESE_APDU_PIPE_LIST_INDEX].bGateId = phHciNfc_e_ApduGateId;
/* Register for Events for the pipe on APDU Gate Pipe*/
PH_LOG_HCI_INFO_STR("Register for APDU pipe events.");
tHciRegData.eMsgType = phHciNfc_e_HciMsgTypeEvent;
tHciRegData.bPipeId = pReadSessionIdentity->pData[PHHCI_ESE_APDU_PIPE_STORAGE_INDEX];
(void)phHciNfc_RegisterCmdRspEvt(pHciCtx,