init ems server code

This commit is contained in:
2024-09-27 15:39:34 +08:00
parent 9d4009aaca
commit 9930e4e58f
1551 changed files with 110216 additions and 102864 deletions

97
plat/8ecp/Makefile Normal file
View 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
View 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
View 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");
}
}

View 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

View 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

96
plat/aif/Makefile Normal file
View File

@@ -0,0 +1,96 @@
##----------------------------------------------------------##
## ##
## 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 = aif
TYPE = plat
DBUG_FLAGS_ADD = -D_AIFG_DEBUG_
RELS_FLAGS_ADD =
##Default commonly as below
BUILD = lib
CFG = debug
PLT_LIB = cunit public debug iptrans snmp mtp3 sccp
APP_LIB =
LIB_ADD =
SRC_PATH = ./src
INC_PATH = ./src/include
PLT_PATH = ../../plat
APP_PATH = ../../app
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 = yes
COVER_REPORT_PATH = ./ut/ut_doc/output
MAKE_INCLUDE = $(HOME)/ems.git/include
##---------------------------------------------------------------------##
##--------------------------------------
##
## include makefile.rules (Do not change)
##
##--------------------------------------
include $(MAKE_INCLUDE)/Makefile.rules

View File

@@ -0,0 +1,21 @@
ACRD Software Module Release Notes
Module Name: AIFG
#----------------------------------------------
[Version]
R9V0_05P2
[Release Date]
2008-1-8
[Author]
Roy Jiang
[Changes]
Bug fixed:
1.NA
Improvements:
1.NA
New features:
1.NA
[Remark]
1.Initial Clearcase release
#----------------------------------------------

265
plat/aif/src/aifg.c Normal file
View File

@@ -0,0 +1,265 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_if.c
Description: Interface of AIFG
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-12
History:
2007-3-6 v9.0.1 Create
*********************************************************************/
#include "./include/aifg_var_ext.h"
#include "../../public/src/include/license_id.h"
/*
Name: aifg_bind
Purpose: Request to create a SAP in AIFG module.
Input: aifg_sap_type type: type of upper layer entity
int (*callback)(): pointer to call back function
Output: SAP id
*/
int aifg_bind(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *))
{
//checking parameters
assert(type == AIFG_SAP_MSC || type == AIFG_SAP_BSC);
assert(callback != NULL);
assert(sap[type].enable == 0);
if (wxc2_get_license(LIC_AIF) != 1)
return -1;
sap[type].enable = 1;
sap[type].callback_func = callback;
return (int)type;
}
/*
Name: aifg_modify
Purpose: Request to modify the SAP parameter in AIFG module.
Input: aifg_sap_type type: type of upper layer entity
aifg_callback_func *callback: new callback functions, null if no need to modify
Output: None
*/
void aifg_modify(int sapid, int (*callback)(aifg_indication, aifg_msg_pre_decoded*))
{
//checking parameters
assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC);
assert(sap[sapid].enable == 1);
sap[sapid].enable = 1;
if(callback != NULL)
sap[sapid].callback_func = callback;
return;
}
/*
Name: aifg_set_running_mode
Purpose: Set the running mode of AIFG module.
Input: enum aifg_run_mode mode: running mode, 0 - single, 1 - dual
int alter_ip:IP address of the alternative server, hex format
Output: None
*/
void aifg_set_running_mode(aifg_run_mode mode)
{
assert(mode == AIFG_RUN_MODE_SINGLE || mode == AIFG_RUN_MODE_DUAL);
dual_server.mode = mode;
return;
}
/*
Name: aifg_createCircuitGroup
Purpose: Request to create a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int dpc: DPC of the circuit group.
aifg_ni ni: NI of the circuit group.
Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module
whenever it request to send a message through this circuit group
AIFG_ERR_NO_RESOURCE: Create failed
*/
int aifg_createCircuitGroup(int sapid, int dpc, aifg_ni ni, int tgid)
{
int i;
assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC);
assert(ni >= 0 && ni <= 3);
assert(dpc >= 0);
if (sap[sapid].enable == 0)
goto ERR_PROC;
//check if there is a existing CG with the same dpc and ni
for(i=0; i < AIFG_MAX_CG; i++){
if(cg[i].enable == 1 && cg[i].dpc == dpc && cg[i].ni == ni)
return i;
}
//create a new circuit group
i = 0;
while(cg[i].enable == 1)
i++;
if(i >= AIFG_MAX_CG){
aifg_event = AIFG_ERR_OUT_OF_RESOURCE;
goto ERR_PROC;
}
cg[i].enable = 1;
cg[i].dpc = dpc;
cg[i].ni = ni;
cg[i].sapid = sapid;
cg[i].tgid = tgid;
return i;
ERR_PROC:
return -1;
}
/*
Name: aifg_delCircuitGroup
Purpose: Request to delete a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int cgid: Circuit Group ID
Output: None
*/
void aifg_delCircuitGroup(int sapid, int cgid)
{
assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC);
assert(cgid >= 0 && cgid < AIFG_MAX_CG);
cg[cgid].enable = 0;
cg[cgid].dpc = 0;
cg[cgid].ni = 0;
cg[cgid].sapid = 0;
cg[cgid].tgid = 0;
return;
}
/*
Name: aifg_modCircuitGroup
Purpose: Request to modify the parameter of a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int cgid: Circuit Group ID
int dpc: new DPC of the circuit group, -1 if no need to change.
enum aifg_ni: new NI of the circuit group, -1 if no need to change.
Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module
whenever it request to send a message through this circuit group
*/
int aifg_modCircuitGroup(int sapid, int cgid, int dpc, int ni)
{
assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC);
assert(cg[cgid].sapid == sapid);
assert(ni >= 0 && ni <= 3);
assert(dpc >= 0);
assert(cgid >= 0 && cgid < AIFG_MAX_CG);
cg[cgid].enable = 1;
cg[cgid].dpc = dpc;
cg[cgid].ni = ni;
return cgid;
}
/*
Name: aifg_send
Purpose: Request to send a message through A-interface.
Input: int sapid: SAP ID of upper layer entity.
int cgid: Circuit Group ID
int u_port: process port of upper layer entity
aifg_msg *msg: content of assign request message
Output: 0 - succeed
-1 - failed, no free port available
-2 - failed, circuit group not ready
*/
int aifg_send(int sapid, int cgid, int u_port, aifg_msg_t *msg)
{
int protocol;
assert(sapid == AIFG_SAP_MSC || sapid == AIFG_SAP_BSC);
assert(cgid >= 0 && cgid < AIFG_MAX_CG);
assert(msg != NULL);
if (sap[sapid].enable == 0){
aifg_event = AIFG_ERR_SAP_NOT_CREATED;
goto ERR_PROC;
}
//check message protocol and pd
msg->app_port = u_port;
if(msg->id <= AIFG_MSG_ID_RP_SMMA){
if(msg->id <= AIFG_MSG_ID_MM_INFO)
msg->pd = AIFG_PD_DTAP_MM;
else if(msg->id <= AIFG_MSG_ID_FACILITY)
msg->pd = AIFG_PD_DTAP_CC;
else if(msg->id <= AIFG_MSG_ID_RELEASE_CMP_SS)
msg->pd = AIFG_PD_DTAP_SS;
else if(msg->id <= AIFG_MSG_ID_RP_SMMA)
msg->pd = AIFG_PD_DTAP_SMS;
else
assert(0);
protocol = AIFG_MSG_DTAP;
}
else{
if(msg->id <= AIFG_MSG_ID_HO_CAN_RESP)
msg->pd = AIFG_PD_BSSMAP_GLOBAL;
else if(msg->id <= AIFG_MSG_ID_LSA_INFO)
msg->pd = AIFG_PD_BSSMAP_DEDICATED;
else
assert(0);
protocol = AIFG_MSG_BSSMAP;
}
if(msg->aif_port == -1 || msg->pd == AIFG_PD_BSSMAP_GLOBAL){
if(msg->pd != AIFG_PD_BSSMAP_GLOBAL || msg->id == AIFG_MSG_ID_PAGING){
if((msg->aif_port = aifg_port_assign(sapid, cgid, -1)) < 0){
aifg_event = AIFG_ERR_ASSIGN_PORT_FAIL;
goto ERR_PROC;
}
aifg_pcb[msg->aif_port].upper_port = u_port;
aifg_pcb[msg->aif_port].trace_flag = msg->trace_flag;
}
else{
msg->aif_port = -1; //no port need
aifg_send_udt(cgid, msg, NULL); //global BSSMAP message needs no aifg port, except paging
}
}
else if (aifg_pcb[msg->aif_port].stat == AIFG_PORT_TRANSACTION && aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_UNKNOW){
if((msg->id == AIFG_MSG_ID_SETUP
&& (aifg_pcb[msg->aif_port].ti_stat > 0 || aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_CC))
|| (msg->id == AIFG_MSG_ID_RP_DATA
&& aifg_pcb[msg->aif_port].ti_type != AIFG_TRANS_SMS))
{
//new transaction
int new_port = aifg_port_assign(sapid, cgid, -1);
if (new_port < 0){
aifg_event = AIFG_ERR_ASSIGN_PORT_FAIL;
goto ERR_PROC;
}
aifg_pcb[new_port].upper_port = u_port;
aifg_pcb[new_port].link_id = aifg_pcb[msg->aif_port].link_id;
aifg_pcb[new_port].trace_flag = msg->trace_flag;
msg->aif_port = new_port;
}
}
if(msg->aif_port != -1){
if (aifg_pcb[msg->aif_port].stat == AIFG_PORT_IDLE){
aifg_event = AIFG_ERR_MSG_SD_TO_IDLE_PORT;
goto ERR_PROC;
}
aifg_pcb[msg->aif_port].cgid = cgid;
aifg_port_proc(&aifg_pcb[msg->aif_port], msg, NULL);
}
aifg_debug_print(msg->aif_port, AIFG_EVENT_RV_REQ, msg, 0);
return AIFG_SUCCEED;
ERR_PROC:
aifg_debug_print(msg->aif_port, aifg_event, msg, u_port);
return AIFG_ERROR;
}

310
plat/aif/src/aifg_csta.c Normal file
View File

@@ -0,0 +1,310 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_csta.c
Description: CSTA of AIFG
Version: v9.0.0
Author: XH Chen
Create Date: 2008-3-12
History:
2007-3-6 v9.0.1 Create
*********************************************************************/
#include "../../../plat/public/src/include/includes.h"
#include "../../../plat/snmp/src/include/snmp.h"
#include "./include/aifg_type_def.h"
#define NO_EXIST 0
#define EXIST 1
#define OID_OFFSET 14
#define AIF_10SEC 1000
struct obj_view {
int entry_oidlen;
int column_oidlen;
int full_oidlen;
DWORD *entry;
DWORD *column;
DWORD *iid; /* Instance ID */
BYTE csta_pos;
BYTE csta_len;
};
typedef void *(*lookup_level_1)(u32 *oid_1);
typedef void *(*lookup_level_2)(u32 oid_1, u32 *oid_2);
typedef int (*get_csta)(struct obj_view *view, u8 *pdata, u8 *vartype);
struct tab_view{
BYTE exist_flag;
BYTE entry_id;
BYTE level; /* Three level: 1, 2*/
lookup_level_1 lookup_1;
lookup_level_2 lookup_2;
get_csta get_aif_csta;
u8 next_column[16];
struct obj_view view;
};
#define AIF_OID {1,3,6,1,4,1,1373,2,3,2,6}
#define AIF_OIDLEN 11
typedef struct{
unsigned long timestamp;
int msg_stat[AIFG_MAX_MESSAGE*2];
}aifg_csta;
BYTE aifCSTAInd;
aifg_csta aifCSTA[96];
//DTAP:RR MM CC SS SMS; BSSMAP:Global Dedicated
const BYTE cstaLen[8] = {0, 2, 21, 31, 3, 4, 18, 36};
const BYTE postion[8] = {0, 0, 4, 46, 108, 114, 122, 158};
extern int msg_statistics[AIFG_MAX_MESSAGE][2];
u32 *findnext_quater(u32 *id);
int get_aif_csta(struct obj_view *view, BYTE *pdata, BYTE *vartype);
int aifg_get_resp(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype);
int aif_getnext_resp(u8 prev_oidlen, u32 *prev_oid, u8 *oidlen, u32 *oid, u8 *pdata, u8 *vartype);
static struct tab_view aif_csta_table[8]={
{NO_EXIST},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
{
EXIST, OID_OFFSET, 1,
(void *)findnext_quater, NULL,
get_aif_csta,
{1, 2, 0}
},
};
void aifg_csta_init(void)
{
DWORD aif_oid_prefix[20] = AIF_OID;
inquire_getmsg(AIF_OIDLEN, aif_oid_prefix, aifg_get_resp);
inquire_getnextmsg(AIF_OIDLEN, aif_oid_prefix, aif_getnext_resp);
memset(aifCSTA, 0, sizeof(aifCSTA));
}
void aifg_csta_proc(void)
{
static int counter = 0;
static BYTE flag = 0;
struct tm *t;
unsigned long l_time;
if(counter ++ >= AIF_10SEC)
{
l_time = time(NULL);
t = localtime(&l_time);
counter = 0;
if(t->tm_min % 15 < 2) //per 15 min
{
if(flag == 0)
{
/* get csta index */
aifCSTAInd = t->tm_hour * 4 + t->tm_min / 15;
/* copy the msg statistic to the csta buffer */
memcpy(aifCSTA[aifCSTAInd].msg_stat, msg_statistics, sizeof(msg_statistics));
aifCSTA[aifCSTAInd].timestamp = l_time;
/* clear msg statistic */
memset(msg_statistics, 0, sizeof(msg_statistics));
flag = 1;
}
}
else
flag = 0;
}
}
u32 *findnext_quater(u32 *id)
{
int csta_inst = aifCSTAInd;
//CHECKME: to make sure it can run across 24 hours
if(csta_inst > 0)
csta_inst -= 1;
if(*id != csta_inst)
{
*id = csta_inst;
return id;
}
*id = 0;
return NULL;
}
struct obj_view *gen_obj_view(struct tab_view *table, u32 *oid)
{
struct obj_view *view = &table->view;
view->entry = oid + table->entry_id;
view->entry_oidlen = table->entry_id + 1;
view->column =view->entry + 1;
view->column_oidlen = view->entry_oidlen + 1;
view->iid = view->column + 1;
view->full_oidlen = view->column_oidlen + table->level;
view->csta_pos = postion[oid[table->entry_id-1]];
view->csta_len = cstaLen[oid[table->entry_id-1]];
return view;
}
struct tab_view *lookup_csta_table(BYTE oidlen, DWORD *oid)
{
int index;
if(oidlen < AIF_OIDLEN +2)
return NULL;
index = oid[AIF_OIDLEN];
if(index >= 8)
return NULL;
else if(aif_csta_table[index].exist_flag == 0)
return NULL;
else
return &aif_csta_table[index];
}
void aifg_encode_csta(BYTE *pData, BYTE pos, BYTE Len, aifg_csta *pCsta)
{
unsigned long *pDW = (unsigned long *)pData;
int *pSrc = (int *)&pCsta->msg_stat[2];
int *pDst = (int *)(pData + 4);
int i;
pDW[0] = htonl(pCsta->timestamp);
for(i = 0; i < Len*2; i++)
pDst[i] = htonl(pSrc[pos + i]);
}
int get_aif_csta(struct obj_view *view, BYTE *pdata, BYTE *vartype)
{
int dataLen = 0;
int csta_inst;
if((csta_inst = view->iid[0]) >= 96)
return -1;
switch(*(view->column))
{
case 1:
*((int *)pdata) = htonl(csta_inst);
*vartype = 0x02;
dataLen = 4;
break;
case 2:
if(aifCSTA[csta_inst].timestamp == 0)
return 0;
*vartype = 0x04;
aifg_encode_csta(pdata,view->csta_pos, view->csta_len, &aifCSTA[csta_inst]);
dataLen = (view->csta_len*sizeof(int)*2+4);
break;
}
return dataLen;
}
int aifg_get_resp(BYTE oidlen, DWORD *oid, BYTE *pdata, BYTE *vartype)
{
struct tab_view *table;
struct obj_view *view;
if((table = lookup_csta_table(oidlen, oid)) == NULL)
return -1;
view = gen_obj_view(table, oid);
if(oidlen != view->full_oidlen)
return -1;
if(*(view->entry) != 1)
return -1;
if(table->get_aif_csta == NULL)
return -1;
else
return table->get_aif_csta(view, pdata, vartype);
}
static int get_nextOid(u8 *oidlen, u32 *oid)
{
struct tab_view *table;
struct obj_view *view;
if((table = lookup_csta_table(*oidlen, oid)) == NULL)
return 0;
view = gen_obj_view(table, oid);
if(*oidlen < view->full_oidlen)
{
memset(&oid[*oidlen], 0, view->full_oidlen-*oidlen);
if(*oidlen < view->entry_oidlen)
*view->entry = 1;
if(*oidlen < view->column_oidlen)
*view->column = table->next_column[0];
if(*oidlen == view->full_oidlen-1)
{
*oidlen = view->full_oidlen;
}
*oidlen = view->full_oidlen;
}
for(; *(view->column) != 0; *(view->column) = table->next_column[*(view->column)])
{
switch(table->level)
{
case 1:
if(table->lookup_1(view->iid) != NULL)
return 1;
break;
case 2:
break;
case 3:
break;
}
}
return 0;
}
int aif_getnext_resp(u8 prev_oidlen, u32 *prev_oid, u8 *oidlen, u32 *oid, u8 *pdata, u8 *vartype)
{
memcpy(oid, prev_oid, prev_oidlen*sizeof(u32));
*oidlen = prev_oidlen;
if(get_nextOid(oidlen, oid))
{
return aifg_get_resp(*oidlen, oid, pdata, vartype);
}
else
return -1;
}

1296
plat/aif/src/aifg_debug.c Normal file

File diff suppressed because it is too large Load Diff

2227
plat/aif/src/aifg_ie.c Normal file

File diff suppressed because it is too large Load Diff

1689
plat/aif/src/aifg_m.c Normal file

File diff suppressed because it is too large Load Diff

7614
plat/aif/src/aifg_mpp.c Normal file

File diff suppressed because it is too large Load Diff

118
plat/aif/src/include/aifg.h Normal file
View File

@@ -0,0 +1,118 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg.h
Description: API Definition of AIFG module
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-6
History:
2007-3-6 v9.0.0 Create
2007-7-7 v9.0.1 Remove Block/Unblock/Reset/Reset CC/Overload/HO Can. Enq. API,
replace with aifg_send
*********************************************************************/
#ifndef _WXC2_AIFG_H
#define _WXC2_AIFG_H
#include "aifg_msg.h"
/*******************************SAP Management**********************************/
/*
Name: aifg_bind
Purpose: Request to create a SAP in AIFG module.
Input: aifg_sap_type type: type of upper layer entity
int opc:OPC of upper layer entity.
aifg_ni ni: NI of upper layer entity.
Output: SAP id
*/
int aifg_bind(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *));
/*
Name: aifg_modify
Purpose: Request to modify the SAP parameter in AIFG module.
Input: aifg_sap_type type: type of upper layer entity
int opc: new OPC, -1 if no need to modify
aifg_ni ni:new NI, -1 if no need to modify
aifg_callback_func *callback: new callback functions, null if no need to modify
Output: none
*/
void aifg_modify(aifg_sap_type type, int (*callback)(aifg_indication, aifg_msg_pre_decoded *));
/*
Name: aifg_set_running_mode
Purpose: Set the running mode of AIFG module.
Input: enum aifg_run_mode mode: running mode, 0 - single, 1 - dual
int alter_ip:IP address of the alternative server, hex format
Output: None
*/
void aifg_set_running_mode(aifg_run_mode mode);
/*
Name: aifg_createCircuitGroup
Purpose: Request to create a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int dpc: DPC of the circuit group.
aifg_ni ni: NI of the circuit group.
Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module
whenever it request to send a message through this circuit group
-1: Create failed
*/
int aifg_createCircuitGroup(int sapid, int dpc, aifg_ni ni, int tgid);
/*
Name: aifg_modCircuitGroup
Purpose: Request to modify the parameter of a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int cgid: Circuit Group ID
int dpc: new DPC of the circuit group, -1 if no need to change.
enum aifg_ni: new NI of the circuit group, -1 if no need to change.
Output: Circuit Group ID - Upper layer entity should record this ID and pass it to AIFG module
whenever it request to send a message through this circuit group
*/
int aifg_modCircuitGroup(int sapid, int cgid, int dpc, int ni);
/*
Name: aifg_delCircuitGroup
Purpose: Request to delete a circuit group in AIFG module.
Input: int sapid: SAP ID of upper layer entity
int cgid: Circuit Group ID
Output: None
*/
void aifg_delCircuitGroup(int sapid, int cgid);
/*
Name: aifg_send
Purpose: Request to send a message through A-interface.
Input: int sapid: SAP ID of upper layer entity.
int cgid: Circuit Group ID
int u_port: process port of upper layer entity
aifg_msg *msg: content of assign request message
Output: 0 - succeed
-1 - failed
-2 - failed, circuit group not ready
*/
int aifg_send(int sapid, int cgid, int u_port, aifg_msg_t *msg);
/*
Name: aifg_paging
Purpose: Request to paging.
Input: int sapid: SAP ID of upper layer entity
int cgid: Circuit Group ID
int u_port: process port of upper layer entity
aifg_msg_bm_paging *msg: paging message
Output: 0 - succeed
-1 - failed
-2 - failed, circuit group not ready
*/
int aifg_paging(int sapid, int cgid, int u_port, aifg_msg_t *msg);
/*
Name: aifg_ie_decode
Purpose: Information element decode function
Input: aifg_msg_protocol protocol: BSSMAP or DTAP
aifg_pre_decoded_ie *pre_decoded: pre-decoded IE structure
aifg_ie *dst: pointer to a aifg_ie structure object in which the decoded message will be stored.
Output: Total length of decoded IE
*/
int aifg_ie_decode(aifg_ie_ptr *pre_decoded, aifg_ie *dst);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,31 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_if.h
Description: Interface declearation for wxc2main
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-14
History:
2007-3-14 v9.0.0 Create
*********************************************************************/
#ifndef _WXC2_AIFG_IF_H
#define _WXC2_AIFG_IF_H
/*
Name: aifg_init
Purpose: Init AIFG module.
Input: None
Output: None
*/
void aifg_init();
/*
Name: aifg_init
Purpose: 10ms routing of AIFG module.
Input: None
Output: None
*/
void aifg_proc();
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_public.h
Description: Public definition of AIFG module
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-6
History:
2007-3-6 v9.0.0 Create
*********************************************************************/
#ifndef _WXC2_AIFG_PUBLIC_H
#define _WXC2_AIFG_PUBLIC_H
//Common include
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../../../public/src/include/public.h"
typedef enum _aifg_sap_type{
AIFG_SAP_MSC,
AIFG_SAP_BSC
}aifg_sap_type;
typedef enum _aifg_ni{
AIFG_NI_INTERNATIONAL,
AIFG_NI_INTERNATIONAL_SPARE,
AIFG_NI_NATIONAL,
AIFG_NI_NATIONAL_SPARE,
}aifg_ni;
typedef enum _aifg_run_mode{
AIFG_RUN_MODE_SINGLE = 0,
AIFG_RUN_MODE_DUAL,
}aifg_run_mode;
typedef enum _aifg_indication{
AIFG_IND_RV_MSG,
}aifg_indication;
#endif

View File

@@ -0,0 +1,445 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_type_def.h
Description: Data structure definition of AIFG module
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-12
History:
2007-3-6 v9.0.12 Create
*********************************************************************/
#ifndef _WXC2_AIFG_TYPE_DEF_H
#define _WXC2_AIFG_TYPE_DEF_H
#include "aifg_public.h"
#include "aifg_msg.h"
#include "../../../sccp/src/include/scoc_if.h"
#ifndef NULL
#define NULL 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#define SCCP_SAP_AIFG 3
#define AIFG_PROC_FINISH 1
#define AIFG_PROC_CONTINUE 0
#define AIFG_MAX_CG 256
#define AIFG_MAX_SAP 2
#define MSG_PROC_EACH_TIME 64
#define AIFG_MAX_PORT 8192
#define AIFG_MAX_MSG_LENGTH 256
#define AIFG_MAX_TI_PER_LINK 16
#define AIFG_MAX_MESSAGE 128
#define SCCP_MAX_LINK 8192
typedef struct{
int port;
BYTE *data_ptr;
}aifg_raw_msg;
enum {AIFG_CG_AVAILABLE, AIFG_CG_UNAVAILABLE};
typedef struct{
BYTE enable;
int (*callback_func)(aifg_indication, aifg_msg_pre_decoded *);
}aifg_sap;
typedef struct{
BYTE mode;
}aifg_dual_server;
typedef enum{
AIFG_CG_STATE_DOWN,
AIFG_CG_STATE_UP,
}aifg_cg_state;
//port status definition
typedef enum {
AIFG_PORT_IDLE,
AIFG_PORT_INIT,
AIFG_PORT_PAGING,
AIFG_PORT_RESET,
AIFG_PORT_TRANSACTION,
AIFG_PORT_TRANSPARENT,
AIFG_PORT_RELEASE,
AIFG_PORT_FINISH,
}AIFG_PORT_STATE;
typedef enum{
AIFG_TRANS_UNKNOW = -1,
AIFG_TRANS_LU = 1,
AIFG_TRANS_CC = AIFG_PD_DTAP_CC, //3
AIFG_TRANS_SMS = AIFG_PD_DTAP_SMS, //9
AIFG_TRANS_SS = AIFG_PD_DTAP_SS, //11
}AIFG_TRANS_TYPE;
typedef struct aifg_port_t{
aifg_sap_type sapid; //SAP id
BYTE cgid; //circuit group id
int link_id; //link id
int new_link; //for handover, new link id to which the call will be handover to
int upper_port; //process port of upper layer
AIFG_PORT_STATE stat; //port status
int timer; //process timer
struct aifg_port_t *pNextOpenPort; //pointer to the next port in the opened port list
struct aifg_port_t *pPrevOpenPort; //pointer to the previous port in the opened port list
struct aifg_port_t *pNextPort; //pointer to the next port of the same BSSMAP transaction, such as paging/block
struct aifg_port_t *pPrevPort; //pointer to the previous port of the same BSSMAP transaction, such as paging/block
char ti; //TI value, including the TI flag
AIFG_TRANS_TYPE ti_type; //Transaction type of this port (CC/SS/SMS)
BYTE ti_stat; //Transaction status
BYTE rel_cause; //release cause
BYTE diagnostic[32]; //diagnostic for release
BYTE diag_len; //diagnostic length
BYTE imsi[16]; //associated mobile IMSI
BYTE imsi_len; //associated mobile IMSI length
BYTE ho_stat; //handover status
int app_ho_port; //application handover process port
SP_UiPriPara sd_buffer; //send message buffer, used in case when message re-send is needed
BYTE app_rel_flag; //flag to indicate whether app is released
BYTE trace_flag; //for debug trace
#ifdef _AIFG_DEBUG_
unsigned int dead_timer; //for resource leak checking
#endif
}aifg_port;
//timer definition, second
#define T1S_MULTIPLIER 100
enum{
AIFG_TIMER_T2 = 3 * T1S_MULTIPLIER, //Reset guard period at the MSC
AIFG_TIMER_T13 = 3 * T1S_MULTIPLIER, //Reset guard period at the BSS
AIFG_TIMER_T14 = 60 * T1S_MULTIPLIER, //Time to receive RESET ACKNOWLEDGE at the BSS
AIFG_TIMER_T16 = 60 * T1S_MULTIPLIER, //Time to receive RESET ACKNOWLEDGE at the MSC
AIFG_TIMER_T3113 = 15 * T1S_MULTIPLIER, //Time to receive PAGING RESPONSE at MSC
AIFG_TIMER_REPAGE = 8 * T1S_MULTIPLIER, //Time to resend PAGING REQUEST at MSC
AIFG_TIMER_TRANS_TIMEOUT = 120 * T1S_MULTIPLIER, //120s
AIFG_TIMER_CLEAR_TIMEOUT = 10 * T1S_MULTIPLIER, //10s
AIFG_TIMER_RELEASE_TIMEOUT = 10 * T1S_MULTIPLIER, //10s
AIFG_TIMER_WAIT_RELEASE_CMP = 50 //500ms
};
typedef struct{
BYTE enable;
int dpc;
aifg_ni ni;
BYTE sapid; //SAP which owns this CG
int tgid; //MSC trunk group id
}aifg_circuit_group;
typedef struct{
BYTE en_flag;
BYTE cleared; //if the link was cleared, all the ports belongs to it will be released
aifg_sap_type sapid; //SAP which owns this link
int cur_port; //in MSC:current activated local port
//in BSC:current activated upper port, for no AIFG local port need at BSC side
BYTE ti_number; //number of current activated ti, used at MSC side
BYTE next_ti; //TI value for next network initiate transaction
struct{
BYTE en_flag;
BYTE tio;
int port; //corresponding port number
}ti[3][AIFG_MAX_TI_PER_LINK]; //0-7 is assigned by network, 8-15 is assigned by mobile, used at MSC side
//totally 3 types of TI according to different SAP: CC, SMS or SS
}aifg_link_info;
enum TI_TYPE{
TI_FOR_CC,
TI_FOR_SMS,
TI_FOR_SS,
};
typedef enum{
AIFG_SUCCEED = 0,
AIFG_ERROR = -1,
//Error definition 1 ~ 1023
AIFG_ERR_OUT_OF_RESOURCE = 1,
AIFG_ERR_UNKNOW_MSG,
AIFG_ERR_UNKNOW_IE,
AIFG_ERR_ERROR_MSG,
AIFG_ERR_ERROR_IE,
AIFG_ERR_UP_NOT_EXIST,
AIFG_ERR_NO_UD_IN_CR,
AIFG_ERR_UNEXPECTED_DT1,
AIFG_ERR_UNEXPECTED_UDT,
AIFG_ERR_UNEXPECTED_CC,
AIFG_ERR_OVERLOAD,
AIFG_ERR_CG_NOT_READY,
AIFG_ERR_UNEXPECTED_PAGING_RESP,
AIFG_ERR_INVALID_TI,
AIFG_ERR_MISS_MANDATORY,
AIFG_ERR_MSG_RV_TO_IDLE_PORT,
AIFG_ERR_MSG_SD_TO_IDLE_PORT,
AIFG_ERR_ASSIGN_PORT_FAIL,
AIFG_ERR_SAP_NOT_CREATED,
AIFG_ERR_PORT_TIMER_OUT,
AIFG_ERR_CAN_NOT_FIND_TI,
AIFG_ERR_PAGING_NOT_RESP,
AIFG_ERR_PORT_RELEASED,
//event definition 1024 ~ 2048
AIFG_EVENT_SD_MSG = 1024, //Message sent to sccp
AIFG_EVENT_RV_MSG, //Message received from sccp
AIFG_EVENT_SD_IND, //Indication sent to upper app
AIFG_EVENT_RV_REQ, //Request received from upper app
AIFG_EVENT_REDIR_MSG, //Message redirected
AIFG_EVENT_CG_UP, //Circuit come up
AIFG_EVENT_LINK_RELEASE, //Link release
AIFG_EVENT_PORT_RELEASE,
}aifg_event_code;
typedef enum{
//DTAP
//RR
AIFG_MSG_T_PAGING_RESP = 0x27, //Paging response
AIFG_MSG_T_RR_HO_CMD = 0x2B, //RR Handover command
//MM
AIFG_MSG_T_IMSI_DETACH_IND = 0x01, //IMSI detach indication
AIFG_MSG_T_LU_ACCEPT = 0x02, //Location updating accept
AIFG_MSG_T_LU_REJECT = 0x04, //Location updating reject
AIFG_MSG_T_LU_REQUEST = 0x08, //Location updating request
AIFG_MSG_T_AUTH_REJECT = 0x11, //Authentication reject
AIFG_MSG_T_AUTH_REQUEST = 0x12, //Authentication request
AIFG_MSG_T_AUTH_RESPONSE = 0x14, //Authentication response
AIFG_MSG_T_ID_REQUEST = 0x18, //Identity request
AIFG_MSG_T_ID_RESPONSE = 0x19, //Identity response
AIFG_MSG_T_TMSI_REALLOC_CMD = 0x1A, //TMSI reallocation command
AIFG_MSG_T_TMSI_REALLOC_CMP = 0x1B, //TMSI reallocation complete
AIFG_MSG_T_CM_ACCEPT = 0x21, //CM service accept
AIFG_MSG_T_CM_REJECT = 0x22, //CM service reject
AIFG_MSG_T_CM_ABORT = 0x23, //CM service abort
AIFG_MSG_T_CM_REQUEST = 0x24, //CM service request
AIFG_MSG_T_CM_PROMPT = 0x25, //CM service prompt
AIFG_MSG_T_CM_REEST_REQUEST = 0x28, //CM re-establishment request
AIFG_MSG_T_ABORT = 0x29, //Abort
AIFG_MSG_T_MM_NULL = 0x30, //MM NULL
AIFG_MSG_T_MM_STATUS = 0x31, //MM status
AIFG_MSG_T_MM_INFO = 0x32, //MM information
//CC
AIFG_MSG_T_ALERTING = 0x01, //Alerting
AIFG_MSG_T_CALL_CONFIRMED = 0x08, //Call confirmed
AIFG_MSG_T_CALL_PROCEEDING = 0x02, //Call proceeding
AIFG_MSG_T_CONNECT = 0x07, //Connect
AIFG_MSG_T_CONNECT_ACK = 0x0F, //Connect ack
AIFG_MSG_T_EMERGENCY_SETUP = 0x0E, //Emergency setup
AIFG_MSG_T_PROGRESS = 0x03, //Progress
AIFG_MSG_T_SETUP = 0x05, //Setup
AIFG_MSG_T_MODIFY = 0x17, //Modify
AIFG_MSG_T_MODIFY_CMP = 0x1F, //Modify complete
AIFG_MSG_T_MODIFY_REJECT = 0x13, //Modify reject
AIFG_MSG_T_USER_INFO = 0x10, //User information
AIFG_MSG_T_HOLD = 0x18, //Hold
AIFG_MSG_T_HOLD_ACK = 0x19, //Hold ack
AIFG_MSG_T_HOLD_REJECT = 0x1A, //Hold reject
AIFG_MSG_T_RETRIEVE = 0x1C, //Retrieve
AIFG_MSG_T_RETRIEVE_ACK = 0x1D, //Retrieve ack
AIFG_MSG_T_RETRIEVE_REJECT = 0x1E, //Retrieve reject
AIFG_MSG_T_DISCONNECT = 0x25, //Disconnect
AIFG_MSG_T_RELEASE = 0x2D, //Release
AIFG_MSG_T_RELEASE_CMP = 0x2A, //Release complete
AIFG_MSG_T_CONGESTION_CTRL = 0x39, //Congestion control
AIFG_MSG_T_NOTIFY = 0x3E, //Notify
AIFG_MSG_T_STATUS = 0x3D, //Status
AIFG_MSG_T_STATUS_ENQ = 0x34, //Status enquiry
AIFG_MSG_T_START_DTMF = 0x35, //Start DTMF
AIFG_MSG_T_STOP_DTMF = 0x31, //Stop DTMF
AIFG_MSG_T_STOP_DTMF_ACK = 0x32, //Stop DTMF ack
AIFG_MSG_T_START_DTMF_ACK = 0x36, //Start DTMF ack
AIFG_MSG_T_START_DTMF_REJECT = 0x37, //Start DTMF reject
AIFG_MSG_T_FACILITY = 0x3A, //Facility
//SMS
AIFG_MSG_T_CP_DATA = 0x01, //CP-DATA
AIFG_MSG_T_CP_ACK = 0x04, //CP-ACK
AIFG_MSG_T_CP_ERROR = 0x10, //CP-ERRPR
AIFG_MSG_T_RP_DATA_MS = 0x00, //RP-DATA MS side
AIFG_MSG_T_RP_ACK_MS = 0x02, //RP-ACK MS side
AIFG_MSG_T_RP_ERROR_MS = 0x04, //RP-ERRPR MS side
AIFG_MSG_T_RP_SMMA = 0x06, //RP-SMMA MS side
AIFG_MSG_T_RP_DATA_NW = 0x01, //RP-DATA network side
AIFG_MSG_T_RP_ACK_NW = 0x03, //RP-ACK network side
AIFG_MSG_T_RP_ERROR_NW = 0x05, //RP-ERRPR network side
//SS
AIFG_MSG_T_FACILITY_SS = 0x3A, //Facility SS
AIFG_MSG_T_REGISTER = 0x3B, //Register
AIFG_MSG_T_RELEASE_CMP_SS = 0x2A, //Release complete SS
//BSSMAP
AIFG_MSG_T_ASSIGN_REQ = 0x01, //Assign request
AIFG_MSG_T_ASSIGN_CMP = 0x02, //Assign complete
AIFG_MSG_T_ASSIGN_FAIL = 0x03, //Assign failure
AIFG_MSG_T_HO_REQUEST = 0x10, //Handover request
AIFG_MSG_T_HO_REQUIRED = 0x11, //Handover required
AIFG_MSG_T_HO_REQ_ACK = 0x12, //Handover request ack
AIFG_MSG_T_HO_CMD = 0x13, //Handover command
AIFG_MSG_T_HO_CMP = 0x14, //Handover complete
AIFG_MSG_T_HO_SUC = 0x15, //Handover succeeded
AIFG_MSG_T_HO_FAIL = 0x16, //Handover failure
AIFG_MSG_T_HO_PERFORMED = 0x17, //Handover performed
AIFG_MSG_T_HO_CAN_ENQ = 0x18, //Handover candidate enquire
AIFG_MSG_T_HO_CAN_RESP = 0x19, //Handover candidate response
AIFG_MSG_T_HO_REQ_REJ = 0x1A, //Handover required reject
AIFG_MSG_T_HO_DETECT = 0x1B, //Handover detect
AIFG_MSG_T_CLR_CMD = 0x20, //Clear command
AIFG_MSG_T_CLR_CMP = 0x21, //Clear complete
AIFG_MSG_T_CLR_REQ = 0x22, //Clear request
AIFG_MSG_T_SAPI_REJ = 0x25, //SAPI 'n' reject
AIFG_MSG_T_CONFUSION = 0x26, //Confusion
AIFG_MSG_T_SUSPEND = 0x28, //Suspend
AIFG_MSG_T_RESUME = 0x29, //Resume
AIFG_MSG_T_LOC_INFO_CMD = 0x2A, //Location information command
AIFG_MSG_T_LOC_INFO_RPT = 0x2B, //Location information report
AIFG_MSG_T_RESET = 0x30, //Reset
AIFG_MSG_T_RESET_ACK = 0x31, //Reset ack
AIFG_MSG_T_OVERLOAD = 0x32, //Overload
AIFG_MSG_T_RESET_CC = 0x34, //Reset circuit
AIFG_MSG_T_RESET_CC_ACK = 0x35, //Reset circuit ack
AIFG_MSG_T_MSC_INVK_TRACE = 0x36, //MSC invoke trace
AIFG_MSG_T_BSC_INVK_TRACE = 0x37, //BSC invoke trace
AIFG_MSG_T_BLOCK = 0x40, //Block
AIFG_MSG_T_BLOCK_ACK = 0x41, //Blocking ack
AIFG_MSG_T_UNBLOCK = 0x42, //Unblock
AIFG_MSG_T_UNBLOCK_ACK = 0x43, //Unblocking ack
AIFG_MSG_T_CC_GROUP_BLK = 0x44, //Circuit group block
AIFG_MSG_T_CC_GROUP_BLK_ACK = 0x45, //Circuit group block ack
AIFG_MSG_T_CC_GROUP_UNBLK = 0x46, //Circuit group unblock
AIFG_MSG_T_CC_GROUP_UNBLK_ACK = 0x47, //Circuit group unblock ack
AIFG_MSG_T_UNEQUIP_CC = 0x48, //Unequipped circuit
AIFG_MSG_T_CHANGE_CC = 0x4E, //Change circuit
AIFG_MSG_T_CHANGE_CC_ACK = 0x4F, //Change circuit ack
AIFG_MSG_T_RESRC_REQ = 0x50, //Resource request
AIFG_MSG_T_RESRC_IND = 0x51, //Resource indication
AIFG_MSG_T_PAGING = 0x52, //Paging
AIFG_MSG_T_CIPHER_MODE_CMD = 0x53, //Cipher mode command
AIFG_MSG_T_CM_UPDATE = 0x54, //Classmark update
AIFG_MSG_T_CIPHER_MODE_CMP = 0x55, //Cipher mode complete
AIFG_MSG_T_QUEUE_IND = 0x56, //Queuing indication
AIFG_MSG_T_L3_INFO = 0x57, //Complete layer 3 information
AIFG_MSG_T_CLASSMARK_REQ = 0x58, //Classmark request
AIFG_MSG_T_CIPHER_MODE_REJ = 0x59, //Cipher mode reject
AIFG_MSG_T_LOAD_IND = 0x5A, //Load indication
}aifg_msg_type;
typedef enum _aifg_iei_coding{
//For BSSMAP
AIFG_IEI_BM_CIC = 0x01, //CIC
AIFG_IEI_BM_RESOURCEAVAIL = 0x03, //Resource available
AIFG_IEI_BM_CAUSE = 0x04, //Cause
AIFG_IEI_BM_CELLID = 0x05, //Cell identifier
AIFG_IEI_BM_PRIORITY = 0x06, //Priority
AIFG_IEI_BM_L3HEADERINFO = 0x07, //Layer 3 header information
AIFG_IEI_BM_IMSI = 0x08, //IMSI
AIFG_IEI_BM_TMSI = 0x09, //TMSI
AIFG_IEI_BM_ENCRYPTINFO = 0x0A, //Encrypt information
AIFG_IEI_BM_CHANNELTYPE = 0x0B, //Channel type
AIFG_IEI_BM_PERIODICITY = 0x0C, //Periodicity
AIFG_IEI_BM_EXTRESOURCEIND = 0x0D, //Extended resource indicator
AIFG_IEI_BM_MSNUM = 0x0E, //Number of MSs
AIFG_IEI_BM_CLASSMARKINFO2 = 0x12, //Classmark information type 2
AIFG_IEI_BM_CLASSMARKINFO3 = 0x13, //Classmark information type 3
AIFG_IEI_BM_BANDUSED = 0x14, //Band to be used
AIFG_IEI_BM_RRCAUSE = 0x15, //RR cause
AIFG_IEI_BM_L3INFO = 0x17, //Layer 3 information
AIFG_IEI_BM_DLCI = 0x18, //DLCI
AIFG_IEI_BM_DTXFLAG = 0x19, //DTC flag
AIFG_IEI_BM_CELLIDLIST = 0x1A, //Cell identity list
AIFG_IEI_BM_RESPREQ = 0x1B, //Response request
AIFG_IEI_BM_RESOURCEINDMEHTOD = 0x1C, //Resource indication method
AIFG_IEI_BM_CLASSMARKINFO1 = 0x1D, //Classmark information type 1
AIFG_IEI_BM_CICLIST = 0x1E, //CIC list
AIFG_IEI_BM_DIGNOSTIC = 0x1F, //Dignostic
AIFG_IEI_BM_L3MSGCONTENT = 0x20, //Layer 3 message content
AIFG_IEI_BM_CHOSENCHANNEL = 0x21, //Chosen channel
AIFG_IEI_BM_TOTALRESOURCE = 0x22, //Total resource accessible
AIFG_IEI_BM_CIPHERRESPMODE = 0x23, //Cipher response mode
AIFG_IEI_BM_CHANNELNEEDED = 0x24, //Channel needed
AIFG_IEI_BM_TRACETYPE = 0x25, //Trace type
AIFG_IEI_BM_TRIGGERID = 0x26, //Trigger ID
AIFG_IEI_BM_TRACEREF = 0x27, //Trace reference
AIFG_IEI_BM_TRANSACTIONID = 0x28, //Transaction ID
AIFG_IEI_BM_MOBILEID = 0x29, //Mobile identity
AIFG_IEI_BM_OMCID = 0x2A, //OMC ID
AIFG_IEI_BM_FORWARDIND = 0x2B, //Forward indication
AIFG_IEI_BM_CHOSENENCRYPT = 0x2C, //Chosen encrypt algorithm
AIFG_IEI_BM_CIRCUITPOOL = 0x2D, //Circuit pool
AIFG_IEI_BM_CIRCUITPOOLLIST = 0x2E, //Circuit pool list
AIFG_IEI_BM_TIMEIND = 0x2F, //Time indicator
AIFG_IEI_BM_RESOURCESITUATION = 0x30, //Resource situation
AIFG_IEI_BM_CURCHANNELTYPE1 = 0x31, //Current channel type 1
AIFG_IEI_BM_QUEUEIND = 0x32, //Queuing indicator
AIFG_IEI_BM_ASSIGNREQUIREMENT = 0x33, //Assignment requirement
AIFG_IEI_BM_TALKERFLAG = 0x34, //Talker flag
AIFG_IEI_BM_CONNRELREQ = 0x35, //Connection release request
AIFG_IEI_BM_GROUPCALLREF = 0x36, //Group call reference
AIFG_IEI_BM_EMLPP = 0x37, //eMLPP
AIFG_IEI_BM_CFGEVOIND = 0x38, //Configuration evolution indication
AIFG_IEI_BM_BSSOLDTONEW = 0x39, //Old BSS to new BSS
AIFG_IEI_BM_LSAID = 0x3A, //LSA identity
AIFG_IEI_BM_LSAIDLIST = 0x3B, //LSA identity list
AIFG_IEI_BM_LSAINFO = 0x3C, //LSA information
AIFG_IEI_BM_LOCATIONINFO = 0x3D, //Location information
AIFG_IEI_BM_SPEECHVER = 0x40, //Speech version
//For DTAP
//common
AIFG_IEI_DT_LAI = 0x13, //location area identification
AIFG_IEI_DT_MOBILEID = 0x17, //mobile identity
AIFG_IEI_DT_MSCM3 = 0x20, //mobile station classmark 3
//MM
AIFG_IEI_DT_FLONPROCEED = 0xa1, //Follow on proceed
AIFG_IEI_DT_CTS = 0xa2, //CTS permission
AIFG_IEI_DT_FULL_NWNAME = 0x43, //Full name for network
AIFG_IEI_DT_SHORT_NWNAME = 0x45, //Short name for network
AIFG_IEI_DT_TIMEZONE = 0x46, //Network time zone
AIFG_IEI_DT_TZTIME = 0x47, //Universal time and time zone
AIFG_IEI_DT_LSAID = 0x48, //LSA Identity
//CC
AIFG_IEI_DT_PRIORITYLEVEL = 0x80, //Priority Level
AIFG_IEI_DT_SHIFT = 0x90, //Locking and non-locking shift procedure
AIFG_IEI_DT_REPEATIND = 0xD0, //Repease indicator
AIFG_IEI_DT_MOREDATA = 0xA0, //More data
AIFG_IEI_DT_CLIRSUP = 0xA1, //CLIR Suppression
AIFG_IEI_DT_CLIRIVO = 0xA2, //CLIR Invocation
AIFG_IEI_DT_REVCALLDIR = 0xA3, //Reverse call setup direction
AIFG_IEI_DT_BEARERCAP = 0x04, //Bearer capability
AIFG_IEI_DT_CAUSE = 0x08, //Cause
AIFG_IEI_DT_CCCAP = 0x15, //Call Control Capabilities
AIFG_IEI_DT_FACILITY = 0x1C, //Facility
AIFG_IEI_DT_PROGIND = 0x1E, //Progress indicator
AIFG_IEI_DT_AUXSTAT = 0x24, //Auxiliary states
AIFG_IEI_DT_CALLEDBCD = 0x5E, //Called party BCD
AIFG_IEI_DT_CALLEDSUBADDR = 0x6D, //Called party subaddress
AIFG_IEI_DT_CALLERBCD = 0x5C, //Calling party BCD
AIFG_IEI_DT_CALLERSUBADDR = 0x5D, //Calling party subaddress
AIFG_IEI_DT_CONNNUM = 0x4C, //Connected number
AIFG_IEI_DT_CONNSUBADDR = 0x4D, //Connected subaddress
AIFG_IEI_DT_HIGHCOM = 0x7D, //Higher layer compatibility
AIFG_IEI_DT_KEYPAD = 0x2C, //Keypad facility
AIFG_IEI_DT_LOWCOM = 0x7C, //Lower layer compatibility
AIFG_IEI_DT_REDIRBCD = 0x74, //Redirecting party BCD
AIFG_IEI_DT_REDIRSUBADDR = 0x75, //Redirecting party subaddress
AIFG_IEI_DT_SIGNAL = 0x34, //Signal
AIFG_IEI_DT_SSVER = 0x7F, //SS version indicator
AIFG_IEI_DT_USERUSER = 0x7E, //User-user
AIFG_IEI_DT_ALERTPATTERN = 0x19, //Alert pattern
//SMS
AIFG_IEI_DT_RP_UD = 0x41, //RP User data
AIFG_IEI_DT_RP_CAUSE = 0x42, //RP Cause
}aifg_iei;
#endif

View File

@@ -0,0 +1,68 @@
/********************************************************************
Copyright ?2007 LGC Wireless, Inc. All rights reserved
File Name: aifg_var_ext.h
Description: Public variant definition of AIFG module
Version: v9.0.0
Author: Roy Jiang
Create Date: 2007-3-12
History:
2007-3-6 v9.0.12 Create
*********************************************************************/
#ifndef _WXC2_AIFG_VAR_EXT_H
#define _WXC2_AIFG_VAR_EXT_H
#include <assert.h>
#include "aifg_type_def.h"
//Variant declaration
extern aifg_circuit_group cg[AIFG_MAX_CG];
extern aifg_sap sap[AIFG_MAX_SAP];
extern aifg_dual_server dual_server;
extern aifg_port aifg_pcb[AIFG_MAX_PORT];
extern aifg_event_code aifg_event;
extern aifg_msg_t sd_msg;
aifg_msg_pre_decoded rv_msg;
extern int cur_port; //current processing port
extern aifg_link_info link_info[SCCP_MAX_LINK];
extern int msg_statistics[AIFG_MAX_MESSAGE][2];
int aifg_ie_encode(aifg_msg_protocol protocol, int ie_id, ie_u *src, BYTE *dst, int m_o_flag);
int aifg_ie_decode(aifg_ie_ptr *src, aifg_ie *dst);
int aifg_msgtype_to_localid(aifg_pd pd, int msg_type);
int aifg_send_cr(int sapid, int cgid, aifg_msg_t *msg);
void aifg_send_dt1(int linkid, aifg_msg_t *msg, int ti);
void aifg_send_udt(int cgid, aifg_msg_t *msg, SP_UiPriPara *buf_ptr);
void aifg_mpp_init();
int aifg_mpp_proc();
void aifg_port_proc(aifg_port *pPort, aifg_msg_t *upper_msg, aifg_msg_pre_decoded *peer_msg);
inline int aifg_port_assign(int sapid, int cgid, int linkid);
inline void aifg_port_release(aifg_port *pPort);
inline int aifg_get_local_port(int u_port);
inline int aifg_get_paging_port(int cgid, BYTE *imsi_ptr, int imsi_len);
inline int aifg_ti2lport(int ti, int link_id, int pd);
inline int aifg_get_link(int u_port);
inline int aifg_add_link(int linkid, int sapid);
inline int aifg_del_link(int sccp_link_id);
inline void aifg_link_release(int link_id);
inline aifg_link_info *aifg_get_link_info(int link_id);
inline int aifg_get_cg(int dpc, int ni);
inline void aifg_add_ti(int link_id, int ti, int ti_type, int port);
inline int aifg_get_ti(int link_id, int port, int ti_type);
inline int aifg_del_ti(int link_id, int ti, int ti_type);
void aifg_send_rlsd(int linkid);
void aifg_debug_init();
void aifg_debug_timer();
void aifg_debug_print(int port, aifg_event_code event, void *msg, int o_info);
void aifg_log(char *info);
#endif

23
plat/aif/ut/aifg_main.c Normal file
View File

@@ -0,0 +1,23 @@
/*
*Test program of AIFG module --by Roy Jiang
*/
#include "../src/include/aifg.h"
#include "../src/include/aifg_if.h"
void aifg_test();
int main()
{
printf("Test of AIFG\n");
aifg_test();
#ifdef _WINDOWS_
system("PAUSE");
#endif
return 0;
}

7083
plat/aif/ut/aifg_test.c Normal file

File diff suppressed because it is too large Load Diff

40
plat/aif/ut/makefile Normal file
View File

@@ -0,0 +1,40 @@
#WXC2 R9.0 AIFG makefile
#Create by Roy Jiang
#2007-3-12
CC = gcc
CFLAG = -g -Wall -c #-fprofile-arcs -ftest-coverage
AIFG_LIB_OBJ = aifg_m.o aifg.o aifg_mpp.o aifg_debug.o aifg_ie.o
AIFG_TST_OBJ = aifg_main.o aifg_test.o
AIFG_LIB = -L../lib -laif
TEST_LIB = -L/usr/local/lib/CUnit -lcunit -lgcov
aifg_main: $(AIFG_TST_OBJ)
$(CC) $(AIFG_TST_OBJ) -o test_main $(AIFG_LIB) $(TEST_LIB)
aifg_main.o: aifg_main.c
$(CC) $(CFLAG) $<
aifg_test.o: aifg_test.c
$(CC) $(CFLAG) $<
aifg.o: aifg.c
$(CC) $(CFLAG) $<
aifg_m.o: aifg_m.c
$(CC) $(CFLAG) $<
aifg_mpp.o: aifg_mpp.c
$(CC) $(CFLAG) $<
aifg_debug.o: aifg_debug.c
$(CC) $(CFLAG) $<
aifg_ie.o: aifg_ie.c
$(CC) $(CFLAG) $<
clean:
rm -f main *.o *.a *.xml *.gcov *.gcda *.gcno core test_main

99
plat/bicc/Makefile Normal file
View 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 = bicc
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 = ../../mss
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

View File

@@ -0,0 +1,206 @@
#include <stdio.h>
#include <string.h>
#include "./include/q765_5e.h"
void apm_decode_action(ActionInd_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_action(u8 *flw_ptr, const ActionInd_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_bncid(BncId_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->len = length - 1;
memcpy(ptr->val, flw_ptr+1, ptr->len);
}
u32 apm_encode_bncid(u8 *flw_ptr, const BncId_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
memcpy(flw_ptr+1, ptr->val, ptr->len);
return ptr->len + 1;
}
void apm_decode_bncchr(BncChr_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_bncchr(u8 *flw_ptr, const BncChr_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_bcinfo(BcInfo_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->bctp.bvei = (flw_ptr[1] >> 6) & 0x01;
ptr->bctp.btcp_version = flw_ptr[1] & 0x1f;
ptr->bctp.tpei = (flw_ptr[2] >> 6) & 0x01;
ptr->bctp.tunnel_protocol = flw_ptr[2] & 0x3f;
ptr->bctp.ipbcp_len = length - 3;
memcpy(ptr->bctp.ipbcp_content, flw_ptr+3, ptr->bctp.ipbcp_len);
}
u32 apm_encode_bcinfo(u8 *flw_ptr, const BcInfo_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = (ptr->bctp.bvei << 6) + (1 << 5) + ptr->bctp.btcp_version;
flw_ptr[2] = (ptr->bctp.tpei << 6) + ptr->bctp.tunnel_protocol;
memcpy(flw_ptr+3, ptr->bctp.ipbcp_content, ptr->bctp.ipbcp_len);
return ptr->bctp.ipbcp_len + 3;
}
void apm_decode_bctunnel(BcTunnel_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_bctunnel(u8 *flw_ptr, const BcTunnel_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_signaltype(SignalType_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_signaltype(u8 *flw_ptr, const SignalType_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_duration(Duration_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = (flw_ptr[1] << 8) + flw_ptr[2];
}
u32 apm_encode_duration(u8 *flw_ptr, const Duration_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val >> 8;
flw_ptr[2] = ptr->val & 0xff;
return 3;
}
void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length)
{
const u8 *old_ptr = flw_ptr;
while(flw_ptr+flw_ptr[1]+2-old_ptr <= length)
{
if(*flw_ptr == 0)
break;
switch(*flw_ptr)
{
case AP_ACTION:
apm_decode_action(&ptr->action, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BNCID:
apm_decode_bncid(&ptr->bnc_id, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BNCCHR:
apm_decode_bncchr(&ptr->bnc_chr, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BCINFO:
apm_decode_bcinfo(&ptr->bc_info, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BCTUNNEL:
apm_decode_bctunnel(&ptr->bc_tunnel, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_SIGNALTYPE:
apm_decode_signaltype(&ptr->signal_type, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_DURATION:
apm_decode_duration(&ptr->duration, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
default:
flw_ptr += flw_ptr[1] + 2;
break;
}
}
}
u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr)
{
u8 *old_ptr = flw_ptr;
if(ptr->action.pres == 1)
{
flw_ptr[0] = AP_ACTION;
flw_ptr[1] = apm_encode_action(flw_ptr+2, &ptr->action);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bnc_id.pres == 1)
{
flw_ptr[0] = AP_BNCID;
flw_ptr[1] = apm_encode_bncid(flw_ptr+2, &ptr->bnc_id);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bnc_chr.pres == 1)
{
flw_ptr[0] = AP_BNCCHR;
flw_ptr[1] = apm_encode_bncchr(flw_ptr+2, &ptr->bnc_chr);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bc_info.pres == 1)
{
flw_ptr[0] = AP_BCINFO;
flw_ptr[1] = apm_encode_bcinfo(flw_ptr+2, &ptr->bc_info);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bc_tunnel.pres == 1)
{
flw_ptr[0] = AP_BCTUNNEL;
flw_ptr[1] = apm_encode_bctunnel(flw_ptr+2, &ptr->bc_tunnel);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->signal_type.pres == 1)
{
flw_ptr[0] = AP_SIGNALTYPE;
flw_ptr[1] = apm_encode_signaltype(flw_ptr+2, &ptr->signal_type);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->duration.pres == 1)
{
flw_ptr[0] = AP_DURATION;
flw_ptr[1] = apm_encode_duration(flw_ptr+2, &ptr->duration);
flw_ptr += flw_ptr[1] + 2;
}
return flw_ptr - old_ptr;
}

View File

@@ -0,0 +1,882 @@
#include "./include/var_ext.h"
//static u32 bicc_object_id[BICC_PREOID_LEN] = {1,3,6,1,4,1,1373,1,3,2,2,6};
//static u16 bicc_sub_page[BICC_DEBUG_PAGE] = {0};
//static u8 bicc_ascii_in[BICC_ASCIN_LEN] = {0};
//static u8 bicc_ascii_out[BICC_ASCOUT_LEN] = {0};
#define BICC_DEBUG_ID 17
#define BICC_VER_DEBUG "R91V0_01"
#define MONITOR_NONE 0x0000
#define MONITOR_ERROR 0x0010
#define MONITOR_ALL 0xffff
#define TRACE_FLAG_ON 1
#define TRACE_FLAG_OFF 0
u8 AsciInBuf[4096];
u8 AsciOutBuf[4096];
u8 AsciTempBuf[4096];
WORD MonitorFg;
u8 info[1024];
static u8 log_help[] = {
"BICC debug Help:\n\r\
\n\r\
1.help\n\r\
2.log all/none\n\r\
3.log error on/off\n\r\
4.list cg[-cgNo] \n\r\
5.list circuit[-circuitNo]\n\r\
6.list port[-portNo]\n\r\
7.list dmp\n\r\
8.trace on-portNo\n\r\
9.trace off[-portNo]\n\r\n\r\
"
};
static WORD disp_page[10];
static u8 *disp_ptr = (u8 *) disp_page;
static DWORD debug_status_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_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,BICC_DEBUG_ID + 2,2
};
static DWORD debug_ascin_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,3
};
static DWORD debug_ascout_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,4
};
static DWORD debug_page_title[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,1
};
static DWORD debug_page_line[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,2,1
};
const static u8 BASE_ID_LEN = 15;
const static u8 PAGE_POINT = 14;
const static u8 LINE_POINT = 15;
static u8 title1_p[] =
{
" BICC Page 01 SAP Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
Enable\n\r\
CG num\n\r"
};
static u8 title2_p[] =
{
" BICC Page 02 CG Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
Enable\n\r\
SAP id\n\r\
NI\n\r\
DPC\n\r"
};
static u8 title3_p[] =
{
" BICC Page 03 CIrcuit Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
CG id\n\r\
CIC range\n\r\
HEAD CIC\n\r"
};
static u8 title4_p[] =
{
" BICC Page 04 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\
Enable\n\r\
FSM State\n\r\
CIC State\n\r"
};
static u8 debug_disp_line(u8 page, u8 line)
{
u8 disp_length;
disp_length = 0;
disp_ptr = (u8 *) disp_page;
switch (page)
{
/*
case 1: // Page 1: sap Info
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
break;
case 1:
disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_enable;
disp_length = 16;
break;
case 2:
disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_cg_num;
disp_length = 16;
break;
default:
break;
}
break;
case 2: // Page 2: cg Info
//disp_page[page] = (disp_page[page]+1)%BICC_MAX_CG;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 2;
break;
case 1: //enable
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].used_flag);
disp_length = 16;
break;
case 2: //sap_id
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].sap_id);
disp_length = 16;
break;
case 3: //network_id
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.network_id);
disp_length = 16;
break;
case 4: //dpc
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.dpc);
disp_length = 16;
break;
default:
break;
}
break;
case 3: // Page 3: circuit Info
//disp_page[page] = (disp_page[page]+1)%BICC_MAX_CIRCUIT;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 16;
break;
case 1: //cg_id
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].cg_id);
disp_length = 16;
break;
case 2: //cic_range
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.cic_range);
disp_length = 16;
break;
case 3: //head_cic
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.head_cic);
disp_length = 16;
break;
default:
break;
}
break;
case 4: // Page 4: port Info
//disp_page[page] = (disp_page[page]+32)%BICC_MAX_PORT;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 16;
break;
case 1: //enable
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].used_flag);
disp_length = 16;
break;
case 2: //fsm_state
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].fsm_state);
disp_length = 16;
break;
case 3: //cic_state
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].cic_state);
disp_length = 16;
break;
default:
break;
}
break;
*/
default:
disp_length = 0;
break;
}
return disp_length;
}
static void debug_disp_page(u8 page)
{
u8 disp_line;
u8 disp_length;
debug_page_line[PAGE_POINT] = page + 5;
for (disp_line = 0; disp_line < 22; disp_line++)
{
disp_length = debug_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 bicc_debug_init(void)
{
BYTE page;
BYTE data[10];
BYTE *ptr;
strcpy(AsciInBuf, "\0");
strcpy(AsciOutBuf, "\0");
MonitorFg = MONITOR_NONE;
bzero(disp_page, 20);
ptr = data;
debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1);
debug_set_response(BASE_ID_LEN, debug_name_id, BICC_VER_DEBUG, 10);
debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096);
debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 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[PAGE_POINT] = 5 + page;
debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
debug_disp_page(page);
}
return 1;
}
void bicc_asciout_proc(const char *fmt, ...)
{
va_list ap;
char buf[1024];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
if((strlen(AsciOutBuf) + strlen(buf)) < 4096)
strcat(AsciOutBuf, buf);
else
strcpy(AsciOutBuf, buf);
va_end(ap);
}
void bicc_debug_refresh(void)
{
// int i;
#if 0
for(i=0;i<16;i++)
{
Bicc_Data.debug_data.sap_enable[i] = BiccResource.sap_pond[i].used_flag;
Bicc_Data.debug_data.sap_cg_num[i] = BiccResource.sap_pond[i].cg_num;
}
#endif
}
#if 0
void list_sap(WORD sapNo)
{
//u8 sapinfo[1024];
if(sapNo >= BICC_MAX_SAP)
return;
sprintf(info,"\
Enable:%d\n\r\
cg num:%d\n\r",
BiccResource.sap_pond[sapNo].used_flag,BiccResource.sap_pond[sapNo].cg_num);
bicc_asciout_proc(info);
}
void list_all_sap()
{
int i;
sprintf(info, "Index CG(s)\n\r");
bicc_asciout_proc(info);
for(i=0; i<BICC_MAX_SAP; i++)
{
if(BiccResource.sap_pond[i].used_flag == 1)
{
sprintf(info, " %d %d\n\r", i, BiccResource.sap_pond[i].cg_num);
bicc_asciout_proc(info);
}
}
}
#endif
void list_cg(WORD cgNo)
{
const pal_cg_struct *pcg;
if(cgNo >= PAL_MAX_CG)
return;
pcg = pal_cg_ptr(cgNo);
if(pcg == NULL)
return;
sprintf(info, "\
Enable:%d\n\r\
sap id:%d\n\r\
circuit num:%d\n\r\
variant_type:%d\n\r\
priority:%d\n\r\
network id:%d\n\r\
opc:%ld\n\r\
dpc:%ld\n\r\
tg_id:%ld\n\r",
pcg->enable,pcg->sap_id,pcg->circuit_num,pcg->attrib.variant,pcg->attrib.priority,pcg->attrib.network_id,pcg->attrib.opc,pcg->attrib.dpc,pcg->attrib.tg_id);
bicc_asciout_proc(info);
}
void list_all_cg()
{
int i = 0;
const pal_cg_struct *pcg;
sprintf(info, "Index SAP Circuit(s) NetInd DPC OPC TG\n\r");
bicc_asciout_proc(info);
for(i=0; i<PAL_MAX_CG; i++)
{
pcg = pal_cg_ptr(i);
if(pcg == NULL)
continue;
if(pcg->enable==0)
continue;
if(pcg->attrib.protocol != PROTO_BICC)
continue;
sprintf(info, " %d %d %d %d %ld %ld %ld\n\r", i, pcg->sap_id, pcg->circuit_num, pcg->attrib.network_id, pcg->attrib.dpc, pcg->attrib.opc, pcg->attrib.tg_id);
bicc_asciout_proc(info);
}
}
void list_circuit(WORD circuitNo)
{
const pal_circuit_struct *pcircuit;
if(circuitNo >= PAL_MAX_CIRCUIT)
return;
pcircuit = pal_circuit_ptr(circuitNo);
if(pcircuit == NULL)
return ;
sprintf(info,"\
Enable:%d\n\r\
cg id:%d\n\r\
head cic:%ld\n\r\
cic range:%d\n\r\
plat id:%d\n\r",
pcircuit->enable,pcircuit->cg_id,pcircuit->attrib.head_cic,pcircuit->attrib.cic_range,pcircuit->attrib.plat_id);
bicc_asciout_proc(info);
}
void list_all_circuit()
{
int i = 0, j = 0;
const pal_circuit_struct *pcircuit;
const pal_cg_struct *pcg;
// for(i = 0; i < BICC_MAX_SAP; i ++)
//{
sprintf(info, "Index CG PLAT CIC(s)\n\r");
bicc_asciout_proc(info);
for(i=0; i<PAL_MAX_CG; i++)
{
pcg = pal_cg_ptr(i);
if(pcg == NULL)
continue;
if(pcg->enable == 0)
continue;
if(pcg->attrib.protocol != PROTO_BICC)
continue;
for(j = 0; j<PAL_MAX_CIRCUIT; j++)
{
pcircuit = pal_circuit_ptr(j);
if(pcircuit == NULL)
continue;
if(pcircuit->enable == 0 || pcircuit->cg_id != pcg->id)
continue;
sprintf(info, " %d %d %d %d (%ld~~%ld)\n\r", i, pcircuit->cg_id, pcircuit->attrib.plat_id, pcircuit->attrib.cic_range, pcircuit->attrib.head_cic, pcircuit->attrib.head_cic+pcircuit->attrib.cic_range);
bicc_asciout_proc(info);
}
}
}
void list_port(WORD portNo)
{
if(portNo>=BICC_MAX_PORT)
return;
sprintf(info,"\
upper port:%ld\n\r\
sprc_cmd:%x\n\r\
primitive_cmd:%x\n\r\
internal_cmd:%x\n\r\
cic state{\n\r\
call state:%d\n\r\
suspend state:%d\n\r\
block state:%d\n\r\
}\n\r\
fsm state{\n\r\
cpc_state:%d\n\r\
mgbs_state:%d\n\r\
mgbr_state:%d\n\r\
crs_state:%d\n\r\
crr_state:%d\n\r\
cgrs_state:%d\n\r\
cgrr_state:%d\n\r\
}\n\r",
Bicc_Data.port_data[portNo].su_proc_id,Bicc_Data.port_data[portNo].sprc_cmd,
Bicc_Data.port_data[portNo].primitive_cmd,Bicc_Data.port_data[portNo].internal_cmd,
Bicc_Data.port_data[portNo].cic_state.call_state,Bicc_Data.port_data[portNo].cic_state.sus_state,
Bicc_Data.port_data[portNo].cic_state.blo_state,Bicc_Data.port_data[portNo].fsm_state.cpc_state,
Bicc_Data.port_data[portNo].fsm_state.mgbs_state,Bicc_Data.port_data[portNo].fsm_state.mgbr_state,
Bicc_Data.port_data[portNo].fsm_state.crs_state,Bicc_Data.port_data[portNo].fsm_state.crr_state,
Bicc_Data.port_data[portNo].fsm_state.cgrs_state,Bicc_Data.port_data[portNo].fsm_state.cgrr_state);
bicc_asciout_proc(info);
}
void list_busy_port()
{
int i,j=0;
sprintf(info, "Index PortNo CallState\n\r");
bicc_asciout_proc(info);
for(i=0;i<BICC_MAX_PORT;i++)
{
if(Bicc_Data.port_data[i].used_flag == 1)
{
sprintf(info,"%d %d %s\n\r",j++,i,(Bicc_Data.port_data[i].cic_state.call_state==1)?"INCOMING":"OUTGOING");
bicc_asciout_proc(info);
}
}
}
void list_dmp()
{
sprintf(info, "\
dmp active: %d\n\r\
local plat id: %d\n\r\
remote ip: %lx\n\r", Bicc_Data.dmp_data.active,Bicc_Data.dmp_data.processor_id,Bicc_Data.dmp_data.remote_ip);
bicc_asciout_proc(info);
}
void bicc_debug_timer(void)
{
BYTE in_page, err_fg = 0;
BYTE *ascii_in_ptr = NULL;
BYTE *str_start = NULL, * tmpStr;
WORD str_len, portNo=0;
WORD num, cgNo, circuitNo;
if ((str_len = strlen(AsciInBuf)) > 0)
{
in_page = AsciInBuf[0] - 1;
ascii_in_ptr = AsciInBuf + 1;
if (in_page > 4)
err_fg = 1;
else if (strcmp(ascii_in_ptr,"log error on") == 0)
{
MonitorFg = MonitorFg | MONITOR_ERROR;
}
else if (strcmp(ascii_in_ptr,"log error off") == 0)
{
MonitorFg = MonitorFg & (~MONITOR_ERROR);
}
else if (strcmp(ascii_in_ptr,"log all") == 0)
{
MonitorFg = MONITOR_ALL;
}
else if (strcmp(ascii_in_ptr,"log none") == 0)
{
MonitorFg = MONITOR_NONE;
}
else if (strcmp(ascii_in_ptr,"help") == 0)
{
bicc_asciout_proc(log_help);
}
else if (isdigit(ascii_in_ptr[0]))
{
num = strtoul(ascii_in_ptr, NULL, 10);
disp_page[in_page] = num;
debug_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;
debug_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;
debug_disp_page(in_page);
}
#if 0
else if ((strstr (ascii_in_ptr, "list sap")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
sapNo = strtoul (tmpStr + 1, NULL, 10);
list_sap(sapNo);
}
else
{
list_all_sap();
}
}
#endif
else if ((strstr (ascii_in_ptr,"list cg")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
// if((tmpStr = strsep(&&ascii_in_ptr, " \t")) != NULL)
{
cgNo = strtoul (tmpStr+1, NULL, 10);
// strsep(, " \t");
list_cg(cgNo);
}
else
{
list_all_cg();
}
}
else if ((strstr (ascii_in_ptr, "list circuit")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
circuitNo = strtoul (tmpStr + 1, NULL, 10);
list_circuit(circuitNo);
}
else
{
list_all_circuit();
}
}
else if ((strstr (ascii_in_ptr, "list port")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul (tmpStr + 1, NULL, 10);
list_port(portNo);
}
else
{
list_busy_port();
}
}
else if((strstr (ascii_in_ptr, "list dmp")) != NULL)
{
list_dmp();
}
else if((strstr(ascii_in_ptr, "trace on")) != NULL)
{
if((tmpStr = strstr(ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul(tmpStr + 1, NULL, 10);
//trace_port(portNo);
Bicc_Data.port_data[portNo].trace_flag = 1;
}
else
{}
}
else if ((strstr (ascii_in_ptr, "trace off")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul (tmpStr + 1, NULL, 10);
Bicc_Data.port_data[portNo].trace_flag = 0;
}
else
{
int i;
for(i=0; i<BICC_MAX_PORT; i++)
Bicc_Data.port_data[i].trace_flag = 0;
}
}
else
err_fg = 1;
if (err_fg == 0)
bicc_asciout_proc("Command OK!\n\r");
else
bicc_asciout_proc("Command Error!\n\r");
strcpy(AsciInBuf, "\0");
}
bicc_debug_refresh();
}
void bicc_log_err(const char *fmt, ...)
{
if ((MonitorFg & MONITOR_ERROR) == MONITOR_ERROR)
{
va_list ap;
char buf[1024];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
if((strlen(AsciOutBuf) + strlen(buf)) < 4096-15)
{
strcat(AsciOutBuf, "\33[31m");
strcat(AsciOutBuf, buf);
strcat(AsciOutBuf, "\33[37m");
}
else
{
strcpy(AsciOutBuf, "\33[31m");
strcat(AsciOutBuf, buf);
strcat(AsciOutBuf, "\33[37m");
}
va_end(ap);
}
}
int bicc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg)
{
u8 monFlag = 0;
monFlag = 1;
if (monFlag == 1)
{
if (strlen(msg) >= 4096)
sprintf(AsciTempBuf, "log msg is too long!\n\r");
else
sprintf(AsciTempBuf, "%s\n\r", msg);
bicc_asciout_proc(AsciTempBuf);
return 0;
}
return -1;
}
void display_bicc_msgtype(u8 msgtype, u32 cic)
{
switch(msgtype)
{
case M_ACM:
bicc_asciout_proc("ACM:Address complete");
break;
case M_ANM:
bicc_asciout_proc("ANM:Answer");
break;
case M_BLO:
bicc_asciout_proc("BLO:Blocking");
break;
case M_BLA:
bicc_asciout_proc("BLA:Blocking acknowledgement");
break;
case M_CPG:
bicc_asciout_proc("CPG:Call progress");
break;
case M_CGB:
bicc_asciout_proc("CGB:Circuit/CIC group blocking");
break;
case M_CGBA:
bicc_asciout_proc("CGBA:Circuit/CIC group blocking acknowledgement");
break;
case M_CQM:
bicc_asciout_proc("CQM:Circuit/CIC group query (national use)");
break;
case M_CQR:
bicc_asciout_proc("CQR:Circuit/CIC group query response (national use)");
break;
case M_GRS:
bicc_asciout_proc("GRS:Circuit/CIC group reset");
break;
case M_GRA:
bicc_asciout_proc("GRA:Circuit/CIC group reset acknowledgement");
break;
case M_CGU:
bicc_asciout_proc("CGU:Circuit/CIC group unblocking");
break;
case M_CGUA:
bicc_asciout_proc("CGUA:Circuit/CIC group unblocking acknowledgement");
break;
case M_CRG:
bicc_asciout_proc("CRG:Charge information (national use)");
break;
case M_CFN:
bicc_asciout_proc("CFN:Confusion");
break;
case M_CON:
bicc_asciout_proc("CON:Connect");
break;
case M_COT:
bicc_asciout_proc("COT:Continuity");
break;
case M_FAC:
bicc_asciout_proc("FAC:Facility ");
break;
case M_FAA:
bicc_asciout_proc("FAA:Facility accepted");
break;
case M_FRJ:
bicc_asciout_proc("FRJ:Facility reject");
break;
case M_FAR:
bicc_asciout_proc("FAR:Facility request");
break;
case M_FOT:
bicc_asciout_proc("FOT:Forward transfer");
break;
case M_IDR:
bicc_asciout_proc("IDR:Identification request");
break;
case M_IRS:
bicc_asciout_proc("IRS:Identification response");
break;
case M_INF:
bicc_asciout_proc("INF:Information (national use)");
break;
case M_INR:
bicc_asciout_proc("INR:Information request (national use)");
break;
case M_IAM:
bicc_asciout_proc("IAM:Initial address");
break;
case M_NRM:
bicc_asciout_proc("NRM:Network resource management");
break;
case M_REL:
bicc_asciout_proc("REL:Release");
break;
case M_RLC:
bicc_asciout_proc("RLC:Release complete");
break;
case M_RSC:
bicc_asciout_proc("RSC:Reset circuit/CIC");
break;
case M_RES:
bicc_asciout_proc("RES:Resume");
break;
case M_SGM:
bicc_asciout_proc("SGM:Segmentation");
break;
case M_SAM:
bicc_asciout_proc("SAM:Subsequent address");
break;
case M_SUS:
bicc_asciout_proc("SUS:Suspend");
break;
case M_UBL:
bicc_asciout_proc("UBL:Unblocking");
break;
case M_UBA:
bicc_asciout_proc("UBA:Unblocking acknowledgement");
break;
case M_UCIC:
bicc_asciout_proc("UCIC:Unequipped CIC (national use)");
break;
case M_APM:
bicc_asciout_proc("APM:Application Transport");
break;
case M_USR:
bicc_asciout_proc("USR:User-to-user information");
break;
default:
bicc_asciout_proc("Unknown message");
}
bicc_asciout_proc("(message type=0x%x cic=%d)\r\n",msgtype,cic);
}
void monitor_bicc_msg(BYTE *msg,BYTE buf_len, BYTE flag, u32 cic, u32 portNo)
{
BYTE i,temp_buf[1024];
if(MonitorFg == MONITOR_ALL)
{
if(flag == 0)
bicc_asciout_proc("\33[33mReceive:\33[0m");
else if(flag == 1)
bicc_asciout_proc("\33[32mSend:\33[0m");
else if(flag == 2)
bicc_asciout_proc("\33[34mRedirect:\33[0m");
display_bicc_msgtype(msg[0], cic);
if(flag != 2)
{
for (i = 0; i < buf_len; i ++)
{
sprintf(&temp_buf[3*i]," %02x", msg[i]);
}
sprintf(&temp_buf[3*i],"\n\r");
bicc_asciout_proc(temp_buf);
}
}
if(MonitorFg == MONITOR_NONE)
{}
if(Bicc_Data.port_data[portNo].trace_flag == 1)
{
if(flag == 0)
bicc_asciout_proc("\33[33mReceive:\33[0m");
else if(flag == 1)
bicc_asciout_proc("\33[32mSend:\33[0m");
else if(flag == 2)
bicc_asciout_proc("\33[34mRedirect:\33[0m");
display_bicc_msgtype(msg[0], cic);
if(flag != 2)
{
for (i = 0; i < buf_len; i ++)
{
sprintf(&temp_buf[3*i]," %02x", msg[i]);
}
sprintf(&temp_buf[3*i],"\n\r");
bicc_asciout_proc(temp_buf);
}
}
}

2093
plat/bicc/src.old/bicc_fsm.c Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,362 @@
#include <stdio.h>
#include <string.h>
#include "./include/ipbcp.h"
int sdp_decode_orig(SdpOrig_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->username, token);
strcat(dst_ptr->username, "\0");
break;
case 2:
sprintf(dst_ptr->session_id, token);
strcat(dst_ptr->session_id, "\0");
break;
case 3:
sprintf(dst_ptr->version, token);
strcat(dst_ptr->version, "\0");
break;
case 4:
sprintf(dst_ptr->network_type, token);
strcat(dst_ptr->network_type, "\0");
break;
case 5:
sprintf(dst_ptr->address_type, token);
strcat(dst_ptr->address_type, "\0");
break;
case 6:
sprintf(dst_ptr->address, token);
strcat(dst_ptr->address, "\0");
break;
default:
return 0;
}
}
if(field_id != 6)
return 0;
else
return 1;
}
int sdp_decode_conn(SdpConn_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->network_type, token);
strcat(dst_ptr->network_type, "\0");
break;
case 2:
sprintf(dst_ptr->address_type, token);
strcat(dst_ptr->address_type, "\0");
break;
case 3:
sprintf(dst_ptr->address, token);
strcat(dst_ptr->address, "\0");
break;
default:
return 0;
}
}
if(field_id != 3)
return 0;
else
return 1;
}
int sdp_decode_time(SdpTime_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->start, token);
strcat(dst_ptr->start, "\0");
break;
case 2:
sprintf(dst_ptr->stop, token);
strcat(dst_ptr->stop, "\0");
break;
default:
return 0;
}
}
if(field_id != 2)
return 0;
else
return 1;
}
int sdp_decode_attrib(SdpAttrib_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
if(strstr(src_ptr, "ipbcp:") != src_ptr)
return 0;
src_ptr += strlen("ipbcp:");
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->version, token);
strcat(dst_ptr->version, "\0");
break;
case 2:
sprintf(dst_ptr->type, token);
strcat(dst_ptr->type, "\0");
break;
default:
return 0;
}
}
if(field_id != 2)
return 0;
else
return 1;
}
int sdp_decode_mediaAnn(SdpMediaAnn_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->media, token);
strcat(dst_ptr->media, "\0");
break;
case 2:
sprintf(dst_ptr->port, token);
strcat(dst_ptr->port, "\0");
break;
case 3:
sprintf(dst_ptr->transport, token);
strcat(dst_ptr->transport, "\0");
strcpy(dst_ptr->fmt_list, src_ptr);
strcat(dst_ptr->fmt_list, "\0");
break;
case 4:
// sprintf(dst_ptr->fmt_list, token);
break;
default:
break;
}
}
if(field_id < 4)
return 0;
else
return 1;
}
int sdp_decode_mediaAtt(SdpMediaAtt_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
if(strstr(src_ptr, "rtpmap:") != src_ptr)
return 0;
src_ptr += strlen("rtpmap:");
while((token = strsep(&src_ptr, " /")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->payload, token);
strcat(dst_ptr->payload, "\0");
break;
case 2:
sprintf(dst_ptr->encoding_name, token);
strcat(dst_ptr->encoding_name, "\0");
break;
case 3:
sprintf(dst_ptr->clock_rate, token);
strcat(dst_ptr->clock_rate, "\0");
break;
case 4:
// sprintf(dst_ptr->p_time, token);
field_id --;//to avoid 4 fields
break;
default:
return 0;
}
}
if(field_id != 3)
return 0;
else
return 1;
}
int sdp_decode_ptime(char* p_time, char *src_ptr)
{
char *token;
if((token = strstr(src_ptr, "ptime:")) == NULL)
return 0;
token = strtok(token, ":");
token = strtok(NULL, ":");
// p_time = token;
// if(strlen(token)<8)
if(token)
{
sprintf(p_time, token);
strcat(p_time, "\0");
}
return 1;
}
int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr)
{
char *token;
unsigned char field_id = 0;
char temp_ipbcp[200];
char *temp_ptr;
strncpy(temp_ipbcp, ptr, 200);
temp_ptr = temp_ipbcp;
memset(ipbcp_ptr, 0, sizeof(IPBCP_struct));
while((token = strsep(&temp_ptr, "\r\n")) != NULL)
{
if(strlen(token) == 0)
continue;
switch(++field_id)
{
case 1:
if((token[0] != 'v') || (token[1] != '='))
return 0;
sprintf(ipbcp_ptr->proto_ver, token+2);
strcat(ipbcp_ptr->proto_ver, "\0");
break;
case 2:
if((token[0] != 'o') || (token[1] != '='))
return 0;
if(!sdp_decode_orig(&ipbcp_ptr->orig, token+2))
return 0;
break;
case 3:
if((token[0] != 's') || (token[1] != '='))
return 0;
sprintf(ipbcp_ptr->session_name, token+2);
strcat(ipbcp_ptr->session_name, "\0");
break;
case 4:
if((token[0] != 'c') || (token[1] != '='))
return 0;
if(!sdp_decode_conn(&ipbcp_ptr->conn_data, token+2))
return 0;
break;
case 5:
if((token[0] != 't') || (token[1] != '='))
return 0;
if(!sdp_decode_time(&ipbcp_ptr->time, token+2))
return 0;
break;
case 6:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(!sdp_decode_attrib(&ipbcp_ptr->attrib, token+2))
return 0;
break;
case 7:
if((token[0] != 'm') || (token[1] != '='))
return 0;
if(!sdp_decode_mediaAnn(&ipbcp_ptr->m_ann, token+2))
return 0;
break;
case 8:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(sdp_decode_mediaAtt(&ipbcp_ptr->m_att, token+2))
// return 0;
;
else if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2))
return 0;
break;
case 9:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2))
return 0;
default:
break;
}
}
return 1;
}
int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr)
{
char tmp_buf[128];
sprintf(ptr, "v=%s\r\n", ipbcp_ptr->proto_ver);
sprintf(tmp_buf, "o=%s %s %s %s %s %s\r\n",
ipbcp_ptr->orig.username,
ipbcp_ptr->orig.session_id,
ipbcp_ptr->orig.version,
ipbcp_ptr->orig.network_type,
ipbcp_ptr->orig.address_type,
ipbcp_ptr->orig.address);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "s=%s\r\n", ipbcp_ptr->session_name);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "c=%s %s %s\r\n",
ipbcp_ptr->conn_data.network_type,
ipbcp_ptr->conn_data.address_type,
ipbcp_ptr->conn_data.address);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "t=%s %s\r\n", ipbcp_ptr->time.start, ipbcp_ptr->time.stop);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "a=ipbcp:%s %s\r\n", ipbcp_ptr->attrib.version, ipbcp_ptr->attrib.type);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "m=%s %s %s %s\r\n",
ipbcp_ptr->m_ann.media,
ipbcp_ptr->m_ann.port,
ipbcp_ptr->m_ann.transport,
ipbcp_ptr->m_ann.fmt_list);
strcat(ptr, tmp_buf);
if(strlen(ipbcp_ptr->m_att.payload) != 0)
{
sprintf(tmp_buf, "a=rtpmap:%s %s/%s\r\n",
ipbcp_ptr->m_att.payload,
ipbcp_ptr->m_att.encoding_name,
ipbcp_ptr->m_att.clock_rate);
strcat(ptr, tmp_buf);
}
//ipbcp_ptr->ptime[7]='\0';
if((ipbcp_ptr->ptime[0] != '\0') && (strlen(ipbcp_ptr->ptime)<8))
{
sprintf(tmp_buf, "a=ptime:%s\r\n", ipbcp_ptr->ptime);
strcat(ptr, tmp_buf);
}
return strlen(ptr);
}

1285
plat/bicc/src.old/bicc_msg.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,244 @@
#include "./include/inc.h"
#include "./include/var_ext.h"
#include "./include/q1902_3e.h"
/**********************************************/
/******* BICC Message&Primitive Mapping *******/
/**********************************************/
void app_msg2prm(AppTransM_struct *dst_ptr, AppTrans_struct *src_ptr)
{
dst_ptr->pres = src_ptr->pres;
if(src_ptr->pres == 1)
{
memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct));
dst_ptr->apm_info.sni = src_ptr->sni;
dst_ptr->apm_info.rci = src_ptr->rci;
}
}
void app_prm2msg(AppTrans_struct *dst_ptr, AppTransM_struct *src_ptr)
{
dst_ptr->pres = src_ptr->pres;
if(src_ptr->pres == 1)
{
dst_ptr->aci[0] = 0x00;
dst_ptr->aci[1] = 0x00;
dst_ptr->sni = src_ptr->apm_info.sni;
dst_ptr->rci = src_ptr->apm_info.rci;
dst_ptr->si = 0; //subsequent segment to first segment
dst_ptr->segment = 0; //final segment
dst_ptr->slr = 0;
memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct));
}
}
void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type)
{
memset(prm_ptr, 0, sizeof(BiccReadPrim_union));
switch(msg_type)
{
case M_ACM:
memcpy(&prm_ptr->alert_ind.backCall, &msg_ptr->acm.backCall, sizeof(BackCallInd_struct));
app_msg2prm(&prm_ptr->alert_ind.app, &msg_ptr->acm.app);
memcpy(&prm_ptr->alert_ind.cause, &msg_ptr->acm.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->alert_ind.confTreat, &msg_ptr->acm.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->alert_ind.optBackCall, &msg_ptr->acm.optBackCall, sizeof(OptBackCallInd_struct));
memcpy(&prm_ptr->alert_ind.utuInd, &msg_ptr->acm.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->alert_ind.utuInfo, &msg_ptr->acm.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_ANM:
app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->anm.app);
memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->anm.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->anm.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->anm.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->anm.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->anm.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_APM:
app_msg2prm(&prm_ptr->apm_ind.app, &msg_ptr->apm.app);
break;
case M_CPG:
memcpy(&prm_ptr->cpg_ind.eventInfo, &msg_ptr->cpg.eventInfo, sizeof(EventInfo_struct));
app_msg2prm(&prm_ptr->cpg_ind.app, &msg_ptr->cpg.app);
memcpy(&prm_ptr->cpg_ind.backCall, &msg_ptr->cpg.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->cpg_ind.calldiver,&msg_ptr->cpg.calldiver, sizeof(BiccCpg_struct));
memcpy(&prm_ptr->cpg_ind.cause, &msg_ptr->cpg.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->cpg_ind.confTreat, &msg_ptr->cpg.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->cpg_ind.connNum, &msg_ptr->cpg.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->cpg_ind.utuInd, &msg_ptr->cpg.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->cpg_ind.utuInfo, &msg_ptr->cpg.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_CGB:
memcpy(&prm_ptr->cgb_ind.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgb_ind.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGBA:
memcpy(&prm_ptr->cgb_cnf.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgb_cnf.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGU:
memcpy(&prm_ptr->cgu_ind.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgu_ind.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGUA:
memcpy(&prm_ptr->cgu_cnf.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgu_cnf.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRS:
memcpy(&prm_ptr->grs_ind.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRA:
memcpy(&prm_ptr->grs_cnf.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CON:
app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->con.app);
memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->con.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->con.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->con.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->con.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->con.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_IAM:
memcpy(&prm_ptr->setup_ind.natConn, &msg_ptr->iam.natConn, sizeof(NatConnInd_struct));
memcpy(&prm_ptr->setup_ind.fwdCall, &msg_ptr->iam.fwdCall, sizeof(FwdCallInd_struct));
memcpy(&prm_ptr->setup_ind.callingPtyCat, &msg_ptr->iam.callingPtyCat, sizeof(CallingPtyCat_struct));
memcpy(&prm_ptr->setup_ind.transMedReq, &msg_ptr->iam.transMedReq, sizeof(TransMedReq_struct));
memcpy(&prm_ptr->setup_ind.calledPtyNum, &msg_ptr->iam.calledPtyNum, sizeof(CalledPtyNum_struct));
app_msg2prm(&prm_ptr->setup_ind.app, &msg_ptr->apm.app);
memcpy(&prm_ptr->setup_ind.callingPtyNum, &msg_ptr->iam.callingPtyNum, sizeof(CallingPtyNum_struct));
memcpy(&prm_ptr->setup_ind.collectCallReq, &msg_ptr->iam.collectCallReq, sizeof(CollectCallReq_struct));
memcpy(&prm_ptr->setup_ind.confTreat, &msg_ptr->iam.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_ind.correlationId, &msg_ptr->iam.correlationId, sizeof(CorrelationId_struct));
memcpy(&prm_ptr->setup_ind.origCalledNum, &msg_ptr->iam.origCalledNum, sizeof(OrigCalledNum_struct));
memcpy(&prm_ptr->setup_ind.redirgNum, &msg_ptr->iam.redirgNum, sizeof(RedirgNum_struct));
memcpy(&prm_ptr->setup_ind.redirInfo, &msg_ptr->iam.redirInfo, sizeof(RedirInfo_struct));
memcpy(&prm_ptr->setup_ind.scfId, &msg_ptr->iam.scfId, sizeof(ScfId_struct));
memcpy(&prm_ptr->setup_ind.utuInd, &msg_ptr->iam.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_ind.utuInfo, &msg_ptr->iam.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_REL:
memcpy(&prm_ptr->rel_ind.cause, &msg_ptr->rel.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->rel_ind.utuInd, &msg_ptr->rel.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->rel_ind.utuInfo, &msg_ptr->rel.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_RLC:
memcpy(&prm_ptr->rel_cnf.cause, &msg_ptr->rlc.cause, sizeof(CauseInd_struct));
break;
case M_RES:
memcpy(&prm_ptr->res_ind.susRes, &msg_ptr->res.susRes, sizeof(SusResInd_struct));
break;
case M_SUS:
memcpy(&prm_ptr->sus_ind.susRes, &msg_ptr->sus.susRes, sizeof(SusResInd_struct));
break;
case M_SAM:
memcpy(&prm_ptr->info_ind.subseqNum, &msg_ptr->sam.subseqNum, sizeof(SubseqNum_struct));
break;
default:
break;
}
}
void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type)
{
memset(msg_ptr, 0, sizeof(BiccMsg_union));
switch(msg_type)
{
case M_ACM:
memcpy(&msg_ptr->acm.backCall, &prm_ptr->alert_req.backCall, sizeof(BackCallInd_struct));
app_prm2msg(&msg_ptr->acm.app, &prm_ptr->alert_req.app);
memcpy(&msg_ptr->acm.cause, &prm_ptr->alert_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->acm.confTreat, &prm_ptr->alert_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->acm.optBackCall, &prm_ptr->alert_req.optBackCall, sizeof(OptBackCallInd_struct));
memcpy(&msg_ptr->acm.utuInd, &prm_ptr->alert_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->acm.utuInfo, &prm_ptr->alert_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_ANM:
app_prm2msg(&msg_ptr->anm.app, &prm_ptr->setup_rsp.app);
memcpy(&msg_ptr->anm.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->anm.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->anm.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->anm.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->anm.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_APM:
app_prm2msg(&msg_ptr->apm.app, &prm_ptr->apm_req.app);
break;
case M_CPG:
memcpy(&msg_ptr->cpg.eventInfo, &prm_ptr->cpg_req.eventInfo, sizeof(EventInfo_struct));
app_prm2msg(&msg_ptr->cpg.app, &prm_ptr->cpg_req.app);
memcpy(&msg_ptr->cpg.backCall, &prm_ptr->cpg_req.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->cpg.calldiver, &prm_ptr->cpg_req.calldiver, sizeof(BiccCpg_struct));
memcpy(&msg_ptr->cpg.cause, &prm_ptr->cpg_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->cpg.confTreat, &prm_ptr->cpg_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->cpg.connNum, &prm_ptr->cpg_req.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->cpg.utuInd, &prm_ptr->cpg_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->cpg.utuInfo, &prm_ptr->cpg_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_CGB:
memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_req.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGBA:
memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGU:
memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_req.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGUA:
memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRS:
memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRA:
memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CON:
app_prm2msg(&msg_ptr->con.app, &prm_ptr->setup_rsp.app);
memcpy(&msg_ptr->con.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->con.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->con.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->con.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->con.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_IAM:
memcpy(&msg_ptr->iam.natConn, &prm_ptr->setup_req.natConn, sizeof(NatConnInd_struct));
memcpy(&msg_ptr->iam.fwdCall, &prm_ptr->setup_req.fwdCall, sizeof(FwdCallInd_struct));
memcpy(&msg_ptr->iam.callingPtyCat, &prm_ptr->setup_req.callingPtyCat, sizeof(CallingPtyCat_struct));
memcpy(&msg_ptr->iam.transMedReq, &prm_ptr->setup_req.transMedReq, sizeof(TransMedReq_struct));
memcpy(&msg_ptr->iam.calledPtyNum, &prm_ptr->setup_req.calledPtyNum, sizeof(CalledPtyNum_struct));
app_prm2msg(&msg_ptr->iam.app, &prm_ptr->setup_req.app);
memcpy(&msg_ptr->iam.callingPtyNum, &prm_ptr->setup_req.callingPtyNum, sizeof(CallingPtyNum_struct));
memcpy(&msg_ptr->iam.collectCallReq, &prm_ptr->setup_req.collectCallReq, sizeof(CollectCallReq_struct));
memcpy(&msg_ptr->iam.confTreat, &prm_ptr->setup_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->iam.correlationId, &prm_ptr->setup_req.correlationId, sizeof(CorrelationId_struct));
memcpy(&msg_ptr->iam.origCalledNum, &prm_ptr->setup_req.origCalledNum, sizeof(OrigCalledNum_struct));
memcpy(&msg_ptr->iam.redirgNum, &prm_ptr->setup_req.redirgNum, sizeof(RedirgNum_struct));
memcpy(&msg_ptr->iam.redirInfo, &prm_ptr->setup_req.redirInfo, sizeof(RedirInfo_struct));
memcpy(&msg_ptr->iam.scfId, &prm_ptr->setup_req.scfId, sizeof(ScfId_struct));
memcpy(&msg_ptr->iam.utuInd, &prm_ptr->setup_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->iam.utuInfo, &prm_ptr->setup_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_REL:
memcpy(&msg_ptr->rel.cause, &prm_ptr->rel_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->rel.utuInd, &prm_ptr->rel_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->rel.utuInfo, &prm_ptr->rel_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_RLC:
memcpy(&msg_ptr->rlc.cause, &prm_ptr->rel_rsp.cause, sizeof(CauseInd_struct));
break;
case M_RES:
memcpy(&msg_ptr->res.susRes, &prm_ptr->res_req.susRes, sizeof(SusResInd_struct));
break;
case M_SUS:
memcpy(&msg_ptr->sus.susRes, &prm_ptr->sus_req.susRes, sizeof(SusResInd_struct));
break;
case M_SAM:
memcpy(&msg_ptr->sam.subseqNum, &prm_ptr->info_req.subseqNum, sizeof(SubseqNum_struct));
break;
default:
break;
}
}

1080
plat/bicc/src.old/biccif.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
#include "define.h"
#include "../../../debug/src/include/debug.h"
#define LOG_ERR_FLAG 0x01
#define LOG_BICC_FLAG 0x02
#define LOG_MSG_FLAG 0x04
#define LOG_TIME_FLAG 0x08
#define LOG_DMP_FLAG 0x10
#define LOG_ALL_FLAG 0x1f
#define LOG_FILE_FLAG 0x20
/*******************************/
#define MAX_OPR_LEN 16
#define MAX_OBJ_LEN 32
#define MAX_VALUE_LEN 32
#define BICC_PREOID_LEN 12
#define BICC_DEBUG_OID 17
#define BICC_DEBUG_PAGE 10
#define BICC_ASCIN_LEN 128
#define BICC_ASCOUT_LEN 4096
int bicc_debug_init();
void bicc_debug_timer();
void monitor_bicc_msg(u8 *msg,u8 buf_len, BYTE flag, u32 cic, u32 portNo);
void bicc_asciout_proc(const char *fmt, ...);

View File

@@ -0,0 +1,417 @@
#ifndef _BICCIF_H_
#define _BICCIF_H_
#include "q765_5e.h"
#include "q1902_3e.h"
#include "../../../mtp3/src/include/mtp3.h"
#include "../../../snmp/src/include/snmp.h"
//#include "../../../public/src/include/proto_pub.h"
#include "bicc_debug.h"
#include "../../../pal/pal.h"
/*********************************/
/*** BICC Management Structure ***/
/*********************************/
#define BICC_CM_OK 1 //command request success
#define BICC_CM_FAILED -1 //command request failed
/*************************************
******BICC Resource Structure*********
*************************************/
#define BICC_MAX_PORT 8192
#define BICC_CG_CIRCUIT 32
#define BICC_CIRCUIT_CIC 32
/*** BICC Primitive Parameter Structure (different to q1902_3e) ***/
typedef struct AppTransM_struct { //Application Transport Mechanism
u8 pres;
ApmUser_struct apm_info;
} AppTransM_struct;
/*********************************/
/**** BICC Primitive Structure ***/
/*********************************/
typedef struct BiccSetup_Req {
NatConnInd_struct natConn;//F
FwdCallInd_struct fwdCall;//F
CallingPtyCat_struct callingPtyCat;//F
TransMedReq_struct transMedReq;//F
CalledPtyNum_struct calledPtyNum;//V
AppTransM_struct app;
CallingPtyNum_struct callingPtyNum;
CollectCallReq_struct collectCallReq;
ConfTreatInd_struct confTreat;
CorrelationId_struct correlationId;
OrigCalledNum_struct origCalledNum;
RedirgNum_struct redirgNum;
RedirInfo_struct redirInfo;
ScfId_struct scfId;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccSetup_Req, BiccSetup_Ind;
typedef struct BiccSetup_Rsp {
AppTransM_struct app;
BackCallInd_struct backCall;//C: use it if no alert req is sent before
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccSetup_Rsp, BiccSetup_Cnf;
typedef struct BiccAlert_Req {
BackCallInd_struct backCall;//F
AppTransM_struct app;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
OptBackCallInd_struct optBackCall;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAlert_Req, BiccAlert_Ind;
typedef struct BiccInfo_Req {
SubseqNum_struct subseqNum;//V
} BiccInfo_Req, BiccInfo_Ind;
typedef struct BiccApm_Req {
AppTransM_struct app;
} BiccApm_Req, BiccApm_Ind;
typedef struct BiccCpg_Req {
EventInfo_struct eventInfo;//F
AppTransM_struct app;
BackCallInd_struct backCall;
CallDiverInfo_struct calldiver;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCpg_Req, BiccCpg_Ind;
typedef struct BiccRel_Req {
CauseInd_struct cause;//V
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccRel_Req, BiccRel_Ind;
typedef struct BiccRel_Rsp {
CauseInd_struct cause;
} BiccRel_Rsp, BiccRel_Cnf;
typedef struct BiccRes_Req {
SusResInd_struct susRes;//F
} BiccRes_Req, BiccRes_Ind;
typedef struct BiccSus_Req {
SusResInd_struct susRes;//F
} BiccSus_Req, BiccSus_Ind;
typedef struct BiccCgb_Req {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_Req, BiccCgb_Ind;
typedef struct BiccCgb_Rsp {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_Rsp, BiccCgb_Cnf;
typedef struct BiccCgu_Req {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_Req, BiccCgu_Ind;
typedef struct BiccCgu_Rsp {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_Rsp, BiccCgu_Cnf;
typedef struct BiccGrs_Req {
RangeStatus_struct rangeStatus;//V
} BiccGrs_Req, BiccGrs_Ind;
typedef struct BiccGrs_Rsp {
RangeStatus_struct rangeStatus;//V
} BiccGrs_Rsp, BiccGrs_Cnf;
typedef struct BiccSta_Req
{
BiccMsg_struct biccMsg;
}BiccSta_Req;
typedef struct BiccFac_Req
{
FacInd_struct facInd;
}BiccFac_Req, BiccFac_Ind;
typedef struct BiccFac_Rsp
{
FacInd_struct facInd;
}BiccFac_Rsp, BiccFac_Cnf;
typedef union BiccWritePrim_union {
BiccSetup_Req setup_req;
BiccSetup_Rsp setup_rsp;
BiccAlert_Req alert_req;
BiccInfo_Req info_req;
BiccApm_Req apm_req;
BiccCpg_Req cpg_req;
BiccRel_Req rel_req;
BiccRel_Rsp rel_rsp;
BiccRes_Req res_req;
BiccSus_Req sus_req;
BiccCgb_Req cgb_req;//only used in BICC module
BiccCgb_Rsp cgb_rsp;//only used in BICC module
BiccCgu_Req cgu_req;//only used in BICC module
BiccCgu_Rsp cgu_rsp;//only used in BICC module
BiccGrs_Req grs_req;//only used in BICC module
BiccGrs_Rsp grs_rsp;//only used in BICC module
BiccFac_Req fac_req;
BiccFac_Rsp fac_rsp;
} BiccWritePrim_union;
typedef union BiccReadPrim_union {
BiccSetup_Ind setup_ind;
BiccSetup_Cnf setup_cnf;
BiccAlert_Ind alert_ind;
BiccInfo_Ind info_ind;
BiccApm_Ind apm_ind;
BiccCpg_Ind cpg_ind;
BiccRel_Ind rel_ind;
BiccRel_Cnf rel_cnf;
BiccRes_Ind res_ind;
BiccSus_Ind sus_ind;
BiccCgb_Ind cgb_ind;//only used in BICC module
BiccCgb_Cnf cgb_cnf;//only used in BICC module
BiccCgu_Ind cgu_ind;//only used in BICC module
BiccCgu_Cnf cgu_cnf;//only used in BICC module
BiccGrs_Ind grs_ind;//only used in BICC module
BiccGrs_Cnf grs_cnf;//only used in BICC module
BiccFac_Ind fac_ind;
BiccFac_Cnf fac_cnf;
} BiccReadPrim_union;
/********************************************/
/****** BICC Internal Command *************/
/********************************************/
#define BICC_CMD_UNBLO 0x01
#define BICC_CMD_BLO 0x02
#define BICC_CMD_RESET 0x03
#define BICC_CMD_RESET_COMP 0x04
#define BICC_SI_CPCI 0x10
#define BICC_SI_CPCO 0x20
#define BICC_SI_BLS 0x30
#define BICC_SI_BLR 0x40
#define BICC_SI_MGBR 0x50
#define BICC_SI_MGBS 0x60
#define BICC_SI_CRS 0x70
#define BICC_SI_CRR 0x80
#define BICC_SI_CGRS 0x90
#define BICC_SI_CGRR 0xA0
/********************************************/
/****** BICC Event/Primitive Definition *****/
/********************************************/
#define BICC_SETUP_REQ 0x01 //user-defined, first 4-digit:type of primitive second 4-digit:type of event
#define BICC_SETUP_IND 0x41
#define BICC_SETUP_RSP 0x81
#define BICC_SETUP_CNF 0xc1
#define BICC_ALERT_REQ 0x02
#define BICC_ALERT_IND 0x42
#define BICC_INFO_REQ 0x03
#define BICC_INFO_IND 0x43
#define BICC_APM_REQ 0x04
#define BICC_APM_IND 0x44
#define BICC_PROG_REQ 0x05
#define BICC_PROG_IND 0x45
#define BICC_RELEASE_REQ 0x06
#define BICC_RELEASE_IND 0x46
#define BICC_RELEASE_RSP 0x86
#define BICC_RELEASE_CNF 0xc6
#define BICC_RESET_REQ 0x07
#define BICC_RESET_IND 0x47
#define BICC_RESET_CNF 0xc7
#define BICC_RESET_RSP 0x87
#define BICC_GROUP_RESET_REQ 0x17
#define BICC_BLOCK_REQ 0x08
#define BICC_BLOCK_IND 0x48
#define BICC_BLOCK_RSP 0x88
#define BICC_BLOCK_CNF 0xc8
#define BICC_UNBLOCK_REQ 0x09
#define BICC_UNBLOCK_IND 0x49
#define BICC_UNBLOCK_RSP 0x89
#define BICC_UNBLOCK_CNF 0xc9
#define BICC_SUSPEND_REQ 0x0a
#define BICC_SUSPEND_IND 0x4a
#define BICC_RESUME_REQ 0x0b
#define BICC_RESUME_IND 0x4b
#define BICC_REATTEMPT_IND 0x4c
#define BICC_FAILURE_IND 0x4f
#define BICC_FAC_REQ 0x0d
#define BICC_FAC_RSP 0x8d
#define BICC_FAC_IND 0x4d
#define BICC_FAC_CNF 0xcd
#define BICC_STA_IND 0x4e
#define BICC_STA_REQ 0x0e
#define BICC_MAINTENANCE_IND 0x44 //
#define BICC_STOP_REQ 0xee
#define BICC_STOP_CNF 0xef
typedef int f_bicc_setup_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_setup_anm_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_setup_con_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_release_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_release_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_alert_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_info_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_prog_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_suspend_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_resume_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reset_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reset_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_apm_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reattempt_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_failure_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_block_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_block_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_unblock_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_unblock_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef struct bicc_eventhandle_struct
{
f_bicc_setup_ind *h_bicc_setup_ind;
f_bicc_setup_anm_cnf *h_bicc_setup_anm_cnf;
f_bicc_setup_con_cnf *h_bicc_setup_con_cnf;
f_bicc_release_ind *h_bicc_release_ind;
f_bicc_release_cnf *h_bicc_release_cnf;
f_bicc_alert_ind *h_bicc_alert_ind;
f_bicc_info_ind *h_bicc_info_ind;
f_bicc_prog_ind *h_bicc_prog_ind;
f_bicc_suspend_ind *h_bicc_suspend_ind;
f_bicc_resume_ind *h_bicc_resume_ind;
f_bicc_block_ind *h_bicc_block_ind;
f_bicc_block_cnf *h_bicc_block_cnf;
f_bicc_unblock_ind *h_bicc_unblock_ind;
f_bicc_unblock_cnf *h_bicc_unblock_cnf;
f_bicc_reset_ind *h_bicc_reset_ind;
f_bicc_reset_cnf *h_bicc_reset_cnf;
f_bicc_apm_ind *h_bicc_apm_ind;
f_bicc_reattempt_ind *h_bicc_reattempt_ind;
f_bicc_failure_ind *h_bicc_failure_ind;
}BICC_EventHandle_struct;
typedef struct _bicc_sap_attrib_
{
BICC_EventHandle_struct event_handle;
}bicc_sap_sttrib_;
typedef enum _BICC_network_id
{
SI_INTERNATIONAL = 0,
SI_INTERNATIONAL_SPARE = 1,
SI_NATIONAL = 2,
SI_NATIONAL_SPARE = 3,
}SI_Netwrok_ID;
typedef struct bicc_cic_state
{
u8 call_state;
u8 sus_state; //suspend state, remote hold? local hold?
u8 blo_state; //block state, remote block? local hold?
}BICC_CIC_state;
typedef struct bicc_fsm_state
{
u8 cpc_state;
u8 mgbs_state;
u8 mgbr_state;
u8 crs_state;
u8 crr_state;
u8 cgrs_state;
u8 cgrr_state;
}BICC_Fsm_state;
typedef struct bicc_port_struct
{
u8 used_flag;
u8 trace_flag;
u32 w_time;
u32 su_proc_id;
u8 sprc_cmd;
u8 primitive_cmd;
u8 internal_cmd;
BICC_Fsm_state fsm_state;
BICC_CIC_state cic_state;
up_message_2 s_mtp_msg; //message send to mtp3
}BICC_Port_struct;
extern up_message_2 r_mtp_msg; //message receive from mtp3
typedef struct BiccDmp_struct {
// If DMP is active, circuit 0-127 is according to proccessor 0, circuit 128-255 is accroding to proccessor 1 //
u8 active;
u8 processor_id;
u32 remote_ip;
} BiccDmp_struct;
/**********************
***upper layer interface***
***********************
*/
extern int BICC_con_req(Pst *pst, BiccSetup_Req *ptr); //iam //Connection establishment request
extern int BICC_con_rsp(Pst *pst, BiccSetup_Rsp *ptr); //anm,con //Connection establishment response
extern int BICC_rel_req(Pst *pst, BiccRel_Req *ptr); //Release request
extern int BICC_rel_rsp(Pst *pst, BiccRel_Rsp *ptr); //Release response
extern int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr); //alert
extern int BICC_info_req(Pst *pst, BiccInfo_Req *ptr); //sam
extern int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr); //progress
extern int BICC_apm_req(Pst *pst, BiccApm_Req *ptr);
extern int BICC_sus_req(Pst *pst, BiccSus_Req *ptr); //Call suspend request
extern int BICC_resm_req(Pst *pst, BiccRes_Req *ptr); //Call resume request
extern int BICC_block_req(Pst *pst, BiccCgb_Req *ptr); //block req
extern int BICC_block_rsp(Pst *pst, BiccCgb_Req *ptr);
extern int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr); //unblock req
extern int BICC_unblock_rsp(Pst *pst, BiccCgb_Req *ptr);
extern int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr);
extern int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr); //reset response
extern void BICC_EMPTY_OPTPAR(void *ptr, u8 prim);
extern BOOL bicc_trunk_reachable(u32 cg_id);
/*****************************
*** layer management interface***
******************************
*/
int BICC_active_dmp(u8 plat_id, u32 alter_id );
int BICC_deactive_dmp();
/***********************
*** lower layer interface***
************************
*/
void BICC_msdc_proc(u32 pid, up_message_2 *upmsg_ptr);
int BICC_mdsc_proc();
/******************************
*** system service interface***
*******************************
*/
void BICC_init(int interval_ms, int local_id);
void BICC_timer();
#endif

View File

@@ -0,0 +1,34 @@
#ifndef _DEFINE_H_
#define _DEFINE_H_
//typedef int BOOL;
#ifndef _T_U8
#define _T_U8
typedef unsigned char u8;
#endif
#ifndef _T_U16
#define _T_U16
typedef unsigned short u16;
#endif
#ifndef _T_U32
#define _T_U32
typedef unsigned int u32;
#endif
#define BICC_TOLERANT
#define BICC_REATTEMPT
#define BICC_DEBUG
//Event
#define EN_NONE 0x00
#define EN_ANM 0x01
#define EN_CON 0x02
#define EN_GROUP 0x03
#define M_LOCAL_BLOCK 0x01
#define M_REMOTE_BLOCK 0x02
#endif

View File

@@ -0,0 +1,162 @@
#ifndef _INC_H
#define _INC_H
#include <string.h>
#include <stdio.h>
#include "../../../mtp3/src/include/mtp3.h"
#include "../../../snmp/src/include/snmp.h"
#include "biccif.h"
#define BICC_VERSION {9, 0, 10, 0}
#define BICC_SCREEN_SIZE 32
#define BICC_TIMER_STOP 0
#define BICC_TIMER_EXPIRED 1
#define BICC_T1 15
#define BICC_T5 300
#define BICC_T7 30
#define BICC_T8 10
#define BICC_T9 120
#define BICC_T12 15
#define BICC_T13 300
#define BICC_T14 15
#define BICC_T15 300
#define BICC_T16 15
#define BICC_T17 300
#define BICC_T18 15
#define BICC_T19 300
#define BICC_T20 15
#define BICC_T21 300
#define BICC_T22 15
#define BICC_T23 300
//#define BICC_T24 1
//#define BICC_T25 1
//#define BICC_T26 60
//#define BICC_T27 240
#define BICC_T28 10
#define BICC_T33 12
#define BICC_T34 2
#define BICC_T35 15
//#define BICC_T36 10
//#define BICC_T37 2
#define BICC_T40 10
#define BICC_T41 10
#define BICC_T42 5
#define BICC_T43 5
#define BICC_USER_T10 10//user defined timer,10s
#define BICC_CIC_IDLE 0
#define BICC_INCOMING 1
#define BICC_OUTGOING 2
#define BICC_RESET 3
#define BICC_TYPE_INCOMING 0
#define BICC_TYPE_OUTGOING 1
#define BICC_TYPE_BIDIRECT 2
#define BICC_ORIG_SUSPEND 0 //originating side suspend
#define BICC_TERM_SUSPEND 1 //terminating side suspend
typedef struct BiccTimer_struct
{
int t1;
int t5;
int t7;
int t8;
int t9;
int t12;
int t13;
int t14;
int t15;
int t16;
int t17;
int t18;
int t19;
int t20;
int t21;
int t22;
int t23;
int t28;
int t33;
int t34;
int t35;
int t40;
int t41;
int t42;
int t43;
int user_t10;
}BiccTimer_struct;
typedef struct BiccMng_struct {
u8 state;
u32 lnk_id;
RangeStatus_struct rangeStatus;
} BiccMng_struct;
typedef struct BiccDebug_struct {
u32 flag;
u8 sap_enable[BICC_SCREEN_SIZE];
u8 sap_cg_num[BICC_SCREEN_SIZE];
//u8 cg_enable[BICC_SCREEN_SIZE];
//u8 network_id[BICC_SCREEN_SIZE];
// page 1 //
u8 cic_enable[BICC_SCREEN_SIZE];
u8 cic_type[BICC_SCREEN_SIZE];
u8 l_block[BICC_SCREEN_SIZE];
u8 r_block[BICC_SCREEN_SIZE];
// page 2 //
u8 cic_status[BICC_SCREEN_SIZE];
u8 cpc_state[BICC_SCREEN_SIZE];
u8 mgbs_state[BICC_SCREEN_SIZE];
u8 mgbr_state[BICC_SCREEN_SIZE];
u8 crs_state[BICC_SCREEN_SIZE];
u8 crr_state[BICC_SCREEN_SIZE];
u8 cgrs_state[BICC_SCREEN_SIZE];
u8 cgrr_state[BICC_SCREEN_SIZE];
// page 3 //
u8 sprc_command[BICC_SCREEN_SIZE];
u8 mgbs_command[BICC_SCREEN_SIZE];
u8 mgbr_command[BICC_SCREEN_SIZE];
u8 crs_command[BICC_SCREEN_SIZE];
u8 crr_command[BICC_SCREEN_SIZE];
u8 cgrs_command[BICC_SCREEN_SIZE];
u8 cgrr_command[BICC_SCREEN_SIZE];
u8 prim_command[BICC_SCREEN_SIZE];
// page 4 //
u8 mng_state;
u8 mng_lnk_id;
} BiccDebug_struct;
typedef struct BiccData_struct
{
BiccDebug_struct debug_data;
BiccMng_struct mng_data;
BiccDmp_struct dmp_data;
BiccTimer_struct timer_data[BICC_MAX_PORT];
//BICC_Fsm_state fsm_data[BICC_MAX_PORT];
BICC_Port_struct port_data[BICC_MAX_PORT];
}BiccData_struct;
typedef struct stat_struct {
// u32 en_cic;
u32 lblo_cic;
u32 rblo_cic;
// u32 in_cic;
// u32 out_cic;
// u32 bi_cic;
u32 idle_call;
u32 in_call;
u32 out_call;
u32 lsus_cic;
u32 rsus_cic;
}stat_struct;
#endif

View File

@@ -0,0 +1,60 @@
// Q.1970E; RFC 2327 //
#ifndef _IPBCP_H_
#define _IPBCP_H_
typedef struct SdpOrig_struct {
char username[16];
char session_id[16];
char version[8];
char network_type[8];
char address_type[8];
char address[16];
} SdpOrig_struct;
typedef struct SdpConn_struct {
char network_type[8];
char address_type[8];
char address[16];
} SdpConn_struct;
typedef struct SdpTime_struct {
char start[16]; //0
char stop[16]; //0
} SdpTime_struct;
typedef struct SdpAttrib_struct {
char version[8]; //1
char type[16]; //"Request"/"Accepted"/"Confused"/"Rejected"
} SdpAttrib_struct;
typedef struct SdpMediaAnn_struct {
char media[16];
char port[8];
char transport[16];
char fmt_list[128];
} SdpMediaAnn_struct;
// specify RTP dynamic payload types //
typedef struct SdpMediaAtt_struct {
char payload[8];
char encoding_name[16];
char clock_rate[8];
// char p_time[8];
} SdpMediaAtt_struct;
typedef struct IPBCP_struct {
char proto_ver[8]; //Protocol version (M)
SdpOrig_struct orig; //Orign (M)
char session_name[16]; //Session name (M)
SdpConn_struct conn_data; //Connection data
SdpTime_struct time; //Time
SdpAttrib_struct attrib; //Session attribute
SdpMediaAnn_struct m_ann; //Media announcement (M)
SdpMediaAtt_struct m_att; //Media attributes
char ptime[8];
} IPBCP_struct;
extern int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr);
extern int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr);
#endif

View File

@@ -0,0 +1,456 @@
#ifndef _q1902_3E_H_
#define _q1902_3E_H_
#include "define.h"
#include "q765_5e.h"
/******************************************/
/******** BICC SIO (Q.1901E C.7.3) ********/
/******************************************/
#define BICC_SI 13
/******************************************/
/* Message Type Codes (Q.1902-3E, page 5) */
/******************************************/
#define M_ACM 0x06//Address complete
#define M_ANM 0x09//Answer
#define M_APM 0x41//Application transport
#define M_BLO 0x13//Blocking
#define M_BLA 0x15//Blocking acknowledgement
#define M_CPG 0x2c//Call progress
#define M_CGB 0x18//Circuit/CIC group blocking
#define M_CGBA 0x1a//Circuit/CIC group blocking acknowledgement
#define M_CQM 0x2a//Circuit/CIC group query (national use)
#define M_CQR 0x2b//Circuit/CIC group query response (national use)
#define M_GRS 0x17//Circuit/CIC group reset
#define M_GRA 0x29//Circuit/CIC group reset acknowledgement
#define M_CGU 0x19//Circuit/CIC group unblocking
#define M_CGUA 0x1b//Circuit/CIC group unblocking acknowledgement
#define M_CRG 0x31//Charge information (national use)
#define M_CFN 0x2f//Confusion
#define M_CON 0x07//Connect
#define M_COT 0x05//Continuity
#define M_FAC 0x33//Facility
#define M_FAA 0x20//Facility accepted
#define M_FRJ 0x21//Facility reject
#define M_FAR 0x1f//Facility request
#define M_FOT 0x08//Forward transfer
#define M_IDR 0x36//Identification request
#define M_IRS 0x37//Identification response
#define M_INF 0x04//Information (national use)
#define M_INR 0x03//Information request (national use)
#define M_IAM 0x01//Initial address
#define M_LOP 0x40//Loop prevention
#define M_NRM 0x32//Network resource management
#define M_PRI 0x42//Pre-release information
#define M_REL 0x0c//Release
#define M_RLC 0x10//Release complete
#define M_RSC 0x12//Reset circuit/CIC
#define M_RES 0x0e//Resume
#define M_SGM 0x38//Segmentation
#define M_SAM 0x02//Subsequent address
#define M_SDM 0x43//Subsequent Directory Number (national use)
#define M_SUS 0x0d//Suspend
#define M_UBL 0x14//Unblocking
#define M_UBA 0x16//Unblocking acknowledgement
#define M_UCIC 0x2e//Unequipped CIC (national use)
#define M_USR 0x2d//User-to-user information
/*********************************************/
/* Parameter Name Codes (Q.1902-3E, page 10) */
/*********************************************/
#define P_APPTRANS 0x78//Application transport
#define P_BACKCALLIND 0x11//Backward call indicators
#define P_CALLEDPTYNUM 0x04//Called party number
#define P_CALLINGPTYNUM 0x0a//Calling party number
#define P_CALLINGPTYCAT 0x09//Calling party's category
#define P_CAUSEIND 0x02//Cause indicators
#define P_CICGRPSPV 0x15//Circuit/CIC group supervision message type
#define P_COLLECTCALLREQ 0x79//Collect call request
#define P_CONFTREATIND 0x72//Conference treatment indicators
#define P_CONNNUM 0x21//Connected number
#define P_CORRELATIONID 0x65//Correlation id
#define P_EVENINFO 0x24//Event information
#define P_FACIND 0x18//Facility indicator
#define P_FWDCALLIND 0x07//Forward call indicators
#define P_NATCONNIND 0x06//Nature of connection indicators
#define P_ORIGCALLEDNUM 0x28//Original called number
#define P_RANGESTATUS 0x16//Range and status
#define P_REDIRGNUM 0x0b//Redirecting number
#define P_REDIRINFO 0x13//Redirection information
#define P_SCFID 0x66//SCF id
#define P_SUBSEQNUM 0x05//Subsequent number
#define P_SUSRESIND 0x22//Suspend/Resume indicators
#define P_TRANSMEDREQ 0x02//Transmission medium requirement
#define P_UTUIND 0x2a//User-to-user indicators
#define P_UTUINFO 0x20//User-to-user information
#define P_CALLDIVERINFO 0x36//Call diversion information
#define P_OPTBACKCALLIND 0x29//Optional backward call indicators
/**********************************************/
/* Parameter Structure (Q.1902-3E, section 6) */
/**********************************************/
#define MAX_BICC_DIGIT 32
#define BICC_STATUS_LEN 32
#define BICC_APP_LEN 200
#define MAX_DIAGNOSTIC_LEN 32
typedef struct AppTrans_struct {
u8 pres;
u8 aci[2]; //Application context identifier
u8 :6;
u8 sni:1; //Send notification indicator
u8 rci:1; //Release call indicator
u16 :1;
u16 si:1; //Sequence indicator
u16 segment:6; //APM segmentation indicator
u16 :1;
u16 slr:7; //Segmentation local reference
// APM-user information (For APM'98-user application only) //
ApmUser_struct apm_info;
} AppTrans_struct;
typedef struct BackCallInd_struct {
u8 pres;
u8 val[2];
} BackCallInd_struct;
typedef struct CalledPtyNum_struct {
u8 pres;
u8 nai;
u8 inn;
u8 npi;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} CalledPtyNum_struct;
typedef struct CallingPtyNum_struct {
u8 pres;
u8 nai;
u8 ni;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} CallingPtyNum_struct;
typedef struct CallingPtyCat_struct {
u8 pres;
u8 val;
} CallingPtyCat_struct;
/* defined in Q.850E */
typedef struct CauseInd_struct {
u8 pres;
u8 codingStd;
u8 location;
u8 causeVal;
//diagnostic
} CauseInd_struct;
typedef struct CicGrpSpv_struct {
u8 pres;
u8 val;
} CicGrpSpv_struct;
typedef struct CollectCallReq_struct {
u8 pres;
u8 val;
} CollectCallReq_struct;
typedef struct ConfTreatInd_struct {
u8 pres;
u8 val;
} ConfTreatInd_struct;
typedef struct ConnNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} ConnNum_struct;
typedef struct EventInfo_struct {
u8 pres;
u8 val;
} EventInfo_struct;
typedef struct FacInd_struct {
u8 pres;
u8 val;
} FacInd_struct;
typedef struct FwdCallInd_struct {
u8 pres;
u8 val[2];
} FwdCallInd_struct;
typedef struct GenericNumber_struct {
u8 pres;
u8 nqi; //Number qualifier indicator
u8 nai;
u8 ni;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} GenericNumber_struct;
typedef struct GenericDigits_struct /* Generic Digits */
{
u8 pres;
u8 typeOfDigits;
u8 encodeScheme;
u8 numOfDigit;
u8* digits;
} GenericDigits_struct;
typedef GenericDigits_struct CorrelationId_struct; //R10
//typedef struct CorrelationId_struct { //R9
// u8 pres;
// u8 digit[4]; //4 bytes
//}CorrelationId_struct;
typedef struct NatConnInd_struct {
u8 pres;
u8 val;
} NatConnInd_struct;
typedef struct OrigCalledNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} OrigCalledNum_struct;
typedef struct RangeStatus_struct {
u8 pres;
u8 range;
u8 status[BICC_STATUS_LEN];
} RangeStatus_struct;
typedef struct RedirgNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} RedirgNum_struct;
typedef struct RedirInfo_struct{
u8 pres;
u8 redInd;
u8 origRedirReason;
u8 redirCounter;
u8 redirReason;
}RedirInfo_struct;
typedef GenericDigits_struct ScfId_struct;
/*typedef struct ScfId_struct {
u8 pres;
u8 nai;
u8 inn;
u8 npi;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
}ScfId_struct;
*/
typedef struct SubseqNum_struct {
u8 pres;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} SubseqNum_struct;
typedef struct SusResInd_struct {
u8 pres;
u8 val;
} SusResInd_struct;
typedef struct TransMedReq_struct {
u8 pres;
u8 val;
} TransMedReq_struct;
typedef struct UserToUserInd_struct {
u8 pres;
u8 val;
} UserToUserInd_struct;
typedef struct UserToUserInfo_struct {
u8 pres;
u8 len;
u8 val[129];
} UserToUserInfo_struct;
typedef struct CallDiverInfo_struct
{
u8 pres;
u8 notifSubsOption;
u8 redirReason;
}CallDiverInfo_struct;
typedef struct OptBackCallInd_struct
{
u8 pres;
u8 inbandInfoInd;
u8 callDiverOccurInd;
u8 simpSegmInd;
u8 mlppUserInd;
}OptBackCallInd_struct;
/********************************************/
/* Message structure (Q.1902-3E, section 7) */
/********************************************/
typedef struct BiccAcm_struct {
BackCallInd_struct backCall;//F
AppTrans_struct app;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
OptBackCallInd_struct optBackCall;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAcm_struct;
typedef struct BiccAnm_struct {
AppTrans_struct app;
BackCallInd_struct backCall;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAnm_struct;
typedef struct BiccApm_struct {
AppTrans_struct app;
} BiccApm_struct;
typedef struct BiccCpg_struct {
EventInfo_struct eventInfo;//F
AppTrans_struct app;
BackCallInd_struct backCall;
CallDiverInfo_struct calldiver;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCpg_struct;
typedef struct BiccCgb_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_struct;
typedef struct BiccCgba_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgba_struct;
typedef struct BiccCgu_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_struct;
typedef struct BiccCgua_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgua_struct;
typedef struct BiccGrs_struct {
RangeStatus_struct rangeStatus;//V
} BiccGrs_struct;
typedef struct BiccGra_struct {
RangeStatus_struct rangeStatus;//V
} BiccGra_struct;
typedef struct BiccCon_struct {
BackCallInd_struct backCall;//F
AppTrans_struct app;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCon_struct;
typedef struct BiccIam_struct {
NatConnInd_struct natConn;//F
FwdCallInd_struct fwdCall;//F
CallingPtyCat_struct callingPtyCat;//F
TransMedReq_struct transMedReq;//F
CalledPtyNum_struct calledPtyNum;//V
AppTrans_struct app;
CallingPtyNum_struct callingPtyNum;
CollectCallReq_struct collectCallReq;
ConfTreatInd_struct confTreat;
CorrelationId_struct correlationId;
OrigCalledNum_struct origCalledNum;
RedirgNum_struct redirgNum;
RedirInfo_struct redirInfo;
ScfId_struct scfId;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccIam_struct;
typedef struct BiccRel_struct {
CauseInd_struct cause;//V
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccRel_struct;
typedef struct BiccRlc_struct {
CauseInd_struct cause;
} BiccRlc_struct;
typedef struct BiccRes_struct {
SusResInd_struct susRes;//F
//Optional
} BiccRes_struct;
typedef struct BiccSus_struct {
SusResInd_struct susRes;//F
//Optional
} BiccSus_struct;
typedef struct BiccSam_struct {
SubseqNum_struct subseqNum;//V
//Optional
} BiccSam_struct;
typedef struct BiccMsg_struct
{
}BiccMsg_struct;
typedef union BiccMsg_union {
BiccAcm_struct acm;
BiccAnm_struct anm;
BiccApm_struct apm;
BiccCpg_struct cpg;
BiccCgb_struct cgb;
BiccCgba_struct cgba;
BiccCgu_struct cgu;
BiccCgua_struct cgua;
BiccGrs_struct grs;
BiccGra_struct gra;
BiccCon_struct con;
BiccIam_struct iam;
BiccRel_struct rel;
BiccRlc_struct rlc;
BiccRes_struct res;
BiccSus_struct sus;
BiccSam_struct sam;
} BiccMsg_union;
#endif

View File

@@ -0,0 +1,100 @@
#ifndef _q765_5E_H_
#define _q765_5E_H_
#include "define.h"
#define AP_ACTION 0x01
#define AP_BNCID 0x02
#define AP_IWFADDR 0x03
#define AP_CODECLIST 0x04
#define AP_SINGLECODEC 0x05
#define AP_BATCR 0x06
#define AP_BNCCHR 0x07
#define AP_BCINFO 0x08
#define AP_BCTUNNEL 0x09
#define AP_BCUI 0x0a
#define AP_SIGNAL 0x0b
#define AP_BRC 0x0c
#define AP_BRI 0x0d
#define AP_SIGNALTYPE 0x0e
#define AP_DURATION 0x0f
/************************************************/
/***** Encapsulated application information *****/
/************************************************/
typedef struct ActionInd_struct {
u8 pres;
u8 comp_info;
u8 val;
} ActionInd_struct;
typedef struct BncId_struct {
u8 pres;
u8 comp_info;
u8 len;
u8 val[4];
} BncId_struct;
typedef struct IwfAddr_struct {
u8 pres;
//...
} IwfAddr_struct;
typedef struct BncChr_struct {
u8 pres;
u8 comp_info;
u8 val;
} BncChr_struct;
typedef struct BCTP_struct {
// BTCP (Q.1990) //
u8 :1;
u8 bvei:1; //BCTP Version Error Indicator
u8 :1;
u8 btcp_version:5; //BCTP Version Indicator
u8 :1;
u8 tpei:1; //Tunnelled Protocol Error Indicator
u8 tunnel_protocol:6; //Tunnelled Protocol Indicator
// IPBCP (Q.1970) //
u8 ipbcp_len;
u8 ipbcp_content[200];
} BCTP_struct;
typedef struct BcInfo_struct {
u8 pres;
u8 comp_info;
BCTP_struct bctp;
} BcInfo_struct;
typedef struct BcTunnel_struct {
u8 pres;
u8 comp_info;
u8 val;
} BcTunnel_struct;
typedef struct SignalType_struct {
u8 pres;
u8 comp_info;
u8 val;
} SignalType_struct;
typedef struct Duration_struct {
u8 pres;
u8 comp_info;
u16 val;
} Duration_struct;
typedef struct ApmUser_struct {
u8 :6;
u8 sni:1; //Send notification indicator
u8 rci:1; //Release call indicator
ActionInd_struct action;
BncId_struct bnc_id;
BncChr_struct bnc_chr;
BcInfo_struct bc_info;
BcTunnel_struct bc_tunnel;
SignalType_struct signal_type;
Duration_struct duration;
} ApmUser_struct;
#endif

View File

@@ -0,0 +1,14 @@
#ifndef _VAR_EXT_H_
#define _VAR_EXT_H_
#include "define.h"
#include "biccif.h"
#include "inc.h"
extern u8 Bicc_Version[4];
extern BiccData_struct Bicc_Data;
extern BiccTimer_struct Timer_Data;
extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT];
extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT];
#endif

206
plat/bicc/src/bicc_apm.c Normal file
View File

@@ -0,0 +1,206 @@
#include <stdio.h>
#include <string.h>
#include "./include/q765_5e.h"
void apm_decode_action(ActionInd_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_action(u8 *flw_ptr, const ActionInd_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_bncid(BncId_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->len = length - 1;
memcpy(ptr->val, flw_ptr+1, ptr->len);
}
u32 apm_encode_bncid(u8 *flw_ptr, const BncId_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
memcpy(flw_ptr+1, ptr->val, ptr->len);
return ptr->len + 1;
}
void apm_decode_bncchr(BncChr_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_bncchr(u8 *flw_ptr, const BncChr_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_bcinfo(BcInfo_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->bctp.bvei = (flw_ptr[1] >> 6) & 0x01;
ptr->bctp.btcp_version = flw_ptr[1] & 0x1f;
ptr->bctp.tpei = (flw_ptr[2] >> 6) & 0x01;
ptr->bctp.tunnel_protocol = flw_ptr[2] & 0x3f;
ptr->bctp.ipbcp_len = length - 3;
memcpy(ptr->bctp.ipbcp_content, flw_ptr+3, ptr->bctp.ipbcp_len);
}
u32 apm_encode_bcinfo(u8 *flw_ptr, const BcInfo_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = (ptr->bctp.bvei << 6) + (1 << 5) + ptr->bctp.btcp_version;
flw_ptr[2] = (ptr->bctp.tpei << 6) + ptr->bctp.tunnel_protocol;
memcpy(flw_ptr+3, ptr->bctp.ipbcp_content, ptr->bctp.ipbcp_len);
return ptr->bctp.ipbcp_len + 3;
}
void apm_decode_bctunnel(BcTunnel_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_bctunnel(u8 *flw_ptr, const BcTunnel_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_signaltype(SignalType_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = flw_ptr[1];
}
u32 apm_encode_signaltype(u8 *flw_ptr, const SignalType_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val;
return 2;
}
void apm_decode_duration(Duration_struct *ptr, const u8 *flw_ptr, u8 length)
{
ptr->pres = 1;
ptr->comp_info = flw_ptr[0];
ptr->val = (flw_ptr[1] << 8) + flw_ptr[2];
}
u32 apm_encode_duration(u8 *flw_ptr, const Duration_struct *ptr)
{
flw_ptr[0] = ptr->comp_info;
flw_ptr[1] = ptr->val >> 8;
flw_ptr[2] = ptr->val & 0xff;
return 3;
}
void apm_decode(ApmUser_struct *ptr, const u8 *flw_ptr, u8 length)
{
const u8 *old_ptr = flw_ptr;
while(flw_ptr+flw_ptr[1]+2-old_ptr <= length)
{
if(*flw_ptr == 0)
break;
switch(*flw_ptr)
{
case AP_ACTION:
apm_decode_action(&ptr->action, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BNCID:
apm_decode_bncid(&ptr->bnc_id, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BNCCHR:
apm_decode_bncchr(&ptr->bnc_chr, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BCINFO:
apm_decode_bcinfo(&ptr->bc_info, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_BCTUNNEL:
apm_decode_bctunnel(&ptr->bc_tunnel, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_SIGNALTYPE:
apm_decode_signaltype(&ptr->signal_type, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
case AP_DURATION:
apm_decode_duration(&ptr->duration, flw_ptr+2, flw_ptr[1]);
flw_ptr += flw_ptr[1] + 2;
break;
default:
flw_ptr += flw_ptr[1] + 2;
break;
}
}
}
u32 apm_encode(u8 *flw_ptr, const ApmUser_struct *ptr)
{
u8 *old_ptr = flw_ptr;
if(ptr->action.pres == 1)
{
flw_ptr[0] = AP_ACTION;
flw_ptr[1] = apm_encode_action(flw_ptr+2, &ptr->action);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bnc_id.pres == 1)
{
flw_ptr[0] = AP_BNCID;
flw_ptr[1] = apm_encode_bncid(flw_ptr+2, &ptr->bnc_id);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bnc_chr.pres == 1)
{
flw_ptr[0] = AP_BNCCHR;
flw_ptr[1] = apm_encode_bncchr(flw_ptr+2, &ptr->bnc_chr);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bc_info.pres == 1)
{
flw_ptr[0] = AP_BCINFO;
flw_ptr[1] = apm_encode_bcinfo(flw_ptr+2, &ptr->bc_info);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->bc_tunnel.pres == 1)
{
flw_ptr[0] = AP_BCTUNNEL;
flw_ptr[1] = apm_encode_bctunnel(flw_ptr+2, &ptr->bc_tunnel);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->signal_type.pres == 1)
{
flw_ptr[0] = AP_SIGNALTYPE;
flw_ptr[1] = apm_encode_signaltype(flw_ptr+2, &ptr->signal_type);
flw_ptr += flw_ptr[1] + 2;
}
if(ptr->duration.pres == 1)
{
flw_ptr[0] = AP_DURATION;
flw_ptr[1] = apm_encode_duration(flw_ptr+2, &ptr->duration);
flw_ptr += flw_ptr[1] + 2;
}
return flw_ptr - old_ptr;
}

882
plat/bicc/src/bicc_debug.c Normal file
View File

@@ -0,0 +1,882 @@
#include "./include/var_ext.h"
//static u32 bicc_object_id[BICC_PREOID_LEN] = {1,3,6,1,4,1,1373,1,3,2,2,6};
//static u16 bicc_sub_page[BICC_DEBUG_PAGE] = {0};
//static u8 bicc_ascii_in[BICC_ASCIN_LEN] = {0};
//static u8 bicc_ascii_out[BICC_ASCOUT_LEN] = {0};
#define BICC_DEBUG_ID 17
#define BICC_VER_DEBUG "R91V0_01"
#define MONITOR_NONE 0x0000
#define MONITOR_ERROR 0x0010
#define MONITOR_ALL 0xffff
#define TRACE_FLAG_ON 1
#define TRACE_FLAG_OFF 0
u8 AsciInBuf[4096];
u8 AsciOutBuf[4096];
u8 AsciTempBuf[4096];
WORD MonitorFg;
u8 info[1024];
static u8 log_help[] = {
"BICC debug Help:\n\r\
\n\r\
1.help\n\r\
2.log all/none\n\r\
3.log error on/off\n\r\
4.list cg[-cgNo] \n\r\
5.list circuit[-circuitNo]\n\r\
6.list port[-portNo]\n\r\
7.list dmp\n\r\
8.trace on-portNo\n\r\
9.trace off[-portNo]\n\r\n\r\
"
};
static WORD disp_page[10];
static u8 *disp_ptr = (u8 *) disp_page;
static DWORD debug_status_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_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,BICC_DEBUG_ID + 2,2
};
static DWORD debug_ascin_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,3
};
static DWORD debug_ascout_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,4
};
static DWORD debug_page_title[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,1
};
static DWORD debug_page_line[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,BICC_DEBUG_ID + 2,1,2,1
};
const static u8 BASE_ID_LEN = 15;
const static u8 PAGE_POINT = 14;
const static u8 LINE_POINT = 15;
static u8 title1_p[] =
{
" BICC Page 01 SAP Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
Enable\n\r\
CG num\n\r"
};
static u8 title2_p[] =
{
" BICC Page 02 CG Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
Enable\n\r\
SAP id\n\r\
NI\n\r\
DPC\n\r"
};
static u8 title3_p[] =
{
" BICC Page 03 CIrcuit Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
CG id\n\r\
CIC range\n\r\
HEAD CIC\n\r"
};
static u8 title4_p[] =
{
" BICC Page 04 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\
Enable\n\r\
FSM State\n\r\
CIC State\n\r"
};
static u8 debug_disp_line(u8 page, u8 line)
{
u8 disp_length;
disp_length = 0;
disp_ptr = (u8 *) disp_page;
switch (page)
{
/*
case 1: // Page 1: sap Info
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
break;
case 1:
disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_enable;
disp_length = 16;
break;
case 2:
disp_ptr = (BYTE *) &Bicc_Data.debug_data.sap_cg_num;
disp_length = 16;
break;
default:
break;
}
break;
case 2: // Page 2: cg Info
//disp_page[page] = (disp_page[page]+1)%BICC_MAX_CG;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 2;
break;
case 1: //enable
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].used_flag);
disp_length = 16;
break;
case 2: //sap_id
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].sap_id);
disp_length = 16;
break;
case 3: //network_id
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.network_id);
disp_length = 16;
break;
case 4: //dpc
disp_ptr = (BYTE *) &(BiccResource.cg_pond[disp_page[page]].attrib.dpc);
disp_length = 16;
break;
default:
break;
}
break;
case 3: // Page 3: circuit Info
//disp_page[page] = (disp_page[page]+1)%BICC_MAX_CIRCUIT;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 16;
break;
case 1: //cg_id
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].cg_id);
disp_length = 16;
break;
case 2: //cic_range
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.cic_range);
disp_length = 16;
break;
case 3: //head_cic
disp_ptr = (BYTE *) &(BiccResource.circuit_pond[disp_page[page]].attrib.head_cic);
disp_length = 16;
break;
default:
break;
}
break;
case 4: // Page 4: port Info
//disp_page[page] = (disp_page[page]+32)%BICC_MAX_PORT;
switch(line)
{
case 0:
disp_ptr = (BYTE *) &disp_page[page]; //Subpage
disp_length = 16;
break;
case 1: //enable
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].used_flag);
disp_length = 16;
break;
case 2: //fsm_state
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].fsm_state);
disp_length = 16;
break;
case 3: //cic_state
disp_ptr = (BYTE *) &(BiccResource.port_pond[disp_page[page]].cic_state);
disp_length = 16;
break;
default:
break;
}
break;
*/
default:
disp_length = 0;
break;
}
return disp_length;
}
static void debug_disp_page(u8 page)
{
u8 disp_line;
u8 disp_length;
debug_page_line[PAGE_POINT] = page + 5;
for (disp_line = 0; disp_line < 22; disp_line++)
{
disp_length = debug_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 bicc_debug_init(void)
{
BYTE page;
BYTE data[10];
BYTE *ptr;
strcpy(AsciInBuf, "\0");
strcpy(AsciOutBuf, "\0");
MonitorFg = MONITOR_NONE;
bzero(disp_page, 20);
ptr = data;
debug_set_response(BASE_ID_LEN, debug_status_id, &debug_status, 1);
debug_set_response(BASE_ID_LEN, debug_name_id, BICC_VER_DEBUG, 10);
debug_set_response(BASE_ID_LEN, debug_ascin_id, AsciInBuf, 4096);
debug_set_response(BASE_ID_LEN, debug_ascout_id, AsciOutBuf, 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[PAGE_POINT] = 5 + page;
debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
debug_disp_page(page);
}
return 1;
}
void bicc_asciout_proc(const char *fmt, ...)
{
va_list ap;
char buf[1024];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
if((strlen(AsciOutBuf) + strlen(buf)) < 4096)
strcat(AsciOutBuf, buf);
else
strcpy(AsciOutBuf, buf);
va_end(ap);
}
void bicc_debug_refresh(void)
{
// int i;
#if 0
for(i=0;i<16;i++)
{
Bicc_Data.debug_data.sap_enable[i] = BiccResource.sap_pond[i].used_flag;
Bicc_Data.debug_data.sap_cg_num[i] = BiccResource.sap_pond[i].cg_num;
}
#endif
}
#if 0
void list_sap(WORD sapNo)
{
//u8 sapinfo[1024];
if(sapNo >= BICC_MAX_SAP)
return;
sprintf(info,"\
Enable:%d\n\r\
cg num:%d\n\r",
BiccResource.sap_pond[sapNo].used_flag,BiccResource.sap_pond[sapNo].cg_num);
bicc_asciout_proc(info);
}
void list_all_sap()
{
int i;
sprintf(info, "Index CG(s)\n\r");
bicc_asciout_proc(info);
for(i=0; i<BICC_MAX_SAP; i++)
{
if(BiccResource.sap_pond[i].used_flag == 1)
{
sprintf(info, " %d %d\n\r", i, BiccResource.sap_pond[i].cg_num);
bicc_asciout_proc(info);
}
}
}
#endif
void list_cg(WORD cgNo)
{
const pal_cg_struct *pcg;
if(cgNo >= PAL_MAX_CG)
return;
pcg = pal_cg_ptr(cgNo);
if(pcg == NULL)
return;
sprintf(info, "\
Enable:%d\n\r\
sap id:%d\n\r\
circuit num:%d\n\r\
variant_type:%d\n\r\
priority:%d\n\r\
network id:%d\n\r\
opc:%ld\n\r\
dpc:%ld\n\r\
tg_id:%ld\n\r",
pcg->enable,pcg->sap_id,pcg->circuit_num,pcg->attrib.variant,pcg->attrib.priority,pcg->attrib.network_id,pcg->attrib.opc,pcg->attrib.dpc,pcg->attrib.tg_id);
bicc_asciout_proc(info);
}
void list_all_cg()
{
int i = 0;
const pal_cg_struct *pcg;
sprintf(info, "Index SAP Circuit(s) NetInd DPC OPC TG\n\r");
bicc_asciout_proc(info);
for(i=0; i<PAL_MAX_CG; i++)
{
pcg = pal_cg_ptr(i);
if(pcg == NULL)
continue;
if(pcg->enable==0)
continue;
if(pcg->attrib.protocol != PROTO_BICC)
continue;
sprintf(info, " %d %d %d %d %ld %ld %ld\n\r", i, pcg->sap_id, pcg->circuit_num, pcg->attrib.network_id, pcg->attrib.dpc, pcg->attrib.opc, pcg->attrib.tg_id);
bicc_asciout_proc(info);
}
}
void list_circuit(WORD circuitNo)
{
const pal_circuit_struct *pcircuit;
if(circuitNo >= PAL_MAX_CIRCUIT)
return;
pcircuit = pal_circuit_ptr(circuitNo);
if(pcircuit == NULL)
return ;
sprintf(info,"\
Enable:%d\n\r\
cg id:%d\n\r\
head cic:%ld\n\r\
cic range:%d\n\r\
plat id:%d\n\r",
pcircuit->enable,pcircuit->cg_id,pcircuit->attrib.head_cic,pcircuit->attrib.cic_range,pcircuit->attrib.plat_id);
bicc_asciout_proc(info);
}
void list_all_circuit()
{
int i = 0, j = 0;
const pal_circuit_struct *pcircuit;
const pal_cg_struct *pcg;
// for(i = 0; i < BICC_MAX_SAP; i ++)
//{
sprintf(info, "Index CG PLAT CIC(s)\n\r");
bicc_asciout_proc(info);
for(i=0; i<PAL_MAX_CG; i++)
{
pcg = pal_cg_ptr(i);
if(pcg == NULL)
continue;
if(pcg->enable == 0)
continue;
if(pcg->attrib.protocol != PROTO_BICC)
continue;
for(j = 0; j<PAL_MAX_CIRCUIT; j++)
{
pcircuit = pal_circuit_ptr(j);
if(pcircuit == NULL)
continue;
if(pcircuit->enable == 0 || pcircuit->cg_id != pcg->id)
continue;
sprintf(info, " %d %d %d %d (%ld~~%ld)\n\r", i, pcircuit->cg_id, pcircuit->attrib.plat_id, pcircuit->attrib.cic_range, pcircuit->attrib.head_cic, pcircuit->attrib.head_cic+pcircuit->attrib.cic_range);
bicc_asciout_proc(info);
}
}
}
void list_port(WORD portNo)
{
if(portNo>=BICC_MAX_PORT)
return;
sprintf(info,"\
upper port:%ld\n\r\
sprc_cmd:%x\n\r\
primitive_cmd:%x\n\r\
internal_cmd:%x\n\r\
cic state{\n\r\
call state:%d\n\r\
suspend state:%d\n\r\
block state:%d\n\r\
}\n\r\
fsm state{\n\r\
cpc_state:%d\n\r\
mgbs_state:%d\n\r\
mgbr_state:%d\n\r\
crs_state:%d\n\r\
crr_state:%d\n\r\
cgrs_state:%d\n\r\
cgrr_state:%d\n\r\
}\n\r",
Bicc_Data.port_data[portNo].su_proc_id,Bicc_Data.port_data[portNo].sprc_cmd,
Bicc_Data.port_data[portNo].primitive_cmd,Bicc_Data.port_data[portNo].internal_cmd,
Bicc_Data.port_data[portNo].cic_state.call_state,Bicc_Data.port_data[portNo].cic_state.sus_state,
Bicc_Data.port_data[portNo].cic_state.blo_state,Bicc_Data.port_data[portNo].fsm_state.cpc_state,
Bicc_Data.port_data[portNo].fsm_state.mgbs_state,Bicc_Data.port_data[portNo].fsm_state.mgbr_state,
Bicc_Data.port_data[portNo].fsm_state.crs_state,Bicc_Data.port_data[portNo].fsm_state.crr_state,
Bicc_Data.port_data[portNo].fsm_state.cgrs_state,Bicc_Data.port_data[portNo].fsm_state.cgrr_state);
bicc_asciout_proc(info);
}
void list_busy_port()
{
int i,j=0;
sprintf(info, "Index PortNo CallState\n\r");
bicc_asciout_proc(info);
for(i=0;i<BICC_MAX_PORT;i++)
{
if(Bicc_Data.port_data[i].used_flag == 1)
{
sprintf(info,"%d %d %s\n\r",j++,i,(Bicc_Data.port_data[i].cic_state.call_state==1)?"INCOMING":"OUTGOING");
bicc_asciout_proc(info);
}
}
}
void list_dmp()
{
sprintf(info, "\
dmp active: %d\n\r\
local plat id: %d\n\r\
remote ip: %lx\n\r", Bicc_Data.dmp_data.active,Bicc_Data.dmp_data.processor_id,Bicc_Data.dmp_data.remote_ip);
bicc_asciout_proc(info);
}
void bicc_debug_timer(void)
{
BYTE in_page, err_fg = 0;
BYTE *ascii_in_ptr = NULL;
BYTE *str_start = NULL, * tmpStr;
WORD str_len, portNo=0;
WORD num, cgNo, circuitNo;
if ((str_len = strlen(AsciInBuf)) > 0)
{
in_page = AsciInBuf[0] - 1;
ascii_in_ptr = AsciInBuf + 1;
if (in_page > 4)
err_fg = 1;
else if (strcmp(ascii_in_ptr,"log error on") == 0)
{
MonitorFg = MonitorFg | MONITOR_ERROR;
}
else if (strcmp(ascii_in_ptr,"log error off") == 0)
{
MonitorFg = MonitorFg & (~MONITOR_ERROR);
}
else if (strcmp(ascii_in_ptr,"log all") == 0)
{
MonitorFg = MONITOR_ALL;
}
else if (strcmp(ascii_in_ptr,"log none") == 0)
{
MonitorFg = MONITOR_NONE;
}
else if (strcmp(ascii_in_ptr,"help") == 0)
{
bicc_asciout_proc(log_help);
}
else if (isdigit(ascii_in_ptr[0]))
{
num = strtoul(ascii_in_ptr, NULL, 10);
disp_page[in_page] = num;
debug_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;
debug_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;
debug_disp_page(in_page);
}
#if 0
else if ((strstr (ascii_in_ptr, "list sap")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
sapNo = strtoul (tmpStr + 1, NULL, 10);
list_sap(sapNo);
}
else
{
list_all_sap();
}
}
#endif
else if ((strstr (ascii_in_ptr,"list cg")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
// if((tmpStr = strsep(&&ascii_in_ptr, " \t")) != NULL)
{
cgNo = strtoul (tmpStr+1, NULL, 10);
// strsep(, " \t");
list_cg(cgNo);
}
else
{
list_all_cg();
}
}
else if ((strstr (ascii_in_ptr, "list circuit")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
circuitNo = strtoul (tmpStr + 1, NULL, 10);
list_circuit(circuitNo);
}
else
{
list_all_circuit();
}
}
else if ((strstr (ascii_in_ptr, "list port")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul (tmpStr + 1, NULL, 10);
list_port(portNo);
}
else
{
list_busy_port();
}
}
else if((strstr (ascii_in_ptr, "list dmp")) != NULL)
{
list_dmp();
}
else if((strstr(ascii_in_ptr, "trace on")) != NULL)
{
if((tmpStr = strstr(ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul(tmpStr + 1, NULL, 10);
//trace_port(portNo);
Bicc_Data.port_data[portNo].trace_flag = 1;
}
else
{}
}
else if ((strstr (ascii_in_ptr, "trace off")) != NULL)
{
if((tmpStr = strstr (ascii_in_ptr, "-")) != NULL)
{
portNo = strtoul (tmpStr + 1, NULL, 10);
Bicc_Data.port_data[portNo].trace_flag = 0;
}
else
{
int i;
for(i=0; i<BICC_MAX_PORT; i++)
Bicc_Data.port_data[i].trace_flag = 0;
}
}
else
err_fg = 1;
if (err_fg == 0)
bicc_asciout_proc("Command OK!\n\r");
else
bicc_asciout_proc("Command Error!\n\r");
strcpy(AsciInBuf, "\0");
}
bicc_debug_refresh();
}
void bicc_log_err(const char *fmt, ...)
{
if ((MonitorFg & MONITOR_ERROR) == MONITOR_ERROR)
{
va_list ap;
char buf[1024];
va_start(ap, fmt);
vsprintf(buf, fmt, ap);
if((strlen(AsciOutBuf) + strlen(buf)) < 4096-15)
{
strcat(AsciOutBuf, "\33[31m");
strcat(AsciOutBuf, buf);
strcat(AsciOutBuf, "\33[37m");
}
else
{
strcpy(AsciOutBuf, "\33[31m");
strcat(AsciOutBuf, buf);
strcat(AsciOutBuf, "\33[37m");
}
va_end(ap);
}
}
int bicc_log_procedure(WORD mgNo, WORD portIndex, WORD chnlIndex, char *msg)
{
u8 monFlag = 0;
monFlag = 1;
if (monFlag == 1)
{
if (strlen(msg) >= 4096)
sprintf(AsciTempBuf, "log msg is too long!\n\r");
else
sprintf(AsciTempBuf, "%s\n\r", msg);
bicc_asciout_proc(AsciTempBuf);
return 0;
}
return -1;
}
void display_bicc_msgtype(u8 msgtype, u32 cic)
{
switch(msgtype)
{
case M_ACM:
bicc_asciout_proc("ACM:Address complete");
break;
case M_ANM:
bicc_asciout_proc("ANM:Answer");
break;
case M_BLO:
bicc_asciout_proc("BLO:Blocking");
break;
case M_BLA:
bicc_asciout_proc("BLA:Blocking acknowledgement");
break;
case M_CPG:
bicc_asciout_proc("CPG:Call progress");
break;
case M_CGB:
bicc_asciout_proc("CGB:Circuit/CIC group blocking");
break;
case M_CGBA:
bicc_asciout_proc("CGBA:Circuit/CIC group blocking acknowledgement");
break;
case M_CQM:
bicc_asciout_proc("CQM:Circuit/CIC group query (national use)");
break;
case M_CQR:
bicc_asciout_proc("CQR:Circuit/CIC group query response (national use)");
break;
case M_GRS:
bicc_asciout_proc("GRS:Circuit/CIC group reset");
break;
case M_GRA:
bicc_asciout_proc("GRA:Circuit/CIC group reset acknowledgement");
break;
case M_CGU:
bicc_asciout_proc("CGU:Circuit/CIC group unblocking");
break;
case M_CGUA:
bicc_asciout_proc("CGUA:Circuit/CIC group unblocking acknowledgement");
break;
case M_CRG:
bicc_asciout_proc("CRG:Charge information (national use)");
break;
case M_CFN:
bicc_asciout_proc("CFN:Confusion");
break;
case M_CON:
bicc_asciout_proc("CON:Connect");
break;
case M_COT:
bicc_asciout_proc("COT:Continuity");
break;
case M_FAC:
bicc_asciout_proc("FAC:Facility ");
break;
case M_FAA:
bicc_asciout_proc("FAA:Facility accepted");
break;
case M_FRJ:
bicc_asciout_proc("FRJ:Facility reject");
break;
case M_FAR:
bicc_asciout_proc("FAR:Facility request");
break;
case M_FOT:
bicc_asciout_proc("FOT:Forward transfer");
break;
case M_IDR:
bicc_asciout_proc("IDR:Identification request");
break;
case M_IRS:
bicc_asciout_proc("IRS:Identification response");
break;
case M_INF:
bicc_asciout_proc("INF:Information (national use)");
break;
case M_INR:
bicc_asciout_proc("INR:Information request (national use)");
break;
case M_IAM:
bicc_asciout_proc("IAM:Initial address");
break;
case M_NRM:
bicc_asciout_proc("NRM:Network resource management");
break;
case M_REL:
bicc_asciout_proc("REL:Release");
break;
case M_RLC:
bicc_asciout_proc("RLC:Release complete");
break;
case M_RSC:
bicc_asciout_proc("RSC:Reset circuit/CIC");
break;
case M_RES:
bicc_asciout_proc("RES:Resume");
break;
case M_SGM:
bicc_asciout_proc("SGM:Segmentation");
break;
case M_SAM:
bicc_asciout_proc("SAM:Subsequent address");
break;
case M_SUS:
bicc_asciout_proc("SUS:Suspend");
break;
case M_UBL:
bicc_asciout_proc("UBL:Unblocking");
break;
case M_UBA:
bicc_asciout_proc("UBA:Unblocking acknowledgement");
break;
case M_UCIC:
bicc_asciout_proc("UCIC:Unequipped CIC (national use)");
break;
case M_APM:
bicc_asciout_proc("APM:Application Transport");
break;
case M_USR:
bicc_asciout_proc("USR:User-to-user information");
break;
default:
bicc_asciout_proc("Unknown message");
}
bicc_asciout_proc("(message type=0x%x cic=%d)\r\n",msgtype,cic);
}
void monitor_bicc_msg(BYTE *msg,BYTE buf_len, BYTE flag, u32 cic, u32 portNo)
{
BYTE i,temp_buf[1024];
if(MonitorFg == MONITOR_ALL)
{
if(flag == 0)
bicc_asciout_proc("\33[33mReceive:\33[0m");
else if(flag == 1)
bicc_asciout_proc("\33[32mSend:\33[0m");
else if(flag == 2)
bicc_asciout_proc("\33[34mRedirect:\33[0m");
display_bicc_msgtype(msg[0], cic);
if(flag != 2)
{
for (i = 0; i < buf_len; i ++)
{
sprintf(&temp_buf[3*i]," %02x", msg[i]);
}
sprintf(&temp_buf[3*i],"\n\r");
bicc_asciout_proc(temp_buf);
}
}
if(MonitorFg == MONITOR_NONE)
{}
if(Bicc_Data.port_data[portNo].trace_flag == 1)
{
if(flag == 0)
bicc_asciout_proc("\33[33mReceive:\33[0m");
else if(flag == 1)
bicc_asciout_proc("\33[32mSend:\33[0m");
else if(flag == 2)
bicc_asciout_proc("\33[34mRedirect:\33[0m");
display_bicc_msgtype(msg[0], cic);
if(flag != 2)
{
for (i = 0; i < buf_len; i ++)
{
sprintf(&temp_buf[3*i]," %02x", msg[i]);
}
sprintf(&temp_buf[3*i],"\n\r");
bicc_asciout_proc(temp_buf);
}
}
}

2093
plat/bicc/src/bicc_fsm.c Normal file

File diff suppressed because it is too large Load Diff

362
plat/bicc/src/bicc_ipbcp.c Normal file
View File

@@ -0,0 +1,362 @@
#include <stdio.h>
#include <string.h>
#include "./include/ipbcp.h"
int sdp_decode_orig(SdpOrig_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->username, token);
strcat(dst_ptr->username, "\0");
break;
case 2:
sprintf(dst_ptr->session_id, token);
strcat(dst_ptr->session_id, "\0");
break;
case 3:
sprintf(dst_ptr->version, token);
strcat(dst_ptr->version, "\0");
break;
case 4:
sprintf(dst_ptr->network_type, token);
strcat(dst_ptr->network_type, "\0");
break;
case 5:
sprintf(dst_ptr->address_type, token);
strcat(dst_ptr->address_type, "\0");
break;
case 6:
sprintf(dst_ptr->address, token);
strcat(dst_ptr->address, "\0");
break;
default:
return 0;
}
}
if(field_id != 6)
return 0;
else
return 1;
}
int sdp_decode_conn(SdpConn_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->network_type, token);
strcat(dst_ptr->network_type, "\0");
break;
case 2:
sprintf(dst_ptr->address_type, token);
strcat(dst_ptr->address_type, "\0");
break;
case 3:
sprintf(dst_ptr->address, token);
strcat(dst_ptr->address, "\0");
break;
default:
return 0;
}
}
if(field_id != 3)
return 0;
else
return 1;
}
int sdp_decode_time(SdpTime_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->start, token);
strcat(dst_ptr->start, "\0");
break;
case 2:
sprintf(dst_ptr->stop, token);
strcat(dst_ptr->stop, "\0");
break;
default:
return 0;
}
}
if(field_id != 2)
return 0;
else
return 1;
}
int sdp_decode_attrib(SdpAttrib_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
if(strstr(src_ptr, "ipbcp:") != src_ptr)
return 0;
src_ptr += strlen("ipbcp:");
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->version, token);
strcat(dst_ptr->version, "\0");
break;
case 2:
sprintf(dst_ptr->type, token);
strcat(dst_ptr->type, "\0");
break;
default:
return 0;
}
}
if(field_id != 2)
return 0;
else
return 1;
}
int sdp_decode_mediaAnn(SdpMediaAnn_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
while((token = strsep(&src_ptr, " ")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->media, token);
strcat(dst_ptr->media, "\0");
break;
case 2:
sprintf(dst_ptr->port, token);
strcat(dst_ptr->port, "\0");
break;
case 3:
sprintf(dst_ptr->transport, token);
strcat(dst_ptr->transport, "\0");
strcpy(dst_ptr->fmt_list, src_ptr);
strcat(dst_ptr->fmt_list, "\0");
break;
case 4:
// sprintf(dst_ptr->fmt_list, token);
break;
default:
break;
}
}
if(field_id < 4)
return 0;
else
return 1;
}
int sdp_decode_mediaAtt(SdpMediaAtt_struct *dst_ptr, char *src_ptr)
{
char *token;
unsigned char field_id = 0;
if(strstr(src_ptr, "rtpmap:") != src_ptr)
return 0;
src_ptr += strlen("rtpmap:");
while((token = strsep(&src_ptr, " /")) != NULL)
{
switch(++field_id)
{
case 1:
sprintf(dst_ptr->payload, token);
strcat(dst_ptr->payload, "\0");
break;
case 2:
sprintf(dst_ptr->encoding_name, token);
strcat(dst_ptr->encoding_name, "\0");
break;
case 3:
sprintf(dst_ptr->clock_rate, token);
strcat(dst_ptr->clock_rate, "\0");
break;
case 4:
// sprintf(dst_ptr->p_time, token);
field_id --;//to avoid 4 fields
break;
default:
return 0;
}
}
if(field_id != 3)
return 0;
else
return 1;
}
int sdp_decode_ptime(char* p_time, char *src_ptr)
{
char *token;
if((token = strstr(src_ptr, "ptime:")) == NULL)
return 0;
token = strtok(token, ":");
token = strtok(NULL, ":");
// p_time = token;
// if(strlen(token)<8)
if(token)
{
sprintf(p_time, token);
strcat(p_time, "\0");
}
return 1;
}
int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr)
{
char *token;
unsigned char field_id = 0;
char temp_ipbcp[200];
char *temp_ptr;
strncpy(temp_ipbcp, ptr, 200);
temp_ptr = temp_ipbcp;
memset(ipbcp_ptr, 0, sizeof(IPBCP_struct));
while((token = strsep(&temp_ptr, "\r\n")) != NULL)
{
if(strlen(token) == 0)
continue;
switch(++field_id)
{
case 1:
if((token[0] != 'v') || (token[1] != '='))
return 0;
sprintf(ipbcp_ptr->proto_ver, token+2);
strcat(ipbcp_ptr->proto_ver, "\0");
break;
case 2:
if((token[0] != 'o') || (token[1] != '='))
return 0;
if(!sdp_decode_orig(&ipbcp_ptr->orig, token+2))
return 0;
break;
case 3:
if((token[0] != 's') || (token[1] != '='))
return 0;
sprintf(ipbcp_ptr->session_name, token+2);
strcat(ipbcp_ptr->session_name, "\0");
break;
case 4:
if((token[0] != 'c') || (token[1] != '='))
return 0;
if(!sdp_decode_conn(&ipbcp_ptr->conn_data, token+2))
return 0;
break;
case 5:
if((token[0] != 't') || (token[1] != '='))
return 0;
if(!sdp_decode_time(&ipbcp_ptr->time, token+2))
return 0;
break;
case 6:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(!sdp_decode_attrib(&ipbcp_ptr->attrib, token+2))
return 0;
break;
case 7:
if((token[0] != 'm') || (token[1] != '='))
return 0;
if(!sdp_decode_mediaAnn(&ipbcp_ptr->m_ann, token+2))
return 0;
break;
case 8:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(sdp_decode_mediaAtt(&ipbcp_ptr->m_att, token+2))
// return 0;
;
else if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2))
return 0;
break;
case 9:
if((token[0] != 'a') || (token[1] != '='))
return 0;
if(!sdp_decode_ptime(ipbcp_ptr->ptime, token+2))
return 0;
default:
break;
}
}
return 1;
}
int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr)
{
char tmp_buf[128];
sprintf(ptr, "v=%s\r\n", ipbcp_ptr->proto_ver);
sprintf(tmp_buf, "o=%s %s %s %s %s %s\r\n",
ipbcp_ptr->orig.username,
ipbcp_ptr->orig.session_id,
ipbcp_ptr->orig.version,
ipbcp_ptr->orig.network_type,
ipbcp_ptr->orig.address_type,
ipbcp_ptr->orig.address);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "s=%s\r\n", ipbcp_ptr->session_name);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "c=%s %s %s\r\n",
ipbcp_ptr->conn_data.network_type,
ipbcp_ptr->conn_data.address_type,
ipbcp_ptr->conn_data.address);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "t=%s %s\r\n", ipbcp_ptr->time.start, ipbcp_ptr->time.stop);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "a=ipbcp:%s %s\r\n", ipbcp_ptr->attrib.version, ipbcp_ptr->attrib.type);
strcat(ptr, tmp_buf);
sprintf(tmp_buf, "m=%s %s %s %s\r\n",
ipbcp_ptr->m_ann.media,
ipbcp_ptr->m_ann.port,
ipbcp_ptr->m_ann.transport,
ipbcp_ptr->m_ann.fmt_list);
strcat(ptr, tmp_buf);
if(strlen(ipbcp_ptr->m_att.payload) != 0)
{
sprintf(tmp_buf, "a=rtpmap:%s %s/%s\r\n",
ipbcp_ptr->m_att.payload,
ipbcp_ptr->m_att.encoding_name,
ipbcp_ptr->m_att.clock_rate);
strcat(ptr, tmp_buf);
}
//ipbcp_ptr->ptime[7]='\0';
if((ipbcp_ptr->ptime[0] != '\0') && (strlen(ipbcp_ptr->ptime)<8))
{
sprintf(tmp_buf, "a=ptime:%s\r\n", ipbcp_ptr->ptime);
strcat(ptr, tmp_buf);
}
return strlen(ptr);
}

1285
plat/bicc/src/bicc_msg.c Normal file

File diff suppressed because it is too large Load Diff

244
plat/bicc/src/bicc_prm.c Normal file
View File

@@ -0,0 +1,244 @@
#include "./include/inc.h"
#include "./include/var_ext.h"
#include "./include/q1902_3e.h"
/**********************************************/
/******* BICC Message&Primitive Mapping *******/
/**********************************************/
void app_msg2prm(AppTransM_struct *dst_ptr, AppTrans_struct *src_ptr)
{
dst_ptr->pres = src_ptr->pres;
if(src_ptr->pres == 1)
{
memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct));
dst_ptr->apm_info.sni = src_ptr->sni;
dst_ptr->apm_info.rci = src_ptr->rci;
}
}
void app_prm2msg(AppTrans_struct *dst_ptr, AppTransM_struct *src_ptr)
{
dst_ptr->pres = src_ptr->pres;
if(src_ptr->pres == 1)
{
dst_ptr->aci[0] = 0x00;
dst_ptr->aci[1] = 0x00;
dst_ptr->sni = src_ptr->apm_info.sni;
dst_ptr->rci = src_ptr->apm_info.rci;
dst_ptr->si = 0; //subsequent segment to first segment
dst_ptr->segment = 0; //final segment
dst_ptr->slr = 0;
memcpy(&dst_ptr->apm_info, &src_ptr->apm_info, sizeof(ApmUser_struct));
}
}
void bicc_msg2prm(BiccReadPrim_union *prm_ptr, BiccMsg_union *msg_ptr, u8 msg_type)
{
memset(prm_ptr, 0, sizeof(BiccReadPrim_union));
switch(msg_type)
{
case M_ACM:
memcpy(&prm_ptr->alert_ind.backCall, &msg_ptr->acm.backCall, sizeof(BackCallInd_struct));
app_msg2prm(&prm_ptr->alert_ind.app, &msg_ptr->acm.app);
memcpy(&prm_ptr->alert_ind.cause, &msg_ptr->acm.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->alert_ind.confTreat, &msg_ptr->acm.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->alert_ind.optBackCall, &msg_ptr->acm.optBackCall, sizeof(OptBackCallInd_struct));
memcpy(&prm_ptr->alert_ind.utuInd, &msg_ptr->acm.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->alert_ind.utuInfo, &msg_ptr->acm.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_ANM:
app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->anm.app);
memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->anm.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->anm.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->anm.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->anm.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->anm.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_APM:
app_msg2prm(&prm_ptr->apm_ind.app, &msg_ptr->apm.app);
break;
case M_CPG:
memcpy(&prm_ptr->cpg_ind.eventInfo, &msg_ptr->cpg.eventInfo, sizeof(EventInfo_struct));
app_msg2prm(&prm_ptr->cpg_ind.app, &msg_ptr->cpg.app);
memcpy(&prm_ptr->cpg_ind.backCall, &msg_ptr->cpg.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->cpg_ind.calldiver,&msg_ptr->cpg.calldiver, sizeof(BiccCpg_struct));
memcpy(&prm_ptr->cpg_ind.cause, &msg_ptr->cpg.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->cpg_ind.confTreat, &msg_ptr->cpg.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->cpg_ind.connNum, &msg_ptr->cpg.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->cpg_ind.utuInd, &msg_ptr->cpg.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->cpg_ind.utuInfo, &msg_ptr->cpg.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_CGB:
memcpy(&prm_ptr->cgb_ind.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgb_ind.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGBA:
memcpy(&prm_ptr->cgb_cnf.cicGrpSpv, &msg_ptr->cgb.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgb_cnf.rangeStatus, &msg_ptr->cgb.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGU:
memcpy(&prm_ptr->cgu_ind.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgu_ind.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGUA:
memcpy(&prm_ptr->cgu_cnf.cicGrpSpv, &msg_ptr->cgu.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&prm_ptr->cgu_cnf.rangeStatus, &msg_ptr->cgu.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRS:
memcpy(&prm_ptr->grs_ind.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRA:
memcpy(&prm_ptr->grs_cnf.rangeStatus, &msg_ptr->grs.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CON:
app_msg2prm(&prm_ptr->setup_cnf.app, &msg_ptr->con.app);
memcpy(&prm_ptr->setup_cnf.backCall, &msg_ptr->con.backCall, sizeof(BackCallInd_struct));
memcpy(&prm_ptr->setup_cnf.confTreat, &msg_ptr->con.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_cnf.connNum, &msg_ptr->con.connNum, sizeof(ConnNum_struct));
memcpy(&prm_ptr->setup_cnf.utuInd, &msg_ptr->con.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_cnf.utuInfo, &msg_ptr->con.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_IAM:
memcpy(&prm_ptr->setup_ind.natConn, &msg_ptr->iam.natConn, sizeof(NatConnInd_struct));
memcpy(&prm_ptr->setup_ind.fwdCall, &msg_ptr->iam.fwdCall, sizeof(FwdCallInd_struct));
memcpy(&prm_ptr->setup_ind.callingPtyCat, &msg_ptr->iam.callingPtyCat, sizeof(CallingPtyCat_struct));
memcpy(&prm_ptr->setup_ind.transMedReq, &msg_ptr->iam.transMedReq, sizeof(TransMedReq_struct));
memcpy(&prm_ptr->setup_ind.calledPtyNum, &msg_ptr->iam.calledPtyNum, sizeof(CalledPtyNum_struct));
app_msg2prm(&prm_ptr->setup_ind.app, &msg_ptr->apm.app);
memcpy(&prm_ptr->setup_ind.callingPtyNum, &msg_ptr->iam.callingPtyNum, sizeof(CallingPtyNum_struct));
memcpy(&prm_ptr->setup_ind.collectCallReq, &msg_ptr->iam.collectCallReq, sizeof(CollectCallReq_struct));
memcpy(&prm_ptr->setup_ind.confTreat, &msg_ptr->iam.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&prm_ptr->setup_ind.correlationId, &msg_ptr->iam.correlationId, sizeof(CorrelationId_struct));
memcpy(&prm_ptr->setup_ind.origCalledNum, &msg_ptr->iam.origCalledNum, sizeof(OrigCalledNum_struct));
memcpy(&prm_ptr->setup_ind.redirgNum, &msg_ptr->iam.redirgNum, sizeof(RedirgNum_struct));
memcpy(&prm_ptr->setup_ind.redirInfo, &msg_ptr->iam.redirInfo, sizeof(RedirInfo_struct));
memcpy(&prm_ptr->setup_ind.scfId, &msg_ptr->iam.scfId, sizeof(ScfId_struct));
memcpy(&prm_ptr->setup_ind.utuInd, &msg_ptr->iam.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->setup_ind.utuInfo, &msg_ptr->iam.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_REL:
memcpy(&prm_ptr->rel_ind.cause, &msg_ptr->rel.cause, sizeof(CauseInd_struct));
memcpy(&prm_ptr->rel_ind.utuInd, &msg_ptr->rel.utuInd, sizeof(UserToUserInd_struct));
memcpy(&prm_ptr->rel_ind.utuInfo, &msg_ptr->rel.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_RLC:
memcpy(&prm_ptr->rel_cnf.cause, &msg_ptr->rlc.cause, sizeof(CauseInd_struct));
break;
case M_RES:
memcpy(&prm_ptr->res_ind.susRes, &msg_ptr->res.susRes, sizeof(SusResInd_struct));
break;
case M_SUS:
memcpy(&prm_ptr->sus_ind.susRes, &msg_ptr->sus.susRes, sizeof(SusResInd_struct));
break;
case M_SAM:
memcpy(&prm_ptr->info_ind.subseqNum, &msg_ptr->sam.subseqNum, sizeof(SubseqNum_struct));
break;
default:
break;
}
}
void bicc_prm2msg(BiccMsg_union *msg_ptr, BiccWritePrim_union *prm_ptr, u8 msg_type)
{
memset(msg_ptr, 0, sizeof(BiccMsg_union));
switch(msg_type)
{
case M_ACM:
memcpy(&msg_ptr->acm.backCall, &prm_ptr->alert_req.backCall, sizeof(BackCallInd_struct));
app_prm2msg(&msg_ptr->acm.app, &prm_ptr->alert_req.app);
memcpy(&msg_ptr->acm.cause, &prm_ptr->alert_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->acm.confTreat, &prm_ptr->alert_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->acm.optBackCall, &prm_ptr->alert_req.optBackCall, sizeof(OptBackCallInd_struct));
memcpy(&msg_ptr->acm.utuInd, &prm_ptr->alert_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->acm.utuInfo, &prm_ptr->alert_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_ANM:
app_prm2msg(&msg_ptr->anm.app, &prm_ptr->setup_rsp.app);
memcpy(&msg_ptr->anm.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->anm.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->anm.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->anm.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->anm.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_APM:
app_prm2msg(&msg_ptr->apm.app, &prm_ptr->apm_req.app);
break;
case M_CPG:
memcpy(&msg_ptr->cpg.eventInfo, &prm_ptr->cpg_req.eventInfo, sizeof(EventInfo_struct));
app_prm2msg(&msg_ptr->cpg.app, &prm_ptr->cpg_req.app);
memcpy(&msg_ptr->cpg.backCall, &prm_ptr->cpg_req.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->cpg.calldiver, &prm_ptr->cpg_req.calldiver, sizeof(BiccCpg_struct));
memcpy(&msg_ptr->cpg.cause, &prm_ptr->cpg_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->cpg.confTreat, &prm_ptr->cpg_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->cpg.connNum, &prm_ptr->cpg_req.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->cpg.utuInd, &prm_ptr->cpg_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->cpg.utuInfo, &prm_ptr->cpg_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_CGB:
memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_req.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGBA:
memcpy(&msg_ptr->cgb.cicGrpSpv, &prm_ptr->cgb_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgb.rangeStatus, &prm_ptr->cgb_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGU:
memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_req.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CGUA:
memcpy(&msg_ptr->cgu.cicGrpSpv, &prm_ptr->cgu_rsp.cicGrpSpv, sizeof(CicGrpSpv_struct));
memcpy(&msg_ptr->cgu.rangeStatus, &prm_ptr->cgu_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRS:
memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_req.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_GRA:
memcpy(&msg_ptr->grs.rangeStatus, &prm_ptr->grs_rsp.rangeStatus, sizeof(RangeStatus_struct));
break;
case M_CON:
app_prm2msg(&msg_ptr->con.app, &prm_ptr->setup_rsp.app);
memcpy(&msg_ptr->con.backCall, &prm_ptr->setup_rsp.backCall, sizeof(BackCallInd_struct));
memcpy(&msg_ptr->con.confTreat, &prm_ptr->setup_rsp.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->con.connNum, &prm_ptr->setup_rsp.connNum, sizeof(ConnNum_struct));
memcpy(&msg_ptr->con.utuInd, &prm_ptr->setup_rsp.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->con.utuInfo, &prm_ptr->setup_rsp.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_IAM:
memcpy(&msg_ptr->iam.natConn, &prm_ptr->setup_req.natConn, sizeof(NatConnInd_struct));
memcpy(&msg_ptr->iam.fwdCall, &prm_ptr->setup_req.fwdCall, sizeof(FwdCallInd_struct));
memcpy(&msg_ptr->iam.callingPtyCat, &prm_ptr->setup_req.callingPtyCat, sizeof(CallingPtyCat_struct));
memcpy(&msg_ptr->iam.transMedReq, &prm_ptr->setup_req.transMedReq, sizeof(TransMedReq_struct));
memcpy(&msg_ptr->iam.calledPtyNum, &prm_ptr->setup_req.calledPtyNum, sizeof(CalledPtyNum_struct));
app_prm2msg(&msg_ptr->iam.app, &prm_ptr->setup_req.app);
memcpy(&msg_ptr->iam.callingPtyNum, &prm_ptr->setup_req.callingPtyNum, sizeof(CallingPtyNum_struct));
memcpy(&msg_ptr->iam.collectCallReq, &prm_ptr->setup_req.collectCallReq, sizeof(CollectCallReq_struct));
memcpy(&msg_ptr->iam.confTreat, &prm_ptr->setup_req.confTreat, sizeof(ConfTreatInd_struct));
memcpy(&msg_ptr->iam.correlationId, &prm_ptr->setup_req.correlationId, sizeof(CorrelationId_struct));
memcpy(&msg_ptr->iam.origCalledNum, &prm_ptr->setup_req.origCalledNum, sizeof(OrigCalledNum_struct));
memcpy(&msg_ptr->iam.redirgNum, &prm_ptr->setup_req.redirgNum, sizeof(RedirgNum_struct));
memcpy(&msg_ptr->iam.redirInfo, &prm_ptr->setup_req.redirInfo, sizeof(RedirInfo_struct));
memcpy(&msg_ptr->iam.scfId, &prm_ptr->setup_req.scfId, sizeof(ScfId_struct));
memcpy(&msg_ptr->iam.utuInd, &prm_ptr->setup_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->iam.utuInfo, &prm_ptr->setup_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_REL:
memcpy(&msg_ptr->rel.cause, &prm_ptr->rel_req.cause, sizeof(CauseInd_struct));
memcpy(&msg_ptr->rel.utuInd, &prm_ptr->rel_req.utuInd, sizeof(UserToUserInd_struct));
memcpy(&msg_ptr->rel.utuInfo, &prm_ptr->rel_req.utuInfo, sizeof(UserToUserInfo_struct));
break;
case M_RLC:
memcpy(&msg_ptr->rlc.cause, &prm_ptr->rel_rsp.cause, sizeof(CauseInd_struct));
break;
case M_RES:
memcpy(&msg_ptr->res.susRes, &prm_ptr->res_req.susRes, sizeof(SusResInd_struct));
break;
case M_SUS:
memcpy(&msg_ptr->sus.susRes, &prm_ptr->sus_req.susRes, sizeof(SusResInd_struct));
break;
case M_SAM:
memcpy(&msg_ptr->sam.subseqNum, &prm_ptr->info_req.subseqNum, sizeof(SubseqNum_struct));
break;
default:
break;
}
}

1080
plat/bicc/src/biccif.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
#include "define.h"
#include "../../../debug/src/include/debug.h"
#define LOG_ERR_FLAG 0x01
#define LOG_BICC_FLAG 0x02
#define LOG_MSG_FLAG 0x04
#define LOG_TIME_FLAG 0x08
#define LOG_DMP_FLAG 0x10
#define LOG_ALL_FLAG 0x1f
#define LOG_FILE_FLAG 0x20
/*******************************/
#define MAX_OPR_LEN 16
#define MAX_OBJ_LEN 32
#define MAX_VALUE_LEN 32
#define BICC_PREOID_LEN 12
#define BICC_DEBUG_OID 17
#define BICC_DEBUG_PAGE 10
#define BICC_ASCIN_LEN 128
#define BICC_ASCOUT_LEN 4096
int bicc_debug_init();
void bicc_debug_timer();
void monitor_bicc_msg(u8 *msg,u8 buf_len, BYTE flag, u32 cic, u32 portNo);
void bicc_asciout_proc(const char *fmt, ...);

View File

@@ -0,0 +1,417 @@
#ifndef _BICCIF_H_
#define _BICCIF_H_
#include "q765_5e.h"
#include "q1902_3e.h"
#include "../../../mtp3/src/include/mtp3.h"
#include "../../../snmp/src/include/snmp.h"
//#include "../../../public/src/include/proto_pub.h"
#include "bicc_debug.h"
#include "../../../pal/pal.h"
/*********************************/
/*** BICC Management Structure ***/
/*********************************/
#define BICC_CM_OK 1 //command request success
#define BICC_CM_FAILED -1 //command request failed
/*************************************
******BICC Resource Structure*********
*************************************/
#define BICC_MAX_PORT 8192
#define BICC_CG_CIRCUIT 32
#define BICC_CIRCUIT_CIC 32
/*** BICC Primitive Parameter Structure (different to q1902_3e) ***/
typedef struct AppTransM_struct { //Application Transport Mechanism
u8 pres;
ApmUser_struct apm_info;
} AppTransM_struct;
/*********************************/
/**** BICC Primitive Structure ***/
/*********************************/
typedef struct BiccSetup_Req {
NatConnInd_struct natConn;//F
FwdCallInd_struct fwdCall;//F
CallingPtyCat_struct callingPtyCat;//F
TransMedReq_struct transMedReq;//F
CalledPtyNum_struct calledPtyNum;//V
AppTransM_struct app;
CallingPtyNum_struct callingPtyNum;
CollectCallReq_struct collectCallReq;
ConfTreatInd_struct confTreat;
CorrelationId_struct correlationId;
OrigCalledNum_struct origCalledNum;
RedirgNum_struct redirgNum;
RedirInfo_struct redirInfo;
ScfId_struct scfId;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccSetup_Req, BiccSetup_Ind;
typedef struct BiccSetup_Rsp {
AppTransM_struct app;
BackCallInd_struct backCall;//C: use it if no alert req is sent before
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccSetup_Rsp, BiccSetup_Cnf;
typedef struct BiccAlert_Req {
BackCallInd_struct backCall;//F
AppTransM_struct app;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
OptBackCallInd_struct optBackCall;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAlert_Req, BiccAlert_Ind;
typedef struct BiccInfo_Req {
SubseqNum_struct subseqNum;//V
} BiccInfo_Req, BiccInfo_Ind;
typedef struct BiccApm_Req {
AppTransM_struct app;
} BiccApm_Req, BiccApm_Ind;
typedef struct BiccCpg_Req {
EventInfo_struct eventInfo;//F
AppTransM_struct app;
BackCallInd_struct backCall;
CallDiverInfo_struct calldiver;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCpg_Req, BiccCpg_Ind;
typedef struct BiccRel_Req {
CauseInd_struct cause;//V
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccRel_Req, BiccRel_Ind;
typedef struct BiccRel_Rsp {
CauseInd_struct cause;
} BiccRel_Rsp, BiccRel_Cnf;
typedef struct BiccRes_Req {
SusResInd_struct susRes;//F
} BiccRes_Req, BiccRes_Ind;
typedef struct BiccSus_Req {
SusResInd_struct susRes;//F
} BiccSus_Req, BiccSus_Ind;
typedef struct BiccCgb_Req {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_Req, BiccCgb_Ind;
typedef struct BiccCgb_Rsp {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_Rsp, BiccCgb_Cnf;
typedef struct BiccCgu_Req {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_Req, BiccCgu_Ind;
typedef struct BiccCgu_Rsp {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_Rsp, BiccCgu_Cnf;
typedef struct BiccGrs_Req {
RangeStatus_struct rangeStatus;//V
} BiccGrs_Req, BiccGrs_Ind;
typedef struct BiccGrs_Rsp {
RangeStatus_struct rangeStatus;//V
} BiccGrs_Rsp, BiccGrs_Cnf;
typedef struct BiccSta_Req
{
BiccMsg_struct biccMsg;
}BiccSta_Req;
typedef struct BiccFac_Req
{
FacInd_struct facInd;
}BiccFac_Req, BiccFac_Ind;
typedef struct BiccFac_Rsp
{
FacInd_struct facInd;
}BiccFac_Rsp, BiccFac_Cnf;
typedef union BiccWritePrim_union {
BiccSetup_Req setup_req;
BiccSetup_Rsp setup_rsp;
BiccAlert_Req alert_req;
BiccInfo_Req info_req;
BiccApm_Req apm_req;
BiccCpg_Req cpg_req;
BiccRel_Req rel_req;
BiccRel_Rsp rel_rsp;
BiccRes_Req res_req;
BiccSus_Req sus_req;
BiccCgb_Req cgb_req;//only used in BICC module
BiccCgb_Rsp cgb_rsp;//only used in BICC module
BiccCgu_Req cgu_req;//only used in BICC module
BiccCgu_Rsp cgu_rsp;//only used in BICC module
BiccGrs_Req grs_req;//only used in BICC module
BiccGrs_Rsp grs_rsp;//only used in BICC module
BiccFac_Req fac_req;
BiccFac_Rsp fac_rsp;
} BiccWritePrim_union;
typedef union BiccReadPrim_union {
BiccSetup_Ind setup_ind;
BiccSetup_Cnf setup_cnf;
BiccAlert_Ind alert_ind;
BiccInfo_Ind info_ind;
BiccApm_Ind apm_ind;
BiccCpg_Ind cpg_ind;
BiccRel_Ind rel_ind;
BiccRel_Cnf rel_cnf;
BiccRes_Ind res_ind;
BiccSus_Ind sus_ind;
BiccCgb_Ind cgb_ind;//only used in BICC module
BiccCgb_Cnf cgb_cnf;//only used in BICC module
BiccCgu_Ind cgu_ind;//only used in BICC module
BiccCgu_Cnf cgu_cnf;//only used in BICC module
BiccGrs_Ind grs_ind;//only used in BICC module
BiccGrs_Cnf grs_cnf;//only used in BICC module
BiccFac_Ind fac_ind;
BiccFac_Cnf fac_cnf;
} BiccReadPrim_union;
/********************************************/
/****** BICC Internal Command *************/
/********************************************/
#define BICC_CMD_UNBLO 0x01
#define BICC_CMD_BLO 0x02
#define BICC_CMD_RESET 0x03
#define BICC_CMD_RESET_COMP 0x04
#define BICC_SI_CPCI 0x10
#define BICC_SI_CPCO 0x20
#define BICC_SI_BLS 0x30
#define BICC_SI_BLR 0x40
#define BICC_SI_MGBR 0x50
#define BICC_SI_MGBS 0x60
#define BICC_SI_CRS 0x70
#define BICC_SI_CRR 0x80
#define BICC_SI_CGRS 0x90
#define BICC_SI_CGRR 0xA0
/********************************************/
/****** BICC Event/Primitive Definition *****/
/********************************************/
#define BICC_SETUP_REQ 0x01 //user-defined, first 4-digit:type of primitive second 4-digit:type of event
#define BICC_SETUP_IND 0x41
#define BICC_SETUP_RSP 0x81
#define BICC_SETUP_CNF 0xc1
#define BICC_ALERT_REQ 0x02
#define BICC_ALERT_IND 0x42
#define BICC_INFO_REQ 0x03
#define BICC_INFO_IND 0x43
#define BICC_APM_REQ 0x04
#define BICC_APM_IND 0x44
#define BICC_PROG_REQ 0x05
#define BICC_PROG_IND 0x45
#define BICC_RELEASE_REQ 0x06
#define BICC_RELEASE_IND 0x46
#define BICC_RELEASE_RSP 0x86
#define BICC_RELEASE_CNF 0xc6
#define BICC_RESET_REQ 0x07
#define BICC_RESET_IND 0x47
#define BICC_RESET_CNF 0xc7
#define BICC_RESET_RSP 0x87
#define BICC_GROUP_RESET_REQ 0x17
#define BICC_BLOCK_REQ 0x08
#define BICC_BLOCK_IND 0x48
#define BICC_BLOCK_RSP 0x88
#define BICC_BLOCK_CNF 0xc8
#define BICC_UNBLOCK_REQ 0x09
#define BICC_UNBLOCK_IND 0x49
#define BICC_UNBLOCK_RSP 0x89
#define BICC_UNBLOCK_CNF 0xc9
#define BICC_SUSPEND_REQ 0x0a
#define BICC_SUSPEND_IND 0x4a
#define BICC_RESUME_REQ 0x0b
#define BICC_RESUME_IND 0x4b
#define BICC_REATTEMPT_IND 0x4c
#define BICC_FAILURE_IND 0x4f
#define BICC_FAC_REQ 0x0d
#define BICC_FAC_RSP 0x8d
#define BICC_FAC_IND 0x4d
#define BICC_FAC_CNF 0xcd
#define BICC_STA_IND 0x4e
#define BICC_STA_REQ 0x0e
#define BICC_MAINTENANCE_IND 0x44 //
#define BICC_STOP_REQ 0xee
#define BICC_STOP_CNF 0xef
typedef int f_bicc_setup_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_setup_anm_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_setup_con_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_release_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_release_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_alert_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_info_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_prog_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_suspend_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_resume_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reset_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reset_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_apm_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_reattempt_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_failure_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_block_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_block_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_unblock_ind(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef int f_bicc_unblock_cnf(Pst *pst, const BiccReadPrim_union *prm_ptr);
typedef struct bicc_eventhandle_struct
{
f_bicc_setup_ind *h_bicc_setup_ind;
f_bicc_setup_anm_cnf *h_bicc_setup_anm_cnf;
f_bicc_setup_con_cnf *h_bicc_setup_con_cnf;
f_bicc_release_ind *h_bicc_release_ind;
f_bicc_release_cnf *h_bicc_release_cnf;
f_bicc_alert_ind *h_bicc_alert_ind;
f_bicc_info_ind *h_bicc_info_ind;
f_bicc_prog_ind *h_bicc_prog_ind;
f_bicc_suspend_ind *h_bicc_suspend_ind;
f_bicc_resume_ind *h_bicc_resume_ind;
f_bicc_block_ind *h_bicc_block_ind;
f_bicc_block_cnf *h_bicc_block_cnf;
f_bicc_unblock_ind *h_bicc_unblock_ind;
f_bicc_unblock_cnf *h_bicc_unblock_cnf;
f_bicc_reset_ind *h_bicc_reset_ind;
f_bicc_reset_cnf *h_bicc_reset_cnf;
f_bicc_apm_ind *h_bicc_apm_ind;
f_bicc_reattempt_ind *h_bicc_reattempt_ind;
f_bicc_failure_ind *h_bicc_failure_ind;
}BICC_EventHandle_struct;
typedef struct _bicc_sap_attrib_
{
BICC_EventHandle_struct event_handle;
}bicc_sap_sttrib_;
typedef enum _BICC_network_id
{
SI_INTERNATIONAL = 0,
SI_INTERNATIONAL_SPARE = 1,
SI_NATIONAL = 2,
SI_NATIONAL_SPARE = 3,
}SI_Netwrok_ID;
typedef struct bicc_cic_state
{
u8 call_state;
u8 sus_state; //suspend state, remote hold? local hold?
u8 blo_state; //block state, remote block? local hold?
}BICC_CIC_state;
typedef struct bicc_fsm_state
{
u8 cpc_state;
u8 mgbs_state;
u8 mgbr_state;
u8 crs_state;
u8 crr_state;
u8 cgrs_state;
u8 cgrr_state;
}BICC_Fsm_state;
typedef struct bicc_port_struct
{
u8 used_flag;
u8 trace_flag;
u32 w_time;
u32 su_proc_id;
u8 sprc_cmd;
u8 primitive_cmd;
u8 internal_cmd;
BICC_Fsm_state fsm_state;
BICC_CIC_state cic_state;
up_message_2 s_mtp_msg; //message send to mtp3
}BICC_Port_struct;
extern up_message_2 r_mtp_msg; //message receive from mtp3
typedef struct BiccDmp_struct {
// If DMP is active, circuit 0-127 is according to proccessor 0, circuit 128-255 is accroding to proccessor 1 //
u8 active;
u8 processor_id;
u32 remote_ip;
} BiccDmp_struct;
/**********************
***upper layer interface***
***********************
*/
extern int BICC_con_req(Pst *pst, BiccSetup_Req *ptr); //iam //Connection establishment request
extern int BICC_con_rsp(Pst *pst, BiccSetup_Rsp *ptr); //anm,con //Connection establishment response
extern int BICC_rel_req(Pst *pst, BiccRel_Req *ptr); //Release request
extern int BICC_rel_rsp(Pst *pst, BiccRel_Rsp *ptr); //Release response
extern int BICC_alert_req(Pst *pst, BiccAlert_Req *ptr); //alert
extern int BICC_info_req(Pst *pst, BiccInfo_Req *ptr); //sam
extern int BICC_prog_req(Pst *pst, BiccCpg_Req *ptr); //progress
extern int BICC_apm_req(Pst *pst, BiccApm_Req *ptr);
extern int BICC_sus_req(Pst *pst, BiccSus_Req *ptr); //Call suspend request
extern int BICC_resm_req(Pst *pst, BiccRes_Req *ptr); //Call resume request
extern int BICC_block_req(Pst *pst, BiccCgb_Req *ptr); //block req
extern int BICC_block_rsp(Pst *pst, BiccCgb_Req *ptr);
extern int BICC_unblock_req(Pst *pst, BiccCgb_Req *ptr); //unblock req
extern int BICC_unblock_rsp(Pst *pst, BiccCgb_Req *ptr);
extern int BICC_reset_req(Pst *pst, BiccGrs_Req *ptr);
extern int BICC_reset_rsp(Pst *pst, BiccGrs_Rsp *ptr); //reset response
extern void BICC_EMPTY_OPTPAR(void *ptr, u8 prim);
extern BOOL bicc_trunk_reachable(u32 cg_id);
/*****************************
*** layer management interface***
******************************
*/
int BICC_active_dmp(u8 plat_id, u32 alter_id );
int BICC_deactive_dmp();
/***********************
*** lower layer interface***
************************
*/
void BICC_msdc_proc(u32 pid, up_message_2 *upmsg_ptr);
int BICC_mdsc_proc();
/******************************
*** system service interface***
*******************************
*/
void BICC_init(int interval_ms, int local_id);
void BICC_timer();
#endif

View File

@@ -0,0 +1,34 @@
#ifndef _DEFINE_H_
#define _DEFINE_H_
//typedef int BOOL;
#ifndef _T_U8
#define _T_U8
typedef unsigned char u8;
#endif
#ifndef _T_U16
#define _T_U16
typedef unsigned short u16;
#endif
#ifndef _T_U32
#define _T_U32
typedef unsigned int u32;
#endif
#define BICC_TOLERANT
#define BICC_REATTEMPT
#define BICC_DEBUG
//Event
#define EN_NONE 0x00
#define EN_ANM 0x01
#define EN_CON 0x02
#define EN_GROUP 0x03
#define M_LOCAL_BLOCK 0x01
#define M_REMOTE_BLOCK 0x02
#endif

162
plat/bicc/src/include/inc.h Normal file
View File

@@ -0,0 +1,162 @@
#ifndef _INC_H
#define _INC_H
#include <string.h>
#include <stdio.h>
#include "../../../mtp3/src/include/mtp3.h"
#include "../../../snmp/src/include/snmp.h"
#include "biccif.h"
#define BICC_VERSION {9, 0, 10, 0}
#define BICC_SCREEN_SIZE 32
#define BICC_TIMER_STOP 0
#define BICC_TIMER_EXPIRED 1
#define BICC_T1 15
#define BICC_T5 300
#define BICC_T7 30
#define BICC_T8 10
#define BICC_T9 120
#define BICC_T12 15
#define BICC_T13 300
#define BICC_T14 15
#define BICC_T15 300
#define BICC_T16 15
#define BICC_T17 300
#define BICC_T18 15
#define BICC_T19 300
#define BICC_T20 15
#define BICC_T21 300
#define BICC_T22 15
#define BICC_T23 300
//#define BICC_T24 1
//#define BICC_T25 1
//#define BICC_T26 60
//#define BICC_T27 240
#define BICC_T28 10
#define BICC_T33 12
#define BICC_T34 2
#define BICC_T35 15
//#define BICC_T36 10
//#define BICC_T37 2
#define BICC_T40 10
#define BICC_T41 10
#define BICC_T42 5
#define BICC_T43 5
#define BICC_USER_T10 10//user defined timer,10s
#define BICC_CIC_IDLE 0
#define BICC_INCOMING 1
#define BICC_OUTGOING 2
#define BICC_RESET 3
#define BICC_TYPE_INCOMING 0
#define BICC_TYPE_OUTGOING 1
#define BICC_TYPE_BIDIRECT 2
#define BICC_ORIG_SUSPEND 0 //originating side suspend
#define BICC_TERM_SUSPEND 1 //terminating side suspend
typedef struct BiccTimer_struct
{
int t1;
int t5;
int t7;
int t8;
int t9;
int t12;
int t13;
int t14;
int t15;
int t16;
int t17;
int t18;
int t19;
int t20;
int t21;
int t22;
int t23;
int t28;
int t33;
int t34;
int t35;
int t40;
int t41;
int t42;
int t43;
int user_t10;
}BiccTimer_struct;
typedef struct BiccMng_struct {
u8 state;
u32 lnk_id;
RangeStatus_struct rangeStatus;
} BiccMng_struct;
typedef struct BiccDebug_struct {
u32 flag;
u8 sap_enable[BICC_SCREEN_SIZE];
u8 sap_cg_num[BICC_SCREEN_SIZE];
//u8 cg_enable[BICC_SCREEN_SIZE];
//u8 network_id[BICC_SCREEN_SIZE];
// page 1 //
u8 cic_enable[BICC_SCREEN_SIZE];
u8 cic_type[BICC_SCREEN_SIZE];
u8 l_block[BICC_SCREEN_SIZE];
u8 r_block[BICC_SCREEN_SIZE];
// page 2 //
u8 cic_status[BICC_SCREEN_SIZE];
u8 cpc_state[BICC_SCREEN_SIZE];
u8 mgbs_state[BICC_SCREEN_SIZE];
u8 mgbr_state[BICC_SCREEN_SIZE];
u8 crs_state[BICC_SCREEN_SIZE];
u8 crr_state[BICC_SCREEN_SIZE];
u8 cgrs_state[BICC_SCREEN_SIZE];
u8 cgrr_state[BICC_SCREEN_SIZE];
// page 3 //
u8 sprc_command[BICC_SCREEN_SIZE];
u8 mgbs_command[BICC_SCREEN_SIZE];
u8 mgbr_command[BICC_SCREEN_SIZE];
u8 crs_command[BICC_SCREEN_SIZE];
u8 crr_command[BICC_SCREEN_SIZE];
u8 cgrs_command[BICC_SCREEN_SIZE];
u8 cgrr_command[BICC_SCREEN_SIZE];
u8 prim_command[BICC_SCREEN_SIZE];
// page 4 //
u8 mng_state;
u8 mng_lnk_id;
} BiccDebug_struct;
typedef struct BiccData_struct
{
BiccDebug_struct debug_data;
BiccMng_struct mng_data;
BiccDmp_struct dmp_data;
BiccTimer_struct timer_data[BICC_MAX_PORT];
//BICC_Fsm_state fsm_data[BICC_MAX_PORT];
BICC_Port_struct port_data[BICC_MAX_PORT];
}BiccData_struct;
typedef struct stat_struct {
// u32 en_cic;
u32 lblo_cic;
u32 rblo_cic;
// u32 in_cic;
// u32 out_cic;
// u32 bi_cic;
u32 idle_call;
u32 in_call;
u32 out_call;
u32 lsus_cic;
u32 rsus_cic;
}stat_struct;
#endif

View File

@@ -0,0 +1,60 @@
// Q.1970E; RFC 2327 //
#ifndef _IPBCP_H_
#define _IPBCP_H_
typedef struct SdpOrig_struct {
char username[16];
char session_id[16];
char version[8];
char network_type[8];
char address_type[8];
char address[16];
} SdpOrig_struct;
typedef struct SdpConn_struct {
char network_type[8];
char address_type[8];
char address[16];
} SdpConn_struct;
typedef struct SdpTime_struct {
char start[16]; //0
char stop[16]; //0
} SdpTime_struct;
typedef struct SdpAttrib_struct {
char version[8]; //1
char type[16]; //"Request"/"Accepted"/"Confused"/"Rejected"
} SdpAttrib_struct;
typedef struct SdpMediaAnn_struct {
char media[16];
char port[8];
char transport[16];
char fmt_list[128];
} SdpMediaAnn_struct;
// specify RTP dynamic payload types //
typedef struct SdpMediaAtt_struct {
char payload[8];
char encoding_name[16];
char clock_rate[8];
// char p_time[8];
} SdpMediaAtt_struct;
typedef struct IPBCP_struct {
char proto_ver[8]; //Protocol version (M)
SdpOrig_struct orig; //Orign (M)
char session_name[16]; //Session name (M)
SdpConn_struct conn_data; //Connection data
SdpTime_struct time; //Time
SdpAttrib_struct attrib; //Session attribute
SdpMediaAnn_struct m_ann; //Media announcement (M)
SdpMediaAtt_struct m_att; //Media attributes
char ptime[8];
} IPBCP_struct;
extern int ipbcp_decode(IPBCP_struct *ipbcp_ptr, const char *ptr);
extern int ipbcp_encode(char *ptr, const IPBCP_struct *ipbcp_ptr);
#endif

View File

@@ -0,0 +1,456 @@
#ifndef _q1902_3E_H_
#define _q1902_3E_H_
#include "define.h"
#include "q765_5e.h"
/******************************************/
/******** BICC SIO (Q.1901E C.7.3) ********/
/******************************************/
#define BICC_SI 13
/******************************************/
/* Message Type Codes (Q.1902-3E, page 5) */
/******************************************/
#define M_ACM 0x06//Address complete
#define M_ANM 0x09//Answer
#define M_APM 0x41//Application transport
#define M_BLO 0x13//Blocking
#define M_BLA 0x15//Blocking acknowledgement
#define M_CPG 0x2c//Call progress
#define M_CGB 0x18//Circuit/CIC group blocking
#define M_CGBA 0x1a//Circuit/CIC group blocking acknowledgement
#define M_CQM 0x2a//Circuit/CIC group query (national use)
#define M_CQR 0x2b//Circuit/CIC group query response (national use)
#define M_GRS 0x17//Circuit/CIC group reset
#define M_GRA 0x29//Circuit/CIC group reset acknowledgement
#define M_CGU 0x19//Circuit/CIC group unblocking
#define M_CGUA 0x1b//Circuit/CIC group unblocking acknowledgement
#define M_CRG 0x31//Charge information (national use)
#define M_CFN 0x2f//Confusion
#define M_CON 0x07//Connect
#define M_COT 0x05//Continuity
#define M_FAC 0x33//Facility
#define M_FAA 0x20//Facility accepted
#define M_FRJ 0x21//Facility reject
#define M_FAR 0x1f//Facility request
#define M_FOT 0x08//Forward transfer
#define M_IDR 0x36//Identification request
#define M_IRS 0x37//Identification response
#define M_INF 0x04//Information (national use)
#define M_INR 0x03//Information request (national use)
#define M_IAM 0x01//Initial address
#define M_LOP 0x40//Loop prevention
#define M_NRM 0x32//Network resource management
#define M_PRI 0x42//Pre-release information
#define M_REL 0x0c//Release
#define M_RLC 0x10//Release complete
#define M_RSC 0x12//Reset circuit/CIC
#define M_RES 0x0e//Resume
#define M_SGM 0x38//Segmentation
#define M_SAM 0x02//Subsequent address
#define M_SDM 0x43//Subsequent Directory Number (national use)
#define M_SUS 0x0d//Suspend
#define M_UBL 0x14//Unblocking
#define M_UBA 0x16//Unblocking acknowledgement
#define M_UCIC 0x2e//Unequipped CIC (national use)
#define M_USR 0x2d//User-to-user information
/*********************************************/
/* Parameter Name Codes (Q.1902-3E, page 10) */
/*********************************************/
#define P_APPTRANS 0x78//Application transport
#define P_BACKCALLIND 0x11//Backward call indicators
#define P_CALLEDPTYNUM 0x04//Called party number
#define P_CALLINGPTYNUM 0x0a//Calling party number
#define P_CALLINGPTYCAT 0x09//Calling party's category
#define P_CAUSEIND 0x02//Cause indicators
#define P_CICGRPSPV 0x15//Circuit/CIC group supervision message type
#define P_COLLECTCALLREQ 0x79//Collect call request
#define P_CONFTREATIND 0x72//Conference treatment indicators
#define P_CONNNUM 0x21//Connected number
#define P_CORRELATIONID 0x65//Correlation id
#define P_EVENINFO 0x24//Event information
#define P_FACIND 0x18//Facility indicator
#define P_FWDCALLIND 0x07//Forward call indicators
#define P_NATCONNIND 0x06//Nature of connection indicators
#define P_ORIGCALLEDNUM 0x28//Original called number
#define P_RANGESTATUS 0x16//Range and status
#define P_REDIRGNUM 0x0b//Redirecting number
#define P_REDIRINFO 0x13//Redirection information
#define P_SCFID 0x66//SCF id
#define P_SUBSEQNUM 0x05//Subsequent number
#define P_SUSRESIND 0x22//Suspend/Resume indicators
#define P_TRANSMEDREQ 0x02//Transmission medium requirement
#define P_UTUIND 0x2a//User-to-user indicators
#define P_UTUINFO 0x20//User-to-user information
#define P_CALLDIVERINFO 0x36//Call diversion information
#define P_OPTBACKCALLIND 0x29//Optional backward call indicators
/**********************************************/
/* Parameter Structure (Q.1902-3E, section 6) */
/**********************************************/
#define MAX_BICC_DIGIT 32
#define BICC_STATUS_LEN 32
#define BICC_APP_LEN 200
#define MAX_DIAGNOSTIC_LEN 32
typedef struct AppTrans_struct {
u8 pres;
u8 aci[2]; //Application context identifier
u8 :6;
u8 sni:1; //Send notification indicator
u8 rci:1; //Release call indicator
u16 :1;
u16 si:1; //Sequence indicator
u16 segment:6; //APM segmentation indicator
u16 :1;
u16 slr:7; //Segmentation local reference
// APM-user information (For APM'98-user application only) //
ApmUser_struct apm_info;
} AppTrans_struct;
typedef struct BackCallInd_struct {
u8 pres;
u8 val[2];
} BackCallInd_struct;
typedef struct CalledPtyNum_struct {
u8 pres;
u8 nai;
u8 inn;
u8 npi;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} CalledPtyNum_struct;
typedef struct CallingPtyNum_struct {
u8 pres;
u8 nai;
u8 ni;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} CallingPtyNum_struct;
typedef struct CallingPtyCat_struct {
u8 pres;
u8 val;
} CallingPtyCat_struct;
/* defined in Q.850E */
typedef struct CauseInd_struct {
u8 pres;
u8 codingStd;
u8 location;
u8 causeVal;
//diagnostic
} CauseInd_struct;
typedef struct CicGrpSpv_struct {
u8 pres;
u8 val;
} CicGrpSpv_struct;
typedef struct CollectCallReq_struct {
u8 pres;
u8 val;
} CollectCallReq_struct;
typedef struct ConfTreatInd_struct {
u8 pres;
u8 val;
} ConfTreatInd_struct;
typedef struct ConnNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} ConnNum_struct;
typedef struct EventInfo_struct {
u8 pres;
u8 val;
} EventInfo_struct;
typedef struct FacInd_struct {
u8 pres;
u8 val;
} FacInd_struct;
typedef struct FwdCallInd_struct {
u8 pres;
u8 val[2];
} FwdCallInd_struct;
typedef struct GenericNumber_struct {
u8 pres;
u8 nqi; //Number qualifier indicator
u8 nai;
u8 ni;
u8 npi;
u8 apri;
u8 si;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} GenericNumber_struct;
typedef struct GenericDigits_struct /* Generic Digits */
{
u8 pres;
u8 typeOfDigits;
u8 encodeScheme;
u8 numOfDigit;
u8* digits;
} GenericDigits_struct;
typedef GenericDigits_struct CorrelationId_struct; //R10
//typedef struct CorrelationId_struct { //R9
// u8 pres;
// u8 digit[4]; //4 bytes
//}CorrelationId_struct;
typedef struct NatConnInd_struct {
u8 pres;
u8 val;
} NatConnInd_struct;
typedef struct OrigCalledNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} OrigCalledNum_struct;
typedef struct RangeStatus_struct {
u8 pres;
u8 range;
u8 status[BICC_STATUS_LEN];
} RangeStatus_struct;
typedef struct RedirgNum_struct {
u8 pres;
u8 nai;
u8 npi;
u8 apri;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} RedirgNum_struct;
typedef struct RedirInfo_struct{
u8 pres;
u8 redInd;
u8 origRedirReason;
u8 redirCounter;
u8 redirReason;
}RedirInfo_struct;
typedef GenericDigits_struct ScfId_struct;
/*typedef struct ScfId_struct {
u8 pres;
u8 nai;
u8 inn;
u8 npi;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
}ScfId_struct;
*/
typedef struct SubseqNum_struct {
u8 pres;
u8 numOfDigit;
u8 digit[MAX_BICC_DIGIT];
} SubseqNum_struct;
typedef struct SusResInd_struct {
u8 pres;
u8 val;
} SusResInd_struct;
typedef struct TransMedReq_struct {
u8 pres;
u8 val;
} TransMedReq_struct;
typedef struct UserToUserInd_struct {
u8 pres;
u8 val;
} UserToUserInd_struct;
typedef struct UserToUserInfo_struct {
u8 pres;
u8 len;
u8 val[129];
} UserToUserInfo_struct;
typedef struct CallDiverInfo_struct
{
u8 pres;
u8 notifSubsOption;
u8 redirReason;
}CallDiverInfo_struct;
typedef struct OptBackCallInd_struct
{
u8 pres;
u8 inbandInfoInd;
u8 callDiverOccurInd;
u8 simpSegmInd;
u8 mlppUserInd;
}OptBackCallInd_struct;
/********************************************/
/* Message structure (Q.1902-3E, section 7) */
/********************************************/
typedef struct BiccAcm_struct {
BackCallInd_struct backCall;//F
AppTrans_struct app;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
OptBackCallInd_struct optBackCall;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAcm_struct;
typedef struct BiccAnm_struct {
AppTrans_struct app;
BackCallInd_struct backCall;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccAnm_struct;
typedef struct BiccApm_struct {
AppTrans_struct app;
} BiccApm_struct;
typedef struct BiccCpg_struct {
EventInfo_struct eventInfo;//F
AppTrans_struct app;
BackCallInd_struct backCall;
CallDiverInfo_struct calldiver;
CauseInd_struct cause;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCpg_struct;
typedef struct BiccCgb_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgb_struct;
typedef struct BiccCgba_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgba_struct;
typedef struct BiccCgu_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgu_struct;
typedef struct BiccCgua_struct {
CicGrpSpv_struct cicGrpSpv;//F
RangeStatus_struct rangeStatus;//V
} BiccCgua_struct;
typedef struct BiccGrs_struct {
RangeStatus_struct rangeStatus;//V
} BiccGrs_struct;
typedef struct BiccGra_struct {
RangeStatus_struct rangeStatus;//V
} BiccGra_struct;
typedef struct BiccCon_struct {
BackCallInd_struct backCall;//F
AppTrans_struct app;
ConfTreatInd_struct confTreat;
ConnNum_struct connNum;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccCon_struct;
typedef struct BiccIam_struct {
NatConnInd_struct natConn;//F
FwdCallInd_struct fwdCall;//F
CallingPtyCat_struct callingPtyCat;//F
TransMedReq_struct transMedReq;//F
CalledPtyNum_struct calledPtyNum;//V
AppTrans_struct app;
CallingPtyNum_struct callingPtyNum;
CollectCallReq_struct collectCallReq;
ConfTreatInd_struct confTreat;
CorrelationId_struct correlationId;
OrigCalledNum_struct origCalledNum;
RedirgNum_struct redirgNum;
RedirInfo_struct redirInfo;
ScfId_struct scfId;
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccIam_struct;
typedef struct BiccRel_struct {
CauseInd_struct cause;//V
UserToUserInd_struct utuInd;
UserToUserInfo_struct utuInfo;
} BiccRel_struct;
typedef struct BiccRlc_struct {
CauseInd_struct cause;
} BiccRlc_struct;
typedef struct BiccRes_struct {
SusResInd_struct susRes;//F
//Optional
} BiccRes_struct;
typedef struct BiccSus_struct {
SusResInd_struct susRes;//F
//Optional
} BiccSus_struct;
typedef struct BiccSam_struct {
SubseqNum_struct subseqNum;//V
//Optional
} BiccSam_struct;
typedef struct BiccMsg_struct
{
}BiccMsg_struct;
typedef union BiccMsg_union {
BiccAcm_struct acm;
BiccAnm_struct anm;
BiccApm_struct apm;
BiccCpg_struct cpg;
BiccCgb_struct cgb;
BiccCgba_struct cgba;
BiccCgu_struct cgu;
BiccCgua_struct cgua;
BiccGrs_struct grs;
BiccGra_struct gra;
BiccCon_struct con;
BiccIam_struct iam;
BiccRel_struct rel;
BiccRlc_struct rlc;
BiccRes_struct res;
BiccSus_struct sus;
BiccSam_struct sam;
} BiccMsg_union;
#endif

View File

@@ -0,0 +1,100 @@
#ifndef _q765_5E_H_
#define _q765_5E_H_
#include "define.h"
#define AP_ACTION 0x01
#define AP_BNCID 0x02
#define AP_IWFADDR 0x03
#define AP_CODECLIST 0x04
#define AP_SINGLECODEC 0x05
#define AP_BATCR 0x06
#define AP_BNCCHR 0x07
#define AP_BCINFO 0x08
#define AP_BCTUNNEL 0x09
#define AP_BCUI 0x0a
#define AP_SIGNAL 0x0b
#define AP_BRC 0x0c
#define AP_BRI 0x0d
#define AP_SIGNALTYPE 0x0e
#define AP_DURATION 0x0f
/************************************************/
/***** Encapsulated application information *****/
/************************************************/
typedef struct ActionInd_struct {
u8 pres;
u8 comp_info;
u8 val;
} ActionInd_struct;
typedef struct BncId_struct {
u8 pres;
u8 comp_info;
u8 len;
u8 val[4];
} BncId_struct;
typedef struct IwfAddr_struct {
u8 pres;
//...
} IwfAddr_struct;
typedef struct BncChr_struct {
u8 pres;
u8 comp_info;
u8 val;
} BncChr_struct;
typedef struct BCTP_struct {
// BTCP (Q.1990) //
u8 :1;
u8 bvei:1; //BCTP Version Error Indicator
u8 :1;
u8 btcp_version:5; //BCTP Version Indicator
u8 :1;
u8 tpei:1; //Tunnelled Protocol Error Indicator
u8 tunnel_protocol:6; //Tunnelled Protocol Indicator
// IPBCP (Q.1970) //
u8 ipbcp_len;
u8 ipbcp_content[200];
} BCTP_struct;
typedef struct BcInfo_struct {
u8 pres;
u8 comp_info;
BCTP_struct bctp;
} BcInfo_struct;
typedef struct BcTunnel_struct {
u8 pres;
u8 comp_info;
u8 val;
} BcTunnel_struct;
typedef struct SignalType_struct {
u8 pres;
u8 comp_info;
u8 val;
} SignalType_struct;
typedef struct Duration_struct {
u8 pres;
u8 comp_info;
u16 val;
} Duration_struct;
typedef struct ApmUser_struct {
u8 :6;
u8 sni:1; //Send notification indicator
u8 rci:1; //Release call indicator
ActionInd_struct action;
BncId_struct bnc_id;
BncChr_struct bnc_chr;
BcInfo_struct bc_info;
BcTunnel_struct bc_tunnel;
SignalType_struct signal_type;
Duration_struct duration;
} ApmUser_struct;
#endif

View File

@@ -0,0 +1,14 @@
#ifndef _VAR_EXT_H_
#define _VAR_EXT_H_
#include "define.h"
#include "biccif.h"
#include "inc.h"
extern u8 Bicc_Version[4];
extern BiccData_struct Bicc_Data;
extern BiccTimer_struct Timer_Data;
extern BiccReadPrim_union readPrim_union[BICC_MAX_PORT];
extern BiccWritePrim_union writePrim_union[BICC_MAX_PORT];
#endif

99
plat/debug/Makefile Normal file
View 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 = debug
TYPE = plat
DBUG_FLAGS_ADD = -DDEBUG
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 = ../../mss
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

15649
plat/debug/src/debug.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
/* Debug module strucutre head file */
/* Written by Liu Wei 2005-05-10 */
/* Version 4.0 */
/* -------------------------------- */
#ifndef _DEBUG
#define _DEBUG
#include "debug_struct.h"
#include "dirent.h"
/* by simon at 23/9/25
mib_node *mib_root_node;
mib_node *mib_curr_node;
menu_node *menu_root_node;
menu_node *menu_curr_node;
mib_node mib_nodes[MIB_MAX_NODES];
*/
/* by simon at 23/9/25
//for test
char file_name[128];
FILE *fp_prt;
long int timeuse,max_time;
struct timeval tv_start, tv_end;
//for test
*/
/* by simon at 23/9/25
menu_node menu_nodes[MENU_MAX_NODES];
mib_child_node mib_child_nodes[MIB_MAX_CHILD_NODES];
debug_snmp_agent debug_snmp_agent_buf[MAX_PACKET_NUM];
end by simon */
//////////////////////////////interface declaration////////////////////////
void debug_init();
void debug_rt();
WORD find_child_index(mib_node *node_ptr, DWORD oid, char *name, BYTE type);
mib_node *find_node(mib_node *start_node_ptr, char *node_name, int find_type, DWORD *last_node_oid);
mib_node *search_mib_node(mib_node *start_mib_node_ptr, DWORD *oid, BYTE oid_len);
int debug_set_response(unsigned char object_id_len,unsigned int *object_id,unsigned char *data,unsigned short data_len);
int debug_get_response(unsigned char object_id_len,unsigned int *object_id,unsigned char *data,unsigned char *vartype);
menu_node *search_menu_node(menu_node *start_menu_node_ptr, BYTE *menu_id, BYTE id_len);
void Clear_Access_History();
void debug_set_agent();
void debug_get_agent();
int get_my_address (struct in_addr *addr);
//////////////////////////////end of interface declaration////////////////////////
#endif

View File

@@ -0,0 +1,375 @@
/* Debug module strucutre head file */
/* Written by Liu Zhiguo 2003-04-22 */
/* Version 2.0 */
/* -------------------------------- */
#ifndef _DEBUG_STRUCT
#define _DEBUG_STRUCT
#include "../../../public/src/include/pub_include.h"
#include "../../../iptrans/src/include/iptrans.h"
#include "../../../snmp/src/include/snmp.h"
#include "../../../snmp/src/include/heartbeat.h"
//Module ID
//0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
//a b c d e f g h i j k l m n o p q r s t u v w x y z
//a b c d e f g h i j k l m n o p r s t u v w y z
#define DEBUG_PORT 4965
#define DEBUG_SNMP_PORT 4956
#define SNMP_PORT 4957
#define DEBUG_VERSION "R9V0_03"
#define TELNET_SEND_BUF_LEN 1000
#define SERIAL_BUF_LEN 2048
#define DEBUG_MAX_PAGE 2
#define PAGE_MODULE_COUNT 24
#define MODULE_COUNT (PAGE_MODULE_COUNT*DEBUG_MAX_PAGE)
#define DEBUG_MAX_SEQID 0x7fffffff
#define DEBUG_SEQID_LEN 8
#define DEBUG_OMCBUF_LEN 1024
#define DEBUG_NAME_LEN 8
#define PAGE_COUNT 24
#define LINE_COUNT 23
#define MAX_ROW 25
#define MAX_COLUMN 80
#define TITLE_CHAR 2048
#define MAX_ASCII_LEN (1024*16)
#define DEBUG_SHM_KEY 0xa0600000
#define DEBUG_SHM_PERM 0664
#define MENU_TYPE 0
#define OID_TYPE 1
// MIB wangjian add
#define MIB_LIST_FILE "mib_list_file.txt"
#define MIB_FILES_DIR "./conf/MIB_files/"
#define MIB_OMC_PUB_SYSCONF_FILE "OMC_PUB_sysConf.csv"
#define MIB_PARAM_LIST_FILE "mib_param_list_file.txt"
#define MIB_WRITE_TREE "mib_write_tree.txt"
#define MIB_SYSTEM_CONFIG_FILE "System_Config.txt"
#define MIB_SYSTEM_IP_LIST_FILE "System_IP_List.txt"
#define MENU_TREE_FILE "menu_tree.txt"
#define MIB_MAX_CHILD_NODES_PER_NODE 256
#define MIB_MAX_NODES 1536
#define MIB_MAX_CHILD_NODES 1536 * 5
#define MIB_MAX_PARAM_SELECTS 1536 * 8
#define MIB_MAX_PARAM_INPUTS 1536 * 8
#define MIB_MAX_NODE_PARAMS 1536 * 4
#define MAX_TOTAL_INSTANCE 2048
#define MAX_NODE_PACKET_LENGTH 256
#define MAX_SEND_CHAR_NUM 512
//#define MIB_OPER_TYPE_GET 1
//#define MIB_OPER_TYPE_GET_ALL 2
//#define MIB_OPER_TYPE_SET 3
//#define MIB_OPER_TYPE_HELP 4
#define MIB_MODULE_REVISION_MAX_NUM 10
#define MIB_SUBSYS_MODULE_MAX_NUM 64
#define MIB_HOST_MAX_NUM 127
#define MIB_NODE_PARAM_MAX_LEN 64
#define GROUP_NUM 2
#define MEMBER_MAX_NUM 16
#define MENU_MAX_NODES 640
#define TODEC_HIGH_0 0
#define KEEPHEX_HIGH_0 1
#define KEEPHEX_LOW_0 2
#define KEEPHEX_LOW_E 3
#define KEEPHEX_LOW_F 4
#define TOASCII_LOW_0 5
#define KEEPASC_LOW_F 6
#define MAX_PACKET_NUM 16
#define MAX_SELECT_OPTION_NUM 21
#define MAX_OPTION_LENGTH 32
#define MAX_HOST_IP 16
#define MAX_PARAM_NUM 64
typedef struct CommandList
{
char cmm[128];
struct CommandList *nextcmm;
}cmmset,cmmrem;
// MIB end
typedef struct _DEBUG_TELNET_SEND_DATA
{
int telsend_datah;
BYTE telsend_data[TELNET_SEND_BUF_LEN];
}DEBUG_TELNET_SEND_DATA;
struct debug_line
{
BYTE pt_vartype;
WORD length;
BYTE *pointer;
};
struct debug_page
{
BYTE pointer_set_flag;
char title[TITLE_CHAR];
struct debug_line line_d[LINE_COUNT];
};
typedef struct debug_module_struct
{
char name[DEBUG_NAME_LEN];
char status[2];
char version[20];
BYTE maxpage;
BYTE ascii_in_set_flag;
BYTE ascii_out_set_flag;
BYTE *ascii_in;
WORD ascii_in_len;
BYTE *ascii_out;
WORD ascii_out_len;
struct debug_page page_d[PAGE_COUNT];
int seqid_h; // head sequence id for omc get
int seqid_t; // tail sequence id for omc get
BYTE omc_outbuf[DEBUG_SEQID_LEN][DEBUG_OMCBUF_LEN];
} debug_module_struct;
typedef struct debug_shm_struct
{
debug_module_struct module_d[MODULE_COUNT];
DEBUG_TELNET_SEND_DATA TelnetSendData;
} debug_shm_struct;
// by simon at 23/9/25
//struct debug_shm_struct *debug_shm_ptr;
//struct iptrans_shm *pIptransShm;
// MIB wangjian add
typedef struct _mibfile_imports_data
{
char father_name[64];
char from_file[32];
} mibfile_imports_data;
typedef struct _mibfile_module_data
{
char name[64]; // nod name
char LU[32]; // LAST-UPDATED
char OR[64]; // ORGANIZATION
char CI[128]; // CONTACT-INFO
char DE[1024]; // DESCRIPTION
char RE[MIB_MODULE_REVISION_MAX_NUM][32]; // REVISION
char RE_DE[MIB_MODULE_REVISION_MAX_NUM][1024]; // REVISION'S DESCRIPTION
int RE_index; // the number of RE and RE_DE
char father_name[64]; // father's name
char ID[32]; // child ID
} mibfile_module_data;
typedef struct _mibfile_object_data
{
char name[64]; // nod name
int ST; // STATUS: 1: current, 2: deprecated, 3: obsolete. 0: invalid
char DE[1024]; // DESCRIPTION
char RF[1024]; // ReferPart
char father_name[64]; // father's name
char ID[32]; // child ID
} mibfile_object_data;
typedef struct _mibfile_type_data
{
char name[64]; // nod name
int SY; // SYNTAX: 0:invalid. 1: Integer32, 2: INTEGER, 3: OCTET STRING, 4: OBJECT IDENTIFIER, 5: BITS, 6: IpAddress, 7: Counter32,
// 8: Gauge32, 9: TimeTicks, 10: Opaque, 11: Counter64, 12: Unsigned32, 13:Conceptual Tables
char UP[32]; // UnitsPart
BYTE MA; // MAX-ACCESS: 0: invalid, 1: not-accessible, 2: accessible-for-notify, 3: read-only, 4: read-write, 5: read-create 6: write-only
int ST; // STATUS
char DE[8192]; // DESCRIPTION
int total_instance; // total_instance
char RF[1024]; // ReferPart;
char father_name[64]; // father's name
char ID[32]; // child ID
} mibfile_type_data;
//typedef int (*mib_call)(DWORD *oid, BYTE oid_len, char *name, char *value, BYTE oper_type);
typedef struct _mib_child_node
{
char name[64];
DWORD oid;
void *child_ptr;
} mib_child_node;
typedef struct _mib_node
{
void *parent_ptr;
char name[32];
BYTE oid_len;
DWORD oid[32];
BYTE data_length;
BYTE module_index;
WORD total_instance;
WORD curr_instance;
WORD total_child_nodes;
BYTE enable_field_id;
BYTE enable_flag[32];
BYTE access_history;
char init_value[256];
//mib_call mib_proc;
char *remark_ptr;
//char remark[DEBUG_OMCBUF_LEN * 2];
mib_child_node *child_nodes[MIB_MAX_CHILD_NODES_PER_NODE];
BYTE max_access; // MAX-ACCESS: 0: invalid, 1: not-accessible, 2: accessible-for-notify, 3: read-only, 4: read-write, 5: read-create 6: write-only
}mib_node;
typedef struct _menu_node
{
void *father_ptr;
void *child_node[MENU_MAX_NODES];
mib_node *menu_oid_node;
BYTE oid[23];
BYTE id_len;
BYTE total_menu_child;
char name[32];
BYTE menu_id[20];
BYTE sys_group;
}menu_node;
// MIB FIELD struct
typedef struct _mib_param_select
{
WORD number;
char description[MIB_NODE_PARAM_MAX_LEN];
} mib_param_select;
typedef struct _instance_arr
{
DWORD ins;
BYTE eable;
}INSTANCE_ARR;
typedef struct _mib_param_input
{
BYTE input_param_type; // 0: toDec_high_0
// 1: keepHex_high_0
// 2: keepHex_low_0
// 3: keepHex_low_E
// 4: keepHex_low_F
// 5: toAscii_low_0
// 6: keepAscii_low_F
char input[MIB_NODE_PARAM_MAX_LEN];
} mib_param_input;
typedef struct _mib_node_param
{
void *parent_ptr;
char name[64];
BYTE id;
BYTE byte_begin;
BYTE byte_end;
BYTE bit_begin;
BYTE bit_end;
mib_param_select *select_ptr[16];
BYTE select_total;
BYTE select_value;
mib_param_input *input_ptr;
} mib_node_param;
typedef struct _mib_subsys_module
{
BYTE index;
DWORD oid[8];
char name[10];
BYTE max_group;
//char obj_type_no[3];
}mib_subsys_module;
typedef struct _mib_host
{
BYTE index;
BYTE group_index;
BYTE member_index;
char host_name[32];
WORD host_ip[4];
}mib_host;
typedef struct _module_command_save_flag
{
BYTE module_index;
DWORD oid[32];
BYTE oid_len;
BYTE save_select_id;
BYTE save_field_id;
}module_command_save_flag;
typedef struct param_field
{
char name[48]; //set fill in
char curr_input_value[32]; //set fill in
BYTE input_type;
BYTE curr_select_id;
BYTE total_select;
WORD value_arr[MAX_SELECT_OPTION_NUM];
char value_arr_remark[MAX_SELECT_OPTION_NUM][MAX_OPTION_LENGTH];
}param_field;
typedef struct debug_snmp_agent_packet
{
DWORD oid[32]; //set fill in
//0 idle 1 waitting get 2 waitting set 3 process 4 fail 5 success
BYTE cmm_state; //set fill in
//0 success 1 time out 2 buffer full 3 oid error 4 ip str error
//5 instance error 6 leaf node param forbidden 7 total field error
//8 no select option 9 snmp send error 1xx no child 2xx no select 3xx field input error
BYTE result_state;
BYTE agentClient;
BYTE oid_len; //set fill in
BYTE total_field; //set fill in
WORD total_instance; //set fill in
BYTE total_ip; //set fill in
char dst_ip[MAX_HOST_IP][15]; //set fill inxxx.xxx.xxx.xxx
param_field param_field_arr[MAX_PARAM_NUM];
}debug_snmp_agent;
//MIB end
typedef struct _comput_list
{
BYTE list_field_id;
char field_val[256][32];
mib_node *list_node;
}compute_list;
typedef struct _compute_field
{
char name[32];
mib_node *compute_node;
BYTE field_id;
char syntax_str[10][64];
BYTE syntax_count;
char print_val_str[128][32];
char print_name_str[128][32];
BYTE print_count;
}compute_field;
typedef struct _wxc2_debug_info
{
char wxc2_ver[32];
BYTE sys_type; // cdma 1 gsm 2 gc_ssw 3
BYTE mmi_switch; // on 1 0 off
}wxc2_debug_info;
#endif

926
plat/debug/ut/debug_test.c Normal file
View File

@@ -0,0 +1,926 @@
/************************************************
* debug_test.c
* Author: LiuWei
* Create: 2005-05-31
************************************************/
#include "./include/debug.h"
#include "../../iptrans/src/include/iptrans.h"
#include "../../snmp/src/include/snmp.h"
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/telnet.h>
#include <linux/kd.h>
#include <linux/keyboard.h>
#define BUFLEN 1024
#define MAX_RECV_NONE 20
#define REC_NUM 50
char shellcode[] = "\x97\x97\x97\x97\x97\x97";
//add test line
static struct itimerval itimer, old_itimer;
fd_set rset;
BYTE connect_flag = 0;
struct sockaddr_in sin_addr;
int flag = 1;
int sockfd;
char buffer[2048];
int command_list_count;
BYTE recv_over = 0;
int addr_len = sizeof(struct sockaddr_in);
int len = 0;
BYTE recv_ten_times = 0;
BYTE test_style = 2;
BYTE test_snmp_mode = 0;
char oid_cmm_state[128];
BYTE recv_none = 0;
//char file_name[128];
FILE *fp_conf,*fp_agent;
struct timeval tv_start, tv_end;
long timeuse;
long max_time;
int i, j;
int time_vel;
int multi;
char data_arr[1024], multi_str[16];
char command[1024];
char oid_command[128];
void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len);
void MMI_telnet();
void MMI_telnet_send(char *str);
void MMI_auto_test();
void MMI_telnet_recv();
void Set_Timer();
void On_Timer();
void MMI_telnet_cmd();
void debug_snmp_agent_test_input();
void debug_snmp_agent_test_output();
void debug_snmp_print();
void MMI_File_Test(char *data_arr);
void usage(char *p)
{
printf("Usage: %s [ip] [-a atuo test] [-m manual test] [-n normal start] [-f script file]\n\n", p);
printf("\n");
exit(0);
}
void msg(char *msg)
{
perror(msg);
exit(errno);
}
u_int32_t get_ip(char *host)
{
struct hostent *hp;
if(!(hp = gethostbyname(host)))
{
fprintf(stderr, "cannot resolve %s\n", host);
return (0);
}
return (*(u_int32_t *) hp->h_addr_list[0]);
}
int get_socket(char *target, int port)
{
int sock;
u_int32_t ip;
if(!(ip = get_ip(target)))
return (0);
bzero(&sin_addr, sizeof(sin_addr));
sin_addr.sin_family = AF_INET;
sin_addr.sin_port = htons(port);
sin_addr.sin_addr.s_addr = ip;
if(!(sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
msg("Get socket:");
if(ioctl(sock, FIONBIO, &flag) == -1)
{
printf("Set nonblock:");
close(sockfd);
exit(1);
}
if(connect(sock, (struct sockaddr *)&sin_addr, sizeof(sin_addr)) < 0)
if((errno != EWOULDBLOCK) && (errno != EINPROGRESS))
msg("Connect:");
return (sock);
}
void send_wont(int sock, int option)
{
char buf[3], *ptr = buf;
*ptr++ = IAC;
*ptr++ = WONT;
*ptr++ = (unsigned char)option;
if(write(sock, buf, 3) < 0)
msg("write");
return;
}
void send_will(int sock, int option)
{
char buf[3], *ptr = buf;
*ptr++ = IAC;
*ptr++ = WILL;
*ptr++ = (unsigned char)option;
if(write(sock, buf, 3) < 0)
msg("write");
return;
}
void send_do(int sock, int option)
{
char buf[3], *ptr = buf;
*ptr++ = IAC;
*ptr++ = DO;
*ptr++ = (unsigned char)option;
if(write(sock, buf, 3) < 0)
msg("write");
return;
}
void send_env(int sock, char *name, char *value)
{
char buf[BUFLEN], *ptr = buf;
*ptr++ = IAC;
*ptr++ = SB;
*ptr++ = TELOPT_NEW_ENVIRON;
*ptr++ = TELQUAL_IS;
*ptr++ = NEW_ENV_VAR;
strncpy(ptr, name, BUFLEN - 20);
ptr += strlen(ptr);
*ptr++ = NEW_ENV_VALUE;
strncpy(ptr, value, (&buf[BUFLEN - 1] - ptr) - 1);
ptr += strlen(ptr);
*ptr++ = IAC;
*ptr++ = SE;
if(write(sock, buf, (ptr - buf)) < 0)
msg("write");
return;
}
void do_negotiate(int sock)
{
send_will(sock, TELOPT_ECHO);
send_wont(sock, TELOPT_TTYPE);
send_wont(sock, TELOPT_NAWS);
send_wont(sock, TELOPT_LFLOW);
send_wont(sock, TELOPT_LINEMODE);
send_wont(sock, TELOPT_XDISPLOC);
send_will(sock, TELOPT_LFLOW);
send_will(sock, TELOPT_LINEMODE);
send_wont(sock, TELOPT_OLD_ENVIRON);
send_will(sock, TELOPT_NEW_ENVIRON);
send_will(sock, TELOPT_BINARY);
send_env(sock, "TTYPROMPT", shellcode);
return;
}
int main(int argc, char **argv)
{
int c, port = DEBUG_PORT;
char host[36] = "172.18.234.231";
strcpy(command, "");
strcpy(oid_command, "");
strcpy(oid_cmm_state, "");
if(argc < 2)
usage(argv[0]);
tv_start.tv_sec = 0;
tv_start.tv_usec = 0;
tv_end.tv_sec = 0;
tv_end.tv_usec = 0;
//ioperm(0x378,3,1);
/*
strcpy(file_name, "");
strcat(file_name, "debug_agent.txt");
remove(file_name);
*/
strcpy(file_name, "");
strcat(file_name, "debug_test_time_log.txt");
remove(file_name);
if((fp_prt = fopen(file_name, "a+")) == NULL)
{
printf("[debug] Error: cannot open %s.\r\n", file_name);
return 0;
}
while((c = getopt(argc, argv, "famn")) != -1)
{
switch (c)
{
case 'f': // costumer test
printf("The Debug test control by command script!");
test_style = 4;
break;
case 'a': // auto test
printf("The Debug Atuo Test!");
test_style = 1;
break;
case 'm': // manually test
printf("The Debug manually Test!");
test_style = 2;
break;
case 'n': // normal start
printf("The Debug Normal start!");
test_style = 3;
break;
}
}
debug_init(1);
iptrMainInit();
snmp_init(4957);
if(!(sockfd = get_socket(host, port)))
exit(-1);
command_list_count = 0;
if(test_style == 4)
strcpy(command, "");
strcpy(multi_str, "");
strcpy(data_arr, "");
strcpy(file_name, "");
strcat(file_name, "debug_test_conf.txt");
j = REC_NUM + 1;
if((fp_conf = fopen(file_name, "r")) == NULL)
{
printf("[debug] Error: cannot open %s.\r\n", file_name);
return 0;
}
Set_Timer();
while(1)
{
usleep(10);
}
}
void MMI_File_Test(char *data_arr)
{
for(i = 0; i < strlen(data_arr); i++)
if(data_arr[i] == ' ')
break;
if(i != strlen(data_arr))
strncpy(multi_str, data_arr, i);
multi_str[i] = '\0';
multi = strtoul(multi_str, NULL, 10);
for(; i < strlen(data_arr); i++)
{
if(data_arr[i] != ' ')
break;
}
strcpy(command, data_arr + i);
if(strncasecmp(command, "\\e", 2) == 0)
{
command[0] = 27;
command[1] = '\0';
}
if(strcmp(command, oid_command) != 0)
{
strcpy(oid_command, command);
if(strcmp(command, "\e") == 0)
fprintf(fp_prt, "Command :\e\n");
else
fprintf(fp_prt, "Command :%s \n", command);
}
if(strcmp(command, "\e") != 0)
{
strcat(command, "\r\n");
}
printf("%s", command);
MMI_telnet_send(command);
usleep(5);
recv_over = 0;
usleep(time_vel);
}
void MMI_auto_test()
{
strcpy(command, "");
switch (command_list_count)
{
case 0:
strcpy(command, "\e");
multi = 1;
break;
case 1:
strcpy(command, "menu");
multi = 5;
break;
case 2:
strcpy(command, "contents");
multi = 8;
break;
case 3:
strcpy(command, "cd 1");
multi = 10;
break;
case 4:
strcpy(command, "cd 4");
multi = 10;
break;
case 5:
strcpy(command, "list -a -f[2 4 10] -r -t");
multi = 25;
break;
case 6:
strcpy(command, "get #0.1");
multi = 15;
break;
case 7:
strcpy(command, "cmm");
multi = 15;
break;
case 8:
strcpy(command, "\e");
multi = 20;
break;
/*
case 9:
strcpy(command, "log all");
multi = 150;
break;
case 10:
strcpy(command, "\e");
multi = 10;
break;
case 11:
strcpy(command, "\e");
multi = 10;
break;
case 12:
strcpy(command, "log none");
multi = 15;
break;
case 13:
strcpy(command, "\e");
multi = 15;
break;
case 14:
strcpy(command, "help");
multi = 15;
break;
case 15:
strcpy(command, "\e");
multi = 15;
break;
*/
default:
command_list_count = 0xfffe;
break;
}
command_list_count++;
if(command_list_count == 0xffff)
{
test_snmp_mode = 1;
printf("The command test over\r\n");
printf("Test snmp senior interface......\r\n");
return;
}
time_vel = multi * 500;
if(command_list_count != 0xffff && recv_over == 2)
{
if(strcmp(command, oid_command) != 0)
{
strcpy(oid_command, command);
if(strcmp(command, "\e") == 0)
fprintf(fp_prt, "Command :\e");
else
fprintf(fp_prt, "Command :%s ", command);
}
if(strcmp(command, "\e") != 0)
{
strcat(command, "\r\n");
}
MMI_telnet_send(command);
usleep(5);
if(command_list_count > 0)
printf("%s", command);
recv_over = 0;
usleep(time_vel);
}
else
command_list_count--;
}
void MMI_telnet_recv()
{
len = 0;
bzero(buffer, sizeof(buffer));
len = recvfrom(sockfd, buffer, sizeof(buffer), 0,
(struct sockaddr *)&sin_addr, &addr_len);
if(len > 0)
{
printf("%s", buffer);
recv_none = 0;
}
else
{
if(recv_none < MAX_RECV_NONE)
recv_none++;
else if(recv_over == 1)
recv_over = 2;
return;
}
if(strstr(buffer, "<--"))
{
recv_over = 1;
return;
}
if(strstr(buffer, "CMM>") || strstr(buffer, "CFG>") ||
strstr(buffer, "MENU>") || recv_over == 1)
recv_over = 2;
return;
}
void MMI_telnet_cmd()
{
if(ioctl(fileno(stdin), FIONBIO, &flag) == -1)
{
printf("Set stdin nonblock:");
exit(1);
}
len = 0;
bzero(buffer, sizeof(buffer));
strcpy(command, "");
fgets(buffer, sizeof(buffer), stdin);
len = strlen(buffer);
if(!len)
return;
strcpy(command, buffer);
if(strcmp(command, oid_command) != 0)
{
strcpy(oid_command, command);
if(strcmp(command, "\e") == 0)
fprintf(fp_prt, "Command :ESC");
else
fprintf(fp_prt, "Command :%s ", command);
}
usleep(5);
if(strstr(buffer, "\e\n"))
recv_over = 2;
if(strcmp(buffer, "\e\n") != 0)
{
buffer[strlen(buffer) - 1] = '\0';
strcat(buffer, "\r\n");
}
if(recv_over > 1)
{
if(sendto(sockfd, buffer, len, 0, (struct sockaddr *)&sin_addr,
addr_len) < 0)
msg("Send");
recv_over = 0;
}
}
void MMI_telnet_send(char *str)
{
bzero(buffer, sizeof(buffer));
strcpy(buffer, str);
len = strlen(buffer);
if(strlen(str))
if(sendto(sockfd, buffer, len, 0, (struct sockaddr *)&sin_addr,
addr_len) < 0)
msg("Send");
}
void On_Timer()
{
if(test_style == 1)
{
iptrans_timer();
snmp_timer();
outb(0xff, 0x378);
//timeuse = 0;
//gettimeofday(&tv_start, NULL);
debug_rt();
/*
gettimeofday(&tv_end, NULL);
timeuse =
1000000 * (tv_end.tv_sec - tv_start.tv_sec) -
tv_start.tv_usec + tv_end.tv_usec;
if(timeuse > max_time)
max_time = timeuse;
fprintf(fp_prt,
" debug_rt time used: %ld (u sec)<=%ld\r\n\r\n",
timeuse, max_time);
*/
outb(0x00, 0x378);
if(connect_flag == 0)
{
do_negotiate(sockfd);
MMI_telnet_recv();
send_wont(sockfd, TELOPT_BINARY);
MMI_telnet_recv();
FD_ZERO(&rset);
connect_flag = 1;
}
MMI_telnet_recv();
if(!test_snmp_mode)
MMI_auto_test();
else
{
debug_snmp_agent_test_input();
debug_snmp_agent_test_output();
debug_snmp_print();
}
}
if(test_style == 2)
{
iptrans_timer();
snmp_timer();
outb(0xff, 0x378);
//timeuse = 0;
//gettimeofday(&tv_start, NULL);
debug_rt();
/*
gettimeofday(&tv_end, NULL);
timeuse =
1000000 * (tv_end.tv_sec - tv_start.tv_sec) -
tv_start.tv_usec + tv_end.tv_usec;
if(timeuse > max_time)
max_time = timeuse;
fprintf(fp_prt,
" debug_rt time used: %ld (u sec)<=%ld\r\n\r\n",
timeuse, max_time);
*/
outb(0x00, 0x378);
if(connect_flag == 0)
{
do_negotiate(sockfd);
MMI_telnet_recv();
send_wont(sockfd, TELOPT_BINARY);
MMI_telnet_recv();
FD_ZERO(&rset);
connect_flag = 1;
}
MMI_telnet_recv();
MMI_telnet_cmd();
}
if(test_style == 3)
{
iptrans_timer();
snmp_timer();
//timeuse = 0;
// gettimeofday(&tv_start, NULL);
//outb(0xff, 0x378);
debug_rt();
//outb(0x00, 0x378);
/*
gettimeofday(&tv_end, NULL);
timeuse =
1000000 * (tv_end.tv_sec - tv_start.tv_sec) -
tv_start.tv_usec + tv_end.tv_usec;
if(timeuse > max_time)
max_time = timeuse;
fprintf(fp_prt,
"debug_rt time used: %ld (u sec)<=%ld\r\n\r\n",
timeuse, max_time);
*/
}
if(test_style == 4)
{
iptrans_timer();
snmp_timer();
timeuse = 0;
gettimeofday(&tv_start, NULL);
outb(0xff, 0x378);
debug_rt();
outb(0x00, 0x378);
gettimeofday(&tv_end, NULL);
timeuse =
1000000 * (tv_end.tv_sec - tv_start.tv_sec) -
tv_start.tv_usec + tv_end.tv_usec;
if(timeuse > max_time)
max_time = timeuse;
if(timeuse>500)
fprintf(fp_prt,
" debug_rt time used: %ld (u sec)<=%ld\r\n\r\n",
timeuse, max_time);
if(connect_flag == 0)
{
do_negotiate(sockfd);
MMI_telnet_recv();
send_wont(sockfd, TELOPT_BINARY);
MMI_telnet_recv();
FD_ZERO(&rset);
connect_flag = 1;
}
MMI_telnet_recv();
if(recv_over == 2)
{
if(!feof(fp_conf))
{
fgets(data_arr, 1024, fp_conf);
if(data_arr[strlen(data_arr) - 1] == '\n')
data_arr[strlen(data_arr) - 1] = '\0';
else
{
if(!feof(fp_conf))
{
printf("Debug test conf file error!:%s\n",data_arr);
exit(0);
}
}
if(!strlen(data_arr) ||(strstr(data_arr,"\\")) == data_arr + 0)
return;
MMI_File_Test(data_arr);
}
else
{
if(j == 1)
test_style = 0;
else if(j > 0)
{
j--;
rewind(fp_conf);
}
}
}
}
}
void Set_Timer()
{
struct sigaction act;
act.sa_handler = On_Timer;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if(sigaction(SIGALRM, &act, NULL) < 0)
{
perror("Produce Sigaction");
exit(1);
}
itimer.it_interval.tv_sec = 0;
itimer.it_interval.tv_usec = 20 * 1000;
itimer.it_value.tv_sec = 0;
itimer.it_value.tv_usec = 20 * 1000;
if(setitimer(ITIMER_REAL, &itimer, &old_itimer) != 0)
{
printf("Setting Timer error! \n");
exit(1);
}
}
void debug_snmp_agent_test_input()
{
debug_snmp_agent snmp_agent_packet1;
DWORD temp_oid1[32] =
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 3, 2, 2, 2, 1, 2 };
DWORD temp_oid2[32] =
{ 1, 3, 6, 1, 4, 1, 1373, 1, 3, 3, 2, 2, 2, 1, 3 };
WORD i,index;
for(i=0;i<MAX_PACKET_NUM;i++)
{
if(debug_snmp_agent_buf[i].cmm_state==6)
debug_snmp_agent_buf[i].cmm_state=0;
}
for(index = 0; index < MAX_PACKET_NUM; index++)
if(debug_snmp_agent_buf[index].cmm_state == 0)
break;
if(index==MAX_PACKET_NUM)
return;
switch (test_snmp_mode)
{
case 1: // get once ,do not fill ip
for(i = 0; i < 32; i++)
snmp_agent_packet1.oid[i] = temp_oid1[i];
snmp_agent_packet1.oid_len = 16;
snmp_agent_packet1.oid[snmp_agent_packet1.oid_len - 1] = 0;
snmp_agent_packet1.cmm_state = 1;
break;
case 2: // get once ,fill ip
snmp_agent_packet1.total_ip = 1;
strcpy(snmp_agent_packet1.dst_ip[0], "172.18.133.1");
for(i = 0; i < 32; i++)
snmp_agent_packet1.oid[i] = temp_oid1[i];
snmp_agent_packet1.oid_len = 16;
snmp_agent_packet1.oid[snmp_agent_packet1.oid_len - 1] = 1;
snmp_agent_packet1.cmm_state = 1;
break;
case 3: // get all
if(index==0)
{
for(i = 0; i < 32; i++)
snmp_agent_packet1.oid[i] = temp_oid1[i];
snmp_agent_packet1.oid_len = 16;
snmp_agent_packet1.oid[snmp_agent_packet1.oid_len - 1] = 0;
snmp_agent_packet1.cmm_state = 1;
}
break;
case 4: // get all
if(index==0)
{
for(i = 0; i < 32; i++)
snmp_agent_packet1.oid[i] = temp_oid2[i];
snmp_agent_packet1.oid_len = 16;
snmp_agent_packet1.oid[snmp_agent_packet1.oid_len - 1] = 0;
snmp_agent_packet1.cmm_state = 1;
}
break;
case 5: // set once
for(i = 0; i < 32; i++)
snmp_agent_packet1.oid[i] = temp_oid2[i];
snmp_agent_packet1.oid_len = 16;
snmp_agent_packet1.oid[snmp_agent_packet1.oid_len - 1] = 255;
snmp_agent_packet1.total_ip = 1;
snmp_agent_packet1.total_field = 15;
strcpy(snmp_agent_packet1.dst_ip[0], "172.18.144.1");
strcpy(snmp_agent_packet1.param_field_arr[0].curr_input_value,
"");
snmp_agent_packet1.param_field_arr[0].total_select = 6;
snmp_agent_packet1.param_field_arr[0].curr_select_id = 3;
strcpy(snmp_agent_packet1.param_field_arr[1].curr_input_value,
"");
snmp_agent_packet1.param_field_arr[1].total_select = 6;
snmp_agent_packet1.param_field_arr[1].curr_select_id = 3;
strcpy(snmp_agent_packet1.param_field_arr[2].curr_input_value,
"");
snmp_agent_packet1.param_field_arr[2].total_select = 6;
snmp_agent_packet1.param_field_arr[2].curr_select_id = 3;
strcpy(snmp_agent_packet1.param_field_arr[9].curr_input_value,
"");
snmp_agent_packet1.param_field_arr[9].total_select = 2;
snmp_agent_packet1.param_field_arr[9].curr_select_id = 1;
snmp_agent_packet1.cmm_state = 1;
break;
}
if(index != MAX_PACKET_NUM)
{
memcpy(&debug_snmp_agent_buf[index], &snmp_agent_packet1,
sizeof(debug_snmp_agent));
test_snmp_mode++;
}
}
void debug_snmp_agent_test_output()
{
WORD i;
for(i=0;i<MAX_PACKET_NUM;i++)
{
if(debug_snmp_agent_buf[i].cmm_state>3)
debug_snmp_agent_buf[i].cmm_state=6;
}
}
void debug_snmp_print()
{
char cmm_state_flag[128], result_state_flag[128], temp_str[32];
WORD i, j;
strcpy(file_name, "");
strcat(file_name, "debug_agent.txt");
if((fp_agent = fopen(file_name, "a+")) == NULL)
{
printf("[debug] Error: cannot open %s.\r\n", file_name);
return ;
}
strcpy(cmm_state_flag, "cmm_state: ");
strcpy(result_state_flag, "result : ");
fprintf(fp_agent,"\r\nDebug snmp senior interface buffer: \r\n");
fprintf(fp_agent,"index : ");
for(i = 0; i < 16; i++)
fprintf(fp_agent,"%3d ", i);
fprintf(fp_agent,"\r\n");
for(i = 0; i < MAX_PACKET_NUM; i++)
if(debug_snmp_agent_buf[i].cmm_state != 0)
break;
//if(i == MAX_PACKET_NUM)
// return;
for(i = 0; i < MAX_PACKET_NUM; i++)
{
sprintf(temp_str, "%3d ", debug_snmp_agent_buf[i].cmm_state);
strcat(cmm_state_flag, temp_str);
}
if(strcmp(oid_cmm_state, cmm_state_flag) != 0)
{
strcpy(oid_cmm_state, cmm_state_flag);
fprintf(fp_agent,cmm_state_flag);
fprintf(fp_agent,"\r\n");
for(i = 0; i < MAX_PACKET_NUM; i++)
{
sprintf(temp_str, "%3d ",debug_snmp_agent_buf[i].result_state);
strcat(result_state_flag, temp_str);
}
fprintf(fp_agent,result_state_flag);
fprintf(fp_agent,"\r\n id OID OID_len Total field Total instance \r\n");
for(i = 0; i < MAX_PACKET_NUM; i++)
{
strcpy(cmm_state_flag, "");
sprintf(temp_str, "[%2d]: ", i);
strcat(cmm_state_flag, temp_str);
for(j = 0; j < 32 && debug_snmp_agent_buf[i].oid[j] != 0;
j++)
{
sprintf(temp_str, "%ld.",
debug_snmp_agent_buf[i].oid[j]);
strcat(cmm_state_flag, temp_str);
}
if(j < debug_snmp_agent_buf[i].oid_len - 1)
{
fprintf(fp_agent,"%ld.", debug_snmp_agent_buf[i].oid[j]);
}
sprintf(temp_str, " %d ",
debug_snmp_agent_buf[i].oid_len);
strcat(cmm_state_flag, temp_str);
fprintf(fp_agent,cmm_state_flag);
fprintf(fp_agent," %3d ",
debug_snmp_agent_buf[i].total_field);
fprintf(fp_agent," %3d \r\n",
debug_snmp_agent_buf[i].total_instance);
}
fprintf(fp_agent,"\r\n");
}
fclose(fp_agent);
}
/*
#define numFuncs 2
typedef void ( *ptFuncDef )();
ptFuncDef ptFuncArr[] = { &debug_mmi_list, &debug_snmp_get_rt,&debug_snmp_set_rt,&debug_ };
for ( i = 0; i < numFuncs; i++ )
{
gettimeofday( &start, NULL );
ptFuncArr[i]();
gettimeofday( &end, NULL );
}
*/

99
plat/haepub/Makefile Normal file
View 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 = haepub
TYPE = plat
DBUG_FLAGS_ADD = -DDEBUG -D_MODIFY_AUC -D_MODIFY_EIR
RELS_FLAGS_ADD = -D_MODIFY_AUC -D_MODIFY_EIR
##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 = ../../mss
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

View File

@@ -0,0 +1,344 @@
/* HAE public function c file */
/* Written by Liu Zhiguo V1.0 */
/* Time: 2003-07-31 */
/* -------------------------- */
#include "./include/hae_include.h"
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer IMSI format from normal to anti sequence */
/* 0460022157127001 --> 64002251177200f1 */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi)
{
u8 ii;
u8 aa,bb=0;
for (ii = 1;ii <= IMSI_LEN*2;ii++)
{
if ((ii % 2) == 1)
bb = normal_imsi[ii/2] & 0x0f;
else
{
if (ii == IMSI_LEN * 2)
aa = 0x0f0;
else
aa = normal_imsi[ii/2] & 0x0f0;
anti_imsi[ii/2-1] = aa | bb;
}
}
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer IMSI format from anti to normal sequence */
/* 64002251177200f1 --> 0460022157127001 */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_imsi_aton(u8 *normal_imsi,u8 *anti_imsi)
{ // the IMSI must 15 digits
u8 ii;
u8 aa,bb=0;
normal_imsi[0] = 0;
for (ii = 0;ii < IMSI_LEN*2;ii++)
{
if ((ii % 2) == 1)
{
aa = anti_imsi[ii/2] & 0x0f;
normal_imsi[ii/2] |= aa;
}
else
{
if (ii/2 != IMSI_LEN -1)
{
bb = anti_imsi[ii/2] & 0x0f0;
normal_imsi[ii/2+1] = bb;
}
}
}
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer IMSI format from normal to ascii string */
/* 0460022157127001 --> "460022157127001" */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_imsi_ntos(u8 *str_imsi,u8 *normal_imsi)
{
u8 len;
u8 ii,jj;
str_imsi[0] = (normal_imsi[0] & 0x0f) + '0';
len = 1;
for (ii = 1;ii < IMSI_LEN;ii ++)
{
jj = (normal_imsi[ii] >> 4) & 0x0f;
str_imsi[len++] = jj + '0';
jj = normal_imsi[ii] & 0x0f;
str_imsi[len++] = jj + '0';
}
str_imsi[len] = '\0';
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer IMSI format from ascii string to normal */
/* "460022157127001" --> 0460022157127001 */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_imsi_ston(u8 *normal_imsi,u8 *str_imsi)
{
if (strlen(str_imsi) != IMSI_LEN*2-1)
return;
normal_imsi[0] = str_imsi[0] - '0';
AsciiToBcd(normal_imsi+1,str_imsi+1,IMSI_LEN*2-2);
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer ISDN format from normal to anti sequence */
/* 918675557127001EEE --> 08916857551700E1 */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_isdn_ntoa(u8 *anti_isdn,u8 *normal_isdn)
{
u8 ii;
u8 aa=0,bb=0;
u8 len;
anti_isdn[1] = normal_isdn[0]; // nature of address and numbering plan indicator
len = 1;
for (ii = 1;ii < ISDN_LEN;ii ++)
{
if ((normal_isdn[ii] == 0xee) || (normal_isdn[ii] == 0xff))
break;
else
{
aa = (normal_isdn[ii] & 0x0f0) >> 4;
bb = normal_isdn[ii] & 0x0f;
if (bb > 0x0c)
bb = 0x0f;
anti_isdn[ii+1] = (bb << 4) + aa;
len ++;
}
}
anti_isdn[0] = len;
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer ISDN format from anti to normal sequence */
/* 08916857551700E1 --> 918675557127001EEE */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_isdn_aton(u8 *normal_isdn,u8 *anti_isdn)
{
u8 ii;
u8 aa=0,bb=0;
u8 isdn_len;
isdn_len = anti_isdn[0];
if (isdn_len > ISDN_LEN)
isdn_len = ISDN_LEN;
normal_isdn[0] = anti_isdn[1];
for (ii = 1;ii < isdn_len;ii ++)
{
if ((anti_isdn[ii+1] & 0x0f) >= 0x0e)
break;
aa = (anti_isdn[ii+1] & 0x0f0) >> 4;
if (aa > 0x0c)
aa = 0x0e;
bb = anti_isdn[ii+1] & 0x0f;
normal_isdn[ii] = (bb << 4) + aa;
}
for (;ii < ISDN_LEN;ii ++)
normal_isdn[ii] = 0x0ee;
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer ISDN format from normal to ascii string */
/* 918675557127001EEE --> "8675557127001" */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_isdn_ntos(u8 *str_isdn,u8 *normal_isdn)
{
u8 len = 0;
u8 ii,jj;
for (ii = 1;ii < ISDN_LEN;ii ++)
{
jj = (normal_isdn[ii] >> 4) & 0x0f;
if (jj > 0x0c)
break;
str_isdn[len++] = jj + '0';
jj = normal_isdn[ii] & 0x0f;
if (jj > 0x0c)
break;
str_isdn[len++] = jj + '0';
}
str_isdn[len] = '\0';
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* transfer ISDN format from ascii string to normal */
/* "8675557127001" --> 918675557127001EEE */
/* return value: 0--string has error; 1--success */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_isdn_ston(u8 *normal_isdn,u8 *str_isdn)
{
u8 ii;
u8 len;
len = strlen(str_isdn);
if (len > ISDN_LEN*2-2)
return 0;
if ((len % 2) == 1) // odd number
{
AsciiToBcd(normal_isdn+1,str_isdn,len-1);
ii = len/2 + 1;
normal_isdn[ii] = (str_isdn[len-1] - '0') << 4;
normal_isdn[ii] |= 0x0E;
}
else
{
AsciiToBcd(normal_isdn+1,str_isdn,len);
ii = len/2;
}
memset(normal_isdn+ii+1,0xEE,ISDN_LEN-ii-1);
normal_isdn[0] = 0x91; // default value
return 1;
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
/* extract MAP primitive parameter */
/* return value: 0--extract fail; 1--extract success */
/* +++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_extract_param(struct MapOprSrv_struct *srv_ptr,struct MapOprData_struct *data_ptr)
{
srv_ptr->port_id = data_ptr->port_id;
srv_ptr->dialogue_id = data_ptr->dialogue_id;
srv_ptr->invoke_id = data_ptr->invoke_id;
srv_ptr->message_type = data_ptr->message_type;
srv_ptr->message_flag = data_ptr->message_flag;
if (!(data_ptr->param_flag & 0x20)) // has not parameter
return 0;
return extract_mapparam(srv_ptr,data_ptr->message_type,data_ptr->message_flag,data_ptr->param_len,data_ptr->param);
}
/* +++++++++++++++++++++++++++++++++++++++++++++ */
/* build MAP primitive parameter */
/* return value: 0--build fail; 1--build success */
/* +++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_build_param(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr)
{
u32 len;
u8 buf[4096];
data_ptr->port_id = srv_ptr->port_id;
data_ptr->dialogue_id = srv_ptr->dialogue_id;
data_ptr->invoke_id = srv_ptr->invoke_id;
data_ptr->message_type = srv_ptr->message_type;
data_ptr->message_flag = srv_ptr->message_flag;
data_ptr->param_flag = 0x1f;
len = build_mapparam(srv_ptr,buf);
if (len == 0 || len > MAX_MAPPOPR_LEN)
return 0;
data_ptr->param_len = len;
memcpy(data_ptr->param,buf,len);
data_ptr->param_flag |= 0x20;
return 1;
}
u8 hae_build_param_v2(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr, u8 linked_id)
{
u32 len;
u8 buf[4096];
data_ptr->port_id = srv_ptr->port_id;
data_ptr->dialogue_id = srv_ptr->dialogue_id;
data_ptr->invoke_id = srv_ptr->invoke_id;
data_ptr->message_type = srv_ptr->message_type;
data_ptr->message_flag = srv_ptr->message_flag;
data_ptr->linked_id = linked_id;
data_ptr->param_flag = 0x11f;
len = build_mapparam(srv_ptr,buf);
if (len == 0 || len > MAX_MAPPOPR_LEN)
return 0;
data_ptr->param_len = len;
memcpy(data_ptr->param,buf,len);
data_ptr->param_flag |= 0x20;
return 1;
}
/* ++++++++++++++++++++++++++++++++++++++++++ */
/* check if can send MAP common primitive */
/* return value: 0--can not send; 1--can send */
/* ++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_check_sendcom(u32 did)
{
return map_check_sendcom(did);
}
/* ++++++++++++++++++++++++++++++++++++++++++ */
/* check if can send MAP operation primitive */
/* return value: 0--can not send; 1--can send */
/* ++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_check_sendopr(u32 did)
{
return map_check_sendopr(did);
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* get open from MAP provider */
/* return value: 0--get fail; 1--get success */
/* data_flow stores the message flow received from MAP provider */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_get_open(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 ssn)
{
if (!map_get_open(data_flow,ssn))
return 0;
if (!map_com_ftos(com_ptr,data_flow))
return 0;
return 1;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* get common primitive from MAP provider */
/* return value: 0--get fail; 1--get success */
/* data_flow stores the message flow received from MAP provider */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_get_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u32 did)
{
if (!map_get_comdata(data_flow,did))
return 0;
if (!map_com_ftos(com_ptr,data_flow))
return 0;
return 1;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* send common primitive to MAP provider */
/* return value: 0--send fail; 1--send success */
/* data_flow stores the message flow send to MAP provider */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_send_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 DelimiterFlag)
{
map_com_stof(com_ptr,data_flow,DelimiterFlag);
return map_send_comdata(data_flow);
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* get operation primitive from MAP provider */
/* return value: 0--get fail; 1--get success */
/* data_flow stores the message flow get from MAP provider */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_get_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u32 did)
{
if (!map_get_oprdata(data_flow,did))
return 0;
if (!map_opr_ftos(opr_ptr,data_flow))
return 0;
return 1;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* send operation primitive to MAP provider */
/* return value: 0--send fail; 1--send success */
/* data_flow stores the message flow send to MAP provider */
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
u8 hae_send_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u8 DelimiterFlag)
{
map_opr_stof(opr_ptr,data_flow,DelimiterFlag);
return map_send_oprdata(data_flow);
}

View File

@@ -0,0 +1,51 @@
/* HAE system parameter c file */
/* Written by Liu Zhiguo V1.0 */
/* Time: 2003-07-31 */
/* ---------------------------- */
#include "./include/hae_include.h"
static u32 hae_localip; // local ip address
static u32 hae_peerip; // peer ip address
static u32 hae_primomcip; // primary omc ip address
static u32 hae_secdomcip; // secondary omc ip address
void hae_set_localip(u32 local_ip)
{
hae_localip = local_ip;
}
u32 hae_get_localip(void)
{
return hae_localip;
}
void hae_set_peerip(u32 peer_ip)
{
hae_peerip = peer_ip;
}
u32 hae_get_peerip(void)
{
return hae_peerip;
}
void hae_set_primomcip(u32 primomc_ip)
{
hae_primomcip = primomc_ip;
}
u32 hae_get_primomcip(void)
{
return hae_primomcip;
}
void hae_set_secdomcip(u32 secdomc_ip)
{
hae_secdomcip = secdomc_ip;
}
u32 hae_get_secdomcip(void)
{
return hae_secdomcip;
}

895
plat/haepub/src/hae_sync.c Normal file
View File

@@ -0,0 +1,895 @@
/* HAE sync function c file */
/* Written by Liu Zhiguo V1.0 */
/* Time: 2003-08-08 */
/* -------------------------- */
#include "./include/hae_include.h"
#define PERIOD_SYNC_TIMEOUT 64 //16
#define READ_ITEMS_PER_CYCLE 8 //The max readed items per cylce,must<32
#define MAX_WAIT_TIMEOUT (READ_ITEMS_PER_CYCLE*3)
#define MAX_RAM_INIT_RETRY 4
const u32 HLR_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,3};
const u32 AUC_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,4};
const u32 EIR_OID_PREFIX[11] = {1,3,6,1,4,1,1373,2,3,3,8};
static u32 HLR_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,3,2,7};
static u32 AUC_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,4,2,7};
static u32 EIR_RAM_OID_PREFIX[13]={1,3,6,1,4,1,1373,2,3,3,8,2,7};
static u32 conf_oid[HAE_SYNC_MOD_NUM]={2,2,2};
static u32 sync_ram_oid[HAE_SYNC_MOD_NUM]={7,7,7};
static u32 ramdata_pack_num[HAE_SYNC_MOD_NUM]={0,0,0}; //The Max packets of the Module
static void *ramshm_ptr[HAE_SYNC_MOD_NUM]={NULL,NULL,NULL}; //Restored the pointer of the subs shm.
static u8 master_flag[HAE_SYNC_MOD_NUM]={0,0,0}; //0/1=slave/master
static u8 switch_flag[HAE_SYNC_MOD_NUM]={0,0,0};
static u8 period_flag[HAE_SYNC_MOD_NUM]={1,1,1};
static int sent_pack_no[HAE_SYNC_MOD_NUM]={0,0,0};
static int no_prd_sync[HAE_SYNC_MOD_NUM]={0,0,0}; // number of period sync
static u8 oid_prefix_len[HAE_SYNC_MOD_NUM]={0,0,0};
static u32 read_start[HAE_SYNC_MOD_NUM]={0,0,0};
static u32 recv_stand[HAE_SYNC_MOD_NUM]={0,0,0};
static u32 recv_flag[HAE_SYNC_MOD_NUM]={0,0,0};
static u8 hae_data_ver[HAE_SYNC_MOD_NUM][3]={{0,0,0},{0,0,0},{0,0,0}};
extern int hlr_realsync_proc();
extern void hlr_send_psync_proc();
extern void hlr_set_mastermode();
extern void hlr_set_slavermode();
extern int hlr_recv_psync_proc(u8 oid_len, u32 * oid, u8 * sync_data, u32 data_len, snmp_addr * addr_ptr);
extern void hlr_upgrade_subs_n_1(void *ptr, void *r_ptr, int file_size);
extern void hlr_upgrade_subs_n_2(void *ptr, void *r_ptr, int file_size);
extern int AucSyncNowMsgProc(BYTE OIDLen,DWORD *OID,BYTE *Pdata,u_short DataLen);
extern int EirSyncNowMsgProc(BYTE OIDLen,DWORD *OID,BYTE *Pdata,u_short DataLen);
int get_weekday(char *wday_buf)
{
struct tm *t,tt;
long curr_date;
t=&tt;
curr_date=time((long *)0);
t=localtime(&curr_date);
if( t == NULL )
{
assert(0 && "syscall: Locatime fail");
exit(0);
}
sprintf(wday_buf,"%02d", t->tm_wday);
wday_buf[2]=0;
return t->tm_wday;
}
void hae_init_sync(u8 fun_mod,u8 oid_len,u32 max_mem,u8 *data_ptr,void *shm_ptr)
{
u8 i=0;
oid_prefix_len[fun_mod] = oid_len;
if((max_mem % HAE_PER_PACK_LEN))
ramdata_pack_num[fun_mod] = max_mem/HAE_PER_PACK_LEN+1;
else
ramdata_pack_num[fun_mod] = max_mem/HAE_PER_PACK_LEN;
memcpy(&hae_data_ver[fun_mod],data_ptr,3);
for (i = 0;i < READ_ITEMS_PER_CYCLE;i ++)
recv_stand[fun_mod] |= (0x01<<i);
ramshm_ptr[fun_mod] = shm_ptr;
}
int hae_set_master_flag(u8 fun_mod,u8 MasterFlag)
{
master_flag[fun_mod] = MasterFlag;
return 1;
}
int hae_get_master_flag(u8 fun_mod)
{
return master_flag[fun_mod];
}
int hae_inspect_master(u8 fun_mod)
{
snmp_pdu snmp_buf;
snmp_addr snmp_add;
int i;
int recv_count=0;
switch(fun_mod)
{
case HLR_SYNC_MOD:
snmp_add.local_port = HLR_SYNC_UDPPORT;
for(i = 0;i < 10; i ++) //add here becase if mss-0 and mss-1 start
{
if( snmp_receive(&snmp_buf,&snmp_add) && snmp_buf.var[0].oid[12] == 9 )
recv_count++;
}
break;
case AUC_SYNC_MOD:
snmp_add.local_port = AUC_SYNC_UDPPORT;
if( snmp_receive(&snmp_buf,&snmp_add) )
{
recv_count = 3;
}
break;
case EIR_SYNC_MOD:
snmp_add.local_port = EIR_SYNC_UDPPORT;
if( snmp_receive(&snmp_buf,&snmp_add) )
{
recv_count = 3;
}
break;
default:
return 0;
}
return (recv_count >= 3) ? 1 : 0;
}
int hae_set_period_flag(u8 fun_mod, u8 flag)
{
if(fun_mod < HAE_SYNC_MOD_NUM)
{
period_flag[fun_mod] = flag & 0x01;
return 1;
}
return 0;
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Receive real time sync and periodic sync */
/* Real time sync proc must be implemented by application */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_sync_msg_proc(u8 fun_mod) // hae sync message process
{
int periodic_flag[HAE_SYNC_MOD_NUM]={0,0,0};
void *ptr;
int i;
int instance=0,data_type;
snmp_pdu snmp_buf;
snmp_addr snmp_add;
var_list *varptr=NULL;
u32 master_ip = hae_get_localip();
switch(fun_mod)
{
case HLR_SYNC_MOD:
snmp_add.local_port = HLR_SYNC_UDPPORT;
break;
case AUC_SYNC_MOD:
snmp_add.local_port = AUC_SYNC_UDPPORT;
break;
case EIR_SYNC_MOD:
snmp_add.local_port = EIR_SYNC_UDPPORT;
break;
default:
return;
}
for(i = 0;i < ramdata_pack_num[fun_mod];i ++)
{
if (!snmp_receive(&snmp_buf,&snmp_add))
break;
varptr = &snmp_buf.var[0];
data_type = varptr->oid[12];
switch(data_type)
{
case 2:
switch(varptr->oid[10])
{
case 3://real sync message for HLR
hlr_realsync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add);
break;
case 4://Auc real sync message
#ifdef _MODIFY_AUC
AucSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen);
#endif
break;
case 8://Eir real sync message
#ifdef _MODIFY_EIR
EirSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen);
#endif
break;
}
break;
/* case 3: //real sync message for AUC/EIR
switch(fun_mod)
{
case AUC_SYNC_MOD: //Auc real sync message
#ifdef _MODIFY_AUC
AucSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen);
#endif
break;
case EIR_SYNC_MOD: //Eir real sync message
#ifdef _MODIFY_EIR
EirSyncNowMsgProc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen);
#endif
break;
}
break;
case 6: //real sync message for HLR
hlr_realsync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add);
break;*/
case 7 ://periodic sync message AUC EIR
if( fun_mod != HLR_SYNC_MOD )
{
/*
master_ip = snmp_add.remote_ip;
periodic_flag[fun_mod] = 1;
instance = varptr->oid[13];
if(instance >= ramdata_pack_num[fun_mod])
continue;
if (varptr->msglen != HAE_PER_PACK_LEN)
continue;
ptr = (void *) ramshm_ptr[fun_mod];
memcpy(ptr+instance*HAE_PER_PACK_LEN,varptr->msg,HAE_PER_PACK_LEN);
*/
}
break;
case 9: //periodic sync message HLR
if( fun_mod == HLR_SYNC_MOD )
{
master_ip = snmp_add.remote_ip;
periodic_flag[fun_mod] = 1;
//printf( "hlr recv periodic sync\n");
hlr_recv_psync_proc(varptr->oidlen,varptr->oid,varptr->msg,varptr->msglen,&snmp_add);
}
break;
}
}
if (periodic_flag[fun_mod])
{
if (master_flag[fun_mod] && master_ip < hae_get_localip())
{
master_flag[fun_mod] = 0;
if( fun_mod == HLR_SYNC_MOD )
{
//printf( "hlr set to slaver\n");
hlr_set_slavermode();
}
}
no_prd_sync[fun_mod] = 0;
}
else if(no_prd_sync[fun_mod]++ > PERIOD_SYNC_TIMEOUT)
{
master_flag[fun_mod] = 1;
if( fun_mod == HLR_SYNC_MOD )
{
//printf( "hlr set to master\n");
hlr_set_mastermode();
}
}
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Called by every applicatoin */
/* Receive sync message(real and periodic), and */
/* send periodic sync message if it acts as master server */
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
void hae_syncdata_proc(u8 fun_mod)
{
void *ptr;
snmp_pdu snmp_buf;
snmp_addr snmp_add;
var_list *varlist = NULL;
//printf("psync proc\r\n");
hae_sync_msg_proc(fun_mod); //receive sync message
if(!master_flag[fun_mod])
return;
if((switch_flag[fun_mod]++) & 0x01)
return;
if(!period_flag[fun_mod])
return;
//send periodic sync message
snmp_buf.pdu_type = 0x07; //trap
snmp_buf.var_num = 0x01;
varlist = snmp_buf.var;
varlist->oidlen = oid_prefix_len[fun_mod]+2+1;
varlist->vartype = 0x04;
switch(fun_mod)
{
case HLR_SYNC_MOD:
snmp_add.remote_port = HLR_SYNC_UDPPORT;
snmp_add.local_port = HLR_SYNC_UDPPORT;
memcpy(&varlist->oid,HLR_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32));
break;
case AUC_SYNC_MOD:
snmp_add.remote_port = AUC_SYNC_UDPPORT;
snmp_add.local_port = AUC_SYNC_UDPPORT;
memcpy(&varlist->oid,AUC_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32));
break;
case EIR_SYNC_MOD:
snmp_add.remote_port = EIR_SYNC_UDPPORT;
snmp_add.local_port = EIR_SYNC_UDPPORT;
memcpy(&varlist->oid,EIR_OID_PREFIX,oid_prefix_len[fun_mod]*sizeof(u32));
break;
}
if( fun_mod == HLR_SYNC_MOD )
{
hlr_send_psync_proc();
//printf( "hlr send periodic sync\n");
return ;
}
snmp_add.remote_ip = hae_get_peerip();
snmp_add.local_ip = hae_get_localip();
snmp_add.broadcast = 0x00;
varlist->oid[oid_prefix_len[fun_mod]] = conf_oid[fun_mod]; //configuration
varlist->oid[oid_prefix_len[fun_mod]+1] = sync_ram_oid[fun_mod]; //sync ram
varlist->oid[13] = sent_pack_no[fun_mod]; //account_db
varlist->msglen = HAE_PER_PACK_LEN;//single packet,unit:KB
ptr = (void *)ramshm_ptr[fun_mod];
memcpy(varlist->msg,ptr+sent_pack_no[fun_mod]*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN);
snmp_send(&snmp_buf,&snmp_add);
sent_pack_no[fun_mod] ++;
sent_pack_no[fun_mod] %= ramdata_pack_num[fun_mod];
}
int cmp_data_ver(u8 fun_mod,u8 *src_ptr)
{
if(!memcmp(hae_data_ver[fun_mod],src_ptr,3))
return 1;
return 0;
}
/* The procedure is called back when peer data comes in SNMP GET RESP */
int hae_load_from_peer_resp(u8 fun_mod,snmp_pdu *pdu,snmp_addr *addr)
{
//static int LastInstance[HAE_SYNC_MOD_NUM]={0,0,0};
int instance=0,tmp_val=0;
void *ptr;
/*
if(LastInstance[fun_mod] && (LastInstance[fun_mod]+1) != (instance)){
return 0;
}
LastInstance[fun_mod]=instance;
*/
if (pdu->var[0].oid[12] != 7) // do not ram data
return 0;
instance = pdu->var[0].oid[13]; //for init
if (instance >= ramdata_pack_num[fun_mod])
return 0;
if (pdu->var[0].msglen != HAE_PER_PACK_LEN)
return 0;
tmp_val = instance - read_start[fun_mod];
if (0 <= tmp_val && READ_ITEMS_PER_CYCLE > tmp_val)
recv_flag[fun_mod] |= (0x01 << tmp_val);
else
return 0;
ptr = (void *)ramshm_ptr[fun_mod];
memcpy(ptr+instance*HAE_PER_PACK_LEN,pdu->var[0].msg,HAE_PER_PACK_LEN);
if (0 == instance)
{//check data version
if (!cmp_data_ver(fun_mod,(u8 *)ptr))
{
memset((u8 *)ptr,0,HAE_PER_PACK_LEN);
return 0; // load fail
}
}
return 1;
}
/* Use SNMP GET to load user data from peer server, and wait response */
int hae_load_from_peer(u8 fun_mod)
{//calling during init procedure
snmp_pdu snmp_buf;
snmp_addr snmp_add;
var_list *varlist = NULL;
static int read_pack_no[HAE_SYNC_MOD_NUM]={0,0,0};
static int read_state[HAE_SYNC_MOD_NUM]={0,0,0};
static int try_times[HAE_SYNC_MOD_NUM]={0,0,0};
static int reread_times[HAE_SYNC_MOD_NUM]={0,0,0};
static u8 max_read_item[HAE_SYNC_MOD_NUM]={0,0,0};
// int retval = _LOADING_DATA;
int i=0,oid_len=0;
switch(read_state[fun_mod])
{
case 0: //send request
if (read_pack_no[fun_mod] >= ramdata_pack_num[fun_mod])
{ //init over
read_state[fun_mod] = 0;
try_times[fun_mod] = 0;
reread_times[fun_mod] = 0;
read_pack_no[fun_mod] = 0;
return 2; // load success
}
snmp_buf.pdu_type = 0; // snmp get
snmp_buf.var_num = 0x01;
// snmp_add.remote_ip = PeerIp[fun_mod];
snmp_add.remote_ip = hae_get_peerip();
snmp_add.remote_port = HAE_AGENT_UDPPORT;
snmp_add.local_ip = hae_get_localip();
snmp_add.local_port = HAE_AGENT_UDPPORT;
snmp_add.broadcast = 0x00;
varlist = &snmp_buf.var[0];
switch(fun_mod)
{
case HLR_SYNC_MOD:
oid_len = sizeof(HLR_RAM_OID_PREFIX)/sizeof(u32);
memcpy(&varlist->oid,HLR_RAM_OID_PREFIX,oid_len*4);
break;
case AUC_SYNC_MOD:
oid_len=sizeof(AUC_RAM_OID_PREFIX)/sizeof(u32);
memcpy(&varlist->oid,AUC_RAM_OID_PREFIX,oid_len*4);
break;
case EIR_SYNC_MOD:
oid_len=sizeof(EIR_RAM_OID_PREFIX)/sizeof(u32);
memcpy(&varlist->oid,EIR_RAM_OID_PREFIX,oid_len*4);
break;
}
varlist->oidlen = oid_len+1;
varlist->vartype = 0x04;
varlist->msglen = 0;
if (ramdata_pack_num[fun_mod] >= (read_pack_no[fun_mod]+READ_ITEMS_PER_CYCLE))
max_read_item[fun_mod] = READ_ITEMS_PER_CYCLE;
else
max_read_item[fun_mod] = ramdata_pack_num[fun_mod]-read_pack_no[fun_mod];
read_start[fun_mod] = read_pack_no[fun_mod];
for (i = 0;i < max_read_item[fun_mod];i ++)
{
recv_stand[fun_mod] |= (0x01<<i);
varlist->oid[oid_len] = read_pack_no[fun_mod] + i;
snmp_send(&snmp_buf,&snmp_add);
}
read_state[fun_mod] = 1;
try_times[fun_mod] = 0;
recv_flag[fun_mod] = 0;
break;
case 1: //wait response
if(recv_flag[fun_mod] == recv_stand[fun_mod])
{
try_times[fun_mod] = 0;
read_state[fun_mod] = 0;
reread_times[fun_mod] = 0;
recv_flag[fun_mod] = 0;
recv_stand[fun_mod] = 0;
read_pack_no[fun_mod] += max_read_item[fun_mod];
}
else if (try_times[fun_mod]++ >= MAX_WAIT_TIMEOUT*5)
{
read_state[fun_mod] = 0;
try_times[fun_mod] = 0;
// recv_flag[fun_mod] = 0;
// recv_stand[fun_mod] = 0;
if(reread_times[fun_mod]++ >= MAX_RAM_INIT_RETRY)
{
reread_times[fun_mod] = 0;
read_pack_no[fun_mod] = 0;
printf("Load data form peer timeout\n");
return 0;
}
}
break;
default:
read_state[fun_mod] = 0;
break;
}
return 1; // load data
}
/* The procedure is called when peer server request loading data */
int hae_peerdata_resp(u8 fun_mod,u8 oidLen,u32 *oid,u8 *pdata,u8 *vartype)
{ // Response the Peer's reading request
u32 instance;
void *ptr;
//instance = oid[13];
instance = oid[oidLen-1];
*vartype = 0x04;
if (instance >= ramdata_pack_num[fun_mod])
return 0;
ptr = (void *)ramshm_ptr[fun_mod];
memcpy(pdata,ptr+instance*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN);
return HAE_PER_PACK_LEN;
}
int hae_load_from_local(u8 fun_mod,char *file_name)
{
int i;
FILE *fp=NULL;
void *r_ptr;
void *ptr=(void *)ramshm_ptr[fun_mod];
struct stat fileinfo;
if((fp = fopen(file_name, "r")) == NULL)
return 0;
if(fun_mod == HLR_SYNC_MOD)
{
stat(file_name, &fileinfo);
r_ptr = malloc(fileinfo.st_size);
if( r_ptr == NULL )
{
assert(0 && "syscall: malloc fail");
exit(0);
}
fread(r_ptr, fileinfo.st_size, 1, fp);
// if((hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0]) &&(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1]))
// {
// if(fileinfo.st_size <= ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN)
// memcpy(ptr, r_ptr, fileinfo.st_size);
// else
// memcpy(ptr, r_ptr, ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN);
// }
// if((hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0]) &&(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1]))
// if(hae_data_ver[HLR_SYNC_MOD][1] == ((u8 *)r_ptr)[1])
// {
if(fileinfo.st_size <= ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN)
memcpy(ptr+1024, r_ptr+1024, fileinfo.st_size-1024);
else
memcpy(ptr+1024, r_ptr+1024, ramdata_pack_num[HLR_SYNC_MOD]*HAE_PER_PACK_LEN-1024);
// }
// else if(hae_data_ver[HLR_SYNC_MOD][0] == ((u8 *)r_ptr)[0])
// {
// switch(hae_data_ver[HLR_SYNC_MOD][1] - ((u8 *)r_ptr)[1])
// {
// case 1:
// hlr_upgrade_subs_n_1(ptr, r_ptr, fileinfo.st_size);
// break;
// case 2:
// hlr_upgrade_subs_n_2(ptr, r_ptr, fileinfo.st_size);
// break;
// default:
// printf("Failed to upgrade subscriber data\n");
// break;
// }
// }
free(r_ptr);
}
else
{
for (i = 0;i < ramdata_pack_num[fun_mod];i ++)
{
fread(ptr+i*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN,1,fp);
// if(i == 0)
// {//check data version
// if(!cmp_data_ver(fun_mod,(u8 *)ptr))
// {
// memset((u8 *)ptr,0,HAE_PER_PACK_LEN);
// fclose(fp);
// return 0;
// }
// }
}
}
fclose(fp);
return 2; // load success
}
void hae_tftp_read_req(u16 portno,char *filename)
{
int filename_len;
char readmode[20] = "octetoblksizeo1024";
_msg_list ipmsg;
filename_len = strlen(filename);
ipmsg.msgSrcPort = portno;
ipmsg.msgSrcIP = hae_get_localip();
ipmsg.msgDstPort = 69; //TFTP_PORT;
ipmsg.msgDstIP = hae_get_primomcip();
ipmsg.msgBroadcast = 0x00;
ipmsg.msgContent[0] = 0;
ipmsg.msgContent[1] = 1; //read request
memcpy(ipmsg.msgContent+2,filename,filename_len);
memcpy(ipmsg.msgContent+filename_len+3,readmode,18);
ipmsg.msgContent[filename_len+2] = 0;
ipmsg.msgContent[filename_len+8] = 0;
ipmsg.msgContent[filename_len+16] = 0;
ipmsg.msgContent[filename_len+21] = 0;
ipmsg.msgLength = filename_len+22;
iptrPutMessage(ipmsg);
}
int hae_tftp_read_data(u8 fun_mod,u16 portno,u8 *databuf)
{
static int readblocknum[HAE_SYNC_MOD_NUM] = {0};
static int proc_len[HAE_SYNC_MOD_NUM] = {0};
static int try_timer[HAE_SYNC_MOD_NUM] = {0};
static int try_times[HAE_SYNC_MOD_NUM] = {0};
static int tftp_read_port = 69; // TFTP port for OMC response
int ackblocknum;
int retval=0;
_msg_list ipmsg,ipack;
if (iptrGetMessage(&ipmsg,portno))
{
try_timer[fun_mod] = 0;
try_times[fun_mod] = 0;
switch (ipmsg.msgContent[1])
{
case 3: // response
ackblocknum = ipmsg.msgContent[2]*256+ipmsg.msgContent[3];
proc_len[fun_mod] += ipmsg.msgLength - 4;
if(ackblocknum == readblocknum[fun_mod]+1)
readblocknum[fun_mod] = ackblocknum;
else if(ackblocknum == 0)
{
if(readblocknum[fun_mod] == 0xffff)
readblocknum[fun_mod] = 0;
}
memcpy(databuf,ipmsg.msgContent,ipmsg.msgLength); //length
retval = ipmsg.msgLength;
// read next package
ipack.msgLength = 4;
ipack.msgContent[0] = 0x00;
ipack.msgContent[1] = 0x04;
ipack.msgContent[2] = ackblocknum >> 8;
ipack.msgContent[3] = ackblocknum;
ipack.msgSrcIP = hae_get_localip();
ipack.msgSrcPort = TFTP_SRVC_PORT;
ipack.msgDstPort = ipmsg.msgSrcPort;
ipack.msgDstIP = hae_get_primomcip();
iptrPutMessage(ipack);
tftp_read_port = ipmsg.msgSrcPort;
break;
case 6: // the first package response
proc_len[fun_mod] = 0;
readblocknum[fun_mod] = 0;
ipack.msgLength = 4;
ipack.msgContent[0] = 0x00;
ipack.msgContent[1] = 0x04;
ipack.msgContent[2] = readblocknum[fun_mod]>>8;
ipack.msgContent[3] = readblocknum[fun_mod];
ipack.msgSrcIP = hae_get_localip();
ipack.msgSrcPort = TFTP_SRVC_PORT;
ipack.msgDstPort = ipmsg.msgSrcPort;
ipack.msgDstIP = hae_get_primomcip();
iptrPutMessage(ipack);
tftp_read_port = ipmsg.msgSrcPort;
break;
default:
printf("Error!\n");
break;
}
}
else // do not receive response package
{
if (try_timer[fun_mod]++ > MAX_RAM_INIT_RETRY)
{
try_timer[fun_mod] = 0;
if (try_times[fun_mod]++ > MAX_RAM_INIT_RETRY)
return -1;
if (tftp_read_port == 69) // the request package is not response
return -1;
// resend the unreceived package
ipack.msgLength = 4;
ipack.msgContent[0] = 0x00;
ipack.msgContent[1] = 0x04;
ipack.msgContent[2] = readblocknum[fun_mod]>>8;
ipack.msgContent[3] = readblocknum[fun_mod];
ipack.msgSrcIP = hae_get_localip();
ipack.msgSrcPort = TFTP_SRVC_PORT;
ipack.msgDstPort = tftp_read_port;
ipack.msgDstIP = hae_get_primomcip();
iptrPutMessage(ipack);
}
}
return retval;
}
int hae_load_from_omc(u8 fun_mod)
{
static int tftp_state[HAE_SYNC_MOD_NUM] = {0};
void *ptr;
int blocknum = 0,length = 0;
char filename[18] = {0};
u8 databuf[1024] = {0};
u8 wday = 0,tmp_buf[3] = {0};
switch(tftp_state[fun_mod])
{
case 0:
wday = (get_weekday(tmp_buf)+7-1) % 7;
switch(fun_mod)
{
case HLR_SYNC_MOD:
sprintf(filename,"hlr_backup%02d.dat",wday);
break;
case AUC_SYNC_MOD:
sprintf(filename,"auc_backup%02d.dat",wday);
break;
case EIR_SYNC_MOD:
sprintf(filename,"eir_backup%02d.dat",wday);
break;
}
hae_tftp_read_req(TFTP_SRVC_PORT,filename);
tftp_state[fun_mod] = 1;
break;
case 1:
length = hae_tftp_read_data(fun_mod,TFTP_SRVC_PORT,databuf);
if (length == -1)
{
printf("read from omc timeout\n");
return 0; // load fail
}
else if(length >= 4)
{
blocknum = databuf[2] * 256 + databuf[3];
// if(blocknum>=ramdata_pack_num[fun_mod])
// continue;
ptr = (void *)ramshm_ptr[fun_mod];
memcpy(ptr+(blocknum-1)*HAE_PER_PACK_LEN,databuf+4,length-4); //length is variable
// if (blocknum == 1)
// {//check data version
// if(!cmp_data_ver(fun_mod,(u8 *)ptr))
// {
// memset((u8 *)ptr,0,HAE_PER_PACK_LEN);
// return 0;
// }
// }
if (blocknum == ramdata_pack_num[fun_mod])
return 2; // load succcess
}
break;
default:
break;
}
return 1; // just load data
}
int hae_tftp_write_req(int portno,char *filename)
{
int retval=1,filename_len;
char writemode[20]="octetoblksizeo1024";
_msg_list ipmsg;
filename_len = strlen(filename);
ipmsg.msgSrcPort = portno;
ipmsg.msgSrcIP = hae_get_localip();
ipmsg.msgDstPort = 69; //TFTP_PORT;
ipmsg.msgDstIP = hae_get_primomcip();
ipmsg.msgBroadcast = 0x00;
ipmsg.msgContent[0] = 0;
ipmsg.msgContent[1] = 2; //write request
memcpy(&ipmsg.msgContent[2],filename,filename_len);
memcpy(&ipmsg.msgContent[filename_len+3],writemode,18);
ipmsg.msgContent[filename_len+2] = 0;
ipmsg.msgContent[filename_len+8] = 0;
ipmsg.msgContent[filename_len+16] = 0;
ipmsg.msgContent[filename_len+21] = 0;
ipmsg.msgLength = filename_len+22;
iptrPutMessage(ipmsg);
return retval;
}
int hae_tftp_write_data(u8 fun_mod)
{
int retval = 0;
static int blocknum[HAE_SYNC_MOD_NUM]={1,1,1};
static int ackblocknum[HAE_SYNC_MOD_NUM]={0,0,0};
static int try_times[HAE_SYNC_MOD_NUM]={0,0,0};
static int resend_times[HAE_SYNC_MOD_NUM]={0,0,0};
_msg_list ipmsg,ipsend;
void *ptr = (void *)ramshm_ptr[fun_mod];
if(iptrGetMessage(&ipmsg,TFTP_SRVC_PORT))
{
if(ipmsg.msgContent[1] == 4)
{
ackblocknum[fun_mod] = ipmsg.msgContent[2]*256+ipmsg.msgContent[3];
//printf("ack:%d, real:%d\n",ackblocknum[fun_mod],blocknum[fun_mod]);
if (ackblocknum[fun_mod] == blocknum[fun_mod])
{
if (blocknum[fun_mod]++ >= ramdata_pack_num[fun_mod])
{
blocknum[fun_mod] = 0;
ackblocknum[fun_mod] = 0;
try_times[fun_mod] = 0;
resend_times[fun_mod] = 0;
return 1;
}
}
}
else if (ipmsg.msgContent[1] == 5)
return -2;
else if (ipmsg.msgContent[1] == 6)
blocknum[fun_mod] = 1;
ipsend.msgSrcIP = hae_get_localip();
ipsend.msgSrcPort = TFTP_SRVC_PORT;
ipsend.msgDstPort = ipmsg.msgSrcPort;
ipsend.msgDstIP = ipmsg.msgSrcIP;
ipsend.msgLength = 4 + 1024;
ipsend.msgContent[0] = 0x00;
ipsend.msgContent[1] = 0x03;
ipsend.msgContent[2] = blocknum[fun_mod]>>8;
ipsend.msgContent[3] = blocknum[fun_mod];
memcpy(&ipsend.msgContent[4],ptr+(blocknum[fun_mod]-1)*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN);
iptrPutMessage(ipsend);
resend_times[fun_mod] = 0;
}
else if(try_times[fun_mod]++ > MAX_WAIT_TIMEOUT)
{
try_times[fun_mod]=0;
if(resend_times[fun_mod]++ >= MAX_RAM_INIT_RETRY)
{
resend_times[fun_mod] = 0;
blocknum[fun_mod] = 0;
ackblocknum[fun_mod] = 0;
retval = -1;
}
else if( blocknum[fun_mod] )
{
ipsend.msgSrcIP = hae_get_localip();
ipsend.msgSrcPort = TFTP_SRVC_PORT;
ipsend.msgDstPort = ipmsg.msgSrcPort;
ipsend.msgDstIP = ipmsg.msgSrcIP;
ipsend.msgLength = 4 + 1024;
ipsend.msgContent[0] = 0x00;
ipsend.msgContent[1] = 0x03;
ipsend.msgContent[2] = blocknum[fun_mod]>>8;
ipsend.msgContent[3] = blocknum[fun_mod];
memcpy(&ipsend.msgContent[4],ptr+(blocknum[fun_mod]-1)*HAE_PER_PACK_LEN,HAE_PER_PACK_LEN);
iptrPutMessage(ipsend);
}
}
return retval;
}
int hae_back_to_omc(u8 fun_mod)
{
int retval = 0;
static int back_state[HAE_SYNC_MOD_NUM]={0};
char filename[32];
u8 tmp_buf[3]={0};
switch(fun_mod)
{
case HLR_SYNC_MOD:
sprintf(filename,"hlr_backup%02d.dat",get_weekday(tmp_buf));
break;
case AUC_SYNC_MOD:
sprintf(filename,"auc_backup%02d.dat",get_weekday(tmp_buf));
break;
case EIR_SYNC_MOD:
sprintf(filename,"eir_backup%02d.dat",get_weekday(tmp_buf));
break;
}
switch(back_state[fun_mod])
{
case 0:
if(hae_tftp_write_req(TFTP_SRVC_PORT,filename))
back_state[fun_mod] = 1;
break;
case 1:
if((retval = hae_tftp_write_data(fun_mod)))
back_state[fun_mod] = 0;
break;
default:
break;
}
return retval;
}
int hae_get_syncpercent( u8 fun_mod , u8 oidLen, u32 *oid )
{
int instance=0;
int last_instance = ramdata_pack_num[fun_mod] - ramdata_pack_num[fun_mod]%READ_ITEMS_PER_CYCLE;
if ( oidLen != 13 && oid[12] != 7) // do not ram data
return -1;
instance = oid[oidLen-1];
if (instance >= ramdata_pack_num[fun_mod] || !last_instance)
return -1;
instance = (instance*10000/last_instance) ;
instance = (instance > 9999) ? 0 : instance;
return instance;
}

View File

@@ -0,0 +1,51 @@
/* HAE public function head file */
/* Written by Liu Zhiguo V1.0 */
/* Time: 2003-07-31 */
/* -------------------------- */
#ifndef _HAE_FUNCTION
#define _HAE_FUNCTION
void hae_imsi_ntoa(u8 *anti_imsi,u8 *normal_imsi);
void hae_imsi_aton(u8 *normal_imsi,u8 *anti_imsi);
void hae_imsi_ntos(u8 *str_imsi,u8 *normal_imsi);
void hae_imsi_ston(u8 *normal_imsi,u8 *str_imsi);
void hae_isdn_ntoa(u8 *anti_isdn,u8 *normal_isdn);
void hae_isdn_aton(u8 *normal_isdn,u8 *anti_isdn);
void hae_isdn_ntos(u8 *str_isdn,u8 *normal_isdn);
u8 hae_isdn_ston(u8 *normal_isdn,u8 *str_isdn);
u8 hae_extract_param(struct MapOprSrv_struct *srv_ptr,struct MapOprData_struct *data_ptr);
u8 hae_build_param(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr);
u8 hae_build_param_v2(struct MapOprData_struct *data_ptr,struct MapOprSrv_struct *srv_ptr, u8 linked_id);
u8 hae_check_sendcom(u32 did);
u8 hae_check_sendopr(u32 did);
u8 hae_get_open(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 ssn);
u8 hae_get_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u32 did);
u8 hae_send_comdata(u8 *data_flow,struct MapComSrv_struct *com_ptr,u8 DelimiterFlag);
u8 hae_get_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u32 did);
u8 hae_send_oprdata(u8 *data_flow,struct MapOprData_struct *opr_ptr,u8 DelimiterFlag);
void hae_set_localip(u32 local_ip);
u32 hae_get_localip(void);
void hae_set_peerip(u32 peer_ip);
u32 hae_get_peerip(void);
void hae_set_primomcip(u32 primomc_ip);
u32 hae_get_primomcip(void);
void hae_set_secdomcip(u32 secdomc_ip);
u32 hae_get_secdomcip(void);
void hae_init_sync(u8 fun_mod,u8 oid_len,u32 max_mem,u8 *data_ptr,void *shm_ptr);
int hae_set_master_flag(u8 fun_mod,u8 MasterFlag);
int hae_get_master_flag(u8 fun_mod);
int hae_inspect_master(u8 fun_mod);
int hae_set_period_flag(u8 fun_mod, u8 flag);
void hae_syncdata_proc(u8 fun_mod);
int hae_load_from_peer_resp(u8 fun_mod,snmp_pdu *pdu,snmp_addr *addr);
int hae_load_from_peer(u8 fun_mod);
int hae_peerdata_resp(u8 fun_mod,u8 oidLen,u32 *oid,u8 *pdata,u8 *vartype);
int hae_load_from_local(u8 fun_mod,char *file_name);
int hae_load_from_omc(u8 fun_mod);
int hae_back_to_omc(u8 fun_mod);
int hae_get_syncpercent( u8 fun_mod , u8 oidLen, u32 *oid );
#endif

View File

@@ -0,0 +1,37 @@
/* Define used head file */
/* Written by Liu Zhiguo V1.0 */
/* Time: 2003-07-31 */
/* ------------------------- */
#ifndef _HAE_INCLUDE
#define _HAE_INCLUDE
#include "../../../../plat/public/src/include/pub_include.h"
#include "../../../../plat/snmp/src/include/snmp.h"
#include "../../../../plat/sccp/src/include/sccp.h"
#include "../../../../plat/tcap/src/include/tcap_public.h"
#include "../../../../plat/tcap/src/include/tcap_proc.h"
#include "../../../../plat/xapp/src/mapp/map_code.h"
#include "../../../../plat/xapp/src/mapp/map_acn.h"
#include "../../../../plat/xapp/src/ixap.h"
#include "../../../../plat/xapp/src/mapp/map_public.h"
#include "../../../../plat/xapp/src/conv_prefix.h"
#include "hae_function.h"
#define HAE_AGENT_UDPPORT 4957 // agent udp port
#define HLR_SYNC_UDPPORT 4970 // UDP port for HLR sync process
#define AUC_SYNC_UDPPORT 4972
#define EIR_SYNC_UDPPORT 4969
#define TFTP_SRVC_PORT 4968
#define HAE_PER_PACK_LEN 1024 // one package length
typedef enum HAE_SYNC_MOD_ENUM
{
HLR_SYNC_MOD = 0,
AUC_SYNC_MOD,
EIR_SYNC_MOD,
HAE_SYNC_MOD_NUM,
} HAE_SYNC_MOD_ENUM;
#endif

99
plat/iptrans/Makefile Normal file
View 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 = iptrans
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 = ../../mss
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

Binary file not shown.

View File

@@ -0,0 +1,3 @@
#!/bin/bash
#gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -lcurses -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm
gcc -o iptrans ./src/iptrmain.c -Llib/ -liptrans -L../debug/lib -ldebug -L../snmp/lib -lsnmp -L../public/lib -lpublic -lm

BIN
plat/iptrans/iptrans Normal file

Binary file not shown.

BIN
plat/iptrans/iptrans_bak Normal file

Binary file not shown.

View File

@@ -0,0 +1,81 @@
/*
** CVS: $Id: comfunc.c,v 1.3 2001/01/20 19:58:49 zhangsz Exp $
**
** Title: comfunc.c
** Author: Zhang Shuzhong
** Date: 2000.07.03
**
** Description: Functions of comunication for PACS WLL.
**
*/
#include "../../public/src/include/includes.h"
/*
** passivesock - allocate & bind a server socket using TCP or UDP
*/
/*@ignore@*/
int
passivesock( const char * transport, u_short portbase, int qlen)
{
struct sockaddr_in sin;
int s, type;
memset(& sin, 0, sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_port = htons(portbase);
sin.sin_addr.s_addr = INADDR_ANY;
bzero(&(sin.sin_zero), 8);
if ( strcmp(transport, "UDP") == 0)
type = SOCK_DGRAM;
else
type = SOCK_STREAM;
s = socket(AF_INET, type, 0);
if (s < 0) {
perror("socket");
return -3;
}
if (bind(s, (struct sockaddr *) & sin, sizeof(sin)) < 0) {
perror("bind");
close(s);
return -4;
}
if (type == SOCK_STREAM && listen(s, qlen) < 0) {
perror("listen");
close(s);
return -5;
}
return s;
}
/*
** passiveUDP - create a passive socket for use in a UDP server
*/
int
passiveUDP(u_short portbase)
{
return (passivesock("UDP", portbase, 0) );
}
const char *
Inet_ntoa(const long addr)
{
struct sockaddr_in sin;
sin.sin_addr.s_addr = addr;
return ((char *) inet_ntoa(sin.sin_addr) );
}
const long
Inet_pton(const char *sp)
{
struct in_addr i_addr;
inet_pton(AF_INET, sp, &i_addr);
return i_addr.s_addr;
}
/*@end@*/

65
plat/iptrans/src/daemon.c Normal file
View File

@@ -0,0 +1,65 @@
/*
** CVS: $Id: daemon.c,v 1.4 2001/01/11 04:03:57 zhangsz Exp $
** daemon.c
** created at 2000/08/22
** By Zhang Shuzhong.
** Functions of daemon process.
*/
#include "./include/iptrans.h"
#include <sys/stat.h>
#include <fcntl.h>
#define MAXFD 64
/*@ignore@*/
int
InitDaemon(void)
{
pid_t pid;
if ( (pid = fork()) < 0)
return FAILURE;
else if (pid != 0)
exit(0); /* parent goes bye-bye */
/* child continues */
setsid(); /* become session leader */
// chdir("/"); /* change working direactory */
umask(0); /* clear our file mode creation mask */
return SUCCESS;
}
void
DaemonInit(const char *pname, int facility)
{
int i;
pid_t pid;
if ( (pid = fork()) < 0) /* parent terminates */
err_sys("%s: %s: fork (%d)",
FILE_MACRO, FUNCTION_MACRO, LINE_MACRO);
else if (pid != 0)
exit(0); /* parent goes bye-bye */
/* 41st child continues */
setsid(); /* become session leader */
signal(SIGHUP, SIG_IGN);
if ( (pid = fork()) < 0) /* 1st child terminates */
err_sys("%s: %s: fork (%d)",
FILE_MACRO, FUNCTION_MACRO, LINE_MACRO);
else if (pid != 0)
exit(0); /* 1st child goes bye-bye */
// chdir("/"); /* change working directory */
umask(0); /* clear our file mode creation mask */
for (i = 0; i < MAXFD; i++)
close(i);
openlog(pname, LOG_PID, facility);
}
/*@end@*/

114
plat/iptrans/src/error.c Normal file
View File

@@ -0,0 +1,114 @@
#include <stdio.h>
#include <errno.h> /* for definition of errno */
#include <stdarg.h> /* ANSI C header file */
#include <string.h>
#include "./include/iptrans.h"
static void err_doit(int, const char *, va_list);
char *pname = NULL; /* caller can set this from argv[0] */
/*
** Nonfatal error related to a system call.
** Print a message and return.
*/
/*@ignore@*/
void
err_ret(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error related to a system call.
** Print a message and terminate.
*/
void
err_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
exit(1);
}
/*
** Fatal error related to a system call.
** Print a message, dump core, and terminate.
*/
void
err_dump(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(1, fmt, ap);
va_end(ap);
abort(); /* dump core and terminate */
exit(1); /* shouldn't get here */
}
/*
** Nonfatal error unrelated to a system call.
** Print a message and return.
*/
void
err_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(0, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error unrelated to a system call.
** Print a message and terminate.
*/
void
err_quit(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
err_doit(0, fmt, ap);
va_end(ap);
exit(1);
}
/*
** Print a message and return to caller.
** Caller specifies "errnoflag".
*/
static void
err_doit(int errnoflag, const char *fmt, va_list ap)
{
int errno_save;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
vsprintf(buf, fmt, ap);
if (errnoflag)
sprintf(buf+strlen(buf), ": %s", strerror(errno_save));
strcat(buf, "\n");
fflush(stdout); /* in case stdout and stderr are the same */
fputs(buf, stderr);
fflush(NULL); /* flushes all stdio output streams */
return;
}
/*@end@*/

131
plat/iptrans/src/errorlog.c Normal file
View File

@@ -0,0 +1,131 @@
/* Error routines for programs that can run as a daemon. */
#include <errno.h> /* for definition of errno */
#include <stdarg.h> /* ANSI C header file */
#include <syslog.h>
#include "./include/iptrans.h"
static void log_doit(int, int, const char *, va_list ap);
int debug=1; /* caller must define and set this:
nonzero if interactive, zero if daemon */
int under_develop=1; /* caller must define and set this:
nonzero if under develop, zero if not */
/*@ignore@*/
/* Initialize syslog(), if running as daemon. */
void
log_open(const char *ident, int option, int facility)
{
if (debug == 0)
openlog(ident, option, facility);
}
/*
** Nonfatal error related to a system call.
** Print a message with the system's errno value and return.
*/
void
log_ret(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(1, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error related to a system call.
** Print a message and terminate.
*/
void
log_sys(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(1, LOG_ERR, fmt, ap);
va_end(ap);
exit(2);
}
/*
** Nonfatal error unrelated to a system call.
** Print a message and return.
*/
void
log_msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Debug message unrelated to a system call.
** Print a message and return while .
*/
void
log_debug(const char *fmt, ...)
{
va_list ap;
if (!under_develop) return;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
return;
}
/*
** Fatal error unrelated to a system call.
** Print a message and terminate.
*/
void
log_quit(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
log_doit(0, LOG_ERR, fmt, ap);
va_end(ap);
exit(2);
}
/*
** Print a message and return to caller.
** Caller specifies "errnoflag" and "priority".
*/
static void
log_doit(int errnoflag, int priority, const char *fmt, va_list ap)
{
int errno_save;
char buf[MAXLINE];
errno_save = errno; /* value caller might want printed */
vsprintf(buf, fmt, ap);
if (errnoflag)
sprintf(buf+strlen(buf), ": %s", strerror(errno_save));
strcat(buf, "\n");
if (debug) {
fflush(stdout);
fputs(buf, stderr);
fflush(stderr);
} else
syslog(priority, buf);
return;
}
/*@end@*/

View File

@@ -0,0 +1,3 @@
#!/bin/bash
gcc -o iptrans iptrmain.c -L../lib/ -liptrans -L../../debug/lib -ldebug -lcurses -L../../snmp/lib -lsnmp -L../../public/lib -lpublic -lm

View File

@@ -0,0 +1,23 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** module name: config.h
** CVS $Id: config.h,v 1.2 2001/01/11 04:07:56 zhangsz Exp $
**
** configuration of Prepaid System.
**
*/
#ifndef CONFIG__H
#define CONFIG__H
#define HAVE_FUNCTION_MACRO 1
#define HAVE_FILE_MACRO 1
#define HAVE_TIME_MACRO 1
#define HAVE_DATE_MACRO 1
#define HAVE_LINE_MACRO 1
#endif /* endof CONFIG__H */

View File

@@ -0,0 +1,37 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** file name: dbsync.h
** CVS $Id: dbsync.h,v 1.2 2001/02/08 10:53:33 zhangsz Exp $
**
** Defination for Database Synchronization (dbsync.c).
*/
#ifndef DBSYNC__H
#define DBSYNC__H
#include "iptrans.h"
#define DS_PORT_NO 4959 /* Prepaid service port */
#define DS_PORT_ID DS_PORT_NO - PORT_BASE_NUM
#define DS_SHM_KEY 0x80000000
#define DS_SHM_PERM 0664
#define DS_MSG_TYPE "D0"
#define DS_DBNAME_MAX_LEN 14
#define DS_SQLSCRIPT_MAX_LEN MAX_CONTENT_LEN-DS_DBNAME_MAX_LEN-2
typedef struct _dbsync_msg {
char type[2];
char db_name[DS_DBNAME_MAX_LEN];
char sql_script[DS_SQLSCRIPT_MAX_LEN];
} _dbsync_msg;
typedef struct ds_shm {
char time_created[15];
} ds_shm;
#endif /* DBSYNC__H */

View File

@@ -0,0 +1,53 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
**
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** file name: debug.h
** CVS $Id: debug.h,v 1.2 2001/01/20 19:58:49 zhangsz Exp $
**
** The debug information defination.
**
*/
#ifndef DEBUG__H
#define DEBUG__H
#include "config.h"
#define UNDER_DEVELOP 1
#define DEBUG 1
/* If we have these macros, we can add additional info to the header. */
#ifdef HAVE_FILE_MACRO
#define FILE_MACRO (__FILE__)
#else
#define FILE_MACRO ("")
#endif
#ifdef HAVE_FUNCTION_MACRO
#define FUNCTION_MACRO (__FUNCTION__)
#else
#define FUNCTION_MACRO ("")
#endif
#ifdef HAVE_DATE_MACRO
#define DATE_MACRO (__DATE__)
#else
#define DATE_MACRO ("")
#endif
#ifdef HAVE_TIME_MACRO
#define TIME_MACRO (__TIME__)
#else
#define TIME_MACRO ("")
#endif
#ifdef HAVE_LINE_MACRO
#define LINE_MACRO (__LINE__)
#else
#define LINE_MACRO ("")
#endif
#endif /* DEBUG__H */

View File

@@ -0,0 +1,39 @@
/*
** Error and log proccess functions header file,
** to be included *after* all standard system headers
**
** CVS: $Id: errlog.h,v 1.2 2001/01/11 04:03:57 zhangsz Exp $
*/
#ifndef ERRLOG__H
#define ERRLOG__H
#include <sys/types.h> /* required for some of our prototypes */
#include <stdio.h> /* for convenience */
#include <stdlib.h> /* for convenience */
#include <string.h> /* for convenience */
#include <unistd.h> /* for convenience */
/* default file access permissions for new files */
#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
/* default permissions for new directories */
#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
#define log_flag() \
log_debug("%s: %s: %d", FILE_MACRO, FUNCTION_MACRO, LINE_MACRO)
void err_dump(const char *, ...); /* {App misc_source} */
void err_msg(const char *, ...);
void err_quit(const char *, ...);
void err_ret(const char *, ...);
void err_sys(const char *, ...);
void log_debug(const char *, ...); /* {App misc_source} */
void log_msg(const char *, ...); /* {App misc_source} */
void log_open(const char *, int, int);
void log_quit(const char *, ...);
void log_sys(const char *, ...);
void log_ret(const char *, ...);
#endif /* ERRLOG__H */

View File

@@ -0,0 +1,127 @@
/*
** CVS: $Id: function.h,v 1.6 2001/02/08 10:53:33 zhangsz Exp $
**
** function.h
** Created at 2000/07/23
** public domain code by Zhang Shuzhong
**
** Description: Header file of function definations.
*/
#ifndef FUNCTION__H
#define FUNCTION__H
#define DisplayContent(buf, bcd_buf, nbytes) \
BcdToAscii(buf, bcd_buf, 2 * nbytes); \
FormatOutput(buf, 2*nbytes, 2, ' '); \
log_debug("packets contains (%s):\n%s", FUNCTION_MACRO, buf);
#define BzeroContent(content, length) \
bzero(content+length, MAX_CONTENT_LEN-length);
#define WriteOutBuffer WriteToOutBuffer
#define WriteToOutBuffer(PROG_NAME, ip_semid, poutbuf, pbuf) \
SemLock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \
WriteMsg((in_buffer *) poutbuf, pbuf, OUT_LIST_NUM); \
SemUnlock(PROG_NAME, ip_semid, PORT_NUM, 1, IPC_NOWAIT); \
SemUnlock(PROG_NAME, ip_semid, SEM_NUM-1, 1, IPC_NOWAIT);
#define ReadInBuffer ReadFromInBuffer
#define ReadFromInBuffer(PROG_NAME, ip_semid, port_id, pinbuf, pbuf) \
SemLock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \
ReadMsg((in_buffer *) pinbuf, pbuf, IN_LIST_NUM); \
SemUnlock(PROG_NAME, ip_semid, port_id, 1, IPC_NOWAIT); \
int InitDaemon(void); /* Initialize a daemon process */
void
SetTermSignal(struct termio *ptermio, void (*handler)(int));
/* Initialize a daemon process */
void DaemonInit(const char *pname, int);
/* passive a socket handler, from comfunc.c */
int passivesock( const char * transport, u_short portbase, int qlen);
/* passive a UDP socket handler, from comfunc.c */
int passiveUDP(u_short portbase);
/* Fill string 'c' into last area of 'str'. */
void StringCat(char *str, char *c, int slen);
int ByteLength(BYTE *bcd, int c);
/* Cut string while match character c. */
void StringCut(char *str, int c);
void Bstr2Hstr(char *cptr);
void bitstring(char *str, long byze, int biz, int strwid);
/* Binary string convert to int. */
unsigned int Bstr2Int(char *cptr);
/* Hex string convert to int. */
unsigned int Hstr2Int(char *cptr);
/* Get current hour */
int gethour(char * hour_buf);
int getweek(char * week_buf);
/* Get current hour */
int getmin(char * min_buf);
/* Convert data from ASCII form to left-aligned compact BCD form. */
void AsciiToBcd (BYTE *bcd_buf, const char *ascii_buf, int len);
/* Convert data from left-aligned compact BCD form to ASCII form. */
void BcdToAscii (char *ascii_buf, const BYTE *bcd_buf, int len);
/* Convert data from ASCII form to right-aligned compact BCD form. */
void AsciiToRbcd (BYTE *bcd_buf, const char *ascii_buf, int len);
const char *
getdaytime(char *daytime_buf);
char *GetASCTime(char *timep);
void *
ShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg);
int
SemInit(char *prog_name, key_t key, int sem_num, int sem_flg);
BOOL
SemLock(char *prog_name, int sem_id, int sem_num,
unsigned nsops, int sem_flg);
BOOL
SemUnlock(char *prog_name, int sem_id, int sem_num,
unsigned nsops, int sem_flg);
BOOL
ReadMsg(void *pbuf, void *pmsg, int max_num);
BOOL
WriteMsg(void *pbuf, void *pmsg, int max_num);
const char *
Inet_ntoa(const long addr);
const long
Inet_pton(const char *sp);
char *
FormatOutput(char *sp, size_t, int, int);
void
ByteReverse(BYTE *p1, BYTE *p2, size_t size);
void
SafeFree(void *pmem);
void
GetAsciiField(char *dest, BYTE *src, size_t n);
#endif

View File

@@ -0,0 +1,47 @@
/*
** CVS $Id: includes.h,v 1.3 2001/02/08 10:53:33 zhangsz Exp $
** includes.h
** Created at 2000-10-17
** by Zhang SZ.
** Include all header files of PACS-WLL 2000 Project.
*/
#ifndef INCLUDES__H
#define INCLUDES__H
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/wait.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <time.h>
#include <net/if.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include "public.h"
#include "function.h"
#include "errlog.h"
#include "debug.h"
#ifndef NO_CONFIG_H
#include "config.h"
#endif
#endif /* INCLUDES__H */

View File

@@ -0,0 +1,201 @@
/*
**
**
** file name:
**
** header file include by IP transceiver.
** defination of shared memory structure.
**
*/
#ifndef IPTRANS__H
#define IPTRANS__H
#include "../../../public/src/include/includes.h"
#include "../../../public/src/include/public.h"
#include "../../../public/src/include/pub_fmt.h"
#include "errlog.h"
#include "debug.h"
#ifndef NO_CONFIG_H
#include "config.h"
#endif
#define IN_LIST_NUM 200 /* list number of in_buffer that
can store in the buffer space
*/
#define DS_LIST_NUM IN_LIST_NUM
#define OUT_LIST_NUM 1024 /* list number of out_buffer that
can store in the buffer space
*/
#define PORT_IN_NUM 24 /* number of in port defined */
#define PORT_DS_NUM 1 /* number of port to database sync process */
#define PORT_OUT_NUM 1 /* number of out port defined */
#define PORT_NUM PORT_IN_NUM /* pre-defined port number */
/* Port service */
#define PORT_BASE_NUM 4950 /* minimum port number */
#define MAX_CONTENT_LEN 1514
/* IP transceiver shared memory ipc key and permission */
#define IPTRANS_SHM_KEY 0x60000000
#define IPTRANS_SHM_PERM 0777
#define IPTRANS_DEBUG_SHM 0x61610000
#define IPTRANS_DEBUG_PERM 0664
/* IP transceiver semaphore ipc key and permission */
#define RELEASE 1 /* release semaphore */
#define ACQUIRE -1 /* acquire semaphore */
#define MAX_STATISTICS_SEG 96
#define _msg_list message_list
typedef struct message_list {
unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
unsigned int msgDstIP; //long msgDstIP; /* ip number of Destination host */
u_short msgDstPort; /* port of Destination host */
int msgBroadcast; /* message sent with broadcast mode,
0(default)/1=no/yes.
*/
u_short msgLength; /* message's length */
BYTE msgContent[MAX_CONTENT_LEN]; /* message of packet received */
} message_list;
typedef struct ds_msg {
unsigned int msgSrcIP; //long msgSrcIP; /* ip number of source host */
u_short msgSrcPort; /* port of source host */
unsigned int msgDstIP; //long msgDstIP; /* ip number of Destination host */
u_short msgDstPort; /* port of Destination host */
int msgBroadcast; /* message sent with broadcast mode,
0(default)/1=no/yes.
*/
u_short msgLength; /* message's length */
char msgContent[MAX_CONTENT_LEN]; /* message of packet received */
} db_msg;
typedef struct ds_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
db_msg msgList[DS_LIST_NUM]; /* message list buffer */
} ds_buffer;
#define _in_buffer in_buffer
typedef struct in_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
message_list msgList[IN_LIST_NUM]; /* message list buffer */
} in_buffer;
#define _out_buffer out_buffer
typedef struct out_buffer {
u_short msgReadSub; /* subscript of array msgList for reader */
u_short msgWriteSub; /* subscript of array msgList for writer */
message_list msgList[OUT_LIST_NUM]; /* message list buffer */
} out_buffer;
#define _port_stat port_stat
typedef struct port_stat {
short portStatus; /* port status:
0=idle 1=normal -1=abnormal
*/
DWORD inPackets; /* number of packets received */
DWORD inBytes;
DWORD outPackets; /* number of packets sent */
DWORD outBytes;
DWORD errorPackets; /* number of error packets received */
} port_stat;
/*
#define _port_stat port_stat
typedef struct port_stat{
port_stat_15m port_stat_static[PORT_NUM];
}port_stat;
*/
typedef struct debug_info
{
DWORD debug_status_id[20];
BYTE debug_status;
DWORD debug_ascin_id[20];
DWORD debug_ascout_id[20];
DWORD debug_name_id[20];
DWORD debug_page_title[20];
DWORD debug_page_line[20];
BYTE title0_p[1024];
BYTE title1_p[1024];
BYTE title2_p[1024];
BYTE title3_p[1020];
char iptr_asciin_buf[4096];
char iptr_asciout_buf[4096];
BYTE port_onoff[PORT_NUM];
BYTE port_status[PORT_NUM]; //overflow
BYTE resettimer[4];
DWORD logflag;
DWORD srclog;
DWORD dstlog;
}debug_info;
typedef struct port_configure
{
BYTE port_config[PORT_NUM];
}port_configure;
typedef struct iptrans_cdr_rec
{
DWORD inPackets;
DWORD inBytes;
DWORD outPackets;
DWORD outBytes;
DWORD errorPackets;
}iptrans_cdr_rec;
typedef struct iptrans_cdr_period
{
iptrans_cdr_rec cdr_record[PORT_NUM];
}iptrans_cdr_period;
typedef struct snmp_info
{
BYTE process_conf;
BYTE version[3];
//port_configure port_conf;
//PORT STATUS ; debug_info.port_status
iptrans_cdr_period iptrans_cdr[96];
}snmp_info;
#define _iptrans_shm iptrans_shm
typedef struct iptrans_shm { /* type defination of IP transceiver
shared memory
*/
in_buffer msgPortIn[PORT_NUM]; /* message in_buffer defination,
a port buffer attach only a
application module.
*/
out_buffer msgPortOut;
out_buffer msgPlatPortOut;
} iptrans_shm;
typedef struct _iptrans_status
{
port_stat msgPortStat[PORT_NUM];
debug_info debug_msg;
snmp_info snmp_data;
}iptrans_status;
int iptrans_init();
void iptrans_timer();
int iptrMainInit();
int iptrGetMessage(message_list *msgGet, int port);
int iptrDirectRecvMsg(message_list *msgGet, u_short port);
int iptrPutMessage(message_list msgPut);
int iptrDirectSendMsg(message_list msgPut);
int iptrPlatPutMessage(message_list msgPut);
int set_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD datalen);
int get_iptrans(BYTE oidlen, DWORD *oid, BYTE *pdata, WORD *vartype);
int trap_iptrans(BYTE oidlen, DWORD *oid_ptr, BYTE *msg_ptr, BYTE msg_len);
int CloseTcpConn();
extern void *iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg);
#endif /* IPTRANS__H */

View File

@@ -0,0 +1,9 @@
#ifndef _IPTR_FUNCTION
#define _IPTR_FUNCTION
int init_iptrans();
void iptr_timer_IRQ();
void iptrans_close();
#endif

View File

@@ -0,0 +1,93 @@
/*
** CVS $Id: ipcfunc.c,v 1.4 2001/01/20 19:58:49 zhangsz Exp $
**
** ipcfunc.c
** created at 2000/12/20
** by Zhang SZ
**
** IPC functions for PACS-WLL project.
**
*/
#include "./include/iptrans.h"
/*@ignore@*/
void *
iptrShmInit(int shm_id, char *prog_name, key_t key, int size, int shmflg)
{
void *retp;
char *func_name = "ShmInit";
shm_id = shmget(key, size, shmflg);
if (shm_id == -1)
{
log_sys("%s: %s: shmget(key: %x)", prog_name, func_name, key);
return NULL;
}
retp = shmat(shm_id, (char *)0, 0);
if (retp == (void *) -1)
{
log_sys("%s: %s: shmat", prog_name, func_name);
return NULL;
}
return retp;
}
int
iptrSemInit(char *prog_name, key_t key, int sem_num, int sem_flg)
{
int initarray[sem_num];
int sem_id, retval, i;
char *func_name = "SemInit";
sem_id = semget(key, sem_num, sem_flg);
if (sem_id == -1)
log_sys("%s: %s: semget", prog_name, func_name);
for (i=0; i<sem_num; i++) {
initarray[i] = 1;
retval = semctl(sem_id, i, SETVAL, initarray[i]);
if (retval == -1)
log_sys("%s: %s: semctl", prog_name, func_name);
}
return sem_id;
}
BOOL
iptrSemLock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg)
{
int retval;
struct sembuf lock = {0, ACQUIRE, SEM_UNDO};
lock.sem_num = sem_num;
lock.sem_flg |= sem_flg;
retval = semop(sem_id, &lock, nsops);
if (retval == -1) {
// char *func_name = "SemLock";
// log_ret("%s: %s: semop(%d)", prog_name, func_name, sem_num);
return FAILURE;
}
return SUCCESS;
}
BOOL
iptrSemUnlock(char *prog_name, int sem_id, int sem_num, unsigned nsops, int sem_flg)
{
int retval;
struct sembuf unlock = {0, RELEASE, IPC_NOWAIT|SEM_UNDO};
unlock.sem_num = sem_num;
unlock.sem_flg |= sem_flg;
retval = semop(sem_id, &unlock, nsops);
if (retval == -1) {
// char *func_name = "SemUnlock";
// log_ret("%s: %s: semop(%d)", prog_name, func_name, sem_num);
return FAILURE;
}
return SUCCESS;
}
/*@end@*/

View File

@@ -0,0 +1,51 @@
#include <sys/ipc.h>
#include "./include/iptrans.h"
static iptrans_shm *IPTRANS_shm_ptr;
static int IPTRANS_shm_id;
/*@ignore@*/
int iptransCreate()
{
IPTRANS_shm_ptr = (iptrans_shm *)ShmInit(IPTRANS_shm_id,"iptrans",IPTRANS_SHM_KEY,
sizeof(iptrans_shm),IPTRANS_SHM_PERM | IPC_CREAT);
}
int GetMessage(message_list *msgGet,int port_in)
{
int port;
port=port_in-PORT_BASE_NUM;
if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub !=
IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub)
{
memcpy(msgGet,
&IPTRANS_shm_ptr->msgPortIn[port].msgList[IPTRANS_shm_ptr->msgPortIn[port].msgReadSub],
sizeof(struct message_list));
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub++;
if(IPTRANS_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM)
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0;
return 1;
}
return 0;
}
int PutMessage(message_list msgPut)
{
memcpy(&IPTRANS_shm_ptr->msgPortOut.msgList[IPTRANS_shm_ptr->msgPortOut.msgWriteSub],
&msgPut, sizeof(struct message_list));
IPTRANS_shm_ptr->msgPortOut.msgWriteSub ++;
if(IPTRANS_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM)
IPTRANS_shm_ptr->msgPortOut.msgWriteSub=0;
return 0;
}
int clearPort(int port_in)
{
int port;
port=port_in-PORT_BASE_NUM;
IPTRANS_shm_ptr->msgPortIn[port].msgReadSub=0;
IPTRANS_shm_ptr->msgPortIn[port].msgWriteSub=0;
return 1;
}
/*@end@*/

1864
plat/iptrans/src/iptrans.c Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

100
plat/iptrans/src/iptrmain.c Normal file
View File

@@ -0,0 +1,100 @@
#include "./include/iptrans.h"
extern void iptrans_timer();
/*@ignore@*/
void init_timer_interrupt(void)
{
struct sigaction newact;
newact.sa_handler =iptrans_timer;
newact.sa_flags =0;
sigemptyset(&newact.sa_mask);
sigaction(SIGALRM,&newact,NULL);
}
void setup_interval_timer(void)
{
struct itimerval value;
value.it_interval.tv_sec =0;
value.it_interval.tv_usec =10*1000;
value.it_value.tv_sec = 0;
value.it_value.tv_usec = 10*1000;
setitimer(ITIMER_REAL,&value,NULL);
}
void init_timer()
{
init_timer_interrupt();
setup_interval_timer();
}
void interrupt_handler(int signo)
{
CloseTcpConn();
}
int initSystem()
{
struct sigaction act;
//close(0);
//close(1);
//close(2);
act.sa_handler = interrupt_handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if(sigaction(SIGPIPE,&act,NULL)<0)
fprintf(stderr,"set signal failed\n");
system("sysctl -w net.ipv4.tcp_keepalive_time=20");
system("sysctl -w net.ipv4.tcp_keepalive_probes=2");
return 1;
}
int
main(int argc, char *argv[])
{
int err_flag = FALSE;
int test_mode = FALSE;
int ret;
SetDebugFlag();
/*
** Get option from command line.
** option 'd' is enable to run program with daemon mode.
*/
while ((ret = getopt(argc, argv, "dt")) != -1)
switch (ret)
{
case 'd':
/* Set daemon mode and open a syslog */
DaemonInit("IPTRANS", LOG_USER);
break;
case 't':
test_mode = TRUE; /* test mode: bind port 4950 to recvfrom */
break;
case '?':
err_flag = TRUE;
}
if (err_flag) {
log_msg("Usage: %s -d -t \n", argv[0]);
log_msg(" -d with daemon mode");
log_msg(" -t with test mode");
exit(1);
}
debug_init();
initSystem();
iptrMainInit();
init_timer();
while(1){
usleep(1);
}
exit(0);
}
/*@end@*/

View File

@@ -0,0 +1,59 @@
#include "./include/iptrans.h"
/*@ignore@*/
int
mcast_join(int sockfd, struct sockaddr *sa, socklen_t salen,
const char *ifname,u_int ifindex)
{
u_char flag=1;
int len;
struct hostent *myhost;
switch(sa->sa_family)
{
case AF_INET:{
struct ip_mreq mreq;
struct ifreq ifreq;
memcpy(&mreq.imr_multiaddr,
&((struct sockaddr_in *)sa)->sin_addr,
sizeof(struct in_addr));
if(ifindex>0){
if(if_indextoname(ifindex,ifreq.ifr_name)==NULL){
// errno=ENXIO;
return(-1);
}
goto doioctl;
}
else if(ifname !=NULL){
strncpy(ifreq.ifr_name,ifname,IFNAMSIZ);
doioctl:
if(ioctl(sockfd,SIOCGIFADDR,&ifreq)<0)
return (-1);
memcpy(&mreq.imr_interface.s_addr,
&((struct sockaddr_in *)&ifreq.ifr_addr)->sin_addr,
sizeof(struct in_addr));
return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,
&mreq,sizeof(mreq)));
}
else
mreq.imr_interface.s_addr=htonl(INADDR_ANY);// inet_addr(name);
// setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_IF,&flag,sizeof(flag));
return (setsockopt(sockfd,IPPROTO_IP,IP_ADD_MEMBERSHIP,
&mreq,sizeof(mreq)));
}
default:
// errno=EPROTONOSUPPORT;
return(-1);
}
}
int
mcast_set_loop(int sockfd, int onoff)
{
u_char flag;
flag=onoff;
return (setsockopt(sockfd,IPPROTO_IP,IP_MULTICAST_LOOP,
&flag,sizeof(flag)));
}
/*@end@*/

View File

@@ -0,0 +1,133 @@
/*
** CVS $Id: queuefunc.c,v 1.3 2001/02/08 10:53:33 zhangsz Exp $
**
** filename: queuefunc.c
** created at 2000/12/29
** by Zhang Shuzhong
**
** loop message queue operating functions.
**
*/
#include "./include/iptrans.h"
extern u_char warningFlag;
/*@ignore@*/
/* Read a message from loop queue. */
BOOL
iptrReadMsg(void *pbuf, void *pmsg, int max_num)
{
in_buffer *p;
message_list *msg_ptr;
p = (in_buffer *) pbuf;
msg_ptr = (message_list *) pmsg;
// memset(msg_ptr, EMPTY, sizeof(struct message_list));
/*
** these are some messages not to be read
** while subscript of read isn't equal to subscipt of write.
*/
if (p->msgReadSub == p->msgWriteSub)
return FAILURE;
memcpy(msg_ptr, &p->msgList[p->msgReadSub],
p->msgList[p->msgReadSub].msgLength + 44);
/*message head length */
// sizeof(struct message_list));
/*
** increase READ SUBSCRIPT after got a message,
** set READ SUBSCRIPT to 0 while it equal to max_num.
*/
p->msgReadSub ++;
if (p->msgReadSub == max_num)
p->msgReadSub = 0;
return SUCCESS;
}
/* Write a message to loop queue. */
BOOL
iptrWriteMsg(void *pbuf, void *pmsg, int max_num)
{
in_buffer *p;
message_list *msg_ptr;
int port;
p = (in_buffer *) pbuf;
msg_ptr = (message_list *) pmsg;
memcpy(&p->msgList[p->msgWriteSub], msg_ptr,
msg_ptr->msgLength + 44);//sizeof(struct message_list));
p->msgWriteSub ++;
/*
** if write subscript more than max_num,
** write subscript equal 0.
*/
if (p->msgWriteSub == max_num)
p->msgWriteSub = 0;
/*
** if message written successful,
** Read subscript is same as Write subscript,
** then Read subsrcipt add 1.
*/
if (p->msgReadSub == p->msgWriteSub)
{
(p->msgReadSub == max_num-1) ?
(p->msgReadSub = 0) : (p->msgReadSub ++);
if(warningFlag){
port = msg_ptr->msgDstPort;
SetAsciioutMsg(1,"Warning! Port: %d overflowed!\r\n",port);
return 0;
}
}
return 1;
}
void
iptrByteRev(BYTE *pbuf, BYTE *p, size_t size)
{
int i;
char ch;
for (i=0; i<size; i++) {
ch = *(pbuf++) >> 4;
*pbuf <<= 4;
*pbuf &= ch;
}
memcpy(p, pbuf, size);
}
void
iptrStrrev(char *sp)
{
char ch;
ch = sp[0];
sp[0] = sp[1];
sp[1] = ch;
}
void
iptrByteReverse(BYTE *pbuf, BYTE *p, size_t size)
{
int i;
char *sp=NULL, tmpbuf[3];
sp = (char *) malloc(4*size + 1);
bzero(p, size);
for (i=0; i<2*size; i+=2) {
sprintf(tmpbuf, "%02x", *(pbuf++));
tmpbuf[2]=0;
iptrStrrev(tmpbuf);
strncpy(sp+i, tmpbuf, 2);
}
AsciiToBcd(pbuf, sp, 4*size);
memcpy(p, pbuf, 2*size);
free(sp);
}
/*@end@*/

189
plat/iptrans/src/readmsg.c Normal file
View File

@@ -0,0 +1,189 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** file name: iptrans.c
** CVS: $Id: iptrans.c,v 1.9 2001/02/09 08:53:43 zhangsz Exp $
**
** Description: IP transceiver common module of PACS-WLL Project.
**
*/
#include "./include/iptrans.h"
#define PROG_NAME "iptrans"
extern int debug; /* defined in errorlog.c */
extern int under_develop; /* defined in errorlog.c */
static int iptrans_shm_id;
static int iptrans_sem_id;
static struct termio prev_termio;
static iptrans_shm *iptrans_shm_ptr;
int GetMessage(message_list *msgGet,int port);
void PutMessage(message_list msgPut);
/*@ignore@*/
/* Set debug flag to control debug message print or not */
void SetDebugFlag(void)
{
debug = DEBUG; /* DEBUG defined in debug.h */
under_develop = UNDER_DEVELOP; /* UNDER_DEVELOP defined in debug.h */
}
/*
** Handler of terminatation,
** process while received a signal from user.
*/
static void Terminate(int sig)
{
int retval, i;
usleep(100000);
retval = (int) shmdt(0);
if (retval == -1) log_ret("%s: %s: shmdt", PROG_NAME, FUNCTION_MACRO);
retval = shmctl(iptrans_shm_id, IPC_RMID, NULL);
if (retval == -1) log_ret("%s: %s: shmctl", PROG_NAME, FUNCTION_MACRO);
retval = semctl(iptrans_sem_id, PORT_NUM, IPC_RMID, NULL);
if (retval == -1) log_ret("%s: %s: semctl", PROG_NAME, FUNCTION_MACRO);
exit(sig);
}
int GetMessage(struct message_list *msgGet,int port)
{
message_list msgSend;
if(iptrans_shm_ptr->msgPortIn[port].msgReadSub != iptrans_shm_ptr->msgPortIn[port].msgWriteSub)
{
memcpy(msgGet,
&iptrans_shm_ptr->msgPortIn[port].msgList[iptrans_shm_ptr->msgPortIn[port].msgReadSub],
sizeof(struct message_list));
memcpy(&msgSend,msgGet,sizeof(struct message_list));
PutMessage(msgSend);
fprintf(stderr,"Recv msg %d.\n",port+4951);
iptrans_shm_ptr->msgPortIn[port].msgReadSub ++;
if(iptrans_shm_ptr->msgPortIn[port].msgReadSub==IN_LIST_NUM)
iptrans_shm_ptr->msgPortIn[port].msgReadSub =0;
/*
fprintf(stderr,"iptrans state:\n port=%d\n packet in=%ld out=%ld errors=%ld %ld\n",
port,
iptrans_shm_ptr->msgPortStat[port].inPackets,
iptrans_shm_ptr->msgPortStat[port].outPackets,
iptrans_shm_ptr->msgPortStat[port].errorInPackets,
iptrans_shm_ptr->msgPortStat[port].errorOutPackets);
*/
return 1;
}
else
{
return 0;
}
}
void PutMessage(struct message_list msgPut)
{
memcpy(&iptrans_shm_ptr->msgPortOut.msgList[iptrans_shm_ptr->msgPortOut.msgWriteSub],
&msgPut,sizeof(struct message_list));
iptrans_shm_ptr->msgPortOut.msgWriteSub ++;
if(iptrans_shm_ptr->msgPortOut.msgWriteSub==OUT_LIST_NUM)
iptrans_shm_ptr->msgPortOut.msgWriteSub=0;
}
void timer_IRQ()
{
int i;
struct message_list msgList;
for(i=0;i<13;i++)
{
GetMessage(&msgList,i);
// PutMessage(msgList);
}
}
void init_timer_interrupt(void)
{
struct sigaction newact;
newact.sa_handler =timer_IRQ;
newact.sa_flags =0;
sigemptyset(&newact.sa_mask);
sigaction(SIGALRM,&newact,NULL);
}
void setup_interval_timer(void)
{
struct itimerval value;
value.it_interval.tv_sec =0;
value.it_interval.tv_usec =5*1000;
value.it_value =value.it_interval;
setitimer(ITIMER_REAL,&value,NULL);
}
void init_timer()
{
init_timer_interrupt();
setup_interval_timer();
}
int
main(int argc, char *argv[])
{
int err_flag = FALSE;
int test_mode = FALSE;
int ret;
SetDebugFlag();
/*
** Get option from command line.
** option 'd' is enable to run program with daemon mode.
*/
while ((ret = getopt(argc, argv, "dt")) != -1)
switch (ret)
{
case 'd':
/* Set daemon mode and open a syslog */
DaemonInit(PROG_NAME, LOG_USER);
break;
case 't':
test_mode = TRUE; /* test mode: bind port 4950 to recvfrom */
break;
case '?':
err_flag = TRUE;
}
if (err_flag) {
log_msg("Usage: %s -d -t \n", argv[0]);
log_msg(" -d with daemon mode");
log_msg(" -t with test mode");
exit(1);
}
/*
** Get shared memory block,
** IPTRANS_SHM_KEY to be defined in iptrans.h.
*/
iptrans_shm_ptr = (iptrans_shm *) ShmInit(iptrans_shm_id, PROG_NAME,
IPTRANS_SHM_KEY, sizeof(iptrans_shm), IPTRANS_SHM_PERM|IPC_CREAT);
memset(iptrans_shm_ptr, 0, sizeof(iptrans_shm));
/*
** Get semaphores ID used by shared memory block,
** IPTRANS_SEM_KEY to be defined in iptrans.h.
*/
SetTermSignal(&prev_termio, Terminate);
/*
** Open socket handler for IP transceiver.
** maxinum number is PORT_NUM.
*/
init_timer();
while(1){
usleep(1);
}
exit(0);
}
/*@end@*/

33
plat/iptrans/src/signal.c Normal file
View File

@@ -0,0 +1,33 @@
/*
** PACS-WLL 2000 project, Prepaid System.
**
** The module Copyright (C) 2000-2001 interWAVE Inc.
**
** Written completely by Zhang Shuzhong at iCRD January, 2001
**
** module name: signal.c
** CVS $Id: signal.c,v 1.2 2001/01/11 04:07:56 zhangsz Exp $
**
** Signal functions
**
*/
#include "./include/iptrans.h"
/*
** Set termination signal in a loop program,
** handler of function mostly deal with something,
** e.g. closing file handler, socket handler or free allocatied memory.
*/
/*@ignore@*/
void
SetTermSignal(struct termio *ptermio, void (*handler)(int))
{
ioctl(0, TCGETA, ptermio);
ptermio->c_cc[VINTR] = '\x03';
ioctl(0, TCSETA, ptermio);
signal(SIGINT, handler);
signal(SIGTERM, handler);
}
/*@end@*/

View File

@@ -0,0 +1,21 @@
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
/*@ignore@*/
int main()
{
debug_init();
init_iptrans();
snmp_init(4957);
// heartbeat_init(0);
while(1)
{
debug_rt();
snmp_timer();
// heartbeat_timer();
usleep(1);
}
return 1;
}
/*@end@*/

99
plat/isdn/Makefile Normal file
View 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 = isdn
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 = ../../mss
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

Binary file not shown.

35
plat/isdn/src/Makefile Normal file
View File

@@ -0,0 +1,35 @@
#Create by Chen Gengxin
#2008-03-03
#WXC2 R9.0 ISDN makefile
CC = gcc
CFLAG = -g -Wall -c #-fprofile-arcs -ftest-coverage
ISDN_LIB_OBJ = isdn_msg.o isdn_fsm.o isdn_uif.o isdn_rm.o isdn_ie.o isdn_debug.o
all: $(ISDN_LIB_OBJ)
# ar -r libfsm.a $(ISDN_LIB_OBJ)
#test_sdl: $(ISDN_LIB_OBJ)
# $(cc) -o $@ $< ../kernel/sched.o
isdn_msg.o: isdn_msg.c ./include/isdn_msg.h ./include/isdn_ext.h ./include/isdn_const.h
$(CC) $(CFLAG) $<
isdn_fsm.o: isdn_fsm.c
$(CC) $(CFLAG) $<
isdn_uif.o: isdn_uif.c ./include/isdn_if.h
$(CC) $(CFLAG) $<
isdn_rm.o: isdn_rm.c ./include/isdn_rm.h
$(CC) $(CFLAG) $<
isdn_ie.o: isdn_ie.c ./include/isdn_ie.h
$(CC) $(CFLAG) $<
isdn_debug.o: isdn_debug.c
$(CC) $(CFLAG) $<
clean:
rm -f main *.o *.a *.xml *.gcov *.gcda *.gcno test_sdl core

View File

@@ -0,0 +1,275 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_const.h
Description: ISDN const define
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-24
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_CONST_H
#define _ISDN_CONST_H
//#define PROTO_ISDN 3
//user - network interface
#define NETWORK_SIDE 0
#define USER_SIDE 1
#define ISDN_IP_PORT 4958 //4951 4953
//NFAS
#define NFAS_DISABLE 0x00
#define NFAS_ENABLE 0x01
//priority
#define REATTEMPT 0x00
#define DISCARD 0x01
//run_mode
#define ISDN_SINGLE_MODE 0x00 /* Single Plat */
#define ISDN_DUAL_MODE 0x01 /* Dual Plat */
//call state
#define IDLE_FLAG 0x00
#define CALLIN_FLAG 0x01
#define CALLOUT_FLAG 0x02
//timer_flag
#define DC_M_FLAG 0x04
#define BC_M_FLAG 0x08
//ansi isdn maintenance state
//D-channel state
#define DS_MOOS 0x00 //In Service
#define DS_IS 0x01 //Maintenance Busy
#define DS_OOS 0x02 //Out Of Service
#define DS_STBY 0x04 //Standby
#define DS_WAIT 0x08 //Wait
#define DS_MB 0x10 //Manual Out Of Service
#define DS_INB 0x12 //Installation Busy
//B-channel state
#define IN_SERVICE 0x00
#define MAINTENANCE_SERVICE 0x01
#define OUT_OF_SERVICE 0x02
//iua link state
#define LK_OOS 0x00
#define LK_IS 0x01
/************************************************************
ISDN message type
************************************************************/
#define PROTOCOL_ISDN_LINK_MNG 0xFE
#define PROTOCOL_DISCR 0x08 //Q.931 Protocol discriminator
//Call establishment message
#define MSG_ALERT 0x01 //Alerting
#define MSG_CALL_PROC 0x02 //Call Proceeding
#define MSG_CONN 0x07 //Connect
#define MSG_CONNACK 0x0F //Connect Acknowledge
#define MSG_PROG 0x03 //Progress
#define MSG_SETUP 0x05 //Setup
#define MSG_SETUP_ACK 0x0D //Setup Acknowledge
//Call clearing message
#define MSG_DISC 0x45 //Disconnect
#define MSG_REL 0x4D //Release
#define MSG_REL_COMP 0x5A //Release Complete
#define MSG_RESTART 0x46 //Restart
#define MSG_REST_ACK 0x4E //Restart Acknowledge
//Miscellaneous message
#define MSG_INFORMATION 0x7B //Information
#define MSG_NOTI 0x6E //Notify
#define MSG_STATUS 0x7D //Status
#define MSG_STAT_ENQ 0x75 //Status Enquiry
#define MSG_FAC 0x62 //Facility (connectionless)
//Maintenance message
#define M_PROTOCOL_DISCR 0x43 //Maintenance messages Protocol discriminator
#define MSG_SERVICE 0x0F //Service
#define MSG_SERVICE_ACK 0x07 //Service Acknowledge
/************************************************************
ISDN information element identifier coding
************************************************************/
//Single octet information elements
#define IE_SHIFT 0x01 //Shift
#define IE_MORE_DATA 0xA0 //More data
#define IE_SD_COMP 0xA1 //Send Complete
#define IE_RPT_IND 0xD2 //Repeat indicator
//Variable length information element
#define IE_BR_CAP 0x04 //Bearer capability
#define IE_CAUSE 0x08 //Cause
#define IE_CALL_ID 0x10 //Call identifier
#define IE_CALL_STAT 0x14 //Call state
#define IE_CHNL_ID 0x18 //Channel identification
#define IE_PRG_IND 0x1E //Progress indicator
#define IE_NT_SP_FAC 0x20 //Network-specific facilities
#define IE_NOTIFY_IND 0x27 //Notification indicator
#define IE_DISP 0x28 //Display
#define IE_DT_TIME 0x29 //Date/time
#define IE_KPD_FAC 0x2C //Keypad facility
#define IE_SIGN 0x34 //Signal
#define IE_CG_PTY_NUM 0x6C //Calling party number
#define IE_CG_PTY_ADDR 0x6D //Calling party subaddress
#define IE_CD_PTY_NUM 0x70 //Called party number
#define IE_CD_PTY_ADDR 0x71 //Called party subaddress
#define IE_TRAN_NT_SEL 0x78 //Transit network selection
#define IE_RESTART_IND 0x79 //Restart indicator
#define IE_LL_COMP 0x7C //Low layer compatibility
#define IE_HL_COMP 0x7D //High layer compatibility
#define IE_USR_USR 0x7E //User-user
//ansi
#define IE_CHG_STAT 0x01 //Change status
#define IE_FAC 0x1C //Facility
//#define IE_INFO_REQ 0x32 //Information request
//#define IE_ORG_CG_NUM 0x73 //Original called number
#define IE_REDIR_NUM 0x74 //Redirection number
//QSIG
#define IE_CONN_NUM 0x4C //Connected number
//Codeset 6 information element identifiers TO-DO
/************************************************************
ISDN states exist in the user-network interface
************************************************************/
#define NULL_STATE 0x00
#define CALL_INIT_STATE 0x01
#define OVERLAP_SD_STATE 0x02
#define OUT_CALL_PROC_STATE 0x03
#define CALL_DV_STATE 0x04
#define CALL_PRE_STATE 0x06
#define CALL_RV_STATE 0x07
#define CONN_REQ_STATE 0x08
#define IN_CALL_PROC_STATE 0x09
#define ACTIVE_STATE 0x0A
#define DISC_REQ_STATE 0x0B
#define DISC_IND_STATE 0x0C
#define REL_REQ_STATE 0x13
#define OVERLAP_RV_STATE 0x19
#define GLOBAL_NULL_STATE 0x00
#define GLOBAL_RESTART_REQ_STATE 0x3D
#define GLOBAL_RESTART_STATE 0x3E
//ansi
#define SERVICE_IDLE 0x00
#define WAIT_SERVICE_ACK 0x01
#define RSP_SERVICE 0x02
/************************************************************
ISDN Event/Primitive Definition
************************************************************/
//Primitive
#define ISDN_SETUP_REQ 0x11
#define ISDN_SETUP_IND 0x21
#define ISDN_SETUP_RSP 0x31
#define ISDN_SETUP_CNF 0x41
#define ISDN_DISCONNECT_REQ 0x12
#define ISDN_DISCONNECT_IND 0x22
#define ISDN_RELEASE_REQ 0x32
#define ISDN_RELEASE_IND 0x42
#define ISDN_RELEASE_CNF 0x52
#define ISDN_REJECT_REQ 0x62
#define ISDN_ALERT_REQ 0x13
#define ISDN_ALERT_IND 0x23
#define ISDN_INFO_REQ 0x33
#define ISDN_INFO_IND 0x43
#define ISDN_PROG_REQ 0x53
#define ISDN_PROG_IND 0x63
#define ISDN_SUSPEND_REQ 0x73
#define ISDN_SUSPEND_IND 0x83
#define ISDN_RESUME_REQ 0x93
#define ISDN_RESUME_IND 0xa3
#define ISDN_PROC_REQ 0x14
#define ISDN_PROC_IND 0x24
#define ISDN_MORE_INFO_REQ 0x34
#define ISDN_MORE_INFO_IND 0x44
#define ISDN_NOTI_REQ 0x54
#define ISDN_NOTI_IND 0x64
#define ISDN_STAT_IND 0x74
#define ISDN_SETUP_COMP_REQ 0x84
#define ISDN_SETUP_COMP_IND 0x84
#define ISDN_TIMEOUT_IND 0x15
#define ISDN_RESTART_REQ 0x25
#define ISDN_M_RESTART_REQ 0x35
#define ISDN_RESTART_CNF 0x45
#define ISDN_REATTEMPT_IND 0x55
//ansi
#define ISDN_SERVICE_REQ 0x16
#define ISDN_SERVICE_IND 0x26
#define ISDN_SERVICE_CNF 0x36
#define ISDN_SERVICE_RSP 0x46
#define ISDN_SER_TIMEOUT_IND 0x56
/************************************************************
ISDN Cause Definition
************************************************************/
#define CAUSE_UNASSIGNED 0x01 //unassigned (unallocated) number
#define CAUSE_NOROUTE_NET 0x02 //no route to specified transit network
#define CAUSE_NOROUTE_DES 0x03 //no route to destination
#define CAUSE_NORMAL 0x10 //normal call clearing
#define CAUSE_INVALID_NUM 0x1C //invalid number format(imcomplete number)
#define CAUSE_STAT_ENQ 0x1E //response to status enquiry
#define CAUSE_TEMP_FAIL 0X29 //temporary failure
#define CAUSE_INVALID_CR 0x51 //invalid call reference value
#define CAUSE_CALLID_INUSE 0x54 //call identity in use
#define CAUSE_M_IE_MISS 0x60 //mandatory information element is missing
#define CAUSE_MSG_NONEXI 0x61 //message type non-existent or not implemented
#define CAUSE_MSG_NOTCOMP_NOTIMPL 0x62 //message not compatible with call state or message type non-existent or not implemented
#define CAUSE_IE_NONEXI 0x63 //information element non-existent or not implemented
#define CAUSE_IE_INVALID 0x64 //invalid information element contents
#define CAUSE_MSG_NOTCOMP 0x65 //message not compatible with call state
#define CAUSE_TIMER_EXPIRY 0x66 //recovery on timer expiry
/************************************************************
ISDN Timer Definition (Time Unit = 1s)
************************************************************/
#define ISDN_T301 180 /* 180S */
#define ISDN_T302 15 /* 15S */
#define ISDN_T303 4 /* 4S */
#define ISDN_T304 20 /* 20S */
#define ISDN_T305 30 /* 30S */
#define ISDN_T306 30 /* 30S */
#define ISDN_T307 180 /* 180S */
#define ISDN_T308 4 /* 4S */
#define ISDN_T309 6 /* 6S*/
#define ISDN_T310 10 /* 10S */
#define ISDN_T312 6 /*T303+2S*/
#define ISDN_T313 4 /* 4S */
#define ISDN_T316 120 /* 120S */
#define ISDN_T317 10 /* <T316 */
#define ISDN_T321 40 /* 30S */
#define ISDN_T322 4 /* 4S */
#define ISDN_T40S 40 /* 40S */
#define ISDN_T240S 240 /* 240S */
#define ISDN_T1 1 /* 1S */
#define ISDN_T3M1 120 /* 120S */
#define LINK_MAX_TIME 15000 // 150s
/************************************************************
ISDN Other Definition
************************************************************/
#define IE_MAX_LEN (256)
#define IE_COUNT (13)
//IUA Definition
/*#define IUA_QPTM_MSG 0x05
#define IUA_MGMT_CMD 0xA5
#define IUA_APP 0x1
*/
#endif

View File

@@ -0,0 +1,81 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_debug.h
Description: ISDN Debug
Version: v9.1.0
Author: Gengxin Chen
Create Date: 2008-5-27
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_DEBUG_H
#define _ISDN_DEBUG_H
#include "isdn_rm.h"
#include "../../../pal/pal.h"
//#include "../../../debug/src/include/debug.h"
/*Color Set */
#define COL_WHITE 37
#define COL_RED 31
#define COL_YELLOW 33
#define COL_GREEN 32
#define COL_BLUE 34
#define COL_BROWN 35
#define COL_MEGEN 36
#define COL_GRAY 38
#define COL_HI_WHI 58
#define COL_HI_RED 39
#define COL_HI_YEL 52
#define COL_HI_GRE 51
#define COL_HI_BLU 53
#define COL_HI_BRO 54
#define COL_HI_MEG 55
#define COL_BLACK 30
#define COL_ESC '\033'
typedef struct _isdn_msg_csta //call statistics
{
//receive and send
u32 rv_setup;
u32 sd_setup;
u32 rv_setupAck;
u32 sd_setupAck;
u32 rv_callProc;
u32 sd_callProc;
u32 rv_alert;
u32 sd_alert;
u32 rv_conn;
u32 sd_conn;
u32 rv_connAck;
u32 sd_connAck;
u32 rv_disc;
u32 sd_disc;
u32 rv_rel;
u32 sd_rel;
u32 rv_relComp;
u32 sd_relComp;
//redirect
u32 rd_setup;
u32 rd_setupAck;
u32 rd_callProc;
u32 rd_alert;
u32 rd_conn;
u32 rd_connAck;
u32 rd_disc;
u32 rd_rel;
u32 rd_relComp;
}ISDN_Msg_Csta;
int isdn_debug_init(void);
void isdn_debug_timer(void);
void isdn_log_err(u32 pid,const char *fmt, ...);
void isdn_trace_func(u32 pid,const char *fmt, ...);
void monitor_isdn_msg(u32 pid,u8 *head,IuaMsgStr *msg,u8 col);
void monitor_isdn_port(u32 call_ref,u32 port);
void isdn_msg_csta(u8 msgtype,u8 flag);
#endif

View File

@@ -0,0 +1,33 @@
/***********************************************************
File Name: isdn_ext.h
Description: Public variant definition of ISDN module
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-2-28
************************************************************/
#ifndef _ISDN_EXT_H
#define _ISDN_EXT_H
#include "isdn_if.h"
/************************************************************
ISDN
************************************************************/
IsdnMsgStr isdn_sd_msg, isdn_rv_msg;
extern int isdn_init(u8 systemID, u32 interval_ms);
extern void isdn_timer();
/*extern int isdn_bind_sap(ISDN_Sap_Attrib_ *attrib_p);
extern int isdn_modify_sap(u8 sap_id, ISDN_Sap_Attrib_ *attrib_ptr);
extern int isdn_unbind_sap(u8 sap_id);
extern int isdn_add_cg(u8 sap_id, Cg_Attrib_struct *attrib_ptr);
extern int isdn_modify_cg(u16 cg_id, Cg_Attrib_struct *attrib_ptr);
extern int isdn_remove_cg(u16 cg_id);
extern int isdn_add_circuit(u16 cg_id, Circuit_Attrib_struct *attrib_ptr);
extern int isdn_modify_circuit(u16 cg_id, u16 circuit_id, Circuit_Attrib_struct *attrib_ptr);
extern int isdn_remove_circuit(u16 cg_id, u16 circuit_id);*/
extern int isdn_set_run_mode (u8 run_mode, u32 alter_ip);
#endif

Some files were not shown because too many files have changed in this diff Show More