📄 wap_udpp.c
字号:
+------------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPP |
| STATE : code ROUTINE : sig_dti_udp_connection_opened_ind |
+------------------------------------------------------------------------+
PURPOSE : Process reason parameter REASON_CONNECTION_OPENED
received by dtilib callback function
*/
GLOBAL const void sig_dti_udp_connection_opened_ind()
{
TRACE_FUNCTION("sig_dti_udp_connection_opened_ind()");
if (wap_data->dti_state EQ DTI_SETUP)
{
/*
* set OPEN and send acknowledgement
*/
wap_data->dti_state = DTI_IDLE;
{
PALLOC (wap_dti_cnf, WAP_DTI_CNF);
wap_dti_cnf->dti_conn = WAP_CONNECT_DTI;
PSENDX (ACI, wap_dti_cnf)
}
}
}
/*
+-------------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPP |
| STATE : code ROUTINE : sig_dti_udp_connection_closed_ind |
+-------------------------------------------------------------------------+
PURPOSE : Process reason parameter REASON_CONNECTION_CLOSED
received by dtilib callback function
*/
GLOBAL const void sig_dti_udp_connection_closed_ind()
{
TRACE_FUNCTION("sig_dti_udp_connection_closed_ind()");
/*
* set CLOSED and send indication
*/
wap_data->dti_state = DTI_CLOSED;
{
PALLOC (wap_dti_ind, WAP_DTI_IND);
wap_dti_ind->dti_conn = WAP_DISCONNECT_DTI;
PSENDX (ACI, wap_dti_ind)
}
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPP |
| STATE : code ROUTINE : sig_dti_udp_tx_buffer_full_ind |
+--------------------------------------------------------------------+
PURPOSE : Process reason parameter REASON_TX_BUFFER_FULL
received by dtilib callback function
*/
GLOBAL const void sig_dti_udp_tx_buffer_full_ind()
{
TRACE_FUNCTION("sig_dti_udp_tx_buffer_full_ind()");
wap_data->flow = FALSE;
}
/*
+----------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPP |
| STATE : code ROUTINE : sig_dti_udp_tx_buffer_ready_ind |
+----------------------------------------------------------------------+
PURPOSE : Process reason parameter REASON_TX_BUFFER_READY
received by dtilib callback function
this function replaces former udp_dti_ready_ind
*/
GLOBAL const void sig_dti_udp_tx_buffer_ready_ind()
{
TRACE_FUNCTION("sig_dti_udp_tx_buffer_ready_ind()");
wap_data->flow = TRUE;
if (wap_data->connection_done && wap_data->last_bind_req != -1)
{
wap_data->connection_done = FALSE;
wap_lib_bind_callback(wap_data->ports[wap_data->last_bind_req].id,
wap_data->ports[wap_data->last_bind_req].channel,
wap_data->ports[wap_data->last_bind_req].port,
UDP_BIND_NOERROR);
wap_data->last_bind_req=-1;
}
wap_data->aus_runnable = TRUE;
wap_lib_run_aus_callback();
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPP |
| STATE : code ROUTINE : sig_dti_udp_data_received_ind |
+--------------------------------------------------------------------+
PURPOSE : Process reason parameter REASON_DATA_RECEIVED
received by dtilib callback function
this function replaces former udp_dti_data_ind
*/
GLOBAL const void sig_dti_udp_data_received_ind
(
T_DTI2_DATA_IND *dti_data_ind
)
{
T_desc2 *desc, *tmp;
T_SRC_DES *pSrcDes;
char src_ip[16];
char des_ip[16];
USHORT src_len =4;
USHORT des_len=4;
USHORT src_port;
USHORT des_port;
char* data;
USHORT data_len, i=0;
TRACE_FUNCTION("sig_dti_udp_data_received_ind()");
PACCESS (dti_data_ind);
/*
* prevent dtilib from automatically sending flow control primitives
*
dti_stop
(
wap_hDTI,
WAP_DTI_DN_DEF_INSTANCE,
WAP_DTI_DN_INTERFACE,
WAP_DTI_DN_CHANNEL
);
*
* not necessary here, because we want to send a getdata request
* anyway, when done with this function ..
*/
#ifdef _SIMULATION_
/*
* get the T_SRC_DES out of the first and only descriptor
* created by dtilib and put it in a descriptor of its own
*/
if(dti_data_ind->desc_list2.first &&
dti_data_ind->desc_list2.list_len >= sizeof(T_SRC_DES))
{
T_desc2 *old_desc, *addr_desc, *test_desc;
USHORT i;
old_desc = (T_desc2 *)dti_data_ind->desc_list2.first;
/*
* build the T_SRC_DES for IP-addresses and ports
*/
MALLOC (
addr_desc, (USHORT)(sizeof(T_desc2) - 1 + sizeof(T_SRC_DES))
);
addr_desc->len = sizeof(T_SRC_DES);
addr_desc->size = sizeof(T_SRC_DES);
addr_desc->offset = 0;
for(i=0; i < addr_desc->len; i++)
addr_desc->buffer[i] = old_desc->buffer[i];
/*
* Build a desc for the data
*/
MALLOC (
test_desc,
(USHORT)(sizeof(T_desc2) - 1 +
old_desc->len - sizeof(T_SRC_DES))
);
test_desc->len = old_desc->len - sizeof(T_SRC_DES);
test_desc->size = test_desc->len;
test_desc->offset = 0;
for(i=0; i < test_desc->len; i++)
test_desc->buffer[i]
= old_desc->buffer[i + addr_desc->len];
dti_data_ind->desc_list2.first = (ULONG)addr_desc;
addr_desc->next = (ULONG)test_desc;
test_desc->next = old_desc->next;
MFREE(old_desc);
}
#endif /* _SIMULATION_ */
desc = (T_desc2*)dti_data_ind->desc_list2.first;
pSrcDes = (T_SRC_DES*)desc->buffer;
udp_conv_IP_to_str(pSrcDes->src_ip, src_ip);
udp_conv_IP_to_str(pSrcDes->des_ip, des_ip);
src_port = (pSrcDes->src_port[1]<<8) + pSrcDes->src_port[0];
des_port = (pSrcDes->des_port[1]<<8) + pSrcDes->des_port[0];
/*
* copy data
*/
data_len = dti_data_ind->desc_list2.list_len - desc->len;
if ( 0 == (data = (char*)wip_malloc((ULONG)data_len)))
{
PFREE(dti_data_ind);
/*
* sent automatically by dtilib
*
udp_send_ready();
*/
TRACE_ERROR("wip_malloc() failed");
return;
}
while ((desc = (T_desc2 *)desc->next) != NULL)
{
memcpy(data+i, desc->buffer, desc->len);
i += desc->len;
}
/*
* free descriptors
*/
desc = (T_desc2 *)dti_data_ind->desc_list2.first;
do
{
tmp = desc;
desc = (T_desc2 *) (desc->next);
MFREE(tmp);
} while(desc != NULL);
PFREE (dti_data_ind);
/*
* call AUS
*/
#ifdef TRACE_WAP_UDP
TRACE_EVENT("UDPc_receivedRequest");
{
char temp[100];
char* temp2;
int i, j;
TRACE_EVENT_P1("RECEIVED %d bytes of data", data_len);
TRACE_EVENT_P5("Source IP: %u.%u.%u.%u:%u", (unsigned int)src_ip[0],
(unsigned int)src_ip[1],
(unsigned int)src_ip[2],
(unsigned int)src_ip[3],
(unsigned int)src_port);
TRACE_EVENT_P5("Dest IP: %u.%u.%u.%u:%u", (unsigned int)des_ip[0],
(unsigned int)des_ip[1],
(unsigned int)des_ip[2],
(unsigned int)des_ip[3],
(unsigned int)des_port);
/* Dump the data package in human readable form if you want */
/*
for (j=0; (j<data_len) && (j<100); j+=20) // trace max 100 bytes
{
temp2 = (char*)temp;
temp2 += sprintf(temp2,"%04X: ", j);
for (i=j; ((i<data_len)&&(i<j+20)); i++)
temp2 += sprintf(temp2,"%02X ",data[i]); // The data itself in HEX
for ( ; i<=j+20; i++)
temp2 += sprintf(temp2," ");
temp2 += sprintf(temp2," : "); // fill to the end of line
for (i=j; ((i<data_len)&&(i<j+20)); i++)
{
char c=data[i];
if (c>=' ' && c<127)
*temp2++=c; // add the asci-char
else
*temp2++='.'; // nonprintable char
}
*temp2='\0';
TRACE_EVENT(temp);
}
*/
}
#endif /* TRACE_WAP_UDP */
UDPc_receivedRequest(data,
data_len,
des_ip,
(unsigned char) des_len,
src_ip,
(unsigned char) src_len,
des_port,
src_port,
0);
;
wip_free(data);
/*
* sent automatically by dtilib
*
udp_send_ready();
*/
wap_lib_run_aus_callback();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -