bepcommon.h

来自「基于h323协议的软phone」· C头文件 代码 · 共 443 行

H
443
字号
/************************************************************************
 *
 *    Version %I%
 *
 *       Copyright (C) 2002 By BEP Corporation.
 * This Document Contains Proprietary Information Of BEP Corporation.
 * No Distribution Is Granted Except With Written Permission From
 * BEP Corporation.
 *************************************************************************/
/*
 **
 ** MODULE: common.h
 **
 ** PURPOSE:
 **
 ** LIMITATIONS:
 **
 ** DATE CREATED: 10-27-2003
 **
 ** AUTHOR(S): luozheru
 **
 ** MODIFICATIONS:
 **     userId                  Date            Description
 **
 ** QA Status:
 **      status                   Date             Owner
 **
 */
#ifndef __COMMON_H___
#define __COMMON_H___

#ifdef SIP
#include "sipevent.h"
#endif

#ifdef HC
#include "h323event.h"
#endif

#ifdef MGCP
#include "mgcpevent.h"
#endif

#include "rvwpt.h"
#include "sysdep.h"

#include "configuration.h"
#include "phonerecord.h"
#include "task.h"
#include "pgi_api.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
 *define time for timer
*/
#define ONE_SEC     1 * 1000
#define THREE_SEC   3 * 1000
#define FOUR_SEC    4 * 1000
#define SIX_SEC     6 * 1000
#define TEN_SEC     10 * 1000
#define FIFTEEN_SEC 15 * 1000
#define THIRTY_SEC  30 * 1000
#define ALERTING_SEC 30*1000
#define CONNECT_TIME 90*1000


/* Since the enum LED numbers don't make sense, use these macros: */
#define LED_MSG					23		/* 未接来电指示灯 */
#define LED_SPKR				22		/* 免提指示灯 */
#define LED_MUTE				1		/* 静音指示灯14 */
#define LED_FLASH				0

#define LOCAL_IF  "IPPhone"
#define LOCAL_IF0 "IPPhone0"

#define KEYLAMP_PRIORITY        100

#define MAX_PHONE_BOOK	200
#define MAX_CALL_RECORD	40

#define LENGTH_LOCAL_ID	32

#define BOOT_LINE_SIZE 	255									/* Should match value in prjparams.h! */
#define CONFIG_LOCATION	((BOOT_LINE_SIZE + 1023) & ~1023)	/* Location of configuration items */

#define STEADY_LOCATION  0x21e00000
#define MUTABLE_LOCATION 0x21f00000

#define HTTP_LOGIN_USER	"bep"

typedef enum IfType
{
	IF_TYPE_PPPOE,
	IF_TYPE_NAT
} IfType;

enum FlagTypes {
    FLAG_NORMAL,
    FLAG_TRANSFERRED,
    FLAG_FORWARDED
};

typedef enum errType
{
	MulChoice = 300, /*  ;  Multiple Choices                     */
	MovPer    = 301, /*  ;  Moved Permanently                    */
	MovTemp   = 302, /*  ;  Moved Temporarily                    */
	UsedProxy  = 305, /*  ;  Use Proxy                            */
	AltSer    = 380, /*  ;  Alternative Service                  */

	BadReq    = 400, /*  ;  Bad Request                          */
	Unauth    = 401, /*  ;  Unauthorized                         */
	PayReq    = 402, /*  ;  Payment Required                     */
	Forb      = 403, /*  ;  Forbidden                            */
	NotFound  = 404, /*  ;  Not Found                            */
	MethNAll  = 405, /*  ;  Method Not Allowed                   */
	NotAcc    = 406, /*  ;  Not Acceptable                       */
	ProAuReq  = 407, /*  ;  Proxy Authentication Required        */
	ReqTmOut  = 408, /*  ;  Request Timeout                      */
	Gone      = 410, /*  ;  Gone                                 */
	ReqTooLag = 413, /*  ;  Request Entity Too Large             */
	ReqURL    = 414, /*  ;  Request-URI Too Large                */
	UnsupMed  = 415, /*  ;  Unsupported Media Type               */
	UnsupURI  = 416, /*  ;  Unsupported URI Scheme               */
	BadExt    = 420, /*  ;  Bad Extension                        */
	ExtReq    = 421, /*  ;  Extension Required                   */
	IntTooBrf = 423, /*  ;  Interval Too Brief                   */
	TempMAva  = 480, /*  ;  Temporarily not available            */
	CallNExt  = 481, /*  ;  Call Leg/Transaction Does Not Exist  */
	LoopDet   = 482, /*  ;  Loop Detected                        */
	TooMyHop  = 483, /*  ;  Too Many Hops                        */
	AddIncom  = 484, /*  ;  Address Incomplete                   */
	Ambiguous = 485, /*  ;  Ambiguous                            */
	BusyHere  = 486, /*  ;  Busy Here                            */
	ReqTerm   = 487, /*  ;  Request Terminated                   */
	NotAccH   = 488, /*  ;  Not Acceptable Here                  */
	ReqPend   = 491, /*  ;  Request Pending                      */
	Undec     = 493, /*  ;  Undecipherable                       */

	IntSerErr = 500, /*  ;  Internal Server Error                */
	NotImp    = 501, /*  ;  Not Implemented                      */
	BadGw     = 502, /*  ;  Bad Gateway                          */
	SerUnava  = 503, /*  ;  Service Unavailable                  */
	SerTmOut  = 504, /*  ;  Server Time-out                      */
	SipVerErr = 505, /*  ;  SIP Version not supported            */
	MsgTooLag = 513, /*  ;  Message Too Large                    */

	BusyEvy   = 600, /*  ;  Busy Everywhere                      */
	Decline   = 603, /*  ;  Decline                              */
	DoNotExt  = 604, /*  ;  Does not exist anywhere              */
	GlbNotAcc = 606  /*  ;  Not Acceptable                       */
}ErrType;

/**
* phone config
*/
extern struct s_config phoneconfig;
#ifdef HC
extern unsigned char isReinitStack;
extern unsigned char isRestartAgent;
extern SEM_ID cfgSem;
#endif
extern void LoadDefaultParam();

/**
* define phonebook 
*/
extern struct s_phonebook phonebook[MAX_PHONE_BOOK+1];
extern struct s_callrecord incomingcall[MAX_CALL_RECORD+1]; 
extern struct s_callrecord outgoingcall[MAX_CALL_RECORD+1];
extern struct s_callrecord noanswercall[MAX_CALL_RECORD+1];

/**
 *event for menu process
*/
extern int menu_event;

/**
 *ponit of the wapper message received
*/
extern WrapperMsg * wp_msg;
extern NonWrapperMsg * msg;

/**
 *used by AppTerminateAction for sending BYE message or not
*/
extern int send_bye;

/**
 *
 *used by show string in LCD or not
*/
extern int* menu_inuse;

/*
 * 用于测试按键
 */
extern int IfTestingKey;

/**
 *show mute key is on or off
*/
extern int mute;

/**
 *whether speaker is on
*/
extern int on_speakerphone;

/*  The KLC driver uses these to keep track of the state of the handset and speakerphone. */
extern int handset_up;

/**
 *timer in our system
*/
extern int timer;

/**
 *used by receiving call
*/
extern char remoteName[32+1];
extern char remoteLogin[32];
extern char remoteDomain[32];
extern char remoteNum[32];

extern int PreserveLcdMessage;

extern struct s_task callTask;
extern struct s_task* psMenuTask;

extern unsigned char canStopRingInMenu;

extern unsigned char noAnswerCall;

#ifdef INCLUDE_NAT_APP
extern void natON(IfType type);
extern void natOFF(IfType type);
#endif

/*
 *get SIP error string
 */
int getErrStr(ErrType e, char* errStr, int len);

/*
 *根据电话号码查询名称
 */
int getNameFromPhoneBook(char* phoneNum, char* name, int nameSize);


/*
 * 菜单初始化
 */
extern s_task* InitialMenuTask();

/**
 *for calling out or saving recorder when talking
*/
extern char toAddr[32+1];
extern int num_digits;
extern int digitCollectAmount;
extern int prev_num_digits;
extern int sntp_timer;

/**
 * 初始化话机配置
*/
extern void InitPhoneParam();

/**
 * 保存拨出号码
 * 参数: char *number: 已拨出的号码或IP地址
 * 返回值: int:   执行是否成功,OK or Error
*/
extern int AppRecordOutgoingCall(char * number);

/**
 * 保存未接来电
 * 参数: char *number: 未接来电的号码或IP地址
 * 返回值: int:   执行是否成功,OK or Error
*/
extern int AppRecordNoAnswerCall(char * number);

/**
 * 保存已接来电
 * 参数: char *number: 已接来电的号码或IP地址
 * 返回值: int:   执行是否成功,OK or Error
*/
extern int AppRecordIncomingCall(char * number);

extern int recordIncomingCall();
extern int recordNoanswercall();
extern int recordOutgoingcall();
extern int recordAllCall();
extern int deleteCall(int flag, int index, int maxCallSize);
extern int deletAllCall(int flag);

extern int ConvertChar2Int(char * ipAddr, unsigned int* num);
extern int convertType(int eType);
extern int ConvertChar2CharNum(char* ipAddr, char* digit_set);
extern void ConvertInt2CharNum(char* ipAddr,  unsigned int num, int flag);
extern void LcdLowerShowString(char* msg);
extern void LcdLowerShow(char* msg1, char* msg2);
/*extern void LcdShowDialNum(char* msg);*/
/* LCD显示缺省信息 进程 */
extern void ShowDefaultMessageInLCD();
/* sntp设置 */
extern int ConfigureSntpTime();
/* 模拟按键声音并在LCD上显示号码 */
extern void PlayRedialTone(char* key, int row);
/* 判断何种状态能收集号码,供菜单使用 */ 
extern int CanCollectDigits();
/* 是否可以设置RingVolume、RingType,供菜单使用 */
extern unsigned char  canSetRingInMenu();
/* 发送通话时间到计费服务器 */
extern int sendTimeToBillingServer(char *buf, int size);
extern unsigned char closeNoAnswerCallLed();
void reboot_system();
/**
* 修改HTTP登录密码
* 需要在修改话机密码时调用
*/
void ChangeHttpPwd(char * password);

/**
* 重定向输出得UDP端口
*/
#define OUTPUT_SOCK_PORT	3888
/**
* 保留原先的输出标识符
*/
typedef struct PreFdStruct
{
	char direct;
	int in;
	int out;
	int err;
} PreFdStruct;

extern PreFdStruct preFd;

extern int OutputRedirect();
extern int RestoreOutput();


#ifdef __alpha
typedef unsigned int uint32;
#else
typedef unsigned long uint32;
#endif

struct MD5Context 
{
	uint32 buf[4];
	uint32 bits[2];
	unsigned char in[64];
};

void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, unsigned char const *buf, unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Transform(uint32 buf[4], uint32 const in[16]);

/*
 * This is needed to make RSAREF happy on some MS-DOS compilers.
 */
typedef struct MD5Context MD5_CTX;

typedef struct
{
	char gkMode;
	char gkIp;
	char h323Id;
	char e164;
	char pass;
	char proxy;
}GKConnChange;

/*extern void ChangeGK(GKConnChange* ch);*/

/**
 *used by sip
*/
#ifdef SIP

extern int SipInit();

/**
 *whether REGISTER message is send
*/
extern int register_sent;

/**
 *for redialing
*/
extern char redialAddr[32];


/**
 *for receive invite
*/
extern unsigned receive;
extern char recNum[32];
extern int p2pFlag;

#endif

/**
 *used by h323
*/
#ifdef HC

extern int H323Init();

extern char remoteNumber[MAX_PHONE_NUMBER_LEN+1];

extern int isOnHookState();
#endif



/**
 *used by mgcp
*/
#ifdef MGCP

extern int mgcpInit();

extern char remoteNumber[16];

#endif

#ifdef __cplusplus
}
#endif

#endif

⌨️ 快捷键说明

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