📄 wap_udpc.c
字号:
/*
+-----------------------------------------------------------------------------
| File : wap_udpc.c
+-----------------------------------------------------------------------------
| Copyright Condat AG 1999-2000, Berlin
| All rights reserved.
|
| This file is confidential and a trade secret of Condat AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Condat AG.
+-----------------------------------------------------------------------------
| Purpose : This Modul defines the callback functions provided to
| the AUS WAP browser
+-----------------------------------------------------------------------------
*/
#ifndef WAP_UDPC_C
#define WAP_UDPC_C
#endif
#define ENTITY_WAP
/*==== INCLUDES ===================================================*/
#if defined (NEW_FRAME)
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stddef.h>
#include "typedefs.h"
#include "pcm.h"
#include "pconst.cdg"
#include "mconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "pei.h"
#include "tok.h"
#include "dti.h" /* functionality of the dti library */
#else
#include <string.h>
#include "stddefs.h"
#include "pconst.cdg"
#include "message.h"
#include "ccdapi.h"
#include "custom.h"
#include "gsm.h"
#include "cnf_wap.h"
#include "mon_wap.h"
#include "prim.h"
#include "vsi.h"
#include "pei.h"
#include "tok.h"
#endif
#include "wap.h"
#include "cus_wap.h"
#include "wap_types.h"
#include "capiclnt.h"
#include "aapiudp.h"
#include "capiudp.h"
/**** ***/
/*==== CONST =======================================================*/
/*==== TYPES =======================================================*/
/*==== VAR EXPORT ==================================================*/
/*==== VAR LOCAL ===================================================*/
/*==== FUNCTIONS ===================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-WAP (8444) MODULE : WAP_UDPC |
| STATE : code ROUTINE : UDPa_sendRequest |
+--------------------------------------------------------------------+
PURPOSE : callback for AUS browser;
wrapper for DTI2_DATA_REQ primitive
in case of a blocked DTI_channel, the request will bee silently
discarded
*/
/*
GLOBAL const void UDPa_sendRequest (const CHAR *data,
USHORT dataLength,
const CHAR *destination,
UBYTE destLength,
const CHAR *source,
UBYTE sourceLength,
USHORT destinationPort,
USHORT sourcePort)
*/
VOID UDPa_sendRequest
(const CHAR *data,
UINT16 dataLength,
const CHAR *destination,
UINT8 destLength,
const CHAR *source,
UINT8 sourceLength,
UINT16 destinationPort,
UINT16 sourcePort,
UBYTE objectId,
UBYTE channelId)
{
USHORT len, dataSize;
T_desc2 *d_desc;
ULONG *pLast;
const char *p;
T_SRC_DES pSrcDes;
#ifdef TRACE_WAP_UDP
TRACE_EVENT("UDPa_sendRequest()");
{
char temp[100];
char* temp2;
int i, j;
TRACE_EVENT_P1("TRYING TO SEND %d bytes of data", dataLength);
TRACE_EVENT_P5("Source IP: %u.%u.%u.%u:%u", (unsigned int)source[0],
(unsigned int)source[1],
(unsigned int)source[2],
(unsigned int)source[3],
(unsigned int)sourcePort);
TRACE_EVENT_P5("Dest IP: %u.%u.%u.%u:%u", (unsigned int)destination[0],
(unsigned int)destination[1],
(unsigned int)destination[2],
(unsigned int)destination[3],
(unsigned int)destinationPort);
TRACE_EVENT_P2("objectId %d channel Id %d", (int)objectId, (int)channelId);
/* Dump the data package in human readable form if you want */
/*
for (j=0; (j<dataLength) && (j<100); j+=20) // trace max 100 bytes
{
temp2 = (char*)temp;
temp2 += sprintf(temp2,"%04X: ", j);
for (i=j; ((i<dataLength)&&(i<j+20)); i++)
temp2 += sprintf(temp2,"%02X ",data[i]); // The data itself in HEX
for ( ; i<=j+20; i++)
temp2 += sprintf(temp2," "); // fill to the end of line
temp2 += sprintf(temp2," : ");
for (i=j; ((i<dataLength)&&(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 */
if (dataLength > (65536 - sizeof(T_desc2) - sizeof(T_SRC_DES) - 1)) /*XXX defines needed XXX*/
{
TRACE_ERROR ("dataLength too big ");
return ;
}
if (wap_data->flow) {
PALLOC(dti_data_ind, DTI2_DATA_IND);
/*
* Fill first block with source and destination port/address
*/
MALLOC(d_desc, (USHORT)(sizeof(T_desc2) - 1 + sizeof(T_SRC_DES)));
dti_data_ind->desc_list2.first = (ULONG) d_desc;
udp_conv_str_to_IP(source, pSrcDes.src_ip);
udp_conv_str_to_IP(destination, pSrcDes.des_ip);
pSrcDes.src_port[0] = (UBYTE)((0xFF)&(sourcePort));
pSrcDes.src_port[1] = (UBYTE)(sourcePort>>8);
pSrcDes.des_port[0] = (UBYTE)((0xFF)&(destinationPort));
pSrcDes.des_port[1] = (UBYTE)(destinationPort>>8);
memcpy(d_desc->buffer,&pSrcDes,sizeof(T_SRC_DES));
d_desc->offset = 0;
d_desc->len = sizeof(T_SRC_DES);
d_desc->size = sizeof(T_SRC_DES);
pLast = &d_desc->next;
len = dataLength;
p = data;
while (len >0)
{
if (len > WAP_DTI_DATA_SIZE)
{
dataSize = WAP_DTI_DATA_SIZE;
}
else
{
dataSize = len;
}
MALLOC (d_desc, (USHORT)(sizeof(T_desc2) - 1 + dataSize));
memcpy( d_desc->buffer, p, dataSize);
d_desc->offset = 0;
d_desc->len = dataSize;
d_desc->size = dataSize;
len -= dataSize;
p += dataSize;
*pLast = (ULONG) d_desc;
pLast = &d_desc->next;
#ifdef TRACE_WAP_UDP
{
char temp[60];
int i;
sprintf(temp,"SENDING %d bytes of data",dataLength);
TRACE_EVENT(temp);
}
#endif
}
*pLast = NULL;
dti_data_ind->parameters.st_lines.st_line_sa = DTI_SA_ON;
dti_data_ind->parameters.st_lines.st_line_sb = DTI_SB_ON;
dti_data_ind->parameters.st_lines.st_flow = DTI_FLOW_ON;
dti_data_ind->parameters.st_lines.st_break_len= DTI_BREAK_OFF;
dti_data_ind->link_id = WAP_LINK_ID_DEFAULT;
dti_data_ind->parameters.p_id = DTI_PID_IP;
dti_data_ind->desc_list2.list_len = dataLength + sizeof(T_SRC_DES);
dti_send_data(
wap_hDTI,
WAP_DTI_DN_DEF_INSTANCE,
WAP_DTI_DN_INTERFACE,
WAP_DTI_DN_CHANNEL,
dti_data_ind
);
/*
* wap_data->flow is set to FALSE in
* sig_dti_udp_tx_buffer_full_ind if necessary
*/
}
wap_data->aus_runnable = TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -