init ems server code
This commit is contained in:
146
plat/mgc_v2/src/mgc_ctl.c
Normal file
146
plat/mgc_v2/src/mgc_ctl.c
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
*********************************************************************************
|
||||
* *
|
||||
* NOTICE: *
|
||||
* *
|
||||
*********************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*********************************************************************************
|
||||
* <mgc_ctl.c>
|
||||
* This file contain global variable control
|
||||
*
|
||||
* Author Date
|
||||
* ------ ------
|
||||
* Sam Yao Aug 2008
|
||||
*********************************************************************************/
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* INCLUDE HEADER FILES */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
#include "./include/mgc_ctl.h"
|
||||
|
||||
MGC_CTL mgcCtl;
|
||||
|
||||
|
||||
void mgc_ctl_num_init(WORD sysId , WORD localIp , WORD peerIp)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
pMgcCtl->mgcChlAssigned = 0;
|
||||
pMgcCtl->mgcMgCreated = 0;
|
||||
pMgcCtl->mgcMaxChlNo = MGC_MAX_NUM_OF_CHNL;
|
||||
pMgcCtl->mgcMaxMgNo = MGC_MAX_NUM_OF_MG;
|
||||
|
||||
pMgcCtl->sysId = sysId;
|
||||
pMgcCtl->localIp = localIp;
|
||||
pMgcCtl->peerIp = peerIp;
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL mgc_ctl_is_mg_full(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
if((pMgcCtl->mgcMgCreated + 1) > pMgcCtl->mgcMaxMgNo)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void mgc_ctl_mg_add_one(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
pMgcCtl->mgcMgCreated++;
|
||||
return;
|
||||
}
|
||||
|
||||
void mgc_ctl_mg_remove_one(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
pMgcCtl->mgcMgCreated--;
|
||||
return;
|
||||
}
|
||||
|
||||
BOOL mgc_ctl_is_chnl_full(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
if((pMgcCtl->mgcChlAssigned+ 1) > pMgcCtl->mgcMaxChlNo)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
void mgc_ctl_chnl_add_one(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
pMgcCtl->mgcChlAssigned++;
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void mgc_ctl_chnl_remove_one(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
pMgcCtl->mgcChlAssigned--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int mgc_ctl_set_mg_max_num(int num)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
if((num <= 0)||(num>MGC_MAX_NUM_OF_MG))
|
||||
return -1;
|
||||
|
||||
pMgcCtl->mgcMaxMgNo = num;
|
||||
return num;
|
||||
}
|
||||
|
||||
int mgc_ctl_set_chnl_max_num(int num)
|
||||
{
|
||||
MGC_CTL *pMgcCtl = NULL;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
if((num <= 0)||( num > MGC_MAX_NUM_OF_CHNL))
|
||||
return -1;
|
||||
|
||||
pMgcCtl->mgcMaxChlNo = num;
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MGC_TEST_ENABLE
|
||||
int mgc_ctl_chnl_num(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
return pMgcCtl->mgcChlAssigned;
|
||||
}
|
||||
|
||||
int mgc_ctl_mg_num(void)
|
||||
{
|
||||
MGC_CTL *pMgcCtl;
|
||||
pMgcCtl = &mgcCtl;
|
||||
|
||||
return pMgcCtl->mgcMgCreated;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user