⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cms_wtp.h

📁 wap 协议栈 包括1.2 和2.0 由c开发 基于brew平台
💻 H
字号:
/******************************************************************************

 C   H E A D E R   F I L E

 (c) Copyright MobileSoft Technology (NanJing) Co.,LTD. 2001-2002
 ALL RIGHTS RESERVED

*******************************************************************************

 Project Name: WAP STACK Ver 1.20
 
 File Name   : Cms_WTP.h

 Description : To Implement Browser application

 Last Modify : 06/22/2002
 
 Written By  : Mobilesoft Technology

******************************************************************************/

#ifndef _CMS_WTP_H
#define _CMS_WTP_H

/********************************************************/

typedef struct WTPMachine WTPMachine;
typedef struct WTPEvent WTPEvent;
typedef struct Address Address;

/*******************************************************/

#include "Cms_WAPTypes.h"
#include "Cms_WAPGWLIB.h"
#include "Cms_WAPMsg.h"
#include "Cms_WSP.h"
#include "Cms_WTPSend.h"

/********************************************************/


#define NUMBER_OF_ABORT_REASONS 9
/*
 * For now, timers are defined. They will depend on bearer information fetched
 * from address (or from a header field of the protocol speaking with the
 * bearerbox).
 */
#define B_A_WITHOUT_USER_ACK  2
#define S_A_WITHOUT_USER_ACK  0
#define L_A_WITHOUT_USER_ACK  4

#define B_R_WITHOUT_USER_ACK  5
#define S_R_WITHOUT_USER_ACK  3
#define L_R_WITHOUT_USER_ACK  7
//#define L_R_WITHOUT_USER_ACK  14
#define G_R_WITHOUT_USER_ACK  3

#define B_A_WITH_USER_ACK 2
#define S_A_WITH_USER_ACK 1 
#define L_A_WITH_USER_ACK 4  

#define B_R_WITH_USER_ACK  5
#define S_R_WITH_USER_ACK  4
#define L_R_WITH_USER_ACK  7
#define G_R_WITH_USER_ACK  3

#define WAIT_TIMEOUT_INTERVAL   40
#define L_W_WINDOW  4

#ifdef __SELECTIVE_RETRANSMISSION__
#define WTP_TIMER_NUMBER    4
#define NACK_TIMER_EXPIRE  10
#else 
#define WTP_TIMER_NUMBER    3
#endif

/*
 * Maximum values for counters
 */
#define MAX_RCR  8
#define MAX_AEC  8
#define MAX_NACK 8

/*
 * --Shawn 2002-12-25
 */
#define WTP_MTU                         1500
#define WTP_RECV_MAXSPACE               WTP_MTU+100
#define WTP_PACKET_SIZE                 1395//1020//Bytes
#define WTP_PACKET_NUM_IN_GROUP         1
#define WTP_GROUP_SIZE      WTP_PACKET_SIZE*WTP_PACKET_NUM_IN_GROUP                                 

/*
 * Types of WTP PDUs and numbers assigned for them
 */
enum 
{
     ERRONEOUS = -0x01,
     NOT_ALLOWED = 0x00,
     INVOKE = 0x01,
     RESULT = 0x02,
     ACK = 0x03,
     ABORT = 0x04,
     SEGMENTED_INVOKE = 0x05,
     SEGMENTED_RESULT = 0x06,
     NEGATIVE_ACK = 0x07
};


/*
 * Types of acknowledgements
 */
enum 
{
   ACKNOWLEDGEMENT = 0,
   TID_VERIFICATION = 1
};

enum wtp_abort_reason{
   WTPERRUNKNOWN = 0x00,
   WTPPROTOERR = 0x01,
   INVALIDTID = 0x02,
   NOTIMPLEMENTEDCL2 = 0x03,
   NOTIMPLEMENTEDSAR = 0x04,
   NOTIMPLEMENTEDUACK = 0x05,
   WTPVERSIONZERO = 0x06,
   CAPTEMPEXCEEDED = 0x07,
   NORESPONSE = 0x08,
   MESSAGETOOLARGE = 0x09
};    

/*
 * Types of aborts
 */
enum 
{
     PROVIDER = 0x00,
     USER = 0x01
};

enum event_name 
{  
	NOUSE5=-1
    #define EVENT(name, field) ,name
    #include "Cms_WTPEventsDecl.h"
};

enum states 
{ 
	NOSUE4=-1
    #define STATE_NAME(state) ,state
    #define ROW(state, event, condition, action, next_state)
    #include "Cms_WTPStateDecl.h"
};

typedef enum states states;

struct WTPMachine 
{
        #define INTEGER(name) CMS_S64 name
        #define ENUM(name) states name
        #define OCTSTR(name) Octstr *name
        #define QUEUE(name) WTPEvent *name
		#define CHARARR(name)unsigned char name[WTP_MTU]
		#define CHARARR8(name)unsigned char name[8]//2003.10.30
        #define MACHINE(field) field
        #include "Cms_WTPMachineDecl.h"
};

#define INTEGER(name) CMS_S64 name
#define OCTSTR(name) Octstr *name
#define EVENT(name, field) struct name  field;
#include "Cms_WTPEventsDecl.h"

struct WTPEvent 
{
    enum event_name type;
    WTPEvent *next;
	Octstr *user_data;
	Octstr *big_data;

    #define INTEGER(name) 
    #define OCTSTR(name) 
    #define EVENT(name, field) struct name name;
    #include "Cms_WTPEventsDecl.h"
};

struct Address 
{
   Octstr *source_address;
   CMS_S64 source_port;
   Octstr *destination_address;
   CMS_S64 destination_port;
};

#ifdef __CMS_TOOLKIT__
typedef struct WTP_Get_PackageTag
{
	int	currentIndex;			//该Package的序号
	int	nextPackageOffset;		//如果要在该package后插入数据,插入的偏移量
	struct  WTP_Get_PackageTag *next,*prev;	//下一个、前一个Pakcage
}WTP_Get_Package;

typedef struct WTP_Sar_ProgressTag
{
	int	totalPackage;	//描述本次接收一共会有多少个package
	int	curQuantity;	//当前已经保存的PACKAGE数量
	WTP_Get_Package	*sarPackage;

}WTP_Sar_Progress;

int cmsGetPackageOffset(unsigned char index); //根据当前Package的序号得到偏移量

void cmsInsertPackage(unsigned char index,unsigned short len); //将当前Package的信息插入到SAR过程

CMS_BOOL cmsIfGetAll(void);	//判断是否已经得到全部的数据报,是,返回TRUE

CMS_BOOL cmsIfPackageExist(unsigned char index); //判断某需要的包是否已经收到,是,返回TRUE

void cmsFreeSarProgress(void); //释放SAR过程使用的内存

#ifdef __SELECTIVE_RETRANSMISSION__
CMS_BOOL cmsIfPackageContinuous(void);
#endif

#endif


/********************************************************/

/*
 * Initialize the WTP subsystem. MUST be called before any other calls
 * to this module.
 */
CMS_VOID wtp_init(CMS_VOID);

/*
 * Create a WTPEvent structure and initialize it to be empty. Return a
 * pointer to the structure or NULL if there was a failure.
 */
WTPEvent *wtp_event_create(enum event_name type);


/*
 * Destroy a WTPEvent structure, including all its members.
 */
CMS_VOID wtp_event_destroy(WTPEvent *event);


/*
 * Output (with `debug' in log.h) the type of an event and all
 * the fields of that type.
 */
CMS_VOID wtp_event_dump(WTPEvent *event);


/*
 * Parse a `wdp_datagram' message object (of type Msg, see msg.h) and
 * create a corresponding WTPEvent object. Also check that the datagram
 * is syntactically valid. If there is a problem (memory allocation or
 * invalid packet), then return NULL, and send an appropriate error
 * packet to the phone. Otherwise return a pointer to the event structure
 * that has been created.
 */
WTPEvent *wtp_unpack_wdp_datagram(Msg *msg);


WTPMachine *wtp_machine_create(Octstr *srcaddr, CMS_S64 srcport,
				Octstr *destaddr, CMS_S64 destport, CMS_S64 tid,
				CMS_S64 tcl);


void wtp_machine_destroy(WTPMachine *machine);

/*
 * Checks whether wtp machines data structure includes a spesific machine.
 * The machine in question is identified with with source and destination
 * address and port and tid. Address information is fetched from message
 * fields, tid from an field of the event. If the machine does not exist and
 * the event is RcvInvoke, a new machine is created and added in the machines
 * data structure. If the event was RcvAck or RcvAbort, the event is ignored.
 * If the event is RcvErrorPDU, new machine is created.
 */
WTPMachine *wtp_machine_find_or_create(Msg *msg, WTPEvent *event);


/*
 * Mark a WTP state machine unused. Normally, removing a state machine from the
 * state machines list means marking turning off a flag. Panics when there is
 * no machines to mark unused.
 */
CMS_VOID wtp_machine_mark_unused(WTPMachine *machine);


/* 
 * Removes from the machines list all machines having in_use-flag cleared. Panics  if 
 * machines list is empty. If machines list is busy, does nothing (garbage collection 
 * will eventually start again).
 */


/*
 * Output (with `debug' in gwlib/log.h) the state of the machine  and all
 * its fields.
 */
CMS_VOID wtp_machine_dump(WTPMachine  *machine);


/*
 * Feed an event to a WTP state machine. Handle all errors yourself,
 * and report them to the caller. Generate a pointer to WSP event, if an
 * indication or a confirmation is required.
 */
CMS_VOID wtp_handle_event(WTPMachine *machine, WTPEvent *event);

/*
 * Generates a new transaction handle by incrementing the previous one by one.
 */
CMS_U64 wtp_tid_next(CMS_VOID);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -