/* 
** file name: message.h
**
** Message type defination.
**
*/

#ifndef MESSAGE__H
#define MESSAGE__H
#include  "ramdata.h"

void	SendContinue(u_short);
void	SendReleaseCall(u_short);
void	SendActivityTest(u_short);
void	SendCDR(int);
void	SendPlayAnnouncement(int proc_id, int balance, 
					int expiration, int code_id, int oper_result );
void	SendAccountRealSync(DWORD instance,double balance,double promotion,int ocode);

void	SendPeriodicChargeCDR(int, int, int,int);
void	SendRechargeCDR(int, int, int);
void	SendOperatorRechargeCDR(int, int, int);
void	SendPPSGeneralCDR(int, int, int,char);
void	SendRequestBCSMEvent(u_short portid);
void	SendApplyCharging(u_short portid);
int		GetRamData(u_char oidLen,DWORD *oid,u_char *pdata, u_short dataLen);
int		SetCDRParam(u_char oidLen,DWORD *oid,u_char *pdata, u_short dataLen);
int		GetCDRParam(DWORD oid,u_char *pdata);
int		SetDatabase(u_char oidLen,DWORD *oid,u_char *pdata, u_short dataLen);
int		GetDatabase(u_char oidLen,DWORD *oid,u_char *pdata, BYTE *vartype);

int		ImportUserData(char *record);
int		ImportCommTariffData(FILE *fp);
int		ImportRentTariffData(FILE *fp);
int		ImportCallType(FILE *fp);
int		ImportHolidayTariffData(FILE *fp);
int		ImportDiscountTariffData(FILE *fp);
int		ImportBasicTariffData(FILE *fp);
int		ImportMTTariff(FILE *fp);
int		ImportCalltypeToDiscount(FILE *fp);

int		ppsSendHeartBeating();

void	SendContinueSMS(u_short portid);
void	SendRequestSMSEvents(u_short portid);
void	SendReleaseCall(u_short portid);
void	SendReleaseSMS(u_short portid);

int		AssignProcID(int gy_flag);

int		DeleteSubscriberDataHead(int head);
int		SetUserDataByOMC(u_char oidlen, DWORD *oid, 
	   		     u_char *pdata, u_short datalen);	

void	SendConnectToResource(u_short portid);
void	SendSrfPlayAnnouncement(u_short portid);
void	SendDisconnectForwardConnection(u_short portid);
void	SendPromptAndCollectUserInfo(u_short portid);
int	 	SendAccountInfoPromptToSrf(u_short portid,u_char isOnlyBalance,u_char isLastCallAttatched);
int		SendRechargeInfoPromptToSrf(u_short portid);
void 	SendAccountInfoForLowCredit(char *caller,
										long balance,long expired_date,
										long promo,long promo_expired_date);
void	SendDisconnectForwardConnection(u_short portid);
void	SendFmnPromptAndCollectUserInfo(u_short portid);
void	SendPromptCollectedRechargedUserInfo(u_short portid);

/* defination of message type */
		

#define MAX_MSISDN_LEN        11
#define MIN_MSISDN_LEN        3


#define _CID_ _cap_initial_dp
typedef struct {
    BYTE          callType;  /* 0/1/2:=MO/MT/MF */
	BYTE          servieKey;
	BYTE          eventTypeBCSM;
	BYTE		  callingPartyNumber[11];
	BYTE		  IMSI[9];
	BYTE		  locationInfo[11];
	BYTE		  callReference[9];
	BYTE          calledPartyBCDNumber[20];
	BYTE		  calledPartyNumber[13];
}_cap_initial_dp;

#define _CC_ _cap_continue
typedef struct {
    BYTE          msgLength;
	BYTE          msgReserved;
	BYTE          msgSrvType;
	BYTE		  msgDstID[3];
	BYTE		  msgSrcID[3];
	BYTE		  msgOperaCode;
	BYTE	      EndFlag;
}_cap_continue;

#define _CRC_ _cap_release_call
typedef struct {
    BYTE		  Cause[3];
}_cap_release_call;

#define _CER_ _cap_event_report
typedef struct {
	BYTE           type;
	BYTE           invoke_id;
	BYTE           event_type;
	BYTE           dp_type;
} _cap_event_report;

#define _CAT_ _cap_activity_test
typedef struct {
    BYTE          msgLength;
	BYTE          msgReserved;
	BYTE          msgSrvType;
	BYTE		  msgDstID[3];
	BYTE		  msgSrcID[3];
	BYTE		  msgOperaCode;
	BYTE		  EndFlag;
}_cap_activity_test;

#define MAX_CALL_NUM_BLEN	10
#define MAX_CALL_NUM_ALEN	20

#define _IER_ _ivr_establish_req
typedef struct {
    u_char		   DDO0;
	u_char		   DDO1;
	u_char		   port;
	u_char         type;
	u_char         invoke_id;
	u_char         caller[MAX_CALL_NUM_BLEN];
	u_char         called[MAX_CALL_NUM_BLEN+2];
} _ivr_establish_req;

#define _AIS_ _account_info_sm

typedef struct {
		u_char      msgLength;
		u_char      msgReserved;
		u_char      msgServiceType;
		u_char      msgDstID[3];
		u_char      msgSrcID[3];
		u_char      msgOperaCode;
        u_char		msisdn[8];
		u_char      balance[4];
		u_char      expired_date[4];
		u_char		endFlag;
} _account_info_sm;

/*
typedef struct {
		u_char 		systemID;
		u_char		subSystemID;
		u_char		timeStamp[4];
		u_char		ledStatus[8];
		u_char		alarm[2];
		u_char		reserved0;
		u_char		extLength;
		u_char		version[3];
		u_char		status;
		u_char		sumOfParameter;
		u_char		systemCapability[4];
        u_char      licensedUser[4];
		u_char		realUserNumber[4];
		char		serialNumber[8];
}_pps_heartbeat;

*/
typedef struct {
		u_char 		systemID;
		u_char		subSystemID;
		u_char		timeStamp[4];
		u_char		ledStatus[8];
		u_char		reserved0;
		u_char		alarm[2];
		u_char		extLength_h;
		u_char		extLength_l;
		u_char		component_id_h;
		u_char		component_id_l;
		u_char		component_len_h;
		u_char		component_len_l;
		u_char		version[3];
		u_char		status;
		u_char		sumOfParameter[4];
              u_char           licensedUser[4];
		u_char		realUserNumber[4];
		u_char		serialNumber[4];
		u_char		systemCapability[4];
}_pps_heartbeat;
#endif  /* MESSAGE__H */ 
