📄 gatemain.c
字号:
}
break;
case 'f':
case 'F':
channel = getChannel();
/* Check if valid channel value */
if( (channel <= 0) || (channel > gateChannels) ) {
break;
}
/* Sends Q931 Facility, only in IP_CONNECTED or GATE_CONNECTED state */
if((Session[channel].sessionState == IP_CONNECTED)
|| (Session[channel].sessionState == GATE_CONNECTED)){
activeChannel = channel;
if (SendFacilityMsg(channel) != 0){
if (_logLevel !=0){
printf("\nERROR: Unable to send Facility message on channel %d \n\tReason: Function failed\n",channel);
}
gateERROR(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tUnable to send Facility message on channel %d \n\tReason: Function failed.\n",channel));
}else{
chanInfoIP[channel].Q931Facility_Msg++;
}
}else{
if (_logLevel !=0){
printf("\nERROR: Unable to send Facility message on channel %d \n\tReason: is not in connected state\n",channel);
}
gateERROR(channel,_logLevel,Session[channel].LogFile,(Session[channel].LogFile,"\tUnable to send Facility message on channel %d \n\tReason: is not in connected state.\n",channel));
}
break;
default:
break;
}
}
return(0);
} /* Function waitForKey */
/*****FUNCTION***************************************************
* NAME : printChanInfo
* DESCRIPTION : Prints channel information
* INPUT : fileName - name of the file
* Info[] - array of the information to print
* OUTPUT : None
* RETURNS : void
* CAUTIONS : None
****************************************************************/
void printChanInfo(char *fileName, CHANInfo Info[])
{
unsigned short index;
char bufdate[128];
char buftime[128];
CHANInfo total;
if((ChanInfoFile = fopen(fileName, "a")) == NULL) {
printf("%s","Unable to open log file to print information.\n");
return;
}
fprintf(ChanInfoFile,"\n \n");
memset(buftime,0,sizeof(buftime));
PDLgetDateAndTime(bufdate,buftime);
fprintf(ChanInfoFile,"\n %s %s \n",bufdate,buftime);
fprintf(ChanInfoFile,"%s","------------------------------ CHANNELS INFO ----------------------------------------------\n");
fprintf(ChanInfoFile,"%s","Chan State Make Offer Conn Null Fail Rej UIIM UIIE NSCM NSCE 931M 931E\n");
fprintf(ChanInfoFile,"%s","-------------------------------------------------------------------------------------------\n");
fflush(ChanInfoFile);
for(index = 1; index <=gateChannels; index++) {
fprintf(ChanInfoFile,"%4d %5d %4d %5d %4d %4d %4d %3d %4d %4d %4d %4d %4d %4d\n",
index,
Session[index].sessionState,
Info[index].callsMake,
Info[index].callsOffered,
Info[index].callsConnected,
Info[index].callsNull,
Info[index].callsFailed,
Info[index].callsRejected,
Info[index].UII_Msg,
Info[index].UII_Evt,
Info[index].NonStdCmd_Msg,
Info[index].NonStdCmd_Evt,
Info[index].Q931Facility_Msg,
Info[index].Q931Facility_Evt);
fflush(ChanInfoFile);
}
ZeroMemory(&total, sizeof(CHANInfo));
for(index = 1; index <= gateChannels; index++) {
total.callsMake += Info[index].callsMake;
total.callsOffered += Info[index].callsOffered;
total.callsConnected += Info[index].callsConnected;
total.callsNull += Info[index].callsNull;
total.callsFailed += Info[index].callsFailed;
total.callsRejected += Info[index].callsRejected;
total.UII_Msg += Info[index].UII_Msg;
total.UII_Evt += Info[index].UII_Evt;
total.NonStdCmd_Msg += Info[index].NonStdCmd_Msg;
total.NonStdCmd_Evt += Info[index].NonStdCmd_Evt;
total.Q931Facility_Msg += Info[index].Q931Facility_Msg;
total.Q931Facility_Evt += Info[index].Q931Facility_Evt;
}
fprintf(ChanInfoFile,"%s","-------------------------------------------------------------------------------------------\n");
fprintf(ChanInfoFile,"T O T A L: %4d %5d %4d %4d %4d %3d %4d %4d %4d %4d %4d %4d\n",
total.callsMake,
total.callsOffered,
total.callsConnected,
total.callsNull,
total.callsFailed,
total.callsRejected,
total.UII_Msg,
total.UII_Evt,
total.NonStdCmd_Msg,
total.NonStdCmd_Evt,
total.Q931Facility_Msg,
total.Q931Facility_Evt);
fprintf(ChanInfoFile,"%s","-------------------------------------------------------------------------------------------\n\n");
fflush(ChanInfoFile);
fclose(ChanInfoFile);
}
/*****FUNCTION***************************************************
* NAME : banner
* DESCRIPTION : Prints program banner
* INPUT : void
* OUTPUT : None
* RETURNS : void
* CAUTIONS : None
****************************************************************/
void banner(void)
{
printf("%s%s%s%s",
"***********************************************************\n",
"* *\n",
"* Gateway_R4 Demo - Voice over IP Gateway Demo Program. *\n",
"* Copyright (c) 2001, Intel Corp, Dialogic Division *\n");
printf("* Demo Version : %s *\n",DEMO_VERSION_STRING);
printf("* Util Version : %s *\n",UTIL_VERSION);
printf("* PDL Version : %s *\n",PDL_VERSION);
printf("%s%s",
"* *\n",
"***********************************************************\n");
} /* Function banner */
/*****FUNCTION***************************************************
* NAME : usage
* DESCRIPTION : Command line option ? for help
* INPUT : None
* OUTPUT : Prints help text
* RETURNS : void
* CAUTIONS : None
****************************************************************/
void usage()
{
printf("%s","Usage:\n\tGATEWAY_R4 [-f<Front End>] [-l] \n");
printf("%s","\t\t [-r<[NumRings>] [-n<gateChannels>] [-c<cfgFile>] [-d<Debug Level>] [-p<pstnDial>].\n\n");
printf("%s","Front End : 0 (ANALOG), 1 (DIGITAL - T1), 2 (DIGITAL - E1) ; (default = ANALOG) \n");
printf("%s","-l enables log file printing for the list of channels: ChanXX.txt. options 'all'\n");
printf("%s","for all the channels, a partial list:'a-b,c,e-f,g' where a,b,c,e,f,g represent numbers.\n");
printf("%s","NumRings : 1,2,3..etc. (ONLY IF FRONT END IS ANALOG, default = %d)\n",GATE_RINGS);
printf("%s","Debug level : 0 - prints only fatal error, 1- prints also error, 2- warning, 3- trace, 4-info (default = 0)\n");
printf("%s","gateChannels : (default minimum of ip channels and pstn channels)\n");
printf("%s","Encoding type 'm'(Mu-law) or 'a'(A-law) (default = Mu-law).\n");
printf("%s","cfgFile : File containing info. about codecs, # to call, etc (default %s)\n", GATE_CONFIG_FILE);
printf("%s","pstnDial : 0 (Disable dialing), 1 (Enable dialing).\n\n");
printf("%s","DNISEnable : (Default not enabled).\n\n");
_exit(0);
} /* Function usage */
/*****FUNCTION***************************************************
* NAME : checkArg
* DESCRIPTION : Checks arguments from command line
* INPUT : int argc
* char *argv[]
* OUTPUT : None
* RETURNS : void
* CAUTIONS : None
****************************************************************/
void checkArg(int argc, char *argv[])
{
int ii;
/* Defaults */
frontEnd = GATE_LEGACY_ANALOG;
strcpy(cfgFile, GATE_CONFIG_FILE);
/* parse command line */
for (ii = 1; ii < argc; ii++) {
if (*argv[ii] != '-') {
continue;
}
switch(tolower(*(argv[ii]+1))) {
/* Front End */
case 'f':
frontEnd = atoi(argv[ii]+2);
break;
/* Number of rings */
case 'r':
numRings = atoi(argv[ii]+2);
break;
/* Max Channels to use */
case 'n':
argChannels = atoi(argv[ii]+2);
break;
/* Configuration filename */
case 'c':
strcpy(cfgFile,argv[ii]+2);
break;
/* Debug level printing */
case 'd':
_logLevel = atoi(argv[ii]+2);
break;
/* Enable write to different log file for each channel */
case 'l':
strcpy(logFArr,argv[ii]+2);
logFileFlag = 1;
break;
/* Enable/Disable Dialing */
case 'p':
Dialing = atoi(argv[ii]+2);
break;
/* Enable/Disable DNIS */
case 's':
DnisEnable = 1;
break;
/* Help */
case '?':
case 'h':
default:
usage();
break;
} /* end of switch. */
} /* end of parse command line for */
} /* Function checkArg */
/*****FUNCTION***************************************************
* NAME : IPTResetSession
* DESCRIPTION : Resets session structure to default values
* INPUT : int ch - Channel to reset
* int clear - boolean to know if reset totally
* 1 - clear totaly
* 0 - clear the related fields of this call
* OUTPUT : None
* RETURNS : void
* CAUTIONS : None
****************************************************************/
void IPTResetSession(int ch, int clear)
{
Session[ch].sessionNumber = ch;
Session[ch].NumOfDropExpected = 0;
Session[ch].NumOfDropEvt = 0;
Session[ch].pstnIsListen = 0;
Session[ch].ipParams.currentCRN = 0;
Session[ch].pstnParams.currentCRN = 0;
Session[ch].ipParams.glareCRN = 0;
Session[ch].pstnParams.glareCRN = 0;
strcpy(Session[ch].DNIS , "");
if (!clear){ /* in the END of Call */
gateUpdate(&(Session[ch]),GATE_NULL);
}
if (clear==1) {
if (openLogFile(logFileFlag,ch,(&(Session[ch].LogFile)),gateChannels,logFArr) == 0){
exit(1);
}
gateUpdate(&(Session[ch]),GATE_INIT);
Session[ch].pstnParams.linedev = 0;
Session[ch].pstnParams.TxTSlot = 0;
Session[ch].ipParams.TxTSlot = 0;
Session[ch].ipParams.linedev = 0;
Session[ch].ipParams.nextCRN = 0;
Session[ch].pstnParams.nextCRN = 0;
Session[ch].pstnParams.NetwH = 0;
Session[ch].pstnParams.VoiceH = 0;
unblockedFlage[ch] = 0;
/* Set max Tx coders to Zero, the field will be updated while
parsing from configuration file */
Session[ch].ConfigFileParm.maxTxCoders = 0;
/* ConfigFileParm is a structure containing the information
stored in the configuration file */
strcpy(Session[ch].ConfigFileParm.display,"\0");
strcpy(Session[ch].ConfigFileParm.phoneList,"\0");
strcpy(Session[ch].ConfigFileParm.localPhoneNumber,"\0");
ZeroMemory(&(Session[ch].ConfigFileParm.H221NonStd),sizeof(IP_H221NONSTANDARD));
strcpy(Session[ch].ConfigFileParm.productID,"\0");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -