init ems server code
This commit is contained in:
97
plat/8ecp/Makefile
Normal file
97
plat/8ecp/Makefile
Normal file
@@ -0,0 +1,97 @@
|
||||
|
||||
##----------------------------------------------------------##
|
||||
## ##
|
||||
## Universal Makefile for module Version : V1.4 ##
|
||||
## ##
|
||||
## Created : Wei Liu 07/04/11 ##
|
||||
## Revision: [Last]Wei Liu 07/06/18 ##
|
||||
## ##
|
||||
##----------------------------------------------------------##
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## 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 = 8ecp
|
||||
TYPE = plat
|
||||
|
||||
DBUG_FLAGS_ADD =
|
||||
RELS_FLAGS_ADD =
|
||||
|
||||
##Default commonly as below
|
||||
|
||||
BUILD = lib
|
||||
CFG = debug
|
||||
|
||||
PLT_LIB = public debug iptrans snmp mtp3
|
||||
APP_LIB =
|
||||
LIB_ADD =
|
||||
|
||||
SRC_PATH = ./src
|
||||
INC_PATH = ./src/include
|
||||
PLT_PATH = ../../plat
|
||||
APP_PATH = ../../mss
|
||||
|
||||
OBJ_ADD =
|
||||
TEST_OBJ_PATH = ../../obj
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
##--------------------------------------
|
||||
##
|
||||
## 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 = ./ut/ut_doc/output
|
||||
MAKE_INCLUDE = $(HOME)/ems.git/include
|
||||
|
||||
##---------------------------------------------------------------------##
|
||||
|
||||
|
||||
##--------------------------------------
|
||||
##
|
||||
## include makefile.rules (Do not change)
|
||||
##
|
||||
##--------------------------------------
|
||||
include $(MAKE_INCLUDE)/Makefile.rules
|
||||
|
||||
288
plat/8ecp/src/8ecp.c
Normal file
288
plat/8ecp/src/8ecp.c
Normal file
@@ -0,0 +1,288 @@
|
||||
#include "./include/8ecp.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "./include/8ecp_debug.h"
|
||||
|
||||
SAP_In_8ECP SAPIn8ECP;
|
||||
//time_t t[_8KE1_NUM]; //save the time when the heartbeat message of a 8KE1 was received.
|
||||
BYTE s_msg[128];
|
||||
Card_Struct card_struct[_8KE1_NUM];
|
||||
int _8ecp_bind (_8ECP_SAP * sap)
|
||||
{
|
||||
if (SAPIn8ECP.inUse == InUse)
|
||||
{
|
||||
perror ("unable to bind a SAP, because the SAP is in use.");
|
||||
return -1;
|
||||
}
|
||||
else //If bind successful, save the user name and the functions
|
||||
{
|
||||
SAPIn8ECP.inUse = InUse;
|
||||
strcpy (SAPIn8ECP._8ecp_sap.name, (*sap).name);
|
||||
SAPIn8ECP._8ecp_sap.update_mg_status = sap->update_mg_status;
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status = sap->update_trk_status;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
int _8ecp_unbind (BYTE sapIndex)
|
||||
{
|
||||
if (sapIndex != 0)
|
||||
{
|
||||
perror ("unable to unbind the SAP, because the SAP is not in use");
|
||||
return -1;
|
||||
}
|
||||
else //If unbind successful, set the default value of SAPIn8ECP
|
||||
{
|
||||
SAPIn8ECP.inUse = NotInUse;
|
||||
memset (SAPIn8ECP._8ecp_sap.name, 0,
|
||||
strlen (SAPIn8ECP._8ecp_sap.name));
|
||||
SAPIn8ECP._8ecp_sap.update_mg_status = NULL;
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int _8ecp_createMG(WORD mgNo, DWORD ip, BYTE cardNo)
|
||||
{
|
||||
card_struct[cardNo].mgNo = mgNo;
|
||||
card_struct[cardNo].ip = ip;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int _8ecp_deleteMG(WORD mgNo, DWORD ip, BYTE cardNo)
|
||||
{
|
||||
if(card_struct[cardNo].ip != ip)
|
||||
{
|
||||
printf("the ip is not correct, in 8ecp the ip of card %d is: %ld\n", cardNo, card_struct[cardNo].ip);
|
||||
return 0;
|
||||
}
|
||||
if(card_struct[cardNo].mgNo != mgNo)
|
||||
{
|
||||
printf("the mgNo is not correct, in 8ecp the mgNo of card %d is: %d\n", cardNo, card_struct[cardNo].mgNo);
|
||||
return 0;
|
||||
}
|
||||
card_struct[cardNo].ip = 0;;
|
||||
card_struct[cardNo].mgNo = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
calcurate the IP address where the 8ECP PDU will be sent to
|
||||
*/
|
||||
struct sockaddr_in getIP (WORD orgChnl)
|
||||
{
|
||||
//char ip3, ip[16];
|
||||
//WORD mgNo;
|
||||
BYTE cardNo;
|
||||
struct sockaddr_in s;
|
||||
/* ip3 = orgChnl / 256; //the ID of the 8KE1
|
||||
sprintf (ip, "172.18.%d.1", ip3);
|
||||
*/
|
||||
cardNo = orgChnl / 256;
|
||||
memset (&s, 0, sizeof (struct sockaddr));
|
||||
s.sin_family = AF_INET;
|
||||
s.sin_port = htons (PORT);
|
||||
s.sin_addr.s_addr = card_struct[cardNo].ip;
|
||||
bzero (&(s.sin_zero), 8);
|
||||
return s;
|
||||
}
|
||||
void _8ecp_connect_chnl (WORD orgChnl, WORD dstChnl, BYTE ecDisable)
|
||||
{
|
||||
//int i;
|
||||
DWORD tempip;
|
||||
_8ECP_PDU _8ecp_pdu;
|
||||
message_list msg_list;
|
||||
struct sockaddr_in sin_addr;
|
||||
BYTE temstr[15];
|
||||
if (!SAPIn8ECP.inUse)
|
||||
{
|
||||
perror ("SAP is not bind!");
|
||||
return;
|
||||
}
|
||||
sin_addr = getIP (orgChnl);
|
||||
memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU));
|
||||
_8ecp_pdu.CPC_IFA_Inf = 0x87;
|
||||
if (ecDisable == 0)
|
||||
_8ecp_pdu.type = 0;
|
||||
else if (ecDisable == 1)
|
||||
_8ecp_pdu.type = 06;
|
||||
else
|
||||
{
|
||||
perror ("the value of ecDisable is error!");
|
||||
return;
|
||||
}
|
||||
_8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1
|
||||
_8ecp_pdu.dstModuleID = dstChnl / 256;
|
||||
_8ecp_pdu.dstTimeSlotNo = dstChnl % 256;
|
||||
msg_list.msgSrcPort = PORT;
|
||||
msg_list.msgDstIP = sin_addr.sin_addr.s_addr;
|
||||
tempip = ntohl(msg_list.msgDstIP);
|
||||
msg_list.msgDstPort = PORT;
|
||||
msg_list.msgLength = sizeof (_8ecp_pdu);
|
||||
memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength);
|
||||
memcpy(&temstr,&_8ecp_pdu, msg_list.msgLength);
|
||||
log_procedure(0, temstr); //0:Send msg 1:recv msg
|
||||
iptrPutMessage (msg_list);
|
||||
}
|
||||
void _8ecp_connect_dtmf (WORD orgChnl, WORD dstChnl, BYTE dtmfNo)
|
||||
{
|
||||
struct sockaddr_in sin_addr;
|
||||
//int i;
|
||||
BYTE temstr[15];
|
||||
_8ECP_PDU _8ecp_pdu;
|
||||
message_list msg_list;
|
||||
if (!SAPIn8ECP.inUse)
|
||||
{
|
||||
perror ("SAP is not bind!");
|
||||
return;
|
||||
}
|
||||
sin_addr = getIP (orgChnl);
|
||||
memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU));
|
||||
_8ecp_pdu.CPC_IFA_Inf = 0x87;
|
||||
_8ecp_pdu.type = 03;
|
||||
_8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1
|
||||
_8ecp_pdu.dstModuleID = dstChnl / 256;
|
||||
_8ecp_pdu.dstTimeSlotNo = dstChnl % 256;
|
||||
_8ecp_pdu.Value = dtmfNo;
|
||||
msg_list.msgSrcPort = PORT;
|
||||
msg_list.msgDstIP = sin_addr.sin_addr.s_addr;
|
||||
msg_list.msgDstPort = PORT;
|
||||
msg_list.msgLength = sizeof (_8ecp_pdu);
|
||||
memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength);
|
||||
memcpy(&temstr, &_8ecp_pdu, msg_list.msgLength);
|
||||
log_procedure(0, temstr);
|
||||
iptrPutMessage (msg_list);
|
||||
}
|
||||
void _8ecp_connect_tone (WORD orgChnl, WORD dstChnl, BYTE toneNo, WORD duration)
|
||||
{
|
||||
struct sockaddr_in sin_addr;
|
||||
//int i;
|
||||
BYTE temstr[15];
|
||||
_8ECP_PDU _8ecp_pdu;
|
||||
message_list msg_list;
|
||||
sin_addr = getIP (orgChnl);
|
||||
if (!SAPIn8ECP.inUse)
|
||||
{
|
||||
perror ("SAP is not bind!");
|
||||
return;
|
||||
}
|
||||
sin_addr = getIP (orgChnl);
|
||||
memset (&_8ecp_pdu, 0, sizeof (struct _8ECP_PDU));
|
||||
_8ecp_pdu.CPC_IFA_Inf = 0x87;
|
||||
_8ecp_pdu.type = 2;
|
||||
_8ecp_pdu.sourceTimeSlotNo = orgChnl % 256; //the ID of the timeslot on the 8KE1
|
||||
_8ecp_pdu.dstModuleID = dstChnl / 256;
|
||||
_8ecp_pdu.dstTimeSlotNo = dstChnl % 256;
|
||||
_8ecp_pdu.Value = toneNo;
|
||||
_8ecp_pdu.duration = duration;
|
||||
msg_list.msgSrcPort = PORT;
|
||||
msg_list.msgDstIP = sin_addr.sin_addr.s_addr;
|
||||
msg_list.msgDstPort = PORT;
|
||||
msg_list.msgLength = sizeof (_8ecp_pdu);
|
||||
memcpy (msg_list.msgContent, &_8ecp_pdu, msg_list.msgLength);
|
||||
memcpy(&temstr, &_8ecp_pdu, msg_list.msgLength);
|
||||
log_procedure(0, temstr);
|
||||
iptrPutMessage (msg_list);
|
||||
}
|
||||
void _8ecp_timer ()
|
||||
{
|
||||
|
||||
_8ecp_mon ();
|
||||
}
|
||||
int trap_proc (BYTE oid_len, DWORD * oid_ptr, BYTE * pdata, BYTE msg_len,
|
||||
snmp_addr * addr)
|
||||
{
|
||||
DWORD * oid_in;
|
||||
WORD mgNo;
|
||||
BYTE cardNo;
|
||||
BYTE temstr[128];
|
||||
//int i, index;
|
||||
//time_t now;
|
||||
if(oid_ptr[10] != 1)
|
||||
return 0;
|
||||
if(oid_ptr[11] != 1)
|
||||
return 0;
|
||||
if(oid_ptr[12] != 4)
|
||||
return 0;
|
||||
|
||||
log_procedure(1, pdata);
|
||||
|
||||
memset(&temstr, 0, sizeof(temstr));
|
||||
oid_in = oid_ptr + OID_Prefix;
|
||||
cardNo = E1NumOnCSU * pdata[0] + pdata[1];
|
||||
mgNo = card_struct[cardNo].mgNo;
|
||||
if ((SAPIn8ECP._8ecp_sap.update_mg_status == NULL)||(mgNo == 0))
|
||||
return 0;
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_mg_status (mgNo, 1);
|
||||
if ((SAPIn8ECP._8ecp_sap.update_trk_status == NULL) || (mgNo ==0))
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
{
|
||||
if(pdata[25]&0x01)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 0, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 0, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x02)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 1, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 1, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x04)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 2, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 2, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x08)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 3, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 3, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x10)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 4, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 4, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x20)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 5, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 5, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x40)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 6, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 6, 0); //trk on MG is nok
|
||||
}
|
||||
{
|
||||
if(pdata[25]&0x80)
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 7, 1); //trk on MG is nok
|
||||
else
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status (mgNo, 7, 0); //trk on MG is nok
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void _8ecp_init ()
|
||||
{
|
||||
printf ("8ECP init start!\n");
|
||||
SAPIn8ECP.inUse = NotInUse;
|
||||
memset (SAPIn8ECP._8ecp_sap.name, 0, sizeof (SAPIn8ECP._8ecp_sap.name));
|
||||
SAPIn8ECP._8ecp_sap.update_mg_status = NULL;
|
||||
SAPIn8ECP._8ecp_sap.update_trk_status = NULL;
|
||||
//memset (&t, 0, sizeof (t));
|
||||
memset(&card_struct, 0, sizeof(Card_Struct));
|
||||
_8ecp_debug_set ();
|
||||
inquire_trapmsg ((void *) trap_proc); //register, get heartbeat msg
|
||||
printf ("8ECP init complete!\n");
|
||||
}
|
||||
|
||||
|
||||
352
plat/8ecp/src/8ecp_debug.c
Normal file
352
plat/8ecp/src/8ecp_debug.c
Normal file
@@ -0,0 +1,352 @@
|
||||
#include "./include/8ecp.h"
|
||||
|
||||
#define _8ECP_DEBUG_ID 20
|
||||
#define _8ECP_VER_DEBUG "R9V0_01p1"
|
||||
|
||||
|
||||
BYTE _8ecp_asciin_buf[MAX_ASCIIIN_LEN];
|
||||
BYTE _8ecp_asciout_buf[MAX_ASCIIOUT_LEN];
|
||||
WORD monitor_flag;
|
||||
BYTE _8ecp_sg_mon_flag[MAX_MG_NO];
|
||||
BYTE _8ecp_trk_mon_flag[MAX_TRK_NO];
|
||||
BYTE _8ecp_chl_mon_flag[MAX_CHL_NO];
|
||||
|
||||
BYTE tempstr[128];
|
||||
BYTE tempstr1[256];
|
||||
static BYTE log_help[] = {"8ECP Debug Monitor Help:\n\r\
|
||||
1.[help]\n\r\
|
||||
2.[log all/none]\n\r\
|
||||
3.[log error on/off]\n\r\
|
||||
4.[log mg -mg_no on/off]\n\r\
|
||||
5.[log trk -mg_no -trk_no on/off]\n\r\
|
||||
6.[log chl -mg_no -trk_no -chnl_no on/off]\n\r\n\r"};
|
||||
|
||||
static WORD disp_page[128];
|
||||
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, _8ECP_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,_8ECP_DEBUG_ID + 2,2};
|
||||
|
||||
static DWORD debug_ascin_id[20] =
|
||||
{1, 3, 6, 1, 4, 1, 1373, 1, 1, 2, 3, 1, 2, _8ECP_DEBUG_ID + 2, 3};
|
||||
|
||||
static DWORD debug_ascout_id[20] =
|
||||
{1, 3, 6, 1, 4, 1, 1373, 1, 1, 2, 3, 1, 2, _8ECP_DEBUG_ID + 2, 4};
|
||||
|
||||
static DWORD debug_page_title[20] =
|
||||
{1,3,6,1,4,1,1373,1,1,2,3,1,2,_8ECP_DEBUG_ID + 2,1,1};
|
||||
|
||||
static DWORD debug_page_line[20] =
|
||||
{1,3,6,1,4,1,1373,1,1,2,3,1,2,_8ECP_DEBUG_ID + 2, 1,2,1};
|
||||
|
||||
static BYTE title1_p[] =
|
||||
{
|
||||
" 8ECP Page\n\r\
|
||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
|
||||
Message Info\n\r\
|
||||
"};
|
||||
|
||||
BYTE _8ecp_disp_line(BYTE page, BYTE line)
|
||||
{
|
||||
BYTE disp_length;
|
||||
disp_length = 16;
|
||||
disp_ptr = (BYTE *) disp_page;
|
||||
switch (page)
|
||||
{
|
||||
case 1:
|
||||
if (line == 0)
|
||||
{
|
||||
disp_ptr = (BYTE *) &disp_page[page];
|
||||
disp_length = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(tempstr != NULL)
|
||||
disp_ptr = (BYTE *)tempstr;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
disp_length = 0;
|
||||
break;
|
||||
}
|
||||
return disp_length;
|
||||
}
|
||||
|
||||
void _8ecp_disp_page(BYTE page)
|
||||
{
|
||||
BYTE disp_line;
|
||||
BYTE disp_length;
|
||||
debug_page_line[PAGE_POINT] = page + 5;
|
||||
for (disp_line = 0; disp_line < 22; disp_line++)
|
||||
{
|
||||
disp_length = _8ecp_disp_line(page, disp_line);
|
||||
debug_page_line[LINE_POINT] = disp_line + 2;
|
||||
debug_page_line[LINE_POINT + 1] = 2; // Data Pointer
|
||||
debug_set_response(BASE_ID_LEN + 2, debug_page_line, disp_ptr, disp_length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int _8ecp_asciout_proc (BYTE * out_ptr)
|
||||
{
|
||||
int out_len;
|
||||
out_len = strlen (out_ptr);
|
||||
if (out_len + strlen (_8ecp_asciout_buf) > MAX_ASCIIOUT_LEN - 2)
|
||||
{
|
||||
strcpy (_8ecp_asciout_buf, out_ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat (_8ecp_asciout_buf, out_ptr);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
int _8ecp_debug_set (void)
|
||||
{
|
||||
BYTE page;
|
||||
BYTE data[10];
|
||||
BYTE *ptr;
|
||||
bzero(disp_page,128);
|
||||
ptr = data;
|
||||
bzero(_8ecp_sg_mon_flag,MAX_MG_NO);
|
||||
bzero(_8ecp_trk_mon_flag,MAX_TRK_NO);
|
||||
bzero(_8ecp_chl_mon_flag,MAX_CHL_NO);
|
||||
bzero(tempstr, 40);
|
||||
|
||||
debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1);
|
||||
debug_set_response(BASE_ID_LEN, debug_name_id, _8ECP_VER_DEBUG, 10);
|
||||
debug_set_response (BASE_ID_LEN, debug_ascin_id, _8ecp_asciin_buf, 4096);
|
||||
debug_set_response (BASE_ID_LEN, debug_ascout_id, _8ecp_asciout_buf, 4096);
|
||||
|
||||
for (page = 1; page < 2; page++)
|
||||
{
|
||||
switch (page)
|
||||
{
|
||||
case 1: //page 1
|
||||
ptr = title1_p;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
debug_page_title[PAGE_POINT] = 5 + page;
|
||||
debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
|
||||
_8ecp_disp_page(page);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void log_procedure(BYTE flag, BYTE* tempstr)
|
||||
{
|
||||
int i;
|
||||
if(flag == 0)
|
||||
{
|
||||
for(i = 0; i < 15; i ++)
|
||||
sprintf(&tempstr1[3*i], " %02x",tempstr[i]);
|
||||
}
|
||||
else if(flag == 1)
|
||||
{
|
||||
for(i = 0; i < 41; i ++)
|
||||
sprintf(&tempstr1[3*i], " %02x",tempstr[i]);
|
||||
}
|
||||
if(monitor_flag == MONITOR_ALL)
|
||||
{
|
||||
if(flag == 0)
|
||||
{
|
||||
_8ecp_asciout_proc("\33[32mSend:\33[0m");
|
||||
_8ecp_asciout_proc(tempstr1);
|
||||
_8ecp_asciout_proc("\n");
|
||||
}
|
||||
else if(flag == 1)
|
||||
{
|
||||
_8ecp_asciout_proc("\33[33mReceive:\33[0m");
|
||||
_8ecp_asciout_proc(tempstr1);
|
||||
_8ecp_asciout_proc("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(flag == 1)
|
||||
{
|
||||
for(i = 0; i < MAX_MG_NO; i ++)
|
||||
{
|
||||
if(_8ecp_sg_mon_flag[i] == 1)
|
||||
{
|
||||
if(tempstr[11] == i)
|
||||
_8ecp_asciout_proc(tempstr);
|
||||
}
|
||||
}
|
||||
for(i = 0; i < MAX_TRK_NO; i++)
|
||||
{
|
||||
if(_8ecp_trk_mon_flag[i] == 1)
|
||||
if(tempstr[12] / 32 == i)
|
||||
_8ecp_asciout_proc(tempstr);
|
||||
}
|
||||
for(i = 0; i < MAX_CHL_NO; i++)
|
||||
{
|
||||
if(_8ecp_chl_mon_flag[i] == 1)
|
||||
if(tempstr[12] == i)
|
||||
_8ecp_asciout_proc(tempstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _8ecp_mon (void)
|
||||
{
|
||||
WORD str_len;
|
||||
BYTE * ascii_in_ptr = NULL;
|
||||
BYTE * tmpStr;
|
||||
DWORD mgNo = 0, trkNo = 0, chlNo = 0;
|
||||
BYTE error_flag = 0;
|
||||
if ((str_len = strlen (_8ecp_asciin_buf)) > 0)
|
||||
{
|
||||
ascii_in_ptr = _8ecp_asciin_buf + 1;
|
||||
if (strcmp (ascii_in_ptr, "log all") == 0)
|
||||
{
|
||||
monitor_flag = MONITOR_ALL;
|
||||
}
|
||||
else if (strcmp (ascii_in_ptr, "log none") == 0)
|
||||
{
|
||||
monitor_flag = MONITOR_NONE;
|
||||
}
|
||||
else if (strcmp (ascii_in_ptr, "help") == 0)
|
||||
{
|
||||
_8ecp_asciout_proc (log_help);
|
||||
}
|
||||
else if (strcmp (ascii_in_ptr, "log error on") == 0)
|
||||
{
|
||||
monitor_flag = MONITOR_ERROR_ON;
|
||||
}
|
||||
else if (strcmp (ascii_in_ptr, "log error off") == 0)
|
||||
{
|
||||
monitor_flag = MONITOR_ERROR_OFF;
|
||||
}
|
||||
else if ((strstr (ascii_in_ptr, "log mg")) != NULL)
|
||||
{
|
||||
if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (mgNo >= 0 && mgNo <= 31)
|
||||
{
|
||||
if (strstr (ascii_in_ptr, "on") != NULL)
|
||||
{
|
||||
_8ecp_sg_mon_flag[mgNo] = 1;
|
||||
}
|
||||
else if (strstr (ascii_in_ptr, "off") != NULL)
|
||||
{
|
||||
_8ecp_sg_mon_flag[mgNo] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
error_flag = 1; //the format of command is error
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
}
|
||||
else if (strstr (ascii_in_ptr, "log trk"))
|
||||
{
|
||||
if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (mgNo >= 0 && mgNo <= 31)
|
||||
{
|
||||
while (*++tmpStr != '\0') //get the next char '-'
|
||||
{
|
||||
if (*tmpStr == '-')
|
||||
{
|
||||
trkNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (trkNo >= 0 && trkNo <= 7)
|
||||
{
|
||||
if (strstr (tmpStr, "on") != NULL)
|
||||
{
|
||||
_8ecp_trk_mon_flag[mgNo * 8 + trkNo] = 1;
|
||||
}
|
||||
else if (strstr (tmpStr, "off") != NULL)
|
||||
{
|
||||
_8ecp_trk_mon_flag[mgNo * 8 + trkNo] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
}
|
||||
else if (strstr (ascii_in_ptr, "log chl"))
|
||||
{
|
||||
if ((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
|
||||
{
|
||||
mgNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (mgNo >= 0 && mgNo <= 31)
|
||||
{
|
||||
while (*++tmpStr != '\0') //get the next char '-'
|
||||
{
|
||||
if (*tmpStr == '-')
|
||||
{
|
||||
trkNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (trkNo >= 0 && trkNo <= 7)
|
||||
{
|
||||
while (*++tmpStr != '\0') //get the next char '-'
|
||||
{
|
||||
if (*tmpStr == '-')
|
||||
{
|
||||
chlNo = strtoul (tmpStr + 1, NULL, 10);
|
||||
if (chlNo >= 0 && chlNo <= 31)
|
||||
{
|
||||
if (strstr (tmpStr, "on") != NULL)
|
||||
{
|
||||
_8ecp_chl_mon_flag[mgNo * 8 * 32 + chlNo] = 1;
|
||||
}
|
||||
|
||||
else if (strstr (tmpStr, "off") != NULL)
|
||||
{
|
||||
_8ecp_chl_mon_flag[mgNo * 8 * 32 + chlNo] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
error_flag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
error_flag = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
error_flag = 1;
|
||||
|
||||
if (error_flag == 0)
|
||||
_8ecp_asciout_proc("Command OK!\n\r");
|
||||
else
|
||||
_8ecp_asciout_proc("Command Error!\n\r");
|
||||
|
||||
strcpy (_8ecp_asciin_buf, "\0");
|
||||
}
|
||||
|
||||
}
|
||||
149
plat/8ecp/src/include/8ecp.h
Normal file
149
plat/8ecp/src/include/8ecp.h
Normal file
@@ -0,0 +1,149 @@
|
||||
#ifndef _8ECP__H
|
||||
#define _8ECP__H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <time.h>
|
||||
#include "../../../public/src/include/includes.h"
|
||||
#include "../../../public/src/include/public.h"
|
||||
#include "../../../iptrans/src/include/iptrans.h"
|
||||
#include "../../../snmp/src/include/snmp.h"
|
||||
#include "../../../debug/src/include/debug.h"
|
||||
|
||||
#include "./8ecp_debug.h"
|
||||
|
||||
extern BYTE s_msg[128];
|
||||
|
||||
#ifndef _8ECP_MAX_USER_NAME_LEN
|
||||
#define _8ECP_MAX_USER_NAME_LEN 100
|
||||
#endif
|
||||
|
||||
#ifndef _8KE1_NUM
|
||||
#define _8KE1_NUM 32
|
||||
#endif
|
||||
|
||||
#ifndef MAX_DELAY
|
||||
#define MAX_DELAY 1 //the max delay time of heartbeat message
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef PORT
|
||||
#define PORT 4950
|
||||
#endif
|
||||
|
||||
#ifndef OID_Prefix
|
||||
#define OID_Prefix 8
|
||||
#endif
|
||||
|
||||
#ifndef InUSE
|
||||
#define InUse 1
|
||||
#endif
|
||||
|
||||
#ifndef NotInUse
|
||||
#define NotInUse 0
|
||||
#endif
|
||||
|
||||
#ifndef TrkStartIndex
|
||||
#define TrkStartIndex 8 //the first index of trkno in the heartbeat msg
|
||||
#endif
|
||||
|
||||
#ifndef E1NumOnCSU
|
||||
#define E1NumOnCSU 16
|
||||
#endif
|
||||
|
||||
#ifndef _T_BYTE
|
||||
#define _T_BYTE
|
||||
typedef unsigned char BYTE;
|
||||
#endif
|
||||
|
||||
#ifndef _T_WORD
|
||||
#define _T_WORD
|
||||
typedef unsigned short WORD;
|
||||
#endif
|
||||
|
||||
#ifndef _T_DWORD
|
||||
#define _T_DWORD
|
||||
typedef unsigned int DWORD;
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _8ECP_SAP
|
||||
{
|
||||
char name[_8ECP_MAX_USER_NAME_LEN];
|
||||
|
||||
//8ECP module will use these callback functions to update 8E1 MG and trunk status
|
||||
//Return 0 if success, return -1 if failure
|
||||
int (*update_mg_status)(BYTE mgNo, BYTE status);
|
||||
int (*update_trk_status)(BYTE mgNo, BYTE trkNo, BYTE status);
|
||||
|
||||
}_8ECP_SAP;
|
||||
|
||||
|
||||
typedef struct _8ECP_PDU //the message send to IPTRANS
|
||||
{
|
||||
BYTE reserved;
|
||||
BYTE lenInd;
|
||||
BYTE CPC_IFA_Inf; //fixed value 0x87
|
||||
BYTE dstRef[2];
|
||||
BYTE reserved1;
|
||||
BYTE sourceRef[2];
|
||||
BYTE reserved2;
|
||||
BYTE type; //00=connect time slot with echo
|
||||
//01=connect ack
|
||||
//02=connect tone
|
||||
//03=connect DTMF
|
||||
//04=connect group
|
||||
//05=disconnect group
|
||||
//06=connect time slot without echo
|
||||
BYTE sourceTimeSlotNo;
|
||||
BYTE dstModuleID;
|
||||
BYTE dstTimeSlotNo;
|
||||
BYTE Value; /*when type=02,
|
||||
0=tone#0, 1=tone#1, 2=tone#2, 3=tone#3,
|
||||
4=tone#4, 5=tone#5/,6=tone#6, 7=tone#7
|
||||
|
||||
when type=03
|
||||
0=DTMF1, 1=DTMF2, 2=DTMF3, 3=DTMF4,
|
||||
4=DTMF5, 5=DTMF6, 6=DTMF7, 7=DTMF8,
|
||||
8=DTMF9, 9=DTMF0, 10=DTMF*, 11=DTMF#
|
||||
|
||||
*/
|
||||
|
||||
BYTE duration;
|
||||
|
||||
|
||||
}_8ECP_PDU;
|
||||
|
||||
|
||||
// the struct of SAP in 8ecp
|
||||
typedef struct _SAP_In_8ECP
|
||||
{
|
||||
BYTE inUse;
|
||||
_8ECP_SAP _8ecp_sap;
|
||||
}SAP_In_8ECP;
|
||||
|
||||
// the struct of MG in 8ecp
|
||||
typedef struct Card_Struct
|
||||
{
|
||||
// WORD mgNo;
|
||||
DWORD ip;
|
||||
BYTE mgNo;
|
||||
}Card_Struct;
|
||||
|
||||
|
||||
|
||||
//8ecp interface
|
||||
int _8ecp_bind(_8ECP_SAP *sap);
|
||||
int _8ecp_unbind(BYTE sapIndex);
|
||||
|
||||
int _8ecp_createMG(WORD mgNo, DWORD ip, BYTE cardNo); //create or update MG
|
||||
int _8ecp_deleteMG(WORD mgNo, DWORD ip, BYTE cardNo); //delete MG
|
||||
|
||||
void _8ecp_connect_chnl(WORD orgChnl, WORD dstChnl, BYTE ecDisable); //ecDisable:0/1=enable/disable echo canceller
|
||||
void _8ecp_connect_dtmf(WORD orgChnl, WORD dstChnl, BYTE dtmfNo);
|
||||
void _8ecp_connect_tone(WORD orgChnl, WORD dstChnl, BYTE toneNo, WORD duration);
|
||||
void _8ecp_init(); //called in the main program during initialization stage
|
||||
void _8ecp_timer(); //called every 10ms in the main program
|
||||
#endif
|
||||
33
plat/8ecp/src/include/8ecp_debug.h
Normal file
33
plat/8ecp/src/include/8ecp_debug.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef _8ECP_DEBUG_H
|
||||
#define _8ECP_DEBUG_H
|
||||
|
||||
#define BASE_ID_LEN 15
|
||||
#define PAGE_POINT 14
|
||||
#define LINE_POINT 15
|
||||
#define MAX_ASCIIIN_LEN 4096
|
||||
#define MAX_ASCIIOUT_LEN 4096
|
||||
#define MONITOR_ERROR_OFF 3
|
||||
#define MONITOR_ERROR_ON 2
|
||||
#define MONITOR_ALL 1
|
||||
#define MONITOR_NONE 0
|
||||
#define MAX_MG_NO 32
|
||||
#define MAX_TRK_NO MAX_MG_NO * 8
|
||||
#define MAX_CHL_NO MAX_TRK_NO * 32
|
||||
|
||||
#ifndef _T_BYTE
|
||||
#define _T_BYTE
|
||||
typedef unsigned char BYTE;
|
||||
#endif
|
||||
|
||||
#ifndef _T_WORD
|
||||
#define _T_WORD
|
||||
typedef unsigned short WORD;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int _8ecp_debug_set(void);
|
||||
int _8ecp_asciout_proc(BYTE* out_ptr);
|
||||
void _8ecp_mon(void);
|
||||
void log_procedure(BYTE flag, BYTE* tempstr);
|
||||
#endif
|
||||
Reference in New Issue
Block a user