📄 cms_wsp.c
字号:
return;
}
static void null_scr_1_cnting(WSPMachine *machine,WSPEvent *event,Octstr *tmpcapcode)
{
WTPEvent * wtp_new_event;
CMS_S32 capslength = 0;
CMS_S32 headerslength = 0;
/* create wtp TRInovkeRequire */
wtp_new_event = wtp_event_create( TRInvokeRequire );
wtp_new_event->TRInvokeRequire.ack_type = 0x00; /*--Shawn 2002-12-31--- for mms*/
wtp_new_event->TRInvokeRequire.tcl = 0x02;
wtp_new_event->user_data = octstr_create_empty();
append_uint8(wtp_new_event->user_data, 1L); /* connect pdu*/
append_uint8(wtp_new_event->user_data, 16L);/* version max 1 ,min 0*/
octstr_append_data((Octstr *)wtp_new_event->user_data,(P_CMS_U8)tmpcapcode->data,(CMS_U32)tmpcapcode->len);
wtp_handle_event( WTPGlobalMachine, wtp_new_event);
}
static void null_scr_2_cnting(WSPMachine *machine,WSPEvent *event)
{
Octstr *cap_head = NULL;
Octstr *cap = NULL;
Octstr *head = NULL;
cap = event->SConnectRequest.capability;
head = event->SConnectRequest.head;
append_uintvar(cap_head, octstr_len(cap));
octstr_append_data(cap_head,cap->data,cap->len);
append_uintvar(cap_head, octstr_len(head));
octstr_append_data(cap_head,head->data,head->len);
null_scr_1_cnting(machine,event,cap_head);
octstr_destroy(cap_head);
return;
}
static void cnting_discnt_1_null(WSPMachine *machine,WSPEvent *event)
{
WTPEvent *wtp_event= NULL;
wtp_event = wtp_event_create( TRAbort );
wtp_event->TRAbort.tid = WTPGlobalMachine->tid;
wtp_event->TRAbort.abort_type = USER ;/*wsp abort not wtp abort*/
wtp_event->TRAbort.abort_reason = USERREQ ;
wtp_handle_event(WTPGlobalMachine,wtp_event);
}
static void cnting_trri_cr_cnted(WSPMachine *sm,WSPEvent *current_event)
{
WTPEvent * wtp_new_event = NULL;
WSPEvent * wsp_new_event = NULL;
//cms_debug("WSP STATUS:%sWSP_CONNECTING-->ConnectReply_PDU-->WSP_CONNECTED\n","");
//CmsDebugFunc((unsigned char*)"8880003",(short)0,(void*)NULL);
wtp_new_event = wtp_event_create( TRResultResponse );
wtp_new_event->TRResultResponse.tid = WTPGlobalMachine->tid;
wtp_handle_event( WTPGlobalMachine, wtp_new_event );
//CmsDebugFunc((unsigned char*)"8880040",(short)0,(void*)NULL);
wsp_new_event = wsp_event_create( SConnectConfirmation );
/* send the SConnectConfirmation to MMS */
Browser_Handle_Event(wsp_new_event);
}
static void cnting_trri_rd_null(WSPMachine *sm,WSPEvent *current_event)
{
WTPEvent *wtp_event= NULL;
////cms_trace("redirect");
////cms_trace("redirect");
////cms_trace("redirect");
wtp_event = wtp_event_create( TRAbort );
wtp_event->TRAbort.tid = WTPGlobalMachine->tid;
wtp_event->TRAbort.abort_type = USER ;/*wsp abort not wtp abort*/
wtp_event->TRAbort.abort_reason = CONNECTERR ; //2003.10.30
wtp_handle_event(WTPGlobalMachine,wtp_event);
//2003.10.30
Cms_ReConnectGateway(current_event->TRResultIndication.user_data->data+2);//e->user_data->data+2
}
static void cnting_trai_1_null(WSPMachine *sm,WSPEvent *current_event)
{
WSPEvent * wsp_new_event;
////cms_debug("WSP_SESSION_CONNECTING--TRAbortInd--1--WSP_SESSION_NULL\n%s","");
////CmsDebugFunc((unsigned char*)"8880004",(short)0,(void*)NULL);
wsp_new_event = wsp_event_create( SDisconnectIndication );
if(wsp_new_event)
{
if(current_event->TRAbortIndication.abort_code == WSP_ABORT_USERREQ)
wsp_new_event->SDisconnectIndication.discon_reason = WSP_ABORT_USERREQ;
else
wsp_new_event->SDisconnectIndication.discon_reason = WSP_ABORT_PROERR;
}
Browser_Handle_Event(wsp_new_event);
}
static void cnted_smir_1_waing(WSPMachine *sm,WSPEvent *current_event)
{
/*=== LHY_050217 ===*/
P_CMS_U8 pContentType = NULL;
/*=== end of LHY_050217 ===*/
WTPEvent * wtp_new_event = NULL;
char tmppostheadercode[]={'a','p','p','l','i','c','a','t','i','o','n','/','v','n','d','.','w','a','p','.','m','m','s','-','m','e','s','s','a','g','e','\0'};
char padding[]={(char)0x80,(char)0x61,(char)0x70, (char)0x70, (char)0x6C, (char)0x69, (char)0x63, (char)0x61,
(char)0x74, (char)0x69, (char)0x6F, (char)0x6E, (char)0x2F, (char)0x76 ,(char)0x6E ,(char)0x64 ,
(char)0x2E ,(char)0x77 ,(char)0x61 ,(char)0x70 ,(char)0x2E,(char)0x6D ,(char)0x6D ,(char)0x73 ,(char)0x2D ,
(char)0x6D ,(char)0x65 ,(char)0x73 ,(char)0x73 ,(char)0x61 ,(char)0x67 ,(char)0x65 ,(char)0x00 ,(char)0x88 ,
(char)0x80};
//char gethead[] = {(char)0x80,'a','p','p','l','i','c','a','t','i','o','n','/','v','n','d','.','w','a','p','.','m','m','s','-','m','e','s','s','a','g','e','\0',(char)0x88,(char)0x80};
////cms_debug("WSP STATUS:WSP_CONNECTE->METHODINVOKE-->WSP-WAITING%s\n","");
////CmsDebugFunc((unsigned char*)"8880005",(short)0,(void*)NULL);
wtp_new_event = wtp_event_create( TRInvokeRequire );
wtp_new_event->TRInvokeRequire.ack_type = 0x01;//need user ack
wtp_new_event->TRInvokeRequire.tcl = 0x02;
wtp_new_event->user_data = octstr_create_empty();
/* get pdu revised by shawn 2004.2.17*/
if(current_event->SMethodInvokeRequest.method_type >=0x40 && current_event->SMethodInvokeRequest.method_type < 0x60)
{
////CmsDebugFunc((unsigned char*)"8880051",(short)0,(void*)NULL);
append_uint8(wtp_new_event->user_data, (CMS_S64)current_event->SMethodInvokeRequest.method_type);
append_uintvar(wtp_new_event->user_data, octstr_len(current_event->SMethodInvokeRequest.url)); /*1 is '\0'*/
octstr_append_cstr(wtp_new_event->user_data, octstr_get_cstr(current_event->SMethodInvokeRequest.url));
//octstr_append_data(wtp_new_event->user_data,(P_CMS_U8)"\0",(CMS_U32)1);
//octstr_append_data(wtp_new_event->user_data,(P_CMS_U8)gethead,(CMS_U32)sizeof(gethead));
}
/*post pdu */
if(current_event->SMethodInvokeRequest.method_type >= 0x60 && current_event->SMethodInvokeRequest.method_type <= 0x80)
{
/*=== LHY_050217 ===*/
if(NULL != current_event->SMethodInvokeRequest.content_type) /* 浏览器 */
{
pContentType = current_event->SMethodInvokeRequest.content_type->data;
append_uint8(wtp_new_event->user_data, (CMS_S64)current_event->SMethodInvokeRequest.method_type);
append_uintvar(wtp_new_event->user_data, octstr_len(current_event->SMethodInvokeRequest.url));
if(NULL!=pContentType && pContentType[0]>=0x80)
{
//append_uintvar(wtp_new_event->user_data, (CMS_S64)(current_event->SMethodInvokeRequest.content_type->len)+2);
/* mod by teng yong */
append_uintvar(wtp_new_event->user_data, (CMS_S64)(current_event->SMethodInvokeRequest.content_type->len));
}
else
{
append_uintvar(wtp_new_event->user_data, (CMS_S64)(current_event->SMethodInvokeRequest.content_type->size)+2);
}
octstr_append_cstr(wtp_new_event->user_data, octstr_get_cstr(current_event->SMethodInvokeRequest.url));
octstr_append_data((Octstr *)wtp_new_event->user_data, (P_CMS_U8)current_event->SMethodInvokeRequest.content_type->data,(CMS_U32)current_event->SMethodInvokeRequest.content_type->len);
if(NULL!=pContentType && 0x92!=pContentType[0])
{
if(pContentType[0] < 0x80)
{
octstr_append_char(wtp_new_event->user_data, 0x00);
}
/*=== Cache-Control:No-cache ===*/
octstr_append_char(wtp_new_event->user_data,0x88);
octstr_append_char(wtp_new_event->user_data,0X80);
}
}
/*=== end of LHY_050217 ===*/
else /* 彩信 */
{
////CmsDebugFunc((unsigned char*)"8880050",(short)0,(void*)NULL);
append_uint8(wtp_new_event->user_data, (CMS_S64)current_event->SMethodInvokeRequest.method_type);
append_uintvar(wtp_new_event->user_data, octstr_len(current_event->SMethodInvokeRequest.url));
append_uintvar(wtp_new_event->user_data, (CMS_S64)(sizeof(tmppostheadercode)+sizeof(padding)));
octstr_append_cstr(wtp_new_event->user_data, octstr_get_cstr(current_event->SMethodInvokeRequest.url));
octstr_append_data((Octstr *)wtp_new_event->user_data, (P_CMS_U8)tmppostheadercode,(CMS_U32)sizeof(tmppostheadercode));
octstr_append_data((Octstr *)wtp_new_event->user_data, (P_CMS_U8)padding,(CMS_U32)sizeof(padding));
}
//2003.9.2
if((wtp_new_event->user_data->len+current_event->SMethodInvokeRequest.data->len) <= WTP_PACKET_SIZE)
{
////CmsDebugFunc((unsigned char*)"8880052",(short)0,(void*)NULL);
octstr_append_data((Octstr *)wtp_new_event->user_data, (P_CMS_U8)octstr_get_cstr((Octstr *)current_event->SMethodInvokeRequest.data), (CMS_U32)current_event->SMethodInvokeRequest.data->len);
current_event->SMethodInvokeRequest.data->data = NULL;
current_event->SMethodInvokeRequest.data->len = 0;
}
else
{
////CmsDebugFunc((unsigned char*)"8880053",(short)0,(void*)NULL);
wtp_new_event->big_data = octstr_create_empty();
wtp_new_event->big_data->data = current_event->SMethodInvokeRequest.data->data;
wtp_new_event->big_data->len = current_event->SMethodInvokeRequest.data->len;
current_event->SMethodInvokeRequest.data->data = NULL;
current_event->SMethodInvokeRequest.data->len = 0;
}
}
wtp_handle_event( WTPGlobalMachine, wtp_new_event );
////CmsDebugFunc((unsigned char*)"8880054",(short)0,(void*)NULL);
}
static void waing_trai_1_null(WSPMachine *sm,WSPEvent *current_event)
{
WSPEvent * wsp_new_event = NULL;
////cms_debug("WSP STATUS:WSP_WAITING-->TRAbortIndication-->WSP_CONNECTED\n\n","");
////CmsDebugFunc((unsigned char*)"8880006",(short)0,(void*)NULL);
wsp_new_event = wsp_event_create( SMethodInvokeAbort );
if(wsp_new_event)
{
if(current_event->TRAbortIndication.abort_code == WSP_ABORT_USERREQ)
wsp_new_event->SMethodInvokeAbort.abort_code = WSP_ABORT_USERREQ;
else
wsp_new_event->SMethodInvokeAbort.abort_code = WSP_ABORT_PROERR;
}
Browser_Handle_Event(wsp_new_event);
}
static void waing_disn_1_null(WSPMachine *sm,WSPEvent *current_event)
{
WTPEvent *wtp_event= NULL;
wtp_event = wtp_event_create( TRAbort );
wtp_event->TRAbort.tid = WTPGlobalMachine->tid;
wtp_event->TRAbort.abort_type = USER ;/*wsp abort not wtp abort*/
wtp_event->TRAbort.abort_reason = USERREQ ;
wtp_handle_event(WTPGlobalMachine,wtp_event);
}
static void waing_trri_totaldata_cmpng(WSPMachine *sm,WSPEvent *current_event)
{
WSPEvent * wsp_new_event = NULL;
WSPEvent * wsp_event = NULL;
int ret = 0;
wsp_new_event = wsp_event_create( SMethodResultIndication );
ret = unpack_reply_pdu(current_event->TRResultIndication.user_data,
(P_CMS_S64)&wsp_new_event->SMethodResultIndication.status,
&wsp_new_event->SMethodResultIndication.content_type, NULL,
&wsp_new_event->SMethodResultIndication.content_data);
wsp_event = wsp_event_create( SMethodResultResponse ); //2003.6.30
wsp_handle_event(WSPGlobalMachine, wsp_event);
/* send wsp event to browser */
Browser_Handle_Event(wsp_new_event);
}
static void cmpng_smrr_1_cnded(WSPMachine *sm,WSPEvent *current_event)
{
WTPEvent * wtp_new_event;
//WSPEvent * wsp_new_event;
////cms_trace("access cmpng_smrr_1_cnded:COMPLETEING-->SMRR-->CONNECTED: in\n");
wtp_new_event = wtp_event_create( TRResultResponse );
wtp_new_event->TRResultResponse.tid = WTPGlobalMachine->tid;
wtp_handle_event( WTPGlobalMachine, wtp_new_event );
////cms_trace("access cmpng_smrr_1_cnded:COMPLETEING-->SMRR-->CONNECTED: out\n");
}
/*************************************************************************
* 描 述: 断开wsp
* 返回值: void
* 全局量:
* 日 期: 2004-12-10
* 作 者: 滕永; yongt@mobilesoft.com.cn
************************************************************************/
void CmsWspDisconnect( void )
{
WSPEvent *wsp_event = NULL;
wsp_event = wsp_event_create(Disconnect);
if(wsp_event)
wsp_handle_event(WSPGlobalMachine,wsp_event);
return;
}
/*************************************************************************
* 描 述: 判断wsp是否联接
* 返回值: 1: 联接 0:没有联接
* 全局量:
* 日 期: 2004-12-11
* 作 者: 滕永; yongt@mobilesoft.com.cn
************************************************************************/
int CmsIsWspConnected( void )
{
if( WSPGlobalMachine && WSPGlobalMachine->state == WSP_CONNECTED )
{
return 1;
}
else
{
return 0;
}
}
/*************************************************************************
* 描 述: 发生拨号链路断掉,强制转换WSP状态机为空状态
从而保证WSP重新连接
* 返回值:
* 全局量:
* 日 期: 2005-5-24
* 作 者: lee; shoumingl@mobilesoft.com.cn
************************************************************************/
void setWSPmachineNull(void)
{
if( NULL != WSPGlobalMachine )
{
////cms_trace("hahahhaha by lee by lee\r\n");
WSPGlobalMachine->state = WSP_NULL;
}
}
/*************************************************************************
* 描 述: 判断wsp状态机是否为null状态
* 返回值: int
* 全局量:
* 日 期: 2005-10-25
* 作 者: 陈飞feich@mobilesoft.com.cn
************************************************************************/
int CmsIsWspNullState( void )
{
if ( (NULL != WSPGlobalMachine) && (WSP_NULL == WSPGlobalMachine->state) )
{
return 1;
}
return 0;
}
/*************************************************************************
* 描 述: 判断wsp状态机是否为wait状态
* 返回值: int
* 全局量:
* 日 期: 2005-10-25
* 作 者: 陈飞feich@mobilesoft.com.cn
************************************************************************/
int CmsIsWspWaittingState( void )
{
if ( (NULL != WSPGlobalMachine) && (WSP_WAITING == WSPGlobalMachine->state) )
{
return 1;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -