init ems server code
This commit is contained in:
99
plat/mgc/Makefile
Normal file
99
plat/mgc/Makefile
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
##----------------------------------------------------------##
|
||||
## ##
|
||||
## Universal Makefile for module template : V1.6.3 ##
|
||||
## ##
|
||||
## Created : Wei Liu 07/04/11 ##
|
||||
## Revision: [Last]Wei Liu 07/07/07 ##
|
||||
## ##
|
||||
##----------------------------------------------------------##
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## Project correlation(Customer define)
|
||||
##
|
||||
##--------------------------------------
|
||||
|
||||
## MODULE= [Module Name]
|
||||
## TYPE = app/plat => Module Type
|
||||
|
||||
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ]
|
||||
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release]
|
||||
|
||||
## BUILD = lib/exef => Output file format
|
||||
## CFG = debug/release => Build Configuration
|
||||
|
||||
## SRC_PATH = [Source file path]
|
||||
## INC_PATH = [Include file path]
|
||||
## APP_PATH = [App Module path]
|
||||
## PLT_PATH = [Plat Module path]
|
||||
|
||||
## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main
|
||||
## APP_LIB = [Needed app lib for Link] => just for test or wxc2main
|
||||
## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main
|
||||
|
||||
## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \
|
||||
## 8ecp bicc smpp xapp tcap mtp3 m2ua \
|
||||
## snmp iptrans debug sccp public
|
||||
##
|
||||
## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas
|
||||
## LIB_ADD e.g. = -liba3a8 -lm
|
||||
|
||||
## OBJ_ADD = [Extend third party object files needed]
|
||||
## TEST_OBJ_PATH = [module object files Path for test ] => just for test
|
||||
##---------------------------------------------------------------------##
|
||||
|
||||
MODULE = mgc
|
||||
TYPE = plat
|
||||
|
||||
DBUG_FLAGS_ADD =
|
||||
RELS_FLAGS_ADD =
|
||||
|
||||
##Default commonly as below
|
||||
|
||||
BUILD = lib
|
||||
CFG = debug
|
||||
|
||||
|
||||
PLT_LIB =
|
||||
|
||||
APP_LIB =
|
||||
LIB_ADD =
|
||||
|
||||
SRC_PATH = ./src
|
||||
INC_PATH = ./src/include
|
||||
PLT_PATH = ../../plat
|
||||
APP_PATH = ../../app
|
||||
|
||||
OBJ_ADD =
|
||||
TEST_OBJ_PATH =
|
||||
|
||||
PREPROC_CMD =
|
||||
POSTPROC_CMD =
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## Make configuration(Customer define)
|
||||
##
|
||||
##--------------------------------------
|
||||
|
||||
## CCFLAG_SWITCH = on/off => gcc flag show on/off
|
||||
## COVER_NEED = yes/no => PTF cover report needed
|
||||
## COVER_REPORT_PATH = [path ] => PTF cover report path
|
||||
|
||||
CCFLAG_SWITCH = off
|
||||
COVER_NEED = no
|
||||
COVER_REPORT_PATH = ./output
|
||||
MAKE_INCLUDE = $(HOME)/ems.git/include
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
|
||||
|
||||
##--------------------------------------
|
||||
##
|
||||
## include makefile.rules (Do not change)
|
||||
##
|
||||
##--------------------------------------
|
||||
include $(MAKE_INCLUDE)/Makefile.rules
|
||||
251
plat/mgc/src/include/mgc.h
Normal file
251
plat/mgc/src/include/mgc.h
Normal file
@@ -0,0 +1,251 @@
|
||||
#ifndef _MGC__H
|
||||
#define _MGC__H
|
||||
|
||||
#include "../../../public/src/include/pub_sdp.h"
|
||||
#include "../../../mgcp/src/include/mgcp.h"
|
||||
#include "../../../8ecp/src/include/8ecp.h"
|
||||
|
||||
#define MGC_MAX_NUM_OF_SAP 4
|
||||
#define MGC_MAX_USER_NAME_LEN 8
|
||||
#define MGC_MAX_DOMAIN_LEN 64
|
||||
#define MGC_MAX_PHY_PORT_PER_MG 32
|
||||
|
||||
#define MGC_USER_TYPE_MGC 0
|
||||
#define MGC_USER_TYPE_MG 1
|
||||
|
||||
#define MGC_MAX_NUM_OF_MG 1024
|
||||
#define MGC_MAX_NUM_OF_PHY_PORT 1024
|
||||
#define MGC_MAX_NUM_OF_CHNL 9424
|
||||
#define MGC_MAX_NUM_OF_PORT 8192
|
||||
|
||||
#define MGC_MAX_NUM_OF_AAS_MGC 4
|
||||
|
||||
#define MGC_MG_TYPE_INTERNAL 0
|
||||
#define MGC_MG_TYPE_AudioCoder 1
|
||||
#define MGC_MG_TYPE_LGC_MG 2
|
||||
#define MGC_MG_TYPE_SSW_CSS 3
|
||||
#define MGC_MG_TYPE_IPBSS 4
|
||||
#define MGC_MG_TYPE_ANALOG 11
|
||||
#define MGC_MG_TYPE_ANN 21
|
||||
|
||||
#define MGC_PHY_PORT_TYPE_E1 1
|
||||
#define MGC_PHY_PORT_TYPE_T1 2
|
||||
#define MGC_PHY_PORT_TYPE_ANALOG 3
|
||||
|
||||
#define MGC_MG_CTRL_TYPE_MGCP 0
|
||||
#define MGC_MG_CTRL_TYPE_8ECP 1
|
||||
|
||||
#define MGC_MEDIA_ATTR_EC_FLAG 0x01
|
||||
#define MGC_MEDIA_ATTR_SS_FLAG 0x02
|
||||
#define MGC_MEDIA_ATTR_VT_FLAG 0x04
|
||||
|
||||
#define MGC_OPER_ID_CONNECT_CHNL 1
|
||||
#define MGC_OPER_ID_CONNECT_DTMF 2
|
||||
#define MGC_OPER_ID_CONNECT_TONE 3
|
||||
#define MGC_OPER_ID_CRCX 4
|
||||
#define MGC_OPER_ID_MDCX 5
|
||||
#define MGC_OPER_ID_DLCX 6
|
||||
#define MGC_OPER_ID_RQNT 7
|
||||
#define MGC_OPER_ID_AUEP 8
|
||||
#define MGC_OPER_ID_CONNECT_AAS 9
|
||||
|
||||
#define MGC_OPER_FAILURE 0
|
||||
#define MGC_OPER_SUCCESS 1
|
||||
|
||||
#define MGC_VCTYPE_MAX 13
|
||||
#define MGC_VCTYPE_MAX_1 12
|
||||
|
||||
#define MGC_VCTYPE_PCMA 0
|
||||
#define MGC_VCTYPE_PCMU 1
|
||||
#define MGC_VCTYPE_GSM 2
|
||||
#define MGC_VCTYPE_GSM_EFR 3
|
||||
#define MGC_VCTYPE_AMR_12_2 4
|
||||
#define MGC_VCTYPE_G729B 5
|
||||
#define MGC_VCTYPE_AMR_10_2 6
|
||||
#define MGC_VCTYPE_AMR_7_95 7
|
||||
#define MGC_VCTYPE_AMR_7_4 8
|
||||
#define MGC_VCTYPE_AMR_6_7 9
|
||||
#define MGC_VCTYPE_AMR_5_15 10
|
||||
#define MGC_VCTYPE_AMR_5_9 11
|
||||
#define MGC_VCTYPE_AMR_4_75 12
|
||||
|
||||
|
||||
|
||||
#define MGC_MEDIA_PARA_FLAG_EC 0x0001
|
||||
#define MGC_MEDIA_PARA_FLAG_SS 0x0002
|
||||
#define MGC_MEDIA_PARA_FLAG_VT 0x0004
|
||||
#define MGC_MEDIA_PARA_FLAG_CM 0x0008
|
||||
#define MGC_MEDIA_PARA_FLAG_PT 0x0010
|
||||
|
||||
#define MGC_MAX_NUM_OF_CODEC 16
|
||||
|
||||
#define MGC_HOLD_MUSIC 7
|
||||
#define MGC_TONE_RING 8
|
||||
#define MGC_TONE_BUSY 9
|
||||
#define MGC_TONE_WARN 10
|
||||
|
||||
#define MGC_CONNECT_SILENT_TONE 0x01
|
||||
|
||||
#define MGC_MG_NETWORK_PORT 4967
|
||||
#define MGC_MGC_NETWORK_PORT 4966
|
||||
|
||||
|
||||
#define MGC_CONNECT_STATUS_IDLE 0
|
||||
#define MGC_CONNECT_STATUS_CREATING 1
|
||||
#define MGC_CONNECT_STATUS_CREATED 2
|
||||
#define MGC_CONNECT_STATUS_TONE 3
|
||||
|
||||
typedef enum{
|
||||
MGC_DTMF_1 = 1,
|
||||
MGC_DTMF_2 = 2,
|
||||
MGC_DTMF_3 = 3,
|
||||
MGC_DTMF_4 = 4,
|
||||
MGC_DTMF_5 = 5,
|
||||
MGC_DTMF_6 = 6,
|
||||
MGC_DTMF_7 = 7,
|
||||
MGC_DTMF_8 = 8,
|
||||
MGC_DTMF_9 = 9,
|
||||
MGC_DTMF_0 = 10,
|
||||
MGC_DTMF_START = 11,
|
||||
MGC_DTMF_POUND = 12
|
||||
}MGC_DTMF_DEF;
|
||||
|
||||
typedef enum{
|
||||
MGC_PKG_L = 0,
|
||||
MGC_PKG_D = 1,
|
||||
MGC_PKG_G = 2
|
||||
}MGC_PKG_TYPE;
|
||||
|
||||
typedef struct _OPER_REC
|
||||
{
|
||||
BYTE operaId;
|
||||
BYTE tone;
|
||||
WORD duration;
|
||||
WORD times;
|
||||
}OPER_REC;
|
||||
|
||||
typedef struct _CHNL
|
||||
{
|
||||
WORD mgNo; // mg No.
|
||||
BYTE portNo; // local physical port No. of that mg
|
||||
WORD chlNo; // local channel No. of that trunk
|
||||
WORD connectNo;
|
||||
}CHNL;
|
||||
|
||||
typedef struct _MGC_CODEC_LIST
|
||||
{
|
||||
BYTE num; // num of codecs
|
||||
WORD priority; // priority level, used when comparing different codec list
|
||||
BYTE codec[MGC_MAX_NUM_OF_CODEC]; // codec ID number, high priority codec first
|
||||
}MGC_CODEC_LIST;
|
||||
|
||||
typedef struct _MEDIA_PARA
|
||||
{
|
||||
WORD flag; // which media attribute is affected
|
||||
BYTE ecDisable; // echo canceller disable or enable
|
||||
BYTE ssDisable; // silence suppression disable or enable;
|
||||
BYTE conMode; // connect mode
|
||||
BYTE ptime; // packetization period
|
||||
MGC_CODEC_LIST vocoderType; // vocoder type
|
||||
}MEDIA_PARA;
|
||||
|
||||
typedef struct _MG_ATTR
|
||||
{
|
||||
BYTE ptime; // ptime, in ms
|
||||
BYTE mgType; // non-virtual/ann
|
||||
BYTE ctrlType; // 8ecp or mgcp
|
||||
BYTE epDes; // endpoint description method: structured or unstructured
|
||||
BYTE toneCap; // Tone generation capability
|
||||
BYTE maxPorts; // maximum physical ports of this MG
|
||||
WORD maxChnls; // maximum channels of this MG, only applicable to virtual MG.
|
||||
DWORD ip; // IP address of the MG
|
||||
char domain[MGC_MAX_DOMAIN_LEN]; // domain name of the mg
|
||||
BYTE e1cardNo;
|
||||
DWORD auditTimer;
|
||||
|
||||
MGC_CODEC_LIST codecList; // list of codecs that the MG supports
|
||||
}MG_ATTR;
|
||||
|
||||
typedef struct _MEDIA_ATTR
|
||||
{
|
||||
BYTE ecDisable; // echo canceller disable or enable
|
||||
BYTE ssDisable; // silence suppression disable or enable
|
||||
BYTE vocoderType; // vocoder type
|
||||
BYTE conMode; // connect mode
|
||||
char callId[33]; // call Id
|
||||
char conId[33]; // connection id
|
||||
BYTE ptime; // packetization period
|
||||
WORD pkgEvent; // package + event
|
||||
WORD pkgSignal; // package + signal
|
||||
WORD pkgReq; //package+req
|
||||
WORD restMode; // restart mode
|
||||
WORD restDelay; // restart delay
|
||||
|
||||
PUB_SDP_MSG sdp; // media info of this channel
|
||||
}MEDIA_ATTR;
|
||||
|
||||
typedef struct _EVENT
|
||||
{
|
||||
BYTE pkg; // package name
|
||||
BYTE event; // event name
|
||||
}EVENT;
|
||||
|
||||
typedef struct _SIGNAL
|
||||
{
|
||||
BYTE pkg; // package name
|
||||
BYTE signal; // signal name
|
||||
}SIGNAL;
|
||||
|
||||
typedef struct _MGC_SAP
|
||||
{
|
||||
char usrName[MGC_MAX_USER_NAME_LEN]; // user name
|
||||
BYTE usrType; // user acts as a mg or mgc
|
||||
|
||||
// callback function registration - indication
|
||||
int (*mgc_ind)(CHNL chnl, BYTE cmd, WORD *usrPort, WORD mgcPort, MEDIA_ATTR *mediaAttr);
|
||||
|
||||
// callback function registration - confirmation
|
||||
int (*mgc_cnf)(WORD usrPort, WORD mgcPort, BYTE operId, BYTE success, WORD cause);
|
||||
}MGC_SAP;
|
||||
|
||||
int mgc_bind(MGC_SAP *sap);
|
||||
int mgc_unbind(MGC_SAP *sap, BYTE sapIndex);
|
||||
|
||||
int mgc_crcx_chnl(WORD usrPort, CHNL chnl);
|
||||
int mgc_dlcx_chnl(WORD usrPort, CHNL chnl);
|
||||
int mgc_mdcx_chnl(WORD usrPort, CHNL chnl, MEDIA_PARA *mediaPara, BYTE sdFlag);
|
||||
int mgc_recvonly_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl);
|
||||
int mgc_rqnt_chnl(WORD usrPort, CHNL chnl, EVENT *event, SIGNAL *signal);
|
||||
int mgc_auep_chnl(WORD usrPort, CHNL chnl);
|
||||
|
||||
int mgc_connect_chnl(WORD usrPort, CHNL orgChnl, CHNL destChnl, BYTE flag);
|
||||
int mgc_connect_dtmf(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE dtmfNo);
|
||||
int mgc_connect_tone(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration);
|
||||
int mgc_connect_AAS(WORD usrPort, CHNL orgChnl, CHNL dstChnl, BYTE toneNo, WORD duration, WORD times);
|
||||
|
||||
int mgc_create_MG(BYTE sapIndex, MG_ATTR *mgAttr);
|
||||
int mgc_delete_MG(BYTE sapIndex, WORD mgNo);
|
||||
int mgc_modify_MG(BYTE sapIndex, WORD mgNo, MG_ATTR *mgAttr);
|
||||
|
||||
int mgc_add_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType);
|
||||
int mgc_delete_port(BYTE sapIndex, WORD mgNo, BYTE portNo);
|
||||
int mgc_modify_port(BYTE sapIndex, WORD mgNo, BYTE portNo, BYTE portType);
|
||||
|
||||
int mgc_query_mg_status(WORD mgNo);
|
||||
int mgc_query_port_status(WORD mgNo, BYTE portNo);
|
||||
int mgc_query_channel_status(CHNL chnl);
|
||||
|
||||
int mgc_create_virtual_chnl(WORD port, CHNL *chnl);
|
||||
int mgc_release_virtual_chnl(WORD port, CHNL chnl);
|
||||
|
||||
int mgc_query_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG **mediaInfo, BYTE *mgPayloads, BYTE *mgPlNum);
|
||||
int mgc_update_chnl_media(WORD port, CHNL chnl, PUB_SDP_MSG *mediaInfo);
|
||||
|
||||
int mgc_license_ctrl(WORD maxMgNum, WORD maxChnlNum);
|
||||
|
||||
int mgc_rsp(BYTE cmd, WORD usrPort, WORD port, WORD retCode, MEDIA_ATTR *mediaAttr);
|
||||
|
||||
int mgc_chnl_codec_update(CHNL chnl , MGC_CODEC_LIST codecList);
|
||||
int mgc_query_chnl_status(CHNL chnl);
|
||||
OPER_REC *mgc_query_chnl_oper_rec(CHNL chnl);
|
||||
#endif
|
||||
75
plat/mgc/src/include/mgc_const.h
Normal file
75
plat/mgc/src/include/mgc_const.h
Normal file
@@ -0,0 +1,75 @@
|
||||
#ifndef _MGC_CONST__H
|
||||
#define _MGC_CONST__H
|
||||
|
||||
#define MGC_MAX_OPER_STEPS_NUM 8
|
||||
|
||||
#define MGC_MGCF_STATE_REQUEST 1
|
||||
#define MGC_MGCF_STATE_INDICATION 2
|
||||
#define MGC_MGCF_STATE_INIT 3
|
||||
|
||||
#define MGC_MGCF_TIMER_50MS 5
|
||||
#define MGC_MGCF_TIMER_1S 100
|
||||
#define MGC_MGCF_TIMER_10S 10 * MGC_MGCF_TIMER_1S
|
||||
#define MGC_MGCF_TIMER_20S 20 * MGC_MGCF_TIMER_1S
|
||||
#define MGC_MGCF_TIMER_1H 3600 * MGC_MGCF_TIMER_1S
|
||||
|
||||
#define MGC_CHNL_START_DS 0
|
||||
#define MGC_CHNL_START_INTERNAL 8192
|
||||
#define MGC_CHNL_START_ANN 9216
|
||||
#define MGC_CHNL_START_MSS 9256
|
||||
#define MGC_CHNL_START_AALN 9416
|
||||
|
||||
#define MGC_CHNL_NUM_INTERNAL 1024
|
||||
#define MGC_CHNL_NUM_ANN 200
|
||||
//#define MGC_CHNL_NUM_MSS 4
|
||||
#define MGC_CHNL_NUM_AALN 8
|
||||
#define MGC_CHNL_NUM_DS_TOTAL 8192
|
||||
|
||||
#define MGC_CHNL_NUM_INTERNAL_PER_PORT 1
|
||||
#define MGC_CHNL_NUM_AALN_PER_PORT 1
|
||||
#define MGC_CHNL_NUM_ANN_PER_TYPE 40
|
||||
#define MGC_CHNL_NUM_DS_PER_PORT 32
|
||||
|
||||
#define MGC_MNG_CMD_IDLE 0
|
||||
#define MGC_MNG_CMD_REMOVE_CHNL 1
|
||||
#define MGC_MNG_CMD_OVERWRITE 2
|
||||
#define MGC_MNG_CMD_CLEAR_AFTER_OPER 3
|
||||
|
||||
#define MGC_CHNL_STATUS_IDLE 0
|
||||
#define MGC_CHNL_STATUS_CREATING 1
|
||||
#define MGC_CHNL_STATUS_CREATED 2
|
||||
|
||||
|
||||
#define MGC_INTERNAL_VIRTUAL_MG 0
|
||||
#define MGC_8ECP_MG_OFFSET 1
|
||||
#define MGC_8ECP_MAX_TRK_PER_MG 8
|
||||
|
||||
#define MGC_MAX_NUM_OF_CHNL_CON 512
|
||||
#define MGC_MAX_NUM_OF_CON 8192
|
||||
|
||||
#define MGC_MGCP_MGC_PORT 2727
|
||||
#define MGC_MGCP_MG_PORT 2427
|
||||
|
||||
#define MGC_MAX_ASCIIIN_LEN 4096
|
||||
#define MGC_MAX_ASCIIOUT_LEN 4096
|
||||
#define MGC_MAX_ASCITMP_LEN 4096
|
||||
|
||||
#define MGC_MONITOR_NONE 0x0000
|
||||
#define MGC_MONITOR_ERROR 0x0010
|
||||
#define MGC_MONITOR_ALL 0xffff
|
||||
|
||||
#define MGC_CHNL_CLEAR_PORT 0
|
||||
#define MGC_CHNL_SAVE_PORT 1
|
||||
|
||||
#define MGC_MAX_TONE_NO 16
|
||||
|
||||
//#define MGC_8K_TONE_CHNL_SILENT (0 * 8 + 7) * 32 + 31
|
||||
|
||||
#define MGC_PKG_SIG_G_RT ((MGCP_PKG_G << 8) | MGCP_G_SIG_RT)
|
||||
#define MGC_PKG_SIG_L_BZ ((MGCP_PKG_L << 8) | MGCP_L_SIG_BZ)
|
||||
#define MGC_PKG_SIG_L_WT ((MGCP_PKG_L << 8) | MGCP_L_SIG_WT)
|
||||
|
||||
#define MGC_CHNL_AUEP_IDLE 0
|
||||
#define MGC_CHNL_AUEP_IN_PROGRESS 1
|
||||
|
||||
#endif
|
||||
11
plat/mgc/src/include/mgc_debug.h
Normal file
11
plat/mgc/src/include/mgc_debug.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _MGC_DEBUG__H
|
||||
#define _MGC_DEBUG__H
|
||||
|
||||
void mgc_mon(void);
|
||||
int mgc_debug_set(void);
|
||||
int mgc_asciout_proc(BYTE *out_str);
|
||||
int mgc_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc);
|
||||
int mgc_log_err(char *err_msg);
|
||||
int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg);
|
||||
|
||||
#endif
|
||||
74
plat/mgc/src/include/mgc_def.h
Normal file
74
plat/mgc/src/include/mgc_def.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#ifndef _MGC_DEF__H
|
||||
#define _MGC_DEF__H
|
||||
|
||||
#include "mgc_pub.h"
|
||||
#include "mgc.h"
|
||||
#include "mgc_const.h"
|
||||
#include "mgc_struct.h"
|
||||
|
||||
DWORD sysID;
|
||||
DWORD localIP;
|
||||
DWORD peerIP;
|
||||
|
||||
_8ECP_SAP mgc8ecpSap;
|
||||
MGCP_SAP mgcMgcpSap;
|
||||
int mgc8ecpSapIndex;
|
||||
int mgcMgcpSapIndex;
|
||||
MGC_SAP mgcSap[MGC_MAX_NUM_OF_SAP];
|
||||
|
||||
WORD mgcSelectPort;
|
||||
WORD mgc_select_connection;
|
||||
WORD mgc_select_ass_mgc_mgNo;
|
||||
|
||||
WORD mgc_e1card0_mgNo;
|
||||
WORD mgc_e1card1_mgNo;
|
||||
|
||||
WORD mgc_aas_mgNo[MGC_MAX_NUM_OF_AAS_MGC];
|
||||
|
||||
WORD mgc_8k_tone_card_silent;
|
||||
|
||||
MG_INFO mgcMgInfo[MGC_MAX_NUM_OF_MG];
|
||||
PHY_PORT_INFO mgcPhyPort[MGC_MAX_NUM_OF_PHY_PORT];
|
||||
CHNL_INFO mgcChnl[MGC_MAX_NUM_OF_CHNL];
|
||||
PORT_INFO mgcPort[MGC_MAX_NUM_OF_PORT];
|
||||
|
||||
MGCP_PARA mgcMgcpPara;
|
||||
|
||||
CONNECT_INFO mgcConnectInfo[MGC_MAX_NUM_OF_CON];
|
||||
|
||||
WORD mgcMaxMgNo;
|
||||
WORD mgcMaxChlNo;
|
||||
|
||||
WORD mgcMgCreated;
|
||||
WORD mgcChlAssigned;
|
||||
|
||||
char vcName[MGC_VCTYPE_MAX][16];
|
||||
|
||||
const BYTE MGC_AC_LINE_STATUS_IDLEN = 12;
|
||||
|
||||
DWORD MGC_AC_LINE_STATUS_OID[20] =
|
||||
{
|
||||
1,3,6,1,2,1,10,18,6,1,10,0
|
||||
};
|
||||
|
||||
const BYTE MGC_LGC_MG_STATUS_IDLEN = 13;
|
||||
|
||||
DWORD MGC_LGC_MG_STATUS_OID[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,2,2,30,2,1,0
|
||||
};
|
||||
|
||||
BYTE mgcAsciInBuf[MGC_MAX_ASCIIIN_LEN];
|
||||
BYTE mgcAsciOutBuf[MGC_MAX_ASCIIOUT_LEN];
|
||||
BYTE mgcAsciTempBuf[MGC_MAX_ASCITMP_LEN];
|
||||
WORD mgcMonitorFg;
|
||||
|
||||
const WORD MGC_TONE_NO_TO_PKG_SIG[16] =
|
||||
{
|
||||
MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ,
|
||||
MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ,
|
||||
MGC_PKG_SIG_G_RT, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_WT,
|
||||
MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ, MGC_PKG_SIG_L_BZ
|
||||
};
|
||||
|
||||
#endif
|
||||
39
plat/mgc/src/include/mgc_ext.h
Normal file
39
plat/mgc/src/include/mgc_ext.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef _MGC_EXT__H
|
||||
#define _MGC_EXT__H
|
||||
|
||||
#include "mgc_pub.h"
|
||||
#include "mgc.h"
|
||||
#include "mgc_const.h"
|
||||
#include "mgc_struct.h"
|
||||
|
||||
extern _8ECP_SAP mgc8ecpSap;
|
||||
extern MGCP_SAP mgcMgcpSap;
|
||||
extern int mgc8ecpSapIndex;
|
||||
extern int mgcMgcpSapIndex;
|
||||
extern MGC_SAP mgcSap[MGC_MAX_NUM_OF_SAP];
|
||||
|
||||
extern MG_INFO mgcMgInfo[MGC_MAX_NUM_OF_MG];
|
||||
extern PHY_PORT_INFO mgcPhyPort[MGC_MAX_NUM_OF_PHY_PORT];
|
||||
extern CHNL_INFO mgcChnl[MGC_MAX_NUM_OF_CHNL];
|
||||
extern PORT_INFO mgcPort[MGC_MAX_NUM_OF_PORT];
|
||||
|
||||
extern MGCP_PARA mgcMgcpPara;
|
||||
|
||||
extern WORD mgcMaxMgNo;
|
||||
extern WORD mgcMaxChlNo;
|
||||
|
||||
extern WORD mgcMgCreated;
|
||||
extern WORD mgcChlAssigned;
|
||||
|
||||
extern CONNECT_INFO mgcConnectInfo[MGC_MAX_NUM_OF_CON];
|
||||
|
||||
extern char vcName[MGC_VCTYPE_MAX][16];
|
||||
|
||||
extern BYTE mgcAsciInBuf[MGC_MAX_ASCIIIN_LEN];
|
||||
extern BYTE mgcAsciOutBuf[MGC_MAX_ASCIIOUT_LEN];
|
||||
extern BYTE mgcAsciTempBuf[MGC_MAX_ASCITMP_LEN];
|
||||
extern WORD mgcMonitorFg;
|
||||
|
||||
extern const WORD MGC_TONE_NO_TO_PKG_SIG[16];
|
||||
|
||||
#endif
|
||||
11
plat/mgc/src/include/mgc_fsm.h
Normal file
11
plat/mgc/src/include/mgc_fsm.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef _MGC_FSM__H
|
||||
#define _MGC_FSM__H
|
||||
|
||||
#include "mgc_pub.h"
|
||||
#include "mgc.h"
|
||||
#include "mgc_const.h"
|
||||
#include "mgc_struct.h"
|
||||
|
||||
void mgc_fsm(WORD port);
|
||||
|
||||
#endif
|
||||
7
plat/mgc/src/include/mgc_pub.h
Normal file
7
plat/mgc/src/include/mgc_pub.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef _MGC_PUB__H
|
||||
#define _MGC_PUB__H
|
||||
|
||||
#include "../../../public/src/include/includes.h"
|
||||
#include "../../../public/src/include/public.h"
|
||||
|
||||
#endif
|
||||
40
plat/mgc/src/include/mgc_sess_ctl.h
Normal file
40
plat/mgc/src/include/mgc_sess_ctl.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _MGC_SESS_CTL_H
|
||||
#define _MGC_SESS_CTL_H
|
||||
#include "mgc_pub.h"
|
||||
#include "mgc.h"
|
||||
#include "mgc_const.h"
|
||||
#include "mgc_ext.h"
|
||||
#include "mgc_struct.h"
|
||||
#include "mgc_debug.h"
|
||||
|
||||
#define MGC_SESS_RECORD 8192
|
||||
#define MGC_SDP_IPADDR_LEN 35
|
||||
typedef struct _MGC_SDP_TAG
|
||||
{
|
||||
PUB_SDP_MEDIA m;
|
||||
PUB_SDP_C c;
|
||||
BYTE mode;
|
||||
}MGC_SDP_TAG;
|
||||
|
||||
typedef enum{
|
||||
MGC_SESS_STATUS_UNDEF =-1,
|
||||
MGC_SESS_STATUS_IDLE,
|
||||
MGC_SESS_STATUS_USED
|
||||
}MGC_SESS_STATUS;
|
||||
|
||||
typedef struct _MGC_SESS_REC
|
||||
{
|
||||
int id;
|
||||
MGC_SESS_STATUS status;
|
||||
CHNL chnl;
|
||||
MGC_SDP_TAG sdpTag;
|
||||
}MGC_SESS_REC;
|
||||
|
||||
void mgc_sess_init(void);
|
||||
void mgc_sess_rec_init(MGC_SESS_REC *pSess , int id);
|
||||
MGC_SESS_REC *mgc_sess_is_already_rec(CHNL chnl);
|
||||
BOOL mgc_sess_rec_org_and_dst_chnl(CHNL orgChnl , CHNL destChnl);
|
||||
BOOL mgc_sess_is_chnl_need_update(CHNL chnl, MGCP_PARA *pPara);
|
||||
|
||||
#endif
|
||||
|
||||
114
plat/mgc/src/include/mgc_struct.h
Normal file
114
plat/mgc/src/include/mgc_struct.h
Normal file
@@ -0,0 +1,114 @@
|
||||
#ifndef _MGC_STRUCT__H
|
||||
#define _MGC_STRUCT__H
|
||||
|
||||
#include "mgc.h"
|
||||
#include "mgc_const.h"
|
||||
|
||||
typedef struct _MG_INFO
|
||||
{
|
||||
BYTE created; // created flag;
|
||||
BYTE status; // MG status: available/unavailable
|
||||
BYTE stLast; // MG status last: available/unavailable
|
||||
BYTE monFlag;
|
||||
BYTE usrType; // user acts as a mg or mgc
|
||||
DWORD auditTimer;
|
||||
|
||||
MG_ATTR mgAttr; // MG attributes
|
||||
|
||||
// number and index of the ports created on this MG, not applicable to virtual MG
|
||||
BYTE portNum;
|
||||
WORD portIndex[MGC_MAX_PHY_PORT_PER_MG];// max 32 physical ports per MG
|
||||
|
||||
// number and starting index of the channel created on this MG, only applicable to virtual MG
|
||||
WORD chnlNum;
|
||||
WORD chnlStartIndex;
|
||||
BYTE sapIndex[MGC_MAX_NUM_OF_SAP];
|
||||
|
||||
DWORD requestId; // SNMP request id
|
||||
}MG_INFO;
|
||||
|
||||
typedef struct _PHY_PORT_INFO
|
||||
{
|
||||
BYTE created; // created flag
|
||||
BYTE mgNo; // mg No. this port resides on
|
||||
BYTE portNo; // mg local physical port No.
|
||||
BYTE portType; // port type: E1/T1/analogue
|
||||
BYTE sapIndex; // sap index, indicating which user creates this port
|
||||
BYTE phyStatus; // physical port status: online/offline
|
||||
BYTE stLast; // physical port status: online/offline
|
||||
BYTE monFlag;
|
||||
|
||||
// number and starting index of the channel created on this port, not applicable to virtual MG
|
||||
BYTE chnlNum; // depend on mg type
|
||||
WORD chnlStartIndex;
|
||||
}PHY_PORT_INFO;
|
||||
|
||||
typedef struct _CHNL_INFO
|
||||
{
|
||||
BYTE assigned; // assigned flag
|
||||
BYTE mgNo; // mg No. this channel resides on
|
||||
BYTE portNo; // mg local physical port No., not applicable to virtual MG
|
||||
BYTE status; // connection status, created or not
|
||||
WORD port; // which port is in handling this channel
|
||||
BYTE sapIndex; // sap index, indicating which user creates this channel, applicable for ANN MG
|
||||
BYTE monFlag; // monitor flag
|
||||
BYTE auepSt; // AUEP status
|
||||
WORD connectNum;
|
||||
|
||||
WORD connectIndex[MGC_MAX_NUM_OF_CHNL_CON]; //Media Index
|
||||
MEDIA_ATTR comMediaAttr;
|
||||
|
||||
|
||||
// MGC_CODEC_LIST codecList; // list of codecs that this channel may negotiate with other channel
|
||||
// MEDIA_ATTR mediaAttr; // media info of this channel
|
||||
}CHNL_INFO;
|
||||
|
||||
typedef struct _CONNECT_INFO
|
||||
{
|
||||
BYTE assigned;
|
||||
WORD chlIndex;
|
||||
WORD port; // which port is in handling this connection
|
||||
BYTE status;
|
||||
CHNL aasChnl;
|
||||
DWORD flag;
|
||||
|
||||
MGC_CODEC_LIST codecList;
|
||||
MEDIA_ATTR mediaAttr;
|
||||
OPER_REC operRec;
|
||||
}CONNECT_INFO;
|
||||
|
||||
typedef struct _MGCF_OPER_STEP
|
||||
{
|
||||
CHNL localChnl; // local channel to be operated, mandatory
|
||||
CHNL remChnl; // remote channel to be operated, optional
|
||||
BYTE cmd; // operation command
|
||||
DWORD delay; // delay after the operation
|
||||
WORD pkgSignal; // package + signal
|
||||
MEDIA_PARA media; // media para
|
||||
|
||||
WORD chnlConnectIndex; //chnl connectIndex
|
||||
|
||||
WORD flag;
|
||||
}MGCF_OPER_STEP;
|
||||
|
||||
typedef struct _PORT_INFO
|
||||
{
|
||||
BYTE assigned;
|
||||
BYTE mgcfState; // mgcf state
|
||||
BYTE mgcfState2; // mgcf state2
|
||||
WORD mgcfTimer; // mgcf timer
|
||||
CHNL mgcfChnl; // current operation channel
|
||||
WORD usrPort; // user port
|
||||
WORD llPort; // lower layer port
|
||||
WORD usrCmd; // user command or response
|
||||
WORD llCmd; // lower layer command or response
|
||||
BYTE mngCmd; // management commmand
|
||||
DWORD ip;
|
||||
|
||||
BYTE mgcfOperId;
|
||||
BYTE mgcfOperStepsNum; // total number of operation steps
|
||||
BYTE mgcfOperStepIndex; // current operation step index
|
||||
MGCF_OPER_STEP mgcfOperSteps[MGC_MAX_OPER_STEPS_NUM]; // max 8 steps
|
||||
}PORT_INFO;
|
||||
|
||||
#endif
|
||||
4697
plat/mgc/src/mgc.c
Normal file
4697
plat/mgc/src/mgc.c
Normal file
File diff suppressed because it is too large
Load Diff
478
plat/mgc/src/mgc_debug.c
Normal file
478
plat/mgc/src/mgc_debug.c
Normal file
@@ -0,0 +1,478 @@
|
||||
#include "./include/mgc_pub.h"
|
||||
#include "./include/mgc.h"
|
||||
#include "./include/mgc_const.h"
|
||||
#include "./include/mgc_struct.h"
|
||||
#include "./include/mgc_ext.h"
|
||||
#include "./include/mgc_debug.h"
|
||||
#include "../../debug/src/include/debug.h"
|
||||
|
||||
#define MGC_DEBUG_ID 18
|
||||
#define MGC_VER_DEBUG "R9V0_07"
|
||||
|
||||
static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
|
||||
|
||||
static BYTE log_help[] = {
|
||||
"MGC Debug Monitor Help:\n\r\
|
||||
\n\r\
|
||||
1.[help] display help menu\n\r\
|
||||
2.[log all/none] display all/none logs\n\r\
|
||||
3.[log error on/off] display error logs \n\r\
|
||||
4.[log mg-xxxx on/off] display mg logs \n\r\
|
||||
5.[log port-xxxx-xxx on/off] display port logs \n\r\
|
||||
6.[log chnl-xxxx-xxx-xxxx on/off] display chnl logs\n\r\n\r"
|
||||
};
|
||||
|
||||
static WORD disp_page[10];
|
||||
static BYTE *disp_ptr = (BYTE *) disp_page;
|
||||
|
||||
static DWORD debug_status_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1
|
||||
};
|
||||
|
||||
static BYTE debug_status = 1;
|
||||
|
||||
static DWORD debug_name_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,2
|
||||
};
|
||||
|
||||
static DWORD debug_ascin_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,3
|
||||
};
|
||||
|
||||
static DWORD debug_ascout_id[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,4
|
||||
};
|
||||
|
||||
static DWORD debug_page_title[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,1
|
||||
};
|
||||
|
||||
static DWORD debug_page_line[20] =
|
||||
{
|
||||
1,3,6,1,4,1,1373,1,1,2,3,1,2,MGC_DEBUG_ID + 2,1,2,1
|
||||
};
|
||||
|
||||
const static BYTE MGC_BASE_ID_LEN = 15;
|
||||
const static BYTE MGC_PAGE_POINT = 14;
|
||||
const static BYTE MGC_LINE_POINT = 15;
|
||||
|
||||
static BYTE title1_p[] =
|
||||
{
|
||||
" MGC Page 01 MG Info\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
Subpage\n\r\
|
||||
MG_Info\n\r"
|
||||
};
|
||||
|
||||
static BYTE title2_p[] =
|
||||
{
|
||||
" MGC Page 02 Phy Port Info\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
Subpage\n\r\
|
||||
Phy_Port\n\r"
|
||||
};
|
||||
|
||||
static BYTE title3_p[] =
|
||||
{
|
||||
" MGC Page 03 Channel Info\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
Subpage\n\r\
|
||||
Chnl_Info\n\r"
|
||||
};
|
||||
|
||||
static BYTE title4_p[] =
|
||||
{
|
||||
" MGC Page 04 Port Info\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
Port_Info\n\r"
|
||||
};
|
||||
|
||||
BYTE mgc_disp_line(BYTE page, BYTE line)
|
||||
{
|
||||
BYTE disp_length;
|
||||
|
||||
disp_length = 16;
|
||||
disp_ptr = (BYTE *) disp_page;
|
||||
|
||||
switch (page)
|
||||
{
|
||||
case 1: // Page 1: MG Info
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (BYTE *) &disp_page[page];
|
||||
disp_length = 2;
|
||||
}
|
||||
else
|
||||
disp_ptr = (BYTE *) mgcMgInfo + disp_page[page] * sizeof(MG_INFO) + (line - 1) * 16;
|
||||
break;
|
||||
case 2: // Page 2: Phy Port Info
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (BYTE *) &disp_page[page];
|
||||
disp_length = 2;
|
||||
}
|
||||
else
|
||||
disp_ptr = (BYTE *) mgcPhyPort + disp_page[page] * sizeof(PHY_PORT_INFO) + (line - 1) * 16;
|
||||
break;
|
||||
case 3: // Page 3: Channel Info
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (BYTE *) &disp_page[page];
|
||||
disp_length = 2;
|
||||
}
|
||||
else
|
||||
disp_ptr = (BYTE *) mgcChnl + disp_page[page] * sizeof(CHNL_INFO) + (line - 1) * 16;
|
||||
break;
|
||||
case 4: // Page 4: Software Port Info
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (BYTE *) &disp_page[page];
|
||||
disp_length = 2;
|
||||
}
|
||||
else
|
||||
disp_ptr = (BYTE *) mgcPort + disp_page[page] * sizeof(PORT_INFO) + (line - 1) * 16;
|
||||
break;
|
||||
default:
|
||||
disp_length = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return disp_length;
|
||||
}
|
||||
|
||||
void mgc_disp_page(BYTE page)
|
||||
{
|
||||
BYTE disp_line;
|
||||
BYTE disp_length;
|
||||
|
||||
debug_page_line[MGC_PAGE_POINT] = page + 5;
|
||||
|
||||
for (disp_line = 0; disp_line < 22; disp_line++)
|
||||
{
|
||||
disp_length = mgc_disp_line(page, disp_line);
|
||||
debug_page_line[MGC_LINE_POINT] = disp_line + 2;
|
||||
debug_page_line[MGC_LINE_POINT + 1] = 2; // Data Pointer
|
||||
debug_set_response(MGC_BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length);
|
||||
}
|
||||
}
|
||||
|
||||
int mgc_debug_set(void)
|
||||
{
|
||||
BYTE page;
|
||||
BYTE data[10];
|
||||
BYTE *ptr;
|
||||
|
||||
bzero(disp_page, 20);
|
||||
|
||||
ptr = data;
|
||||
|
||||
debug_set_response(MGC_BASE_ID_LEN, debug_status_id, &debug_status, 1);
|
||||
debug_set_response(MGC_BASE_ID_LEN, debug_name_id, MGC_VER_DEBUG, 10);
|
||||
debug_set_response(MGC_BASE_ID_LEN, debug_ascin_id, mgcAsciInBuf, 4096);
|
||||
debug_set_response(MGC_BASE_ID_LEN, debug_ascout_id, mgcAsciOutBuf, 4096);
|
||||
|
||||
for (page = 1; page < 5; page++)
|
||||
{
|
||||
switch (page)
|
||||
{
|
||||
case 1: //page 1
|
||||
ptr = title1_p;
|
||||
break;
|
||||
case 2: //page 2
|
||||
ptr = title2_p;
|
||||
break;
|
||||
case 3: //page 3
|
||||
ptr = title3_p;
|
||||
break;
|
||||
case 4: //page 4
|
||||
ptr = title4_p;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
debug_page_title[MGC_PAGE_POINT] = 5 + page;
|
||||
debug_set_response(MGC_BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
|
||||
mgc_disp_page(page);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mgc_asciout_proc(BYTE *out_str)
|
||||
{
|
||||
int out_len;
|
||||
|
||||
out_len = strlen(out_str);
|
||||
|
||||
if (out_len + strlen(mgcAsciOutBuf) > MAX_ASCIIOUT_LEN - 2)
|
||||
{
|
||||
strcpy(mgcAsciOutBuf, out_str);
|
||||
}
|
||||
else
|
||||
strcat(mgcAsciOutBuf, out_str);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mgc_log_all()
|
||||
{
|
||||
WORD i;
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_MG; i++)
|
||||
{
|
||||
if (mgcMgInfo[i].created != 0)
|
||||
mgcMgInfo[i].monFlag = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++)
|
||||
{
|
||||
if (mgcPhyPort[i].created != 0)
|
||||
mgcPhyPort[i].monFlag = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++)
|
||||
{
|
||||
if (mgcChnl[i].assigned != 0)
|
||||
mgcChnl[i].monFlag = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void mgc_log_none()
|
||||
{
|
||||
WORD i;
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_MG; i++)
|
||||
{
|
||||
if (mgcMgInfo[i].created != 0)
|
||||
mgcMgInfo[i].monFlag = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_PHY_PORT; i++)
|
||||
{
|
||||
if (mgcPhyPort[i].created != 0)
|
||||
mgcPhyPort[i].monFlag = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MGC_MAX_NUM_OF_CHNL; i++)
|
||||
{
|
||||
if (mgcChnl[i].assigned != 0)
|
||||
mgcChnl[i].monFlag = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void mgc_mon(void)
|
||||
{
|
||||
BYTE in_page, err_fg = 0;
|
||||
BYTE *ascii_in_ptr = NULL;
|
||||
BYTE *str_start = NULL;
|
||||
WORD str_len;
|
||||
WORD mgNo, portNo, chlNo, portIndex, chnlIndex, num;
|
||||
|
||||
if ((str_len = strlen(mgcAsciInBuf)) > 0)
|
||||
{
|
||||
in_page = mgcAsciInBuf[0] - 1;
|
||||
ascii_in_ptr = mgcAsciInBuf + 1;
|
||||
|
||||
if (in_page > 4)
|
||||
err_fg = 1;
|
||||
else if (strcmp(ascii_in_ptr,"log error on") == 0)
|
||||
{
|
||||
mgcMonitorFg = mgcMonitorFg | MGC_MONITOR_ERROR;
|
||||
}
|
||||
else if (strcmp(ascii_in_ptr,"log error off") == 0)
|
||||
{
|
||||
mgcMonitorFg = mgcMonitorFg & (~MGC_MONITOR_ERROR);
|
||||
}
|
||||
else if (strcmp(ascii_in_ptr,"log all") == 0)
|
||||
{
|
||||
mgcMonitorFg = MGC_MONITOR_ALL;
|
||||
mgc_log_all();
|
||||
}
|
||||
else if (strcmp(ascii_in_ptr,"log none") == 0)
|
||||
{
|
||||
mgcMonitorFg = MGC_MONITOR_NONE;
|
||||
mgc_log_none();
|
||||
}
|
||||
else if (strcmp(ascii_in_ptr,"help") == 0)
|
||||
{
|
||||
mgc_asciout_proc(log_help);
|
||||
}
|
||||
else if (strstr(ascii_in_ptr, "log mg") != NULL)
|
||||
{
|
||||
if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul(str_start + 1, NULL, 10);
|
||||
if (mgNo >= MGC_MAX_NUM_OF_MG)
|
||||
err_fg = 1;
|
||||
else if (strstr(ascii_in_ptr, "on") != NULL)
|
||||
mgcMgInfo[mgNo].monFlag = 1;
|
||||
else if (strstr(ascii_in_ptr, "off") != NULL)
|
||||
mgcMgInfo[mgNo].monFlag = 0;
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
else if (strstr(ascii_in_ptr, "log port") != NULL)
|
||||
{
|
||||
if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul(str_start + 1, NULL, 10);
|
||||
if (mgNo >= MGC_MAX_NUM_OF_MG)
|
||||
err_fg = 1;
|
||||
if ((str_start = strstr(str_start + 1, "-")) != NULL)
|
||||
{
|
||||
portNo = strtoul(str_start + 1, NULL, 10);
|
||||
if (portNo >= MGC_MAX_PHY_PORT_PER_MG)
|
||||
err_fg = 1;
|
||||
portIndex = mgcMgInfo[mgNo].portIndex[portNo];
|
||||
if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT)
|
||||
err_fg = 2;
|
||||
else
|
||||
{
|
||||
if (strstr(str_start + 1, "on") != NULL)
|
||||
mgcPhyPort[portIndex].monFlag = 1;
|
||||
else if (strstr(ascii_in_ptr, "off") != NULL)
|
||||
mgcPhyPort[portIndex].monFlag = 0;
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
else if (strstr(ascii_in_ptr, "log chnl") != NULL)
|
||||
{
|
||||
if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul(str_start + 1, NULL, 10);
|
||||
if (mgNo >= MGC_MAX_NUM_OF_MG)
|
||||
err_fg = 1;
|
||||
if ((str_start = strstr(str_start + 1, "-")) != NULL)
|
||||
{
|
||||
portNo = strtoul(str_start + 1, NULL, 10);
|
||||
if (portNo >= MGC_MAX_PHY_PORT_PER_MG)
|
||||
err_fg = 1;
|
||||
portIndex = mgcMgInfo[mgNo].portIndex[portNo];
|
||||
if (portIndex >= MGC_MAX_NUM_OF_PHY_PORT)
|
||||
err_fg = 2;
|
||||
else
|
||||
{
|
||||
if ((str_start = strstr(str_start + 1, "-")) != NULL)
|
||||
{
|
||||
chlNo = strtoul(str_start + 1, NULL, 10);
|
||||
chnlIndex = mgcPhyPort[portIndex].chnlStartIndex + chlNo;
|
||||
if (strstr(str_start + 1, "on") != NULL)
|
||||
mgcChnl[chnlIndex].monFlag = 1;
|
||||
else if (strstr(ascii_in_ptr, "off") != NULL)
|
||||
mgcChnl[chnlIndex].monFlag = 0;
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
err_fg = 1;
|
||||
}
|
||||
else if (isdigit(ascii_in_ptr[0]))
|
||||
{
|
||||
num = strtoul(ascii_in_ptr, NULL, 10);
|
||||
disp_page[in_page] = num;
|
||||
mgc_disp_page(in_page);
|
||||
}
|
||||
else if ((str_start = strstr(ascii_in_ptr, ">")) != NULL)
|
||||
{
|
||||
num = strtoul(str_start + 1, NULL, 10);
|
||||
disp_page[in_page] += num;
|
||||
mgc_disp_page(in_page);
|
||||
}
|
||||
else if ((str_start = strstr(ascii_in_ptr, "<"))!= NULL)
|
||||
{
|
||||
num = strtoul(str_start + 1, NULL, 10);
|
||||
disp_page[in_page] -= num;
|
||||
mgc_disp_page(in_page);
|
||||
}
|
||||
else
|
||||
err_fg = 1;
|
||||
|
||||
if (err_fg == 0)
|
||||
mgc_asciout_proc("Command OK!\n\r");
|
||||
else if (err_fg == 2)
|
||||
mgc_asciout_proc("MG port not created!\n\r");
|
||||
else
|
||||
mgc_asciout_proc("Command Error!\n\r");
|
||||
|
||||
strcpy(mgcAsciInBuf, "\0");
|
||||
}
|
||||
}
|
||||
|
||||
int mgc_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
j = 0;
|
||||
|
||||
for (i = 0; i< from_len; i++)
|
||||
{
|
||||
to_asc[j] = ascii[from_hex[i] >> 4];
|
||||
j++;
|
||||
to_asc[j] = ascii[from_hex[i] & 0x0F];
|
||||
j++;
|
||||
to_asc[j] = ' ';
|
||||
j++;
|
||||
}
|
||||
|
||||
to_asc[j] = '\0';
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mgc_log_err(char *err_msg)
|
||||
{
|
||||
if ((mgcMonitorFg & MGC_MONITOR_ERROR) == MGC_MONITOR_ERROR)
|
||||
{
|
||||
mgc_asciout_proc("\33[31m");
|
||||
if (strlen(err_msg) >= MGC_MAX_ASCITMP_LEN)
|
||||
sprintf(mgcAsciTempBuf, "log msg is too long!\n\r");
|
||||
else
|
||||
sprintf(mgcAsciTempBuf, "%s\n\r", err_msg);
|
||||
strcat(mgcAsciTempBuf, "\33[37m");
|
||||
mgc_asciout_proc(mgcAsciTempBuf);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mgc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg)
|
||||
{
|
||||
BYTE monFlag = 0;
|
||||
|
||||
if ((mgNo < MGC_MAX_NUM_OF_MG) && (mgcMgInfo[mgNo].monFlag == 1))
|
||||
monFlag = 1;
|
||||
else if ((portIndex < MGC_MAX_NUM_OF_PHY_PORT) && (mgcPhyPort[portIndex].monFlag == 1))
|
||||
monFlag = 1;
|
||||
else if ((chnlIndex < MGC_MAX_NUM_OF_CHNL) && (mgcChnl[chnlIndex].monFlag == 1))
|
||||
monFlag = 1;
|
||||
|
||||
if (monFlag == 1)
|
||||
{
|
||||
if (strlen(msg) >= MGC_MAX_ASCITMP_LEN)
|
||||
sprintf(mgcAsciTempBuf, "log msg is too long!\n\r");
|
||||
else
|
||||
sprintf(mgcAsciTempBuf, "%s\n\r", msg);
|
||||
mgc_asciout_proc(mgcAsciTempBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
1456
plat/mgc/src/mgc_fsm.c
Normal file
1456
plat/mgc/src/mgc_fsm.c
Normal file
File diff suppressed because it is too large
Load Diff
199
plat/mgc/src/mgc_sess_ctl.c
Normal file
199
plat/mgc/src/mgc_sess_ctl.c
Normal file
@@ -0,0 +1,199 @@
|
||||
#include "./include/mgc_sess_ctl.h"
|
||||
|
||||
|
||||
MGC_SESS_REC mgcSess[MGC_SESS_RECORD];
|
||||
|
||||
void mgc_sess_rec_init(MGC_SESS_REC *pSess , int id)
|
||||
{
|
||||
if(pSess == NULL)
|
||||
return;
|
||||
|
||||
memset(pSess , 0 , sizeof(MGC_SESS_REC));
|
||||
pSess->status = MGC_SESS_STATUS_IDLE;
|
||||
pSess->id = id;
|
||||
return;
|
||||
}
|
||||
|
||||
void mgc_sess_init(void)
|
||||
{
|
||||
MGC_SESS_REC *pSess;
|
||||
int i;
|
||||
|
||||
for(i=0 ; i<MGC_SESS_RECORD ; i++)
|
||||
{
|
||||
pSess = &mgcSess[i];
|
||||
mgc_sess_rec_init(pSess , i);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void mgc_sess_set_status(MGC_SESS_REC *pSess , MGC_SESS_STATUS status)
|
||||
{
|
||||
if(pSess == NULL)
|
||||
return;
|
||||
|
||||
pSess->status = status;
|
||||
}
|
||||
|
||||
MGC_SESS_STATUS mgc_sess_get_status(MGC_SESS_REC *pSess)
|
||||
{
|
||||
if(pSess == NULL)
|
||||
return MGC_SESS_STATUS_UNDEF;
|
||||
|
||||
return pSess->status;
|
||||
}
|
||||
|
||||
|
||||
MGC_SESS_REC *mgc_sess_get_unused(void)
|
||||
{
|
||||
int i;
|
||||
MGC_SESS_REC *pSess;
|
||||
|
||||
for(i=0 ; i<MGC_SESS_RECORD ; i++)
|
||||
{
|
||||
pSess = &mgcSess[i];
|
||||
|
||||
if(mgc_sess_get_status(pSess) != MGC_SESS_STATUS_IDLE)
|
||||
continue;
|
||||
|
||||
return pSess;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL mgc_sess_is_chnl_equal(CHNL orgChnl , CHNL dstChnl)
|
||||
{
|
||||
if(orgChnl.portNo != dstChnl.portNo)
|
||||
return FALSE;
|
||||
|
||||
if(orgChnl.mgNo != dstChnl.mgNo)
|
||||
return FALSE;
|
||||
|
||||
if(orgChnl.connectNo != dstChnl.connectNo)
|
||||
return FALSE;
|
||||
|
||||
if(orgChnl.chlNo != dstChnl.chlNo)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
MGC_SESS_REC *mgc_sess_is_already_rec(CHNL chnl)
|
||||
{
|
||||
int i;
|
||||
MGC_SESS_REC *pSess;
|
||||
|
||||
for(i=0 ; i<MGC_SESS_RECORD; i++)
|
||||
{
|
||||
pSess = &mgcSess[i];
|
||||
|
||||
if(mgc_sess_get_status(pSess) != MGC_SESS_STATUS_USED)
|
||||
continue;
|
||||
|
||||
if(mgc_sess_is_chnl_equal(pSess->chnl , chnl) == FALSE)
|
||||
continue;
|
||||
|
||||
return pSess;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
BOOL mgc_sess_rec_chnl(MGC_SESS_REC *pSess ,CHNL chnl)
|
||||
{
|
||||
if(pSess == NULL)
|
||||
return FALSE;
|
||||
|
||||
memcpy(&pSess->chnl , &chnl , sizeof(CHNL));
|
||||
mgc_sess_set_status(pSess,MGC_SESS_STATUS_USED);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL mgc_sess_rec_org_and_dst_chnl(CHNL orgChnl , CHNL destChnl)
|
||||
{
|
||||
MGC_SESS_REC *pOrgSess, *pDestSess;
|
||||
|
||||
pOrgSess = mgc_sess_is_already_rec(orgChnl);
|
||||
pDestSess = mgc_sess_is_already_rec(destChnl);
|
||||
|
||||
if(pOrgSess == NULL)
|
||||
{
|
||||
pOrgSess = mgc_sess_get_unused();
|
||||
if(pOrgSess == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mgc_sess_rec_chnl(pOrgSess, orgChnl);
|
||||
|
||||
if(pDestSess == NULL)
|
||||
{
|
||||
pDestSess = mgc_sess_get_unused();
|
||||
if(pDestSess == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mgc_sess_rec_chnl(pDestSess, destChnl);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL mgc_sess_is_media_info_same(MGC_SDP_TAG *pSdpTag , PUB_SDP_MSG *pSdp)
|
||||
{
|
||||
if((pSdpTag == NULL)||(pSdp == NULL))
|
||||
return FALSE;
|
||||
|
||||
if(pSdpTag->m.m.port != pSdp->medias.medias[0].m.port)
|
||||
return FALSE;
|
||||
|
||||
if(strcmp(pSdpTag->c.addr , pSdp->c.addr) != 0)
|
||||
return FALSE;
|
||||
|
||||
if(pSdpTag->m.m.payloads[0] != pSdp->medias.medias[0].m.payloads[0])
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL mgc_sess_is_chnl_need_update(CHNL chnl, MGCP_PARA *pPara)
|
||||
{
|
||||
PUB_SDP_MSG *pSdp;
|
||||
MGC_SDP_TAG *pSdpTag;
|
||||
MGC_SESS_REC *pSess;
|
||||
|
||||
pSess = mgc_sess_is_already_rec(chnl);
|
||||
|
||||
if((pSess == NULL)||(pPara == NULL))
|
||||
return TRUE;
|
||||
|
||||
pSdp = &pPara->sdp;
|
||||
pSdpTag = &pSess->sdpTag;
|
||||
|
||||
|
||||
if(pSdpTag->mode!= pPara->m.mode)
|
||||
{
|
||||
pSdpTag->mode = pPara->m.mode;
|
||||
memcpy(&pSdpTag->c, &pSdp->c , sizeof(PUB_SDP_C));
|
||||
memcpy(&pSdpTag->m, &(pSdp->medias.medias[0]) , sizeof(PUB_SDP_MEDIA));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if((pPara->flag & MGCP_PARA_FLAG_SDP) != MGCP_PARA_FLAG_SDP)
|
||||
return TRUE;
|
||||
|
||||
if(mgc_sess_is_media_info_same(&pSess->sdpTag , &(pPara->sdp)) == TRUE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pSdpTag->mode = pPara->m.mode;
|
||||
memcpy(&pSdpTag->c, &pSdp->c , sizeof(PUB_SDP_C));
|
||||
memcpy(&pSdpTag->m, &(pSdp->medias.medias[0]) , sizeof(PUB_SDP_MEDIA));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user