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

📄 mm32.h

📁 phs 源代码 小灵通协议源代码 phs source code
💻 H
字号:
#ifndef _MM32_H
#define _MM32_H

/* MM State definition begin----------------------------------------------------------*/
#define    MM_STS_CNT		4    			/* 俵俵 state count				*/

typedef  enum
{
	ST_NULL 	= 0,   			/* P0 state: NULL            	*/
	ST_LOCREG 	= 1,  			/* P1 state: Location Registration*/
	ST_AUTH    	= 2,   			/* P2 state: Authentication*/
    ST_LOCREG_R =	3   		/* P3 state: Location registration retry waiting*/
}enumMMState;

#define	   STATE_SAME		0xF0			// Not change MM state
#define	   STATE_MORE		0xF1			// Change to different state depend on some conditions
/* MM State definition end----------------------------------------------------------*/


/* STD-28 MM  Message type definition begin --------------------------------------------------*/
/* Authentication */
#define    L2MM_AUTHENTICATION_REQ     0x01	//Authentication request , down link
#define    MML2_AUTHENICATION_RES     0x02	//Authentication response ,up link
/* Locaton registration */
#define    MML2_LOCATION_REGISTRATION_REQ      0x21	//Location registrtion request,up link
#define    L2MM_LOCATION_REGISTRATION_ACK      0x22 //Location registration acknowledge,down link
#define    L2MM_LOCATION_REGISTRATION_REJ      0x23 //Location registration reject,downlink
#define    L2MM_LOCATION_REGISTRATION_AREA     0x24
/*Function */
#define    MML2_FUNCTION_REQ     		0x41  			//Function request,up link
#define    L2MM_FUNCTION_REP     		0x42  			//Function request response,down link
/*Option message*/
#define    PW_OFF_MSG    				0x61            /* PS power-off message	#J88*/
/* STD-28 MM  Message type definition end --------------------------------------------------*/


enum enumMMClassification
{
	MANDATORY	= 1,
	OPTIONAL = 2
};

enum enumLinkDirection
{
	DOWNLINK,
	UPLINK
};


/*STD-28 MM Information element type definition begin-----------------*/
#define 	MMINFOELE_AUTHTYPE				0x06	//Authentication type
#define		MMINFOELE_AUTHCIPHERING_PATTERN	0x05	//Authentication element identifier
#define		MMINFOELE_AUTHRANDOM_PATTERN		0x07	//Authentication random pattern
#define 	MMINFOELE_CAUSE					0x08	//Cause
#define		MMINFOELE_LOC_REG_AREA_REPORT	0x09	//Location registration area report
#define 	MMINFOELE_PAGING_AREA				0x0A	//Paging area
#define 	MMINFOELE_PAGING_GROUP			0x0B	//Pagin group
#define 	MMINFOELE_PS_NUMBER				0x0C	//PS number
#define		MMINFOELE_RECEPTION_LEVEL		0x0D	//Reception level

#define		MMINFOELE_ACTIVE_AUTH				0x80	//single octet
/*STD-28 MM Information element type definition end-----------------*/



#define    PRTM301P      (U2)0xC0
#define    PRTM303P      (U2)0xC1
#define    PRTM304P      (U2)0xC2

#define    TM301P          50
#define    TM303P          60
#define    TM304P         100

#define    TM301PON      0x01
#define    TM303PON      0x04
#define    TM304PON      0x08

#define    KEYRND_SZ		8

#define	   N			   32	 			/* FEAL-N*/

#ifdef SIMU_ON_PC     /*zch for protocol simulator */
#pragma pack( push, mmstucture,1)
#endif

#ifdef  _ARM607_
__packed			// Added by Yang Yajiang		05/22/2003
#endif
typedef struct
{
	U2 	in_evt[8];
	U2  tsk_id;
	U2  out_evt[8];
	U2  tim_inf[11];
	U1  *inf_ptr;
	U1  *tbl_ptr;
	U1 	evt_source;
	U1 	public_flag;
	U1 	link_direction;
	U1 	version;
	U1 	mandatory_count;
	U1  pre_element_id;
}MM_SYSWRK;

#ifdef  _ARM607_
__packed
#endif
typedef struct
{
	U2		evt_code;
	void 	(*fnc_adr)(void);
	enumMMState state;
}SYS_STATE_TBL;



#ifdef  _ARM607_
__packed			// Added by Yang Yajiang		05/22/2003
#endif
typedef struct {
	U1		*nxt;
	U2		qno;
	U1		msg[MSGDAT_SZ];
} M_MSB;

#ifdef  _ARM607_
__packed			// Added by Yang Yajiang		05/22/2003
#endif
typedef struct {
	U1	*next_po;
	U1	lst_len;
	U1	len;
	U1	dat[L3_MSGSZ];
} MM_MSGDAT;

#ifdef  _ARM607_
__packed			// Added by Yang Yajiang		05/22/2003
#endif
typedef struct
{
	U2	evt_cod;
	U2	dl_typ;
	U2	dl_id;
	U2	dl_sou;
	MM_MSGDAT	*msg_adr;
	U2	dont_care[2];
} MM_DLDEVT;

#ifdef  _ARM607_
__packed			// Added by Yang Yajiang		05/22/2003
#endif
typedef struct
{
	U2  evt_cod;
	U2  pri_cod;
	U1  *buf_adr;
	U2  inf_len;
	U1  *inf_adr;
	U1  add_dat;
	U1	dmy3;
} MM_PRIEVT;

#ifdef  _ARM607_
__packed
#endif
typedef struct
{
	U1	info_ele;			//information element , bit8==1,means single octet,otherwise,means multiple octect
	U1	link_direction	;	//uplink or downlink
	U1	classification;	//M or O
	U1	binfo_len_fixed;	//==1,information lenght is fixed,otherwise is unfixed
	U1	info_len;			//information length
}MM_INFOELE;	//MM Infromation element type, Added by chenxl 08/2/2003



#ifdef _ON_SANYO_
#define	SYS_WORK	((MM_SYSWRK *)Sys_work)
#else
#define SYS_WORK	((MM_SYSWRK*)&mm_syswork)
#endif
#define	IN_DLDEVT	((MM_DLDEVT *)SYS_WORK->in_evt)
#define	OUT_DLDEVT	((MM_DLDEVT *)SYS_WORK->out_evt)
#define	IN_PRIEVT	((MM_PRIEVT *)SYS_WORK->in_evt)
#define	OUT_PRIEVT	((MM_PRIEVT *)SYS_WORK->out_evt)
#define	IN_MSGDAT	((MM_MSGDAT *)IN_DLDEVT->msg_adr)
#define	OUT_MSGDAT	((MM_MSGDAT *)OUT_DLDEVT->msg_adr)


#ifdef SIMU_ON_PC     /*zch for protocol simulator */
#pragma pack( pop, mmstucture,1)
#endif

//Send data link data message to low layer(TASKL2)
#define mm_dldt_req(dltyp)\
{\
	SYS_WORK->tsk_id = TASKL2;\
	OUT_DLDEVT->evt_cod = EDLDTRQ;\
	OUT_DLDEVT->dl_typ = dltyp;\
	OUT_DLDEVT->dl_id = SLOT1;\
	OUT_DLDEVT->dl_sou = 0;\
	m_excreq((WORD*)&SYS_WORK->tsk_id);\
}

//Send primitive message to high layer(TASKMNG)
#define mm_pri_req(pri)\
{\
	SYS_WORK->tsk_id = TASKMNG;\
	OUT_PRIEVT->evt_cod = EMM;\
	OUT_PRIEVT->pri_cod = pri;\
	m_excreq((WORD*)&SYS_WORK->tsk_id);\
}


/************************/
/*		mm32main		*/
/************************/
#ifdef _ON_SANYO_
U1		mm_main(void);
#else
U1		mm_main(void*);
#endif
void		mm_set_time( U1 );
void		mm_stop_time( U1 );


//MM Function
void 	mm_LocReg_req(void);
void 	mm_fnc_req(void);
void 	mm_auth_rep(void);


void 	mm_auth_req(void);
void 	mm_LocReg_ack(void);
void 	mm_LocReg_rej(void);
void	mm_fnc_rep(void);
void	mm_tm_301p(void);
void	mm_tm_303p(void);
void	mm_tm_304p(void);
void	mm_init(void);

/************************/
/*		mm32fealn		*/
/*		FEAL張棟 		*/
/************************/
// Noted by Yang Yajiang
//	void	  Mm_FEALNenc(U1 *, U1 *, U1 *);	/* FEAL-N埫崋壔張棟		*/
//	void	  Mm_FEALNdec(U1 *, U1 *, U1 *);	/* FEAL-N暅崋壔張棟		*/
void		Mm_Exkey(U1 *, U1 [][2]);
void		Mm_f(U1 *, U1 *, U1 *);
void		Mm_fk(U1 *, U1 *, U1 *);
U1		Mm_S0(U1, U1);
U1		Mm_S1(U1, U1);
/* !UT80_014 */
void		Mm_STEPHIenc(U1 *,U1 *,U1 *);
void		Mm_STEPHIdec(U1 *,U1 *,U1 *);
void		Mm_STEPHIExkey(U1 *,U1 [][4]);
void		Mm_STEPHIf(U1 *,U1 *,U1 *);
U2		bit_func1( U2 );
U2		bit_func2( U2 );
U1		bit_1_cnt(U4 );

#endif

⌨️ 快捷键说明

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