📄 mcwap.c
字号:
void mmsWapConnectionCheck(void)
{
if (myFsm.connections == 0 && myFsm.state == WAP_STARTED &&
cfgGetInt(MMS_CFG_DISCONNECT_ON_IDLE) == TRUE)
{
MMS_LOG_I(("MMS COH WAP: Disconnect in %d deciseconds\n",
MMS_DISCONNECT_ON_IDLE_TIMEOUT));
M_TIMER_SET_I( M_FSM_COH_WAP, MMS_DISCONNECT_ON_IDLE_TIMEOUT, TIMER_IDLE);
}
}
void mmsWapFreeContentParams(MmsHttpContent *cont)
{
if (cont != NULL)
{
if (cont->data != NULL)
{
M_FREE(cont->data);
}
M_FREE(cont);
}
}
void mmsWapFreeRequestId(MmsRequestId id)
{
if (id >= MMS_REQUEST_ID_MIN && id <= MMS_REQUEST_ID_MAX)
{
myFsm.requestId[id - MMS_REQUEST_ID_MIN] = FALSE;
}
else
{
MMS_LOG_I(("Wrong request ID (%d)\n", (unsigned int)id));
}
}
MmsRequestId mmsWapGetRequestId(void)
{
int i;
static int nextToUse = 0;
for (i = nextToUse; i < MMS_REQUEST_ID_NUMBER; ++i)
{
if ( !myFsm.requestId[i] )
{
nextToUse = i + 1;
return MMS_REQUEST_ID_MIN + i;
}
}
for (i = 0; i < nextToUse; ++i)
{
if ( !myFsm.requestId[i] )
{
nextToUse = i + 1;
return MMS_REQUEST_ID_MIN + i;
}
}
MMS_LOG_I(("No available request IDs (%d)\n", i));
return -1;
}
UINT32 mmsWapGetUniqueId(void)
{
return myFsm.uniqueId++;
}
void cohWapInit(void)
{
int i;
memset( &myFsm, 0, sizeof(myFsm));
for (i = 0; i < MMS_REQUEST_ID_NUMBER; ++i)
{
myFsm.requestId[i] = (char)FALSE;
}
myFsm.uniqueId = CMNa_currentTime();
myFsm.queueLen = 0;
myFsm.state = WAP_STOPPED;
myFsm.connections = 0;
mSignalRegisterDst(M_FSM_COH_WAP, cohWapMain);
MMS_LOG_I(("MMS FSM COH WAP: initialized\n"));
}
MmsRequestId mmsWapRenewRequestId(MmsRequestId theOld)
{
MmsRequestId theNew = -1L;
theNew = mmsWapGetRequestId();
if (theNew != -1)
{
mmsWapFreeRequestId(theOld);
return theNew;
}
else
{
return theOld;
}
}
void cohWapTerminate(void)
{
int i;
for (i = 0; i < MMS_REQUEST_ID_NUMBER; ++i)
{
myFsm.requestId[i] = FALSE;
}
if (myFsm.connections > 0)
{
MMS_LOG_I(("%s(%d): ===> %d connections active when terminating\n",
__FILE__, __LINE__, myFsm.connections));
myFsm.state = WAP_STOPPING;
MMSa_httpSessionStop();
}
myFsm.connections = 0;
mSignalDeregister(M_FSM_COH_WAP);
MMS_LOG_I(("MMS FSM COH WAP: terminated\n"));
}
MmsResult translateResponseStatus(MmsResponseStatus status)
{
MmsResult res = MMS_RESULT_OK;
switch (status)
{
case MMS_RSP_STATUS_OK :
res = MMS_RESULT_OK;
break;
case MMS_RSP_STATUS_10_MSG_NOT_FOUND :
case MMS_RSP_STATUS_T_MESSAGE_NOT_FOUND :
case MMS_RSP_STATUS_P_MESSAGE_NOT_FOUND :
res = MMS_RESULT_COMM_FILE_NOT_FOUND;
break;
case MMS_RSP_STATUS_10_SERVICE_DENIED :
case MMS_RSP_STATUS_P_SERVICE_DENIED :
case MMS_RSP_STATUS_P_REPLY_CHARG_FORWARDING_DENIED :
case MMS_RSP_STATUS_P_REPLY_CHARG_REQUEST_NOT_ACCEPTED :
res = MMS_RESULT_COMM_FORBIDDEN;
break;
case MMS_RSP_STATUS_10_UNSPECIFIED :
case MMS_RSP_STATUS_10_NETWORK_PROBLEM :
case MMS_RSP_STATUS_T_FAILURE :
case MMS_RSP_STATUS_T_NETWORK_PROBLEM :
case MMS_RSP_STATUS_P_FAILURE :
res = MMS_RESULT_COMM_FAILED;
break;
case MMS_RSP_STATUS_10_CONTENT_NOT_ACCEPTED :
case MMS_RSP_STATUS_P_CONTENT_NOT_ACCEPTED :
res = MMS_RESULT_COMM_UNSUPPORTED_MEDIA_TYPE;
break;
case MMS_RSP_STATUS_10_MSG_FORMAT_CORRUPT :
case MMS_RSP_STATUS_P_MESSAGE_FORMAT_CORRUPT :
res = MMS_RESULT_COMM_ILLEGAL_PDU;
break;
case MMS_RSP_STATUS_UNSUPPORTED_MSG :
res = MMS_RESULT_COMM_PROXY_VERSION;
break;
case MMS_RSP_STATUS_10_ADDRESS_UNRESOLVED :
case MMS_RSP_STATUS_T_SENDING_ADDRESS_UNRESOLVED :
case MMS_RSP_STATUS_P_SENDING_ADDRESS_UNRESOLVED :
res = MMS_RESULT_COMM_ADDRESS_UNRESOLVED;
break;
case MMS_RSP_STATUS_P_REPLY_CHARG_NOT_SUPPORTED :
res = MMS_RESULT_COMM_UNAVAILABLE;
break;
case MMS_RSP_STATUS_P_REPLY_CHARG_LIMITATIONS_NOT_MET :
res = MMS_RESULT_COMM_LIMITATIONS_NOT_MET;
break;
default :
if (status >= MMS_RSP_STATUS_P_FAILURE)
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.1 Permanent Response Status (%d)\n",
__FILE__, __LINE__, status));
}
else if (status >= MMS_RSP_STATUS_T_FAILURE)
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.1 Transient Response Status (%d)\n",
__FILE__, __LINE__, status));
}
else
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.0 Response Status (%d)\n",
__FILE__, __LINE__, status));
}
res = MMS_RESULT_COMM_FAILED;
break;
}
return res;
}
MmsResult translateRetrieveStatus(MmsRetrieveStatus status)
{
MmsResult res = MMS_RESULT_OK;
switch (status)
{
case MMS_RTRV_STATUS_OK :
res = MMS_RESULT_OK;
break;
case MMS_RTRV_STATUS_T_MESSAGE_NOT_FOUND :
case MMS_RTRV_STATUS_P_MESSAGE_NOT_FOUND :
res = MMS_RESULT_COMM_FILE_NOT_FOUND;
break;
case MMS_RTRV_STATUS_P_SERVICE_DENIED :
res = MMS_RESULT_COMM_FORBIDDEN;
break;
case MMS_RTRV_STATUS_T_FAILURE :
case MMS_RTRV_STATUS_T_NETWORK_PROBLEM :
case MMS_RTRV_STATUS_P_FAILURE :
res = MMS_RESULT_COMM_FAILED;
break;
case MMS_RTRV_STATUS_P_CONTENT_UNSUPPORTED :
res = MMS_RESULT_COMM_UNSUPPORTED_MEDIA_TYPE;
break;
default :
if (status >= MMS_RTRV_STATUS_P_FAILURE)
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.1 Permanent Retrieve Status (%d)\n",
__FILE__, __LINE__, status));
}
else if (status >= MMS_RTRV_STATUS_T_FAILURE)
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.1 Transient Retrieve Status (%d)\n",
__FILE__, __LINE__, status));
}
else
{
MMS_LOG_I(("%s(%d): Unlisted MMS 1.0 Retrieve Status (%d)\n",
__FILE__, __LINE__, status));
}
res = MMS_RESULT_COMM_FAILED;
break;
}
return res;
}
#ifdef MMS_LOG_PROTOCOL
#define MMS_WAP_LOG_DELIMITER 0xffffffff
void mmsWapLog(CMN_BOOL isIncoming, int len, char *pdu)
{
static UINT32 fileId = 0;
static INT32 fileLen;
int i;
char *p;
UINT32 data[2];
UINT32 anUint32;
if (fileId == 0)
{
if ( FILEa_create( MMS_FILE_CATEGORY_LOGGING, NULL, &fileId) < 0)
{
MMS_LOG_I(("%s(%d): unable to create protocol log file",
__FILE__, __LINE__));
fileId = 0;
}
fileLen = 0;
}
else if (FILEa_open( MMS_FILE_CATEGORY_LOGGING, fileId, FILE_OPTION_WRITE) == -1)
{
MMS_LOG_I(("%s(%d): unable to open protocol log file %d",
__FILE__, __LINE__, fileId));
return;
}
if (fileId > 0)
{
data[0] = MMS_WAP_LOG_DELIMITER;
data[1] = (UINT32)isIncoming;
if ( (UINT32)FILEa_write( MMS_FILE_CATEGORY_LOGGING, fileId, data, fileLen,
sizeof(data)) != sizeof(data))
{
MMS_LOG_I(("%s(%d): unable to log header %d",
__FILE__, __LINE__, fileId));
}
else
{
fileLen += (INT32)sizeof(data);
p = pdu;
for (i = 0; i <= len - (int)sizeof(UINT32); ++i)
{
memcpy( &anUint32, p, sizeof(anUint32));
if ( anUint32 == MMS_WAP_LOG_DELIMITER)
{
len = i;
break;
}
++p;
}
if (len == 0)
{
MMS_LOG_I(("%s(%d): pdu contains log delimiter at first pos. Logging aborted.",
__FILE__, __LINE__, len));
}
else if ( FILEa_write( MMS_FILE_CATEGORY_LOGGING, fileId, pdu, fileLen,
len) != len)
{
MMS_LOG_I(("%s(%d): unable to log pdu %d",
__FILE__, __LINE__, len));
}
else
{
fileLen += len;
}
}
FILEa_close( MMS_FILE_CATEGORY_LOGGING, fileId);
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -