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

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

View File

@@ -0,0 +1,491 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_ie.h
Description: ISDN information elements structure
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-17
Remark: M:mandatory, O:optional
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_IE_H
#define _ISDN_IE_H
#include "isdn_public.h"
/************************************************************
ISDN information elements structure
************************************************************/
typedef struct _brCap_b4 //Bearer capability octets 4
{
u8 tran_mode; //Transfer mode M
u8 tran_rate; //Information transfer rate M
u8 rate_mul; //Rate multiplier O
}brCap_b4;
typedef struct _brCap_b5 //Bearer capability octets 5
{
u8 usr_layer1; //User information layer 1 protocol
u8 has_ext_a; //
u8 syn_asy; //Synch/asynch (0/1)
u8 neg; //Negot
u8 usr_rate; //User rate
u8 has_ext_b; //
u8 inter_rate; //Intermediate rate
u8 nic_tx; //NIC on Tx
u8 nic_rx; //NIC on Rx
u8 ctl_tx; //Flow control on Tx
u8 ctl_rx; //Flow control on Rx
// u8 ext_b; //
u8 hdr; //Hdr/no Hdr
u8 mul_fra; //Multiframe;
u8 mode; //Mode
u8 lli_neg; //LLI negot.
u8 assign; //Assignor/ee
u8 inband; //In-band neg.
u8 has_ext_c; //
u8 stop_bit; //Number of stop bits
u8 data_bit; //Number of data bits
u8 par; //Parity
u8 has_ext_d;
u8 du_mode; //Duplex Mode
u8 mod_type; //Modem type
}brCap_b5;
typedef struct _brCap_b7 //Bearer capability octets 7
{
u8 usr_layer3; //User information layer 3 protocol
u8 has_ext_a; //
u8 layer3_a; //Additional layer 3 protocol information (most significant bits)
u8 has_ext_b; //
u8 layer3_b; //Additional layer 3 protocol information (most significant bits)
}brCap_b7;
typedef struct _brCap //Bearer capability
{/*<2A><><EFBFBD>ܵð<DCB5>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD>ѡ<EFBFBD>˱<EFBFBD><CBB1>طŵ<D8B7>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E1B9B9><EFBFBD>У<EFBFBD><D0A3><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>˱<EFBFBD><CBB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵط<C4B5><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
u8 pres; //element header
u32 ext_flag; //extension domain flag M
u8 code_stan; //Coding standard (00) M
u8 tran_cap; //Information transfer capability M
brCap_b4 b4; //octets 4
brCap_b5 b5; //octets 5 group
u8 usr_layer2; //User information layer 2 protocol
u8 usr_layer3; //User information layer 3 protocol
// brCap_b7 b7; //octets 7
}BrCap;
typedef struct _callId //Call identity
{
u8 pres; //element header
u8 call_id_len;
u8 call_id[8]; //Call identity(IA5)
}CallId;
typedef struct _callStat //Call state
{
u8 pres; //element header
u8 code_stan; //Coding standard
u8 stat_val; //Call state value/global interface state value(state value is coded in binary)
}CallStat;
typedef struct _cdPtyNum //Called party number
{
u8 pres; //element header
u8 num_type; //Type of number
u8 num_plan_id; //Numbering plan identification
u8 num_digit_len;
u8 num_digit[32]; //Number digits(IA5)
}CdPtyNum;
typedef struct _cdPtyAddr //Called party subaddress
{
u8 pres; //element header
u8 addr_type; //Type of subaddress
u8 odd_even; //Odd/even indicator
u8 addr_info_len;
u8 addr_info[20]; //Subaddress information
}CdPtyAddr;
typedef struct _cgPtyNum_b3
{
u8 num_type; //Type of number
u8 num_plan_id; //Numbering plan identification
u8 has_ext_a; //
u8 pres_ind; //Presentation indicator
u8 screen_ind; //Screening indicator
}cgPtyNum_b3;
typedef struct _cgPtyNum //Calling party number
{
u8 pres; //element header
u32 ext_flag; //extension domain flag M
cgPtyNum_b3 b3;
u8 num_digit_len;
u8 num_digit[32]; //Number digits(IA5)
}CgPtyNum, ConnNum;
typedef struct _cgPtyAddr //Calling party subaddress
{
u8 pres; //element header
u8 addr_type; //Type of subaddress
u8 odd_even; //Odd/even indicator
u8 addr_info_len;
u8 addr_info[20]; //subaddress information
}CgPtyAddr;
typedef struct _cause_b3
{
u8 code_stan; //Coding standard
u8 loc; //Location
u8 has_ext_a; //
u8 rec; //Recommendation
}cause_b3;
typedef struct _cause_b5 //diagnostic
{
u8 attrib_num; //attribute number
// u8 has_ext_a;
u8 rej_attrib; //rejected attribute
u8 has_ext_b;
u8 avail_attrib; //available attribute
//Call rejected diagnostic for cause number 21 TODO
}cause_b5;
typedef struct _causeStr //Cause
{
u8 pres; //element header
u32 ext_flag; //
cause_b3 b3; //octet 3
u8 cause_val; //Cause value
u8 dia_num;
cause_b5 dia[8]; //diagnostic
}CauseStr;
typedef struct _chnlId_b3 //Channel identification octets 3
{
u8 int_id_pre; //Interface identifier present M
u8 int_type; //Interface type M
u8 pref_excl; //Preferable/Exclusive M
u8 chnl_ind; //D-channel indicator M
u8 info_chnl_sel; //Infomation channel selection M
u8 int_id; //Interface identifier;
u8 has_chnl; // 1:wiith 3.2 and 3.3, 0:without 3.2 nor 3.3
u8 code_stan; //Coding standard
u8 num_map; //Number/Map
u8 chnl_type; //Channel type/Map element type
u8 chnl_num; //Channel number/Slot map ect
}chnlId_b3;
typedef struct _chnlId //Channel identification
{
u8 pres; //element header
chnlId_b3 b3; //octets 3
}ChnlId;
typedef struct _conLev //Congestion level
{
u8 pres; //element header
u8 con_lev; //Congestion level
}ConLev;
typedef struct _dtTime //Date/time
{
u8 pres; //element header
u8 ext_flag;
u8 year;
u8 month;
u8 day; //M
u8 hour; //O
u8 minute; // O
u8 second; //O
}DtTime;
typedef struct _disp //Display
{
u8 pres; //element header
u8 disp_info_len;
u8 disp_info[18]; //Display information(IA5)
//ansi
u8 asso_info; //Associated information
u8 disp_type; //display type
}Disp;
typedef struct _hLComp_b4 //High layer compatibility octets 4
{
u8 hl_ch_id; //High layer characteristies identification
u8 ex_hl_ch_id; //Extended high layer characteristics identification
u8 ex_vid_ch_id; //EXtended videotelephony characteristics identification
}hLComp_b4;
typedef struct _hLComp //High layer compatibility
{
u8 pres; //element header
u8 code_stan; //Coding standard
u8 intpr; //Interpretation
u8 pre_meth; //Presentation method of protocol profile
hLComp_b4 b4; //octets 4
}HLComp;
typedef struct _kpdFac //Keypad facility
{
u8 pres; //element header
u8 keyfac_info_len;
u8 key_fac_info[32];//Keypad facility information(IA5)
}KpdFac;
typedef struct _lLComp_b3 //Low layer compatibility octets 3
{
u8 code_stan; //Coding standard M
u8 tran_cap; //Information transfer capability M
u8 has_ext_a;
u8 neg_ind; //Negot indicator O
}lLComp_b3;
typedef struct _lLComp_b4 //Low layer compatibility octets 4
{
u8 tran_mode; //Transfer mode
u8 tran_rate; //Information transfer rate
u8 rate_mul; //Rate multiplier
}lLComp_b4;
typedef struct _lLComp_b5 //Low layer compatibility octets 5
{
u8 layer1_id; //Layer 1 identifier
u8 usr_layer1; //User information layer 1 protocol
u8 has_ext_a; //
u8 syn_asy; //Synch./asynch.
u8 neg; //Negot.
u8 usr_rate; //User Rate
u8 has_ext_b; //
u8 inter_rate; //intermediate rate
u8 nic_tx; //NIC on Tx
u8 nic_rx; //NIC on Rx
u8 ctl_tx; //Flow control on Tx
u8 ctl_rx; //Flow control on Rx
// u8 ext_b; //
u8 hdr; //Hdr/no Hdr
u8 mul_fra; //Multiframe;
u8 mode; //Mode
u8 lli_neg; //LLI negot.
u8 assign; //Assignor/ee
u8 inband; //In-band negot.
u8 has_ext_c; //
u8 stop_bit; //Number of stop bits
u8 data_bit; //Number of data bits
u8 par; //Parity
u8 has_ext_d;
u8 du_mode; //Duplex Mode
u8 mod_type; //Modem type
}lLComp_b5;
typedef struct _lLComp_b6 //Low layer compatibility octets 6
{
u8 layer2_id; //layer 2 identifier
u8 usr_layer2; //User information layer 2 protocol
u8 mode; //Mode
u8 q933_use; //Q.933 use
u8 usr_layer2_info; //User specification layer 2 protocol information
u8 win_size; //Window size(k)
}lLComp_b6;
typedef struct _lLComp_b7 //Low layer compatibility octets 7
{
u8 layer3_id; //layer 3 identifier
u8 usr_layer3; //User information layer 3 protocol
u8 usr_layer3_info; //Optional layer 3 protocol information
u8 mode; //Mode
u8 def_pac_size; //Default packet size
u8 pac_win_size; //Packet window size
u8 layer3_a; //Additional layer 3 protocol information (most significant bits)
u8 layer3_b; //Additional layer 3 protocol information (most significant bits)
}lLComp_b7;
typedef struct _lLComp //Low layer compatibility
{
u8 pres; //element header
u32 ext_flag;
lLComp_b3 b3; //octets 3 M
lLComp_b4 b4; //octets 4 O
lLComp_b5 b5; //octets 5
lLComp_b6 b6; //octets 6
lLComp_b7 b7; //octets 7
//ansi TODO
}LLComp;
typedef struct _ntSpFac_b3 //Network-specific facilities octets 3
{
u8 len_net_id; //Length of network identification M //<2F><>Ϊ0<CEAA><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
u8 net_id_type; //Type of network identification O
u8 net_id_plan; //Network identification plan
u8 net_id; //Network identification(IA5) ect
}ntSpFac_b3;
typedef struct _ntSpFac //Network-specific facilities
{
u8 pres; //element header
ntSpFac_b3 b3; //octets 3 M
u8 spec; //Network-specific facility specification M
//ansi
u8 fac_val; //Facility coding value
u8 ser_par; //Service parameters
}NtSpFac;
typedef struct _notifyInd //Notification indicator
{
u8 pres; //element header
u8 notify_descr; //Notification description
//ansi TODO
}NotifyInd;
typedef struct _prgInd //Progress indicator
{
u8 pres; //element header
u8 code_stan; //Coding standard
u8 loc; //Location
u8 prg_descr; //Progress description
}PrgInd;
typedef struct _rptInd //Repeat indicator
{
u8 pres; //element header
// u8 rpt_ind; //Repeat indication
}RptInd;
typedef struct _restartInd //Restart indicator
{
u8 pres; //element header
u8 clas; //class
}RestartInd;
typedef struct _segMsg //Segmented message
{
u8 pres; //element header
u8 seg_ind; //First segment indicator
u8 other_num; //Number of segments remaining
u8 seg_type; //Segmented message type
}SegMsg;
typedef struct _sdComp //Sending complete
{
u8 pres; //element header
// u8 sd_comp; //sending complete <09><><EFBFBD><EFBFBD>
}SdComp;
typedef struct _sign //Signal
{
u8 pres; //element header
u8 sign_val; //Signal value
}Sign;
typedef struct _tranNtSel //Transit network selection
{
u8 pres; //element header
u8 net_id_type; //Type of network identification
u8 net_id_plan; //Network identification plan
u8 net_id; //Network identification(IA5) ect
}TranNtSel;
typedef struct _usrUsr //User-user
{
u8 pres; //element header
u8 pro_discr; //Protocol discriminator
u8 usr_info_len;
u8 usr_info[258]; //User information
}UsrUsr;
//supplementary services ansi
typedef struct _fac //facility
{
}Fac;
/* the same to the CgPtyNum
typedef struct _connNum //connected number
{
}ConnNum;*/
typedef struct _redirNum_b3 //redirection number octet 3
{
u8 num_type; //Type of number
u8 num_plan_id; //Numbering plan identification
u8 org_num_stat; //Origin of number and presentation status
u8 redir_rs; //Reason for redirection
}redirNum_b3;
typedef struct _redirNum //redirection number
{
u8 pres; //element header
redirNum_b3 b3; //octet 3
u8 num_digit_len;
u8 num_digit[32]; //Number digits(IA5)
}RedirNum;
typedef struct _chgStat //change status
{
u8 pres; //element header
u8 pref; //Preference
u8 new_stat; //New status
}ChgStat;
/************************************************************
ISDN information elements functions interface
************************************************************/
u8 itu_encode_br_cap(u8 *dst, BrCap *src);
int itu_decode_br_cap(BrCap *dst, u8 *src, u8 len);
u8 isdn_encode_br_cap(u8 *dst, BrCap *src);
int isdn_decode_br_cap(BrCap *dst, u8 *src, u8 len);
u8 isdn_encode_cause(u8 *dst, CauseStr *src);
int isdn_decode_cause(CauseStr *dst, u8 *src, u8 len);
u8 isdn_encode_call_id(u8 *dst, CallId *src);
int isdn_decode_call_id(CallId *dst, u8 *src, u8 len);
u8 isdn_encode_call_stat(u8 *dst, CallStat *src);
int isdn_decode_call_stat(CallStat *dst, u8 *src, u8 len);
u8 qsig_encode_chnl_id(u8 *dst, ChnlId *src);
int qsig_decode_chnl_id(ChnlId *dst, u8 *src, u8 len);
u8 isdn_encode_chnl_id(u8 *dst, ChnlId *src);
int isdn_decode_chnl_id(ChnlId *dst, u8 *src, u8 len);
u8 isdn_encode_prg_ind(u8 *dst, PrgInd *src);
int isdn_decode_prg_ind(PrgInd *dst, u8 *src, u8 len);
u8 ansi_encode_ntsp_fac(u8 *dst, NtSpFac *src);
int ansi_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len);
u8 isdn_encode_ntsp_fac(u8 *dst, NtSpFac *src);
int isdn_decode_ntsp_fac(NtSpFac *dst, u8 *src, u8 len);
u8 ansi_encode_notify_ind(u8 *dst, NotifyInd *src);
int ansi_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len);
u8 isdn_encode_notify_ind(u8 *dst, NotifyInd *src);
int isdn_decode_notify_ind(NotifyInd *dst, u8 *src, u8 len);
u8 isdn_encode_disp(u8 *dst, Disp *src);
int isdn_decode_disp(Disp *dst, u8 *src, u8 len);
u8 isdn_encode_dt_time(u8 *dst, DtTime *src);
int isdn_decode_dt_time(DtTime *dst, u8 *src, u8 len);
u8 isdn_encode_kpd_fac(u8 *dst, KpdFac *src);
int isdn_decode_kpd_fac(KpdFac *dst, u8 *src, u8 len);
u8 isdn_encode_sign(u8 *dst, Sign *src);
int isdn_decode_sign(Sign *dst, u8 *src, u8 len);
u8 isdn_encode_cg_num(u8 *dst, CgPtyNum *src);
int isdn_decode_cg_num(CgPtyNum *dst, u8 *src, u8 len);
u8 isdn_encode_cg_addr(u8 *dst, CgPtyAddr *src);
int isdn_decode_cg_addr(CgPtyAddr *dst, u8 *src, u8 len);
u8 isdn_encode_cd_num(u8 *dst, CdPtyNum *src);
int isdn_decode_cd_num(CdPtyNum *dst, u8 *src, u8 len);
u8 isdn_encode_cd_addr(u8 *dst, CdPtyAddr *src);
int isdn_decode_cd_addr(CdPtyAddr *dst, u8 *src, u8 len);
u8 isdn_encode_tran_sel(u8 *dst, TranNtSel *src);
int isdn_decode_tran_sel(TranNtSel *dst, u8 *src, u8 len);
u8 isdn_encode_restart_ind(u8 *dst, RestartInd *src);
int isdn_decode_restart_ind(RestartInd *dst, u8 *src, u8 len);
u8 isdn_encode_ll_comp(u8 *dst, LLComp *src);
int isdn_decode_ll_comp(LLComp *dst, u8 *src, u8 len);
u8 isdn_encode_hl_comp(u8 *dst, HLComp *src);
int isdn_decode_hl_comp(HLComp *dst, u8 *src, u8 len);
u8 isdn_encode_usr_usr(u8 *dst, UsrUsr *src);
int isdn_decode_usr_usr(UsrUsr *dst, u8 *src, u8 len);
//ansi
u8 ansi_encode_chg_stat(u8 *dst, ChgStat *src);
int ansi_decode_chg_stat(ChgStat *dst, u8 *src, u8 len);
u8 ansi_encode_redir_num(u8 *dst, RedirNum *src);
int ansi_decode_redir_num(RedirNum *dst, u8 *src, u8 len);
//QSIG
u8 qsig_encode_conn_num(u8 *dst, ConnNum *src);
int qsig_decode_conn_num(ConnNum *dst, u8 *src, u8 len);
#endif

View File

@@ -0,0 +1,119 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_if.h
Description: ISDN interface declaration for wxc2main
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-17
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_IF_H
#define _ISDN_IF_H
#include "isdn_msg.h"
#include "isdn_inc.h"
/************************************************************
ISDN Module parameter structure
************************************************************/
//Send to upper layer primitives, save data to structure
typedef int f_isdn_setup_ind(Pst *pst, IsdnSetup *ptr); //Setup indication
typedef int f_isdn_setup_cnf(Pst *pst, IsdnConn *ptr); //Setup confirm
typedef int f_isdn_proc_ind(Pst *pst, IsdnCallProc *ptr); //Proceeding indication
typedef int f_isdn_alert_ind(Pst *pst, IsdnAlert *ptr); //Alerting indication
typedef int f_isdn_disc_ind(Pst *pst, IsdnDisc *ptr); //Disconnect indication
typedef int f_isdn_rel_ind(Pst *pst, IsdnRel *ptr); //Release indication
typedef int f_isdn_rel_cnf(Pst *pst, IsdnRelComp *ptr); //Release confirm
typedef int f_isdn_rel_cnf_err(Pst *pst, IsdnRelComp *ptr); //Release confirm error
typedef int f_isdn_prog_ind(Pst *pst, IsdnProg *ptr); //Progress indication
typedef int f_isdn_info_ind(Pst *pst, IsdnInfo *ptr); //Info indication
typedef int f_isdn_minfo_ind(Pst *pst, IsdnSetupAck *ptr); //More info indication //IsdnSetupAck <20><> IsdnInfo
typedef int f_isdn_noti_ind(Pst *pst, IsdnNoti *ptr); //Notify indication
typedef int f_isdn_stat_ind(Pst *pst, IsdnStatus *ptr); //Status indication
typedef int f_isdn_stat_ind_err(Pst *pst, IsdnStatus *ptr); //Status indication(error)
typedef int f_isdn_resu_ind(Pst *pst, IsdnResuRejReq *ptr); //Resume indication
typedef int f_isdn_rej_ind(Pst *pst, IsdnResuRejReq *ptr); //Reject indication
typedef int f_Isdn_susp_ind(Pst *pst, IsdnSusp *ptr); //Suspend indication
typedef int f_isdn_restart_req(Pst *pst, IsdnRestart *ptr); //Restart request
typedef int f_isdn_rest_cnf(Pst *pst, IsdnRestAck *ptr); //Restart confirm
typedef int f_isdn_timeout_ind(Pst *pst); //TIMEOUT
typedef int f_isdn_reattempt_ind(Pst *pst); //REATTEMPT
//ansi
typedef int f_isdn_service_ind(Pst *pst, IsdnService *ptr); //Service
typedef int f_isdn_service_cnf(Pst *pst, IsdnServAck *ptr); //Service Ack
typedef int f_isdn_ser_timeout_ind(Pst *pst); //Service TIMEOUT
typedef struct _isdn_eventhandle_struct
{
f_isdn_setup_ind *h_isdn_setup_ind;
f_isdn_setup_cnf *h_isdn_setup_cnf;
f_isdn_proc_ind *h_isdn_proc_ind;
f_isdn_alert_ind *h_isdn_alert_ind;
f_isdn_disc_ind *h_isdn_disc_ind;
f_isdn_rel_ind *h_isdn_rel_ind;
f_isdn_rel_cnf *h_isdn_rel_cnf;
f_isdn_rel_cnf_err *h_isdn_rel_cnf_err;
f_isdn_prog_ind *h_isdn_prog_ind;
f_isdn_info_ind *h_isdn_info_ind;
f_isdn_minfo_ind *h_isdn_minfo_ind;
f_isdn_noti_ind *h_isdn_noti_ind;
f_isdn_stat_ind *h_isdn_stat_ind;
f_isdn_stat_ind_err *h_isdn_stat_ind_err;
f_isdn_resu_ind *h_isdn_resu_ind;
f_isdn_rej_ind *h_isdn_rej_ind;
// f_isdn_susp_ind *h_isdn_susp_ind;
f_isdn_restart_req *h_isdn_restart_req;
f_isdn_rest_cnf *h_isdn_rest_cnf;
f_isdn_timeout_ind *h_isdn_timeout_ind;
f_isdn_reattempt_ind *h_isdn_reattempt_ind;
//ansi
f_isdn_service_ind *h_isdn_service_ind;
f_isdn_service_cnf *h_isdn_service_cnf;
f_isdn_ser_timeout_ind *h_isdn_ser_timeout_ind;
}ISDN_EventHandle_struct;
typedef struct _isdn_sap_attrib_
{
ISDN_EventHandle_struct event_handle;
}ISDN_Sap_Attrib_;
/************************************************************
ISDN Module interface
************************************************************/
//Receive upper layer interface primitives
extern int isdn_setup_req(Pst *pst, IsdnSetup *ptr); //Setup request
extern int isdn_setup_resp(Pst *pst, IsdnConn *ptr); //Setup response
//extern int isdn_setup_comp_req(Pst *pst, IsdnConnAck *ptr); //Setup complete request
extern int isdn_call_proc_req(Pst *pst, IsdnCallProc *ptr); //Proceeding request
extern int isdn_alert_req(Pst *pst, IsdnAlert *ptr); //Alerting request
extern int isdn_disc_req(Pst *pst, IsdnDisc *ptr); //Disconnect request
extern int isdn_rel_req(Pst *pst, IsdnRel *ptr); //Release request
extern int isdn_rej_req(Pst *pst, IsdnRelComp *ptr); //Reject request
extern int isdn_prog_req(Pst *pst, IsdnProg *ptr); //Progress request
extern int isdn_info_req(Pst *pst, IsdnInfo *ptr); //Infomation request
extern int isdn_m_info_req(Pst *pst, IsdnSetupAck *ptr); //More Infomation request //IsdnSetupAck <20><> IsdnInfo
extern int isdn_noti_req(Pst *pst, IsdnNoti *ptr); //Notify request
extern int isdn_rej_req(Pst *pst, IsdnRelComp *ptr); //Reject request
extern int isdn_resu_resp(Pst *pst, IsdnResuResp *ptr); //Resume response
extern int isdn_resu_rej_req(Pst *pst, IsdnResuRejReq *ptr); //Resume reject request
extern int isdn_susp_resp(Pst *pst, IsdnSusp *ptr); //Suspend response
extern int isdn_susp_rej_req(Pst *pst, IsdnSuspRejReq *ptr); //Suspend reject request
extern int isdn_restart_req(Pst *pst, IsdnRestart *ptr); //Restart request
extern int isdn_m_restart_req(Pst *pst, IsdnRestart *ptr); //Management restart request
extern int isdn_restart_cnf(Pst *pst, IsdnRestAck *ptr); //Restart confirm
extern int isdn_timeout(Pst *pst); //Time out
//ansi
extern int isdn_service_bc_req(Pst *pst, IsdnService *ptr); //maintenance B-channel SERVICE request
extern int isdn_service_bc_rsp(Pst *pst, IsdnServAck *ptr); //maintenance B-channel SERVICE response
#endif

View File

@@ -0,0 +1,27 @@
/***********************************************************
File Name: isdn_inc.h
Description: Public variant definition of ISDN module
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-2-28
************************************************************/
#ifndef _ISDN_INC_H
#define _ISDN_INC_H
#include <netinet/in.h>
#include "../../../public/src/include/license_id.h"
#include "../../../m2ua/src/include/m2ua.h"
//#include "../../../public/src/include/proto_pub.h"
#include "../../../iptrans/src/include/iptrans.h"
#include "../../../debug/src/include/debug.h"
#include "../../../pal/pal.h"
//#include "../../../../mss/msc/mng/param.h"
/************************************************************
ISDN
************************************************************/
extern int wxc2_get_license(int functionID);
extern int put_xua_msg(xua_up_msg_t *data_ptr);
#endif

View File

@@ -0,0 +1,333 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_msg.h
Description: ISDN message structure or correlation
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-17
Remark: M:mandatory, O:optional
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_MSG_H
#define _ISDN_MSG_H
#include "isdn_const.h"
#include "isdn_ie.h"
/************************************************************
ISDN mandatory information elements structure
************************************************************/
typedef struct _msgMan //Message mandatory information elements
{
u8 proto_Discr; //Protocol discriminator
u8 cr_len; //Length of call reference value(in octets)
u8 call_ref[2]; //Call reference value
u8 msg_type; //Message type
}MsgMan;
/************************************************************
ISDN message structure
************************************************************/
typedef struct _isdnAlert //ALERTING
{
ChnlId chnl_id; //Channel identification O/M
PrgInd prg_ind; //Progress indicator O
BrCap br_cap; //Bearer capability O
Disp disp; //Display
Sign sign; //Signal
HLComp hl_comp; //High layer compatibility
//ansi
Fac facility; //facility
}IsdnAlert;
typedef struct _isdnCallProc //CALL PROCEEDING
{
ChnlId chnl_id; //Channel identification O/M
BrCap br_cap; //Bearer capability O
PrgInd prg_ind; //Progress indicator
Disp disp; //Display
HLComp hl_comp; //High layer compatibility
}IsdnCallProc;
typedef struct _isdnConn //CONNECT
{
ChnlId chnl_id; //Channel identification O/M
BrCap br_cap; //Bearer capability O
PrgInd prg_ind; //Progress indicator
Disp disp; //Display
DtTime dt_time; //Date/time
Sign sign; //Signal
LLComp ll_comp; //Low layer compatibility
HLComp hl_comp; //High layer compatibility
//QSIG
ConnNum conn_num; //Connected number
//Connected subaddress
}IsdnConn;
typedef struct _isdnConnAck //CONNECT ACKNOWLEDGE
{
Disp disp; //Display O
Sign sign; //Signal
}IsdnConnAck;
typedef struct _isdnDisc //DISCONNECT
{
CauseStr cause; //Cause M
PrgInd prg_ind; //Progress indicator O
Disp disp; //Display
Sign sign; //Signal
}IsdnDisc;
typedef struct _isdnInfo //INFORMATION
{
SdComp sd_comp; //Sending complete O
Disp disp; //Display
KpdFac kpd_fac; //Keypad facility
Sign sign; //Signal
CdPtyNum cd_pty_num; //Called party number
}IsdnInfo;
typedef struct _isdnNoti //NOTIFY
{
NotifyInd notify_ind; //Notification indicator M
Disp disp; //Display O
BrCap br_cap; //Bearer capability O
}IsdnNoti;
typedef struct _isdnProg //PROGRESS
{
PrgInd prg_ind; //Progress indicator M
BrCap br_cap; //Bearer capability O
CauseStr cause; //Cause O
Disp disp; //Display
HLComp hl_comp; //High layer compatibility
//ansi
Fac facility; //facility
}IsdnProg;
typedef struct _isdnRel //RELEASE
{
CauseStr cause; //Cause O
Disp disp; //Display
Sign sign; //Signal
}IsdnRel, IsdnRelComp;
/*typedef struct _isdnRelComp //RELEASE COMPLETE
{
CauseStr cause; //Cause O
Disp disp; //Display
Sign sign; //Signal
}IsdnRelComp;
*/
typedef struct _isdnRestart //Restart
{
ChnlId chnl_id; //Channel identification O
RestartInd restart_ind; //Restart indicator M
Disp disp; //Display
}IsdnRestart, IsdnRestAck;
typedef struct _isdnSetup //SETUP
{
BrCap br_cap; //Bearer capability M
ChnlId chnl_id; //Channel identification O/M
PrgInd prg_ind; //Progress indicator
NtSpFac nt_sp_fac; //Network specific facilities
Disp disp; //Display
CgPtyNum cg_pty_num; //Calling party number
CdPtyNum cd_pty_num; //Called party number
TranNtSel tran_nt_sel; //Transit network selection
SdComp sd_comp; //Sending complete O
RptInd rpt_ind; //Repeat indicator O
DtTime dt_time; //Date/time
KpdFac kpd_fac; //Keypad facility
Sign sign; //Signal
CgPtyAddr cg_pty_addr; //Calling party subaddress
CdPtyAddr cd_pty_addr; //Called party subaddress
LLComp ll_comp; //Low layer compatibility
HLComp hl_comp; //High layer compatibility
//ansi
Fac facility; //facility
RedirNum redir_num; //Redirection number
// OrgCdNum org_cd_num; //original called number
}IsdnSetup;
typedef struct _isdnSetupAck //SETUP ACKNOWLEDGE
{
ChnlId chnl_id; //Channel identification O
PrgInd prg_ind; //Progress indicator
Disp disp; //Display
Sign sign; //Signal
}IsdnSetupAck;
typedef struct _isdnStatus //STATUS
{
CauseStr cause; //Cause M
CallStat call_stat; //Call state M
Disp disp; //Display O
}IsdnStatus;
typedef struct _isdnStatEnq //STATUS ENQUIRY
{
Disp disp; //Display O
}IsdnStatEnq;
typedef struct _isdnResuResp
{
}IsdnResuResp;
typedef struct _isdnResuRejReq
{
}IsdnResuRejReq;
typedef struct _isdnSusp
{
}IsdnSusp;
typedef struct _isdnSuspRejReq
{
}IsdnSuspRejReq;
typedef struct _isdnTimeout
{
}IsdnTimeout;
//ansi
typedef struct _isdnService //Service
{
ChgStat chg_stat; //change status M
ChnlId chnl_id; //channel identification M
}IsdnService, IsdnServAck;
typedef struct _isdnFac //Facility
{
}IsdnFac;
typedef struct _isdnMsgStr
{
MsgMan msg_m;
union
{
/*******Call establishment messages*******/
IsdnAlert alert; //alerting
IsdnCallProc callProc; //Call proceeding
IsdnConn conn; //Connect
IsdnConnAck connAck; //Connect acknowledge
IsdnProg prog; //progress
IsdnSetup setup; //setup
IsdnSetupAck setupAck; //Setup acknowledge
/*******Call information phase messages:*******/
IsdnResuRejReq resuRejReq; //resume reject require
/*******Call clearing messages:*******/
IsdnDisc disc; //disconnect
IsdnRel rel; //release
IsdnRelComp relComp; //release complete
IsdnRestart restart; //restart
IsdnRestAck restAck; //restart Acknowledge
/*******Miscellaneous messages:*******/
IsdnInfo info; //
IsdnNoti noti; //
IsdnStatus status; //
IsdnStatEnq statEnq; //
/*******Maintenance messages*******/
IsdnService service; //service
IsdnServAck servAck; //service acknowledge
}msg_list;
}IsdnMsgStr;
typedef struct _IuaMsgStr
{
u8 pad[25];
u8 msg_class; /*xua msg type=0x05*/
u8 e1_no; /* E1 number */
u16 msg_length __attribute__((packed)); /* ISDN Message length */
union
{
struct
{
u8 mtp3_ip; /* reserved */
u8 opercode; /* 1=Out Of Service 5=In Service 6=Processor Outage*/
u8 alarmcode;
}lkmsg;
struct
{
MsgMan msg_m;
u8 ie_content[IE_MAX_LEN]; /* information elements Content */
}isdn_msg; /*isdn message content*/
}msgcontent;
}IuaMsgStr;
/************************************************************
ISDN timer structure
************************************************************/
typedef struct _isdnTimerStr //<2F><><EFBFBD><EFBFBD>, <20>м<EFBFBD><D0BC><EFBFBD>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD>
{
u16 t301;
u16 t302;
u16 t303;
u16 t304;
u16 t305;
u16 t306;
u16 t307;
u16 t308;
u16 t309;
u16 t310;
u16 t312;
u16 t313;
u16 t316;
u16 t317;
u16 t321;
u16 t322;
u16 t1s;
u16 t40s;
u16 t240s;
//ansi
u16 t3M1;
}IsdnTimerStr;
IsdnTimerStr isdn_timer_var;
IuaMsgStr iua_sd_msg, iua_rv_msg;
#endif

View File

@@ -0,0 +1,56 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_public.h
Description: Redefine type byname
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-18
History:
<author> <date> <version> <desc>
************************************************************/
#ifndef _ISDN_PUBLIC_H_
#define _ISDN_PUBLIC_H_
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <assert.h>
#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
#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
#define ISDN_CM_OK 1 //Command request success
#define ISDN_CM_FAILED 0 //Command request failed
#endif

View File

@@ -0,0 +1,151 @@
/***********************************************************
File Name: isdn_rm.h
Description: ISDN Resource Management declaration
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-1-23
************************************************************/
#ifndef _ISDN_RM_H
#define _ISDN_RM_H
#include "isdn_if.h"
#include "isdn_inc.h"
/************************************************************
ISDN Resource structure
************************************************************/
#define ISDN_MAX_SAP 16
#define ISDN_MAX_CG 256
#define ISDN_MAX_CIRCUIT 256
#define ISDN_MAX_PORT 8192
#define ISDN_CIRCUIT_CIC 32
/*
typedef struct _isdn_cg_attrib_
{
// u8 variant_type;
u8 priority; //0:reattempt; 1:discard
u8 network_id; //Network identifier
u32 tg_id;
}ISDN_Cg_Attrib_;
typedef struct _isdn_circuit_attrib_
{
u8 plat_id;
u8 cic_range;
u32 head_cic;
u32 circuit_id;
}ISDN_Circuit_Attrib_;
typedef struct _isdn_sap_struct
{
u8 enable;
ISDN_Sap_Attrib_ attrib;
}ISDN_Sap_struct;
typedef struct _isdn_cg_struct
{
u8 enable;
u8 sap_id;
u8 circuit_num;
u8 circuit_used[ISDN_MAX_CIRCUIT];
Cg_Attrib_struct attrib;
}ISDN_Cg_struct;
typedef struct _isdn_circuit_struct
{
u8 enable;
u16 cg_id;
u8 user_network_if;
u8 interface_id;
u8 restart_clas; //restart indicator class
u8 lk3_status;
u8 lk2_status;
u8 dc_status; //ansi maintenance D-channel status
u8 heartbeat_time;
Circuit_Attrib_struct attrib;
}ISDN_Circuit_struct;
*/
typedef struct _isdn_cic_state_
{
u8 call_state;
u8 maintenance_state; //ansi maintenance B-channel state blo_state
}ISDN_CIC_state_;
typedef struct _isdn_fsm_state_
{
int cpc_state;
int m_state; //bls_state and blr_state
}ISDN_Fsm_state_;
typedef struct _isdn_link_struct
{
u8 enable;
// u8 circuit_id;
u8 restart_clas; //restart indicator class
u8 lk3_status;
u8 lk2_status;
u8 dc_status; //ansi maintenance D-channel status
u16 plat_heartbeat_time; //to another plat
u16 link_heartbeat_time; //from iua
}ISDN_Link_struct;
typedef struct _isdn_port_struct
{
u8 enable;
u16 call_ref;
u8 callout_fg; //<2F><><EFBFBD><EFBFBD>λ, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>DZ<EFBFBD><C7B1>з<EFBFBD><D0B7><EFBFBD><EFBFBD><EFBFBD>
u16 timer_flag;
u32 w_time;
u32 su_proc_id; //for normal call
u8 pre_send_msg;
u8 msg_cmd;
u8 primitive_cmd;
u8 g_pri_cmd;
u8 timeout_fg; //0:never timeout, 1:once timeout
u32 cic_val;
ISDN_CIC_state_ cic_state;
ISDN_Fsm_state_ fsm_state;
int trace_flag;
}ISDN_Port_struct;
typedef struct _isdn_attrib_struct
{
u8 systemID;
u8 isdn_run_mode;
u32 isdn_remote_ip;
}ISDN_Attrib_struct;
typedef struct _isdn_resource_pond
{
// ISDN_Sap_struct sap_pond[ISDN_MAX_SAP];
// ISDN_Cg_struct cg_pond[ISDN_MAX_CG];
// ISDN_Circuit_struct circuit_pond[ISDN_MAX_CIRCUIT];
ISDN_Link_struct link_pond[ISDN_MAX_CIRCUIT];
// u8 e1_start;
ISDN_Port_struct port_pond[ISDN_MAX_PORT];
ISDN_Attrib_struct attrib;
}ISDN_Resource_Pond;
ISDN_Resource_Pond isdn_rs;
/************************************************************
ISDN Resource functions interface
************************************************************/
u32 find_port_by_callref(u16 cref, u16 circuit_id);
extern int find_port_by_sap(Pst *pst);
extern u32 isdn_assign_port(u16 circuit_id);
extern u32 find_port_by_cic(u32 cic, u16 circuit_id);
extern int find_circuit_by_interfaceId(int cg_id, u8 interface_id);
#endif

1373
plat/isdn/src/isdn_debug.c Normal file

File diff suppressed because it is too large Load Diff

3124
plat/isdn/src/isdn_fsm.c Normal file

File diff suppressed because it is too large Load Diff

1665
plat/isdn/src/isdn_ie.c Normal file

File diff suppressed because it is too large Load Diff

3439
plat/isdn/src/isdn_msg.c Normal file

File diff suppressed because it is too large Load Diff

515
plat/isdn/src/isdn_rm.c Normal file
View File

@@ -0,0 +1,515 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_rm.c
Description: ISDN Resource Management
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-2-19
History:
<author> <date> <version> <desc>
************************************************************/
#include "./include/isdn_const.h"
#include "../../m2ua/src/include/m2ua_const.h"
#include "./include/isdn_rm.h"
#include "./include/isdn_debug.h"
#include "./include/isdn_ext.h"
#include "./include/isdn_inc.h"
extern int isdn_receive_msg();
extern int isdn_redirect_receive();
extern void isdn_send_heartbeat(int link_id);
extern void isdn_cpc_timer(u32 pid);
extern void maintenance_timer(u32 pid);
extern void isdn_restart_timer(u32 pid);
extern void service_dc_proc(u32 pid);
extern void isdn_restart_ctrl(u32 pid);
extern int trans_callref_sd_rest_req(u32 pid, u8 g_pri_cmd);
/*************************************************************
Function: timer_init
Description: initialize the timers of isdn
Input: interval_ms:time cycle
Return: NULL
*************************************************************/
static void timer_init(u32 interval_ms)
{
isdn_timer_var.t301 = ISDN_T301 * 1000 / interval_ms;
isdn_timer_var.t302 = ISDN_T302 * 1000 / interval_ms;
isdn_timer_var.t303 = ISDN_T303 * 1000 / interval_ms;
isdn_timer_var.t304 = ISDN_T304 * 1000 / interval_ms;
isdn_timer_var.t305 = ISDN_T305 * 1000 / interval_ms;
isdn_timer_var.t306 = ISDN_T306 * 1000 / interval_ms;
isdn_timer_var.t307 = ISDN_T307 * 1000 / interval_ms;
isdn_timer_var.t308 = ISDN_T308 * 1000 / interval_ms;
isdn_timer_var.t309 = ISDN_T309 * 1000 / interval_ms;
isdn_timer_var.t310 = ISDN_T310 * 1000 / interval_ms;
isdn_timer_var.t312 = ISDN_T312 * 1000 / interval_ms;
isdn_timer_var.t313 = ISDN_T313 * 1000 / interval_ms;
isdn_timer_var.t316 = ISDN_T316 * 1000 / interval_ms;
isdn_timer_var.t317 = ISDN_T317 * 1000 / interval_ms;
isdn_timer_var.t321 = ISDN_T321 * 1000 / interval_ms;
isdn_timer_var.t322 = ISDN_T322 * 1000 / interval_ms;
isdn_timer_var.t1s = ISDN_T1 * 1000 / interval_ms + 20;
isdn_timer_var.t3M1 = ISDN_T3M1 * 1000 / interval_ms;
}
/*************************************************************
Function: isdn_init
Description: initialize the parameters of isdn
Input: systemID:plat id, interval_ms:time cycle
Return: ISDN_CM_OK:success
*************************************************************/
int isdn_init(u8 systemID, u32 interval_ms)
{
u32 stack_size;
if(interval_ms == 0)
interval_ms = 10;
printf("Start ISDN module init...\n");
memset(&isdn_rs, 0, sizeof(ISDN_Resource_Pond));
memset(&isdn_timer_var, 1, sizeof(IsdnTimerStr));
memset(&isdn_rv_msg, 0, sizeof(IsdnMsgStr));
memset(&isdn_sd_msg, 0, sizeof(IsdnMsgStr));
memset(&iua_rv_msg, 0, sizeof(IuaMsgStr));
memset(&iua_sd_msg, 0, sizeof(IuaMsgStr));
timer_init(interval_ms);
isdn_rs.attrib.systemID = systemID;
isdn_rs.attrib.isdn_remote_ip = 0;
isdn_rs.attrib.isdn_run_mode = 0;
stack_size = sizeof(ISDN_Resource_Pond) + sizeof(IsdnTimerStr);
isdn_debug_init();
printf("ISDN module init completed, stack size: %ld bytes\n", stack_size);
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_sd_link
Description: isdn send link command to iua
Input: iua_id:link number, opercode:link command parameter
Return: ISDN_CM_OK:success
*************************************************************/
int isdn_sd_link(u8 link_id, u8 opercode)
{
IuaMsgStr isdn_lk;
isdn_lk.msg_class = IUA_MGMT_CMD;
isdn_lk.e1_no = link_id;
isdn_lk.msg_length = htons(0x0003);
isdn_lk.msgcontent.lkmsg.opercode = opercode;
put_xua_msg((xua_up_msg_t*)&isdn_lk.msg_class);
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_link_ctrl
Description: isdn link control
Input: NULL
Return: NULL
*************************************************************/
void isdn_link_ctrl()
{
int i, link_id;
const pal_circuit_struct *circuit_ptr = NULL;
const pal_cg_struct *cg_ptr = NULL;
for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //for timer //setup link
{
circuit_ptr = pal_circuit_ptr(i);
if(circuit_ptr == NULL)
continue;
if(circuit_ptr->enable == 0)
continue;
if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) &&
(circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID))
continue;
cg_ptr = pal_cg_ptr(circuit_ptr->cg_id);
if(cg_ptr == NULL)
continue;
if(cg_ptr->attrib.protocol != PROTO_ISDN)
continue;
if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) ||
(cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE)))
continue;
link_id = circuit_ptr->attrib.link_id;
if(cg_ptr->enable)
{
if(isdn_rs.link_pond[link_id].lk3_status == LK_OOS)
{
if(cg_ptr->attrib.nfas.flag) //nfas
{
if((cg_ptr->attrib.nfas.prim_link != link_id) &&
(cg_ptr->attrib.nfas.backup_link != link_id))
continue;
}
isdn_sd_link(link_id, xUA_ENABLE_xUA_LINK); //enable
isdn_sd_link(link_id, M2UA_MTP3_CMD_ACTIVE_LK); //active
}
}
else //modify by 080821
{
if(isdn_rs.link_pond[link_id].lk3_status == LK_IS)
{
if(cg_ptr->attrib.nfas.flag)
{
if((cg_ptr->attrib.nfas.prim_link != link_id) &&
(cg_ptr->attrib.nfas.backup_link != link_id))
continue;
}
isdn_sd_link(link_id, M2UA_MTP3_CMD_DEACTIVE_LK);
isdn_sd_link(link_id, xUA_STOP_xUA_LINK);
}
}
}
for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //release link
{
circuit_ptr = pal_circuit_ptr(i);
if(circuit_ptr == NULL)
continue;
/* if(circuit_ptr->enable == 0)
{
continue;
}*/
if(((isdn_rs.attrib.isdn_run_mode == ISDN_SINGLE_MODE) ||
(isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE &&
circuit_ptr->attrib.plat_id == isdn_rs.attrib.systemID)) &&
(circuit_ptr->enable == 1)) //modify by 080821
continue;
cg_ptr = pal_cg_ptr(circuit_ptr->cg_id);
if(cg_ptr == NULL)
continue;
if(cg_ptr->attrib.protocol != PROTO_ISDN)
continue;
if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) ||
(cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE)))
continue;
link_id = circuit_ptr->attrib.link_id;
if(isdn_rs.link_pond[link_id].lk3_status == LK_IS)
{
if(cg_ptr->attrib.nfas.flag)
{
if((cg_ptr->attrib.nfas.prim_link != link_id) &&
(cg_ptr->attrib.nfas.backup_link != link_id))
continue;
}
isdn_sd_link(link_id, M2UA_MTP3_CMD_DEACTIVE_LK);
isdn_sd_link(link_id, xUA_STOP_xUA_LINK);
}
}
}
void isdn_heartbeat_timer(int link_id)
{
if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0)
{
isdn_rs.link_pond[link_id].plat_heartbeat_time--;
if(isdn_rs.link_pond[link_id].plat_heartbeat_time == 0)
{
isdn_rs.link_pond[link_id].dc_status = DS_OOS;
isdn_log_err(0, "link %d heartbeat timeout: another plat doesnot send link state!\r\n",link_id);
}
}
}
/*************************************************************
Function: isdn_timer
Description: isdn task schedule, include isdn link control, isdn receive msg from iua and control the timer
Input: NULL
Return: NULL
*************************************************************/
void isdn_timer()
{
u16 i, j, chnl_j, cg_id;
u32 offset, pid;
int circuit_cic, link_id, ds_0, ds_1;
static int link_10s = 0;
const pal_circuit_struct *circuit_ptr = NULL;
const pal_cg_struct *cg_ptr = NULL;
link_10s++;
if(link_10s % 600 == 0) // 6s
{
isdn_link_ctrl(); //setup link
link_10s = 0;
}
for(i = 0; i < 64; i++)
{
if(isdn_receive_msg() == 0)
break; //no message in lower layer
if(isdn_redirect_receive() == 0)
break; //no message from another plat
}
for(i = 0; i < ISDN_MAX_CIRCUIT; i++) //for timer
{
circuit_ptr = pal_circuit_ptr(i);
if(circuit_ptr == NULL)
continue;
if(circuit_ptr->enable == 0)
continue;
if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) &&
(circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID))
continue;
cg_id = circuit_ptr->cg_id;
cg_ptr = pal_cg_ptr(cg_id);
if(cg_ptr == NULL)
continue;
if(cg_ptr->attrib.protocol != PROTO_ISDN)
continue;
if(!(cg_ptr->attrib.variant == VARIANT_ITU || cg_ptr->attrib.variant == VARIANT_ANSI || cg_ptr->attrib.variant == VARIANT_QSIG) ||
(cg_ptr->attrib.variant == VARIANT_QSIG && (cg_ptr->attrib.nfas.flag || circuit_ptr->attrib.user_network_if == NETWORK_SIDE)))
continue;
link_id = circuit_ptr->attrib.link_id;
isdn_rs.link_pond[link_id].link_heartbeat_time++;
if(isdn_rs.link_pond[link_id].link_heartbeat_time % LINK_MAX_TIME == 0)
{
isdn_rs.link_pond[link_id].lk3_status = isdn_rs.link_pond[link_id].lk2_status;
isdn_rs.link_pond[link_id].lk2_status = LK_OOS;
isdn_rs.link_pond[link_id].link_heartbeat_time = 0;
}
circuit_cic = circuit_ptr->attrib.cic_range;
offset = ISDN_CIRCUIT_CIC * i; //ISDN_CIRCUIT_CIC
if(circuit_cic == 24) //T1
{
if((trans_callref_sd_rest_req(offset+24, ISDN_RESTART_CNF)) == circuit_cic)
{
isdn_rs.port_pond[offset+24].g_pri_cmd = ISDN_RESTART_CNF;
isdn_restart_ctrl(offset+24); //restart control
}
// offset++;
}
else
{
if((trans_callref_sd_rest_req(offset, ISDN_RESTART_CNF)) == circuit_cic)
{
isdn_rs.port_pond[offset].g_pri_cmd = ISDN_RESTART_CNF;
isdn_restart_ctrl(offset); //restart control
}
}
for(j = 0; j < circuit_cic; j++)
{
chnl_j = j;
if(circuit_cic == 24) //T1
chnl_j = j + 1;
pid = offset + chnl_j;
if(cg_ptr->attrib.nfas.flag) //NFAS
{
ds_0 = cg_ptr->attrib.nfas.prim_link;
ds_1 = cg_ptr->attrib.nfas.backup_link;
if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel
{
if(ds_0 == link_id)
{
if(isdn_rs.link_pond[link_id].lk3_status == LK_IS)
{
if((isdn_rs.link_pond[ds_0].dc_status == DS_MOOS) &&
(isdn_rs.link_pond[ds_1].dc_status != DS_IS))
isdn_rs.port_pond[pid].g_pri_cmd = ISDN_SERVICE_REQ;
}
else
isdn_rs.link_pond[link_id].dc_status = DS_OOS;
service_dc_proc(pid);
if((link_10s % 100 == 0) && (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE)) //send heartbeat per 1 second
isdn_send_heartbeat(link_id);
if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0)
isdn_rs.link_pond[link_id].plat_heartbeat_time = 0;
}
else if(ds_1 == link_id)
{
if(isdn_rs.link_pond[link_id].lk3_status == LK_IS)
{
if((isdn_rs.link_pond[ds_1].dc_status == DS_MOOS) &&
((isdn_rs.link_pond[ds_0].dc_status == DS_OOS) ||
(isdn_rs.link_pond[ds_0].dc_status == DS_STBY)))
isdn_rs.port_pond[pid].g_pri_cmd = ISDN_SERVICE_REQ;
}
else
isdn_rs.link_pond[link_id].dc_status = DS_OOS;
service_dc_proc(pid);
if((link_10s % 100 == 0) && (isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE)) //send heartbeat per 1 second
isdn_send_heartbeat(link_id);
if(isdn_rs.link_pond[link_id].plat_heartbeat_time > 0)
isdn_rs.link_pond[link_id].plat_heartbeat_time = 0;
}
}
}
else //associated signaling
{
if(isdn_rs.link_pond[link_id].lk3_status == LK_IS)
{
if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel
isdn_rs.link_pond[link_id].dc_status = DS_IS;
}
else
{
if(circuit_ptr->attrib.d_chnl == chnl_j) //d-channel
isdn_rs.link_pond[link_id].dc_status = DS_OOS;
}
}
if(isdn_rs.port_pond[pid].enable)
isdn_cpc_timer(pid);
isdn_restart_timer(pid);
maintenance_timer(pid);
}
if(isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE)
isdn_heartbeat_timer(i);
}
isdn_debug_timer();
}
/*************************************************************
Function: isdn_assign_port
Description: isdn assign the port id
Input: e1no:link number
Return: port id:success
0:failed
*************************************************************/
u32 isdn_assign_port(u16 circuit_id)
{
u8 i, chnl;
u32 e1nox32 = 0;
u32 portnum = 0;
chnl = 32;
e1nox32 = circuit_id;
e1nox32 = (e1nox32 << 5);
for(i = 0; i < 31; i++)
{
chnl = (chnl - i) & 0x1F;
if (((chnl & 0x1F) != 0) && (chnl != 16))
{
portnum = e1nox32 + chnl;
if (isdn_rs.port_pond[portnum].enable == 0)
{
if(isdn_rs.port_pond[portnum].cic_state.maintenance_state != IN_SERVICE)
{
isdn_log_err(0, "this cic is not in service in assign port!\r\n");
break;
}
isdn_rs.port_pond[portnum].enable = 1;
return portnum;
}
}
}
return 0;
}
/*************************************************************
Function: find_port_by_callref
Description: find port id by the call referrence and link id
Input: cref:call referrence, circuit_id:circuit id
Return: port id:success
0:failed
*************************************************************/
u32 find_port_by_callref(u16 cref, u16 circuit_id)
{
int i, circuit_cic, d_chnl=16;
u32 portnum = 0;
const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id);
if(circuit_ptr == NULL)
return ISDN_CM_FAILED;
circuit_cic = circuit_ptr->attrib.cic_range;
if(circuit_cic == 24) //T1
{
d_chnl = 24;
}
portnum = (circuit_id * ISDN_CIRCUIT_CIC) + 1;
for (i = 1; i < circuit_cic; i++, portnum++)
{
if (i != d_chnl)
{
if(isdn_rs.port_pond[portnum].call_ref == cref)
return portnum;
}
}
// isdn_log_err(0, "find port by callref err!call_ref=%d, circuit_id=%d\r\n",cref, circuit_id);
return 0;
}
/*************************************************************
Function: find_port_by_cic
Description: find port id by the cic of one link
Input: cic:cic, circuit_id:circuit id
Return: port id:success
*************************************************************/
u32 find_port_by_cic(u32 cic, u16 circuit_id)
{
u32 head_cic;
const pal_circuit_struct *circuit_ptr = pal_circuit_ptr(circuit_id);
if(circuit_ptr == NULL)
return ISDN_CM_FAILED;
head_cic = circuit_ptr->attrib.head_cic;
if(circuit_ptr->attrib.cic_range == 24)
head_cic--;
return ISDN_CIRCUIT_CIC * circuit_id + (cic - head_cic);
}
int find_circuit_by_interfaceId(int cg_id, u8 interface_id)
{
int i;
const pal_circuit_struct *circuit_ptr = NULL;
for(i = 0; i < ISDN_MAX_CIRCUIT; i++)
{
circuit_ptr = pal_circuit_ptr(i);
if(circuit_ptr == NULL)
continue;
if(circuit_ptr->enable == 0)
continue;
if((isdn_rs.attrib.isdn_run_mode == ISDN_DUAL_MODE) &&
(circuit_ptr->attrib.plat_id != isdn_rs.attrib.systemID))
continue;
if(circuit_ptr->cg_id != cg_id)
continue;
if((circuit_ptr->attrib.cic_range != 0) && (circuit_ptr->attrib.head_cic / circuit_ptr->attrib.cic_range) == interface_id)
return i;
}
isdn_log_err(0, "find circuit by interface id err!cg_id=%d, interface_id=%d\r\n",cg_id, interface_id);
return -1;
}
//d-channel status
int check_dc_status(u8 link_id)
{
if(isdn_rs.link_pond[link_id].dc_status == DS_IS)
return ISDN_CM_OK;
else
return ISDN_CM_FAILED;
}
int isdn_set_run_mode (u8 run_mode, u32 alter_ip)
{
isdn_trace_func(0,"APP => function trace: %s\r\n", __FUNCTION__);
isdn_rs.attrib.isdn_run_mode = run_mode % 2;
isdn_rs.attrib.isdn_remote_ip = alter_ip;
return ISDN_CM_OK;
}

428
plat/isdn/src/isdn_uif.c Normal file
View File

@@ -0,0 +1,428 @@
/***********************************************************
Copyright (C), LGC Wireless.
File Name: isdn_uif.c
Description: ISDN USER INTERFACE
Version: v9.0.0
Author: Gengxin Chen
Create Date: 2008-2-19
History:
<author> <date> <version> <desc>
************************************************************/
#include "./include/isdn_const.h"
#include "./include/isdn_rm.h"
#include "./include/isdn_debug.h"
#include "./include/isdn_ext.h"
#include "./include/isdn_inc.h"
extern void isdn_cpc_proc(u32 pid);
extern void isdn_restart_ctrl(u32 pid);
extern void service_bc_proc(u32 pid);
/*************************************************************
Function: isdn_setup_req
Description: msc invokes the function to request setup
Output: pst:post structure pointer, ptr:isdn setup structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_setup_req(Pst *pst, IsdnSetup *ptr)
{
const pal_circuit_struct *circuit_ptr = NULL;
circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic);
if(circuit_ptr == NULL)
{
isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__);
return ISDN_CM_FAILED;
}
pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_ptr->id);
isdn_rs.port_pond[pst->sp_proc_id].su_proc_id = pst->su_proc_id;
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_SETUP_REQ;
isdn_rs.port_pond[pst->sp_proc_id].trace_flag = pst->trace_flag;
isdn_rs.port_pond[pst->sp_proc_id].enable = 1;
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state != IDLE_FLAG)
{
isdn_log_err(pst->sp_proc_id, "call state is not idle, but is %d\n", isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state);
return ISDN_CM_FAILED;
}
memcpy(&(isdn_sd_msg.msg_list.setup), ptr, sizeof(IsdnSetup));
if(circuit_ptr->attrib.user_network_if)
isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state = CALLOUT_FLAG;
else
isdn_rs.port_pond[pst->sp_proc_id].cic_state.call_state = CALLIN_FLAG;
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_m_info_req
Description: msc invokes the function to request more information
Output: pst:post structure pointer, ptr:isdn setup ack structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_m_info_req(Pst *pst, IsdnSetupAck *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_MORE_INFO_REQ;
memcpy(&(isdn_sd_msg.msg_list.setupAck), ptr, sizeof(IsdnSetupAck));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_call_proc_req
Description: msc invokes the function to request call proceeding
Output: pst:post structure pointer, ptr:isdn call proceeding structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_call_proc_req(Pst *pst, IsdnCallProc *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_PROC_REQ;
memcpy(&(isdn_sd_msg.msg_list.callProc), ptr, sizeof(IsdnCallProc));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_alert_req
Description: msc invokes the function to request alerting
Output: pst:post structure pointer, ptr:isdn alerting structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_alert_req(Pst *pst, IsdnAlert *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_ALERT_REQ;
memcpy(&(isdn_sd_msg.msg_list.alert), ptr, sizeof(IsdnAlert));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_setup_resp
Description: msc invokes the function to request setup response
Output: pst:post structure pointer, ptr:isdn connect structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_setup_resp(Pst *pst, IsdnConn *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_SETUP_RSP;
memcpy(&(isdn_sd_msg.msg_list.conn), ptr, sizeof(IsdnConn));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_disc_req
Description: msc invokes the function to request disconnect
Output: pst:post structure pointer, ptr:isdn disconnect structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_disc_req(Pst *pst, IsdnDisc *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_DISCONNECT_REQ;
memcpy(&(isdn_sd_msg.msg_list.disc), ptr, sizeof(IsdnDisc));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_rel_req
Description: msc invokes the function to request release
Output: pst:post structure pointer, ptr:isdn release structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_rel_req(Pst *pst, IsdnRel *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_RELEASE_REQ;
memcpy(&(isdn_sd_msg.msg_list.rel), ptr, sizeof(IsdnRel));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
int isdn_rej_req(Pst *pst, IsdnRelComp *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal)\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_REJECT_REQ;
memcpy(&(isdn_sd_msg.msg_list.relComp), ptr, sizeof(IsdnRelComp));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_info_req
Description: msc invokes the function to request information
Output: pst:post structure pointer, ptr:isdn information structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_info_req(Pst *pst, IsdnInfo *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_INFO_REQ;
memcpy(&(isdn_sd_msg.msg_list.info), ptr, sizeof(IsdnInfo));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_prog_req
Description: msc invokes the function to request progress
Output: pst:post structure pointer, ptr:isdn progress structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_prog_req(Pst *pst, IsdnProg *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_PROG_REQ;
memcpy(&(isdn_sd_msg.msg_list.prog), ptr, sizeof(IsdnProg));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_noti_req
Description: msc invokes the function to request notify
Output: pst:post structure pointer, ptr:isdn notify structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_noti_req(Pst * pst, IsdnNoti * ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = ISDN_NOTI_REQ;
memcpy(&(isdn_sd_msg.msg_list.noti), ptr, sizeof(IsdnNoti));
isdn_cpc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd);
isdn_rs.port_pond[pst->sp_proc_id].primitive_cmd = 0;
}
return ISDN_CM_OK;
}
/*************************************************************
Function: isdn_m_restart_req
Description: msc invokes the function to request management restart
Output: pst:post structure pointer, ptr:isdn restart structure pointer
Return: ISDN_CM_OK:success
ISDN_CM_FAILED:failed
*************************************************************/
int isdn_m_restart_req(Pst *pst, IsdnRestart *ptr) //restart indicated channel
{
u32 pid, link_id;
int circuit_id;
const pal_cg_struct *cg_ptr = NULL;
const pal_circuit_struct *circuit_ptr = NULL;
isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__);
cg_ptr = pal_cg_ptr(pst->cg_id);
if(cg_ptr == NULL)
return ISDN_CM_FAILED;
if(cg_ptr->attrib.protocol != PROTO_ISDN)
return ISDN_CM_FAILED;
circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic);
if(circuit_ptr == NULL)
{
isdn_log_err(0, "isdn_m_restart_req err!circuit_ptr cann't be found by vcg_id=%d,cic=%ld \r\n", pst->cg_id, pst->cic);
return ISDN_CM_FAILED;
}
circuit_id = circuit_ptr->id;
pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_id);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
memcpy(&(isdn_sd_msg.msg_list.restart), ptr, sizeof(IsdnRestart));
pid = (circuit_id) * ISDN_CIRCUIT_CIC;
link_id = circuit_ptr->attrib.link_id;
if(ptr->restart_ind.clas == 0)
isdn_rs.port_pond[pid].cic_val = pst->cic;
else
isdn_rs.port_pond[pid].cic_val = 0;
isdn_rs.link_pond[link_id].restart_clas = ptr->restart_ind.clas;
isdn_rs.port_pond[pid].g_pri_cmd = ISDN_M_RESTART_REQ;
isdn_restart_ctrl(pid);
if(isdn_rs.port_pond[pid].g_pri_cmd != 0)
{
isdn_trace_func(pid, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd);
isdn_rs.port_pond[pid].g_pri_cmd = 0;
}
return ISDN_CM_OK;
}
//ansi
int isdn_service_bc_req(Pst *pst, IsdnService *ptr)
{
const pal_circuit_struct *circuit_ptr = NULL;
circuit_ptr = pal_locate_circuit(pst->cg_id, pst->cic);
if(circuit_ptr == NULL)
{
isdn_trace_func(0, "APP => function trace: %s\r\n", __FUNCTION__);
return ISDN_CM_FAILED;
}
pst->sp_proc_id = find_port_by_cic(pst->cic, circuit_ptr->id);
isdn_rs.port_pond[pst->sp_proc_id].su_proc_id = pst->su_proc_id;
isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = ISDN_SERVICE_REQ;
isdn_rs.port_pond[pst->sp_proc_id].trace_flag = pst->trace_flag;
// isdn_rs.port_pond[pst->sp_proc_id].enable = 1;
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
memcpy(&(isdn_sd_msg.msg_list.service), ptr, sizeof(IsdnService));
service_bc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd);
isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = 0;
}
return ISDN_CM_OK;
}
int isdn_service_bc_rsp(Pst *pst, IsdnServAck *ptr)
{
isdn_trace_func(pst->sp_proc_id, "APP => function trace: %s\r\n", __FUNCTION__);
if(pst->sp_proc_id >= ISDN_MAX_PORT)
{
isdn_log_err(0, "pid=%d, is paranormal\r\n", pst->sp_proc_id);
return ISDN_CM_FAILED;
}
isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = ISDN_SERVICE_RSP;
memcpy(&(isdn_sd_msg.msg_list.servAck), ptr, sizeof(IsdnServAck));
service_bc_proc(pst->sp_proc_id);
if(isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd != 0)
{
isdn_trace_func(pst->sp_proc_id, "[waring]global primitive cmd discard.(cmd=%d)\r\n", isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd);
isdn_rs.port_pond[pst->sp_proc_id].g_pri_cmd = 0;
}
return ISDN_CM_OK;
}