📄 entry_point.c
字号:
/*****************************************************************************/
/* entry_point.c - Copyright Wavecom S.A. (c) 2006 */
/* */
/* DISCLAIMER OF WARRANTY */
/* ====================== */
/* This Software is provided free of charge on an 'as is' basis. No warranty */
/* is given by Wavecom S.A. in relation to the Software of the uses to which */
/* it may be put by you, the user, or its merchantability, fitness or */
/* suitability for any particular purpose or conditions; and/or that the use */
/* of the Software and all documentation relating thereto by the Licensee */
/* will not infringe any third party copyright or other intellectual property*/
/* rights. Wavecom S.A. shall furthermore be under no obligation */
/* to provide support of any nature for the Software and the Documentation. */
/* */
/* LIMIT OF LIABILITY */
/* ================== */
/* In no event shall Wavecom S.A. be liable for any loss or damages */
/* whatsoever or howsoever caused arising directly or indirectly in */
/* connection with this licence, the Software, its use or otherwise except to*/
/* the extent that such liability may not be lawfully excluded. */
/* Notwithstanding the generality of the foregoing, Wavecom S.A. expressly */
/* excludes liability for indirect, special, incidental or consequential loss*/
/* or damage which may arise in respect of the Software or its use, or in */
/* respect of other equipment or property, or for loss of profit, business, */
/* revenue, goodwill or anticipated savings. */
/* */
/*****************************************************************************/
/****************************************************************************
* File : entry_point.c
*
* Very basic TCP client application:
* - Connects a TCP client socket to the TCP server on host [PEER_STRADDR]
* on port [PEER_PORT]
* - Sends all data in [snd_buffer], possibly in several steps, by using
* [WIP_CEV_WRITE] events to control data flow.
* - Puts everything received by the socket into [rcv_buffer], until
* the table is full.
*/
/*
* $LogWavecom:$
* --------------------------------------------------------------------------
* Date | Author | Revision | Description
* ----------+--------+----------------+-------------------------------------
* 27.10.06 | FFT | 1.0 | Initial revision.
* ----------+--------+----------------+-------------------------------------
*/
/***************************************************************************/
/* Defines */
/***************************************************************************/
#define PEER_STRADDR "211.142.222.45"
#define PEER_PORT 21
#define RCV_BUFFER_SIZE 10240
#include "adl_global.h"
#include "wip.h"
/***************************************************************************/
/* Globals */
/*******************************************
********************************/
static u8 snd_buffer [] =
"POST mmsc.monternet.com HTTP1.1\r\nContent-type: application/vnd.wap.mms-message\r\nAccept: application/vnd.wap.mms-message,text/plain,*/*\r\nUser-Agent: Nokia6681/2.0 (4.00.15) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1\r\nContent-Length: 381\r\nConnection: close\r\n\r\n\x8C\x80\x98\x31\x32\x33\x34\x00\x8D\x90\x85\x04\x49\x2E\x67\xE2\x89\x14\x80\x6D\x6D\x73\x2D\x65\x64\x69\x74\x6F\x72\x40\x74\x6F\x6F\x6C\x6B\x69\x74\x00\x97\x2B\x38\x36\x31\x35\x38\x37\x34\x32\x38\x39\x37\x36\x36\x2F\x54\x59\x50\x45\x3D\x50\x4C\x4D\x4E\x00\x96\x4D\x79\x20\x66\x69\x72\x73\x74\x20\x74\x65\x73\x74\x20\x6D\x65\x73\x73\x61\x67\x65\x21\x00\x86\x81\x94\x81\x90\x81\x8A\x80\x88\x06\x80\x04\x49\x2F\xB9\x62\x87\x06\x80\x04\x49\x2E\x67\xE2\x8F\x80\x84\xA3\x01\x3E\x81\x47\x9D\x8E\x6D\x6D\x73\x31\x2E\x67\x69\x66\x00\x43\x6F\x6E\x74\x65\x6E\x74\x2D\x49\x44\x00\x3C\x43\x49\x44\x31\x3E\x00\xB0\x68\x74\x74\x70\x3A\x2F\x2F\x6F\x72\x69\x67\x2E\x68\x6F\x73\x74\x2F\x6D\x6D\x73\x31\x2E\x67\x69\x66\x00\x92\x04\x49\x2E\x67\xE2\x47\x49\x46\x38\x39\x61\x32\x00\x32\x00\x80\x00\x00\xD7\x25\x42\xFF\xFF\xFF\x2C\x00\x00\x00\x00\x32\x00\x32\x00\x00\x02\xA6\x8C\x8F\xA9\xCB\xED\x0F\xA3\x9C\xB4\xDA\x8B\xB3\xDE\xBC\xFB\x09\x84\xA1\x31\x22\x22\x09\x7C\x67\x59\x9A\x29\xEA\x8D\x62\xDA\x1E\xF3\x5D\x63\x78\x0E\x27\x7C\x96\x6B\xAD\x6E\x2A\xDA\x4B\xF8\x8B\xED\x90\x2C\x62\x07\x67\x7B\x05\x64\xD2\xE2\x2C\xEA\x9A\x42\x37\x57\x6A\x55\x0B\xEE\x01\x8D\x58\xDF\x51\x9A\xB4\x6C\xCD\xA8\xEB\xE7\x0D\x8F\xCB\xE7\xF4\xBA\xFD\x8E\xCF\xEB\xF7\xFC\xBE\xFF\x8F\xE7\x96\xD5\x70\xC2\xB1\x23\x16\x16\x95\x56\xE1\x55\x88\x48\xA5\xD1\xB8\xE6\xE2\x14\xB9\xE4\xB8\xB0\xC8\x48\xE4\x28\x88\x69\x79\x39\x58\xC9\x75\x59\xD5\x94\x68\xA9\x75\x56\x73\xAA\x29\xD1\x58\xD6\xB6\x44\x0A\x76\xAA\xD8\xE5\xFA\xE0\x36\xEA\x90\x0B\xF8\x0B\x1C\x2C\x3C\x1C\x51\x00\x00\x3B";
/* How many bytes of [buffer] have already been sent. */
static int snd_offset = 0;
static int next_rcv_offset = 0 ;
static int next_snd_offset = 0 ;
static char rcv_buffer [RCV_BUFFER_SIZE];
char session_tmp[1024];
static int rcv_offset = 0;
char session_tmp[1024];
char ftp_data_ip[20], ftp_data_port1[10], ftp_data_port2[10];
int ftp_data_port;
static char next_rcv_buffer[RCV_BUFFER_SIZE];
static char temp[RCV_BUFFER_SIZE];
/***************************************************************************/
/* Function prototypes */
/***************************************************************************/
static void evh( wip_event_t *ev, void *ctx);
static void _mms_evh( wip_event_t *ev, void *ctx);
static void _wap_evh( wip_event_t *ev, void *ctx) ;
void abstract_data_info(void);
void send_remained_to_server(u8 ID);
char mms_u8_code[3072];
//="POST http://mmsc.monternet.com/ HTTP/1.1\r\nContent-type: application/vnd.wap.mms-message\r\nAccept: application/vnd.wap.mms-message,text/plain,*/*\r\nUser-Agent: Nokia6681/2.0 (4.00.15) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1\r\nContent-Length: 0\r\nConnection: Keep-Alive\r\n\r\n";
char hexToIntegerValue(char * intValue);
void getHexValue();
void getHexValue()
{
int i = 0 , j = 0 ;
char local_char[3] ;
for(i = 0 ; i < strlen(mms_pdu_codeA) ; i++)
{
local_char[i%2] = mms_pdu_codeA[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
j += strlen(mms_pdu_codeA);
//_mms_sed_number
for( i = 0 ; i < strlen(_mms_sed_number) ; i++ )
{
mms_u8_code[(i*2+j)/2] = _mms_sed_number[i];
}
j += 2*strlen(_mms_sed_number);
for( i = 0 ; i < strlen(mms_tmp_code) ; i++)
{
local_char[i%2] = mms_tmp_code[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
j += strlen(mms_tmp_code);
// _mms_my_number
for( i = 0 ; i < strlen(_mms_my_number) ; i++ )
{
mms_u8_code[(i*2+j)/2] = _mms_my_number[i];
}
j += 2*strlen(_mms_my_number);
for( i = 0 ; i < strlen(mms_pdu_codeB) ; i++)
{
local_char[i%2] = mms_pdu_codeB[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
j += strlen(mms_pdu_codeB);
for( i = 0 ; i < strlen(mms_pdu_codeC) ; i++)
{
local_char[i%2] = mms_pdu_codeC[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
j += strlen(mms_pdu_codeC);
for( i = 0 ; i < strlen(mms_pdu_codeD) ; i++)
{
local_char[i%2] = mms_pdu_codeD[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
j += strlen(mms_pdu_codeD);
for( i = 0 ; i < strlen(mms_pdu_codeE) ; i++)
{
local_char[i%2] = mms_pdu_codeE[i];
if( i%2==1 )
{
mms_u8_code[(i+j)/2] = hexToIntegerValue(local_char);
memset(local_char , '\0' , sizeof(local_char)) ;
}
}
wip_debug( "[SAMPLE]: Returned.\n");
}
char hexToIntegerValue(char * intValue)
{
char first_actual_value , second_actual_value , first_tmp , second_tmp ;
first_tmp = *intValue;
intValue++;
second_tmp = *intValue;
if(first_tmp <=57 && first_tmp >=48) {
first_actual_value = first_tmp - 48;
}
if(first_tmp <=70 && first_tmp >=65)
{
first_actual_value = first_tmp - 55;
}
if(second_tmp <=57 && second_tmp >=48) {
second_actual_value = second_tmp - 48;
}
if(second_tmp <=70 && second_tmp >=65) {
second_actual_value = second_tmp - 55;
}
return first_actual_value*16 + second_actual_value;
}
void abstract_data_info(void)
{
char *cp;
int i = 0, j = 0;
/* abstract ip */
cp = strchr(session_tmp, '(');
if (cp) {
cp++;
while (*cp) {
if (*cp == ',') {
j++;
if (j == 4)
break;
ftp_data_ip[i++] = '.';
cp++;
continue;
}
else
ftp_data_ip[i++] = *cp++;
}
ftp_data_ip[i] = '\0';
/* abstract port */
cp++; i = 0;
while (*cp != ',')
ftp_data_port1[i++] = *cp++;
ftp_data_port1[i] = '\0';
cp++; i = 0;
while (*cp != ')')
ftp_data_port2[i++] = *cp++;
ftp_data_port2[i] = '\0';
}
}
/***************************************************************************/
/* Function : appli_entry_point */
/*-------------------------------------------------------------------------*/
/* Object : Called once the WIP IP stack is fully initialized. */
/* This is the starting point of user applications. */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
/* FTP TEST
void appli_entry_point() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -