Changes due to continue development effort.
This commit is contained in:
@@ -55,7 +55,7 @@ typedef struct _GetAuthTokenRespParse
|
||||
{
|
||||
XML_Parser p;
|
||||
int state;
|
||||
int tokenDataProcessed;
|
||||
int elementDataProcessed;
|
||||
GetAuthTokenResp *pGetAuthTokenResp;
|
||||
CasaStatus status;
|
||||
|
||||
@@ -81,7 +81,7 @@ BuildGetAuthTokenMsg(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
char *pMsg = NULL;
|
||||
@@ -115,14 +115,14 @@ BuildGetAuthTokenMsg(
|
||||
+ 2 // </
|
||||
+ strlen(SERVICE_ELEMENT_NAME)
|
||||
+ 3 // >crlf
|
||||
+ 2 // </
|
||||
+ 1 // <
|
||||
+ strlen(HOST_ELEMENT_NAME)
|
||||
+ 1 // >
|
||||
+ strlen(pHostName)
|
||||
+ 2 // </
|
||||
+ strlen(HOST_ELEMENT_NAME)
|
||||
+ 3 // >crlf
|
||||
+ 2 // </
|
||||
+ 1 // <
|
||||
+ strlen(SESSION_TOKEN_ELEMENT_NAME)
|
||||
+ 1 // >
|
||||
+ strlen(pSessionToken)
|
||||
@@ -196,7 +196,7 @@ GetAuthTokenRespStartElementHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-GetAuthTokenRespStartElementHandler- Start\n", 0);
|
||||
@@ -290,6 +290,95 @@ GetAuthTokenRespStartElementHandler(
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
static
|
||||
CasaStatus
|
||||
ConsumeElementData(
|
||||
IN GetAuthTokenRespParse *pGetAuthTokenRespParse,
|
||||
IN const XML_Char *s,
|
||||
IN int len,
|
||||
INOUT char **ppElementData,
|
||||
INOUT int *pElementDataLen)
|
||||
//
|
||||
// Arguments:
|
||||
//
|
||||
// Returns:
|
||||
//
|
||||
// Abstract:
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
CasaStatus retStatus = CASA_STATUS_SUCCESS;
|
||||
|
||||
DbgTrace(3, "-ConsumeElementData- Start\n", 0);
|
||||
|
||||
// Proceed based on whether or not we have already consumed data
|
||||
// for this element.
|
||||
if (*ppElementData == NULL)
|
||||
{
|
||||
// We have not yet consumed data for this element
|
||||
pGetAuthTokenRespParse->elementDataProcessed = len;
|
||||
|
||||
// Allocate a buffer to hold this element data (null terminated).
|
||||
*ppElementData = (char*) malloc(len + 1);
|
||||
if (*ppElementData)
|
||||
{
|
||||
memset(*ppElementData, 0, len + 1);
|
||||
memcpy(*ppElementData, s, len);
|
||||
|
||||
// Return the length of the element data buffer
|
||||
*pElementDataLen = pGetAuthTokenRespParse->elementDataProcessed + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-ConsumeElementData- Buffer allocation failure\n", 0);
|
||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pNewBuf;
|
||||
|
||||
// We have already received token data, append this data to it.
|
||||
pNewBuf = (char*) malloc(pGetAuthTokenRespParse->elementDataProcessed + len + 1);
|
||||
if (pNewBuf)
|
||||
{
|
||||
memset(pNewBuf,
|
||||
0,
|
||||
pGetAuthTokenRespParse->elementDataProcessed + len + 1);
|
||||
memcpy(pNewBuf,
|
||||
*ppElementData,
|
||||
pGetAuthTokenRespParse->elementDataProcessed);
|
||||
memcpy(pNewBuf + pGetAuthTokenRespParse->elementDataProcessed, s, len);
|
||||
pGetAuthTokenRespParse->elementDataProcessed += len;
|
||||
|
||||
// Swap the buffers
|
||||
free(*ppElementData);
|
||||
*ppElementData = pNewBuf;
|
||||
|
||||
// Return the length of the element data buffer
|
||||
*pElementDataLen = pGetAuthTokenRespParse->elementDataProcessed + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-ConsumeElementData- Buffer allocation failure\n", 0);
|
||||
retStatus = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
}
|
||||
|
||||
DbgTrace(3, "-ConsumeElementData- End, retStatus = %08X\n", retStatus);
|
||||
|
||||
return retStatus;
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
static
|
||||
void XMLCALL
|
||||
@@ -306,7 +395,7 @@ GetAuthTokenRespCharDataHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-GetAuthTokenRespCharDataHandler- Start\n", 0);
|
||||
@@ -322,8 +411,10 @@ GetAuthTokenRespCharDataHandler(
|
||||
switch (pGetAuthTokenRespParse->state)
|
||||
{
|
||||
case AWAITING_DESCRIPTION_DATA:
|
||||
case AWAITING_DESCRIPTION_ELEMENT_END:
|
||||
|
||||
// Ignore the status description data for now.
|
||||
// tbd
|
||||
|
||||
// Advanced to the next state
|
||||
pGetAuthTokenRespParse->state = AWAITING_DESCRIPTION_ELEMENT_END;
|
||||
@@ -373,58 +464,20 @@ GetAuthTokenRespCharDataHandler(
|
||||
case AWAITING_AUTH_TOKEN_DATA:
|
||||
case AWAITING_AUTH_TOKEN_ELEMENT_END:
|
||||
|
||||
// Check if we have already processed token data
|
||||
if (pGetAuthTokenRespParse->tokenDataProcessed == 0)
|
||||
// Consume the data
|
||||
pGetAuthTokenRespParse->status = ConsumeElementData(pGetAuthTokenRespParse,
|
||||
s,
|
||||
len,
|
||||
&pGetAuthTokenRespParse->pGetAuthTokenResp->pToken,
|
||||
&pGetAuthTokenRespParse->pGetAuthTokenResp->tokenLen);
|
||||
if (CASA_SUCCESS(pGetAuthTokenRespParse->status))
|
||||
{
|
||||
// Keep a copy of the authentication token (null terminated)
|
||||
pGetAuthTokenRespParse->pGetAuthTokenResp->pToken = (char*) malloc(len + 1);
|
||||
if (pGetAuthTokenRespParse->pGetAuthTokenResp->pToken)
|
||||
{
|
||||
memset(pGetAuthTokenRespParse->pGetAuthTokenResp->pToken, 0, len + 1);
|
||||
memcpy(pGetAuthTokenRespParse->pGetAuthTokenResp->pToken, s, len);
|
||||
pGetAuthTokenRespParse->tokenDataProcessed = len;
|
||||
|
||||
// Advanced to the next state
|
||||
pGetAuthTokenRespParse->state = AWAITING_AUTH_TOKEN_ELEMENT_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-GetAuthTokenRespCharDataHandler- Buffer allocation failure\n", 0);
|
||||
pGetAuthTokenRespParse->status = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
XML_StopParser(pGetAuthTokenRespParse->p, XML_FALSE);
|
||||
}
|
||||
// Advanced to the next state
|
||||
pGetAuthTokenRespParse->state = AWAITING_AUTH_TOKEN_ELEMENT_END;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *pNewBuf;
|
||||
|
||||
// We have already received token data, append this data to it.
|
||||
pNewBuf = (char*) malloc(pGetAuthTokenRespParse->tokenDataProcessed + len + 1);
|
||||
if (pNewBuf)
|
||||
{
|
||||
memset(pNewBuf,
|
||||
0,
|
||||
pGetAuthTokenRespParse->tokenDataProcessed + len + 1);
|
||||
memcpy(pNewBuf,
|
||||
pGetAuthTokenRespParse->pGetAuthTokenResp->pToken,
|
||||
pGetAuthTokenRespParse->tokenDataProcessed);
|
||||
memcpy(pNewBuf + pGetAuthTokenRespParse->tokenDataProcessed, s, len);
|
||||
pGetAuthTokenRespParse->tokenDataProcessed += len;
|
||||
|
||||
// Swap the buffers
|
||||
free(pGetAuthTokenRespParse->pGetAuthTokenResp->pToken);
|
||||
pGetAuthTokenRespParse->pGetAuthTokenResp->pToken = pNewBuf;
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgTrace(0, "-GetAuthTokenRespCharDataHandler- Buffer allocation failure\n", 0);
|
||||
pGetAuthTokenRespParse->status = CasaStatusBuild(CASA_SEVERITY_ERROR,
|
||||
CASA_FACILITY_AUTHTOKEN,
|
||||
CASA_STATUS_INSUFFICIENT_RESOURCES);
|
||||
XML_StopParser(pGetAuthTokenRespParse->p, XML_FALSE);
|
||||
}
|
||||
XML_StopParser(pGetAuthTokenRespParse->p, XML_FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -455,7 +508,7 @@ GetAuthTokenRespEndElementHandler(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(2, "-GetAuthTokenRespEndElementHandler- Start\n", 0);
|
||||
@@ -572,7 +625,7 @@ CreateGetAuthTokenResp(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
CasaStatus retStatus = CASA_STATUS_SUCCESS;
|
||||
@@ -592,7 +645,7 @@ CreateGetAuthTokenResp(
|
||||
* </get_auth_token_resp>
|
||||
*
|
||||
* When a get authentication token request fails to be successfully processed,
|
||||
* the server responds with an error and a error description string. The message
|
||||
* the server responds with an error and an error description string. The message
|
||||
* format of an unsuccessful reply is as follows:
|
||||
*
|
||||
* <?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
@@ -720,7 +773,7 @@ RelGetAuthTokenResp(
|
||||
//
|
||||
// Notes:
|
||||
//
|
||||
// L0
|
||||
// L2
|
||||
//=======================================================================--
|
||||
{
|
||||
DbgTrace(1, "-RelGetAuthTokenResp- Start\n", 0);
|
||||
@@ -734,3 +787,8 @@ RelGetAuthTokenResp(
|
||||
DbgTrace(1, "-RelGetAuthTokenResp- End\n", 0);
|
||||
}
|
||||
|
||||
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
//++=======================================================================
|
||||
|
||||
|
||||
Reference in New Issue
Block a user