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

99
plat/m2ua/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 = m2ua
TYPE = plat
DBUG_FLAGS_ADD = -D_LKSCTP
RELS_FLAGS_ADD = -D_LKSCTP
##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,140 @@
#ifndef _M2UA__H
#define _M2UA__H
//#include "m2ua_struct.h"
#ifndef M2UA_MAX_MSG_LEN
#define M2UA_MAX_MSG_LEN 300
#endif
typedef struct _m2ua_up_msg
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed));
BYTE sio __attribute__((packed));
union
{
struct
{
BYTE content[M2UA_MAX_MSG_LEN] __attribute__((packed));
}mtp3 __attribute__((packed));
struct
{
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}lm __attribute__((packed));
}msg __attribute__((packed));
}m2ua_up_msg_t;
void m2ua_init(BYTE);
void m2ua_timer(void);
int get_m2ua_msg(m2ua_up_msg_t **data_ptr);
int put_m2ua_msg(m2ua_up_msg_t *data_ptr);
int set_m2ua_link(BYTE link, BYTE *data_ptr);
int set_m2ua_sg(WORD sg, BYTE *data_ptr);
int m2ua_restart();
typedef struct _xua_lm_lk
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed)); /* len = 3 */
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}xua_lm_lk;
typedef struct _xua_iua_msg
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed)); /* len for content */
BYTE content[M2UA_MAX_MSG_LEN] __attribute__((packed));
}xua_iua_msg;
typedef struct _xua_m2ua_msg
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed)); /* len for content */
BYTE content[M2UA_MAX_MSG_LEN] __attribute__((packed));
}xua_m2ua_msg;
typedef struct _xua_m3ua_msg
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed)); /* len for content */
DWORD rc __attribute__((packed));
DWORD opc __attribute__((packed)); /* routing label*/
DWORD dpc __attribute__((packed)); /* Big-Endian (WORD, DWORD) */
BYTE si __attribute__((packed));
BYTE ni __attribute__((packed));
BYTE mp __attribute__((packed));
BYTE sls __attribute__((packed));
BYTE content[M2UA_MAX_MSG_LEN] __attribute__((packed)); /* mtp3-user data */
}xua_m3ua_msg;
typedef struct _xua_rc_cmd
{
BYTE link __attribute__((packed));
WORD len __attribute__((packed)); /* len = 5 */
DWORD rc __attribute__((packed)); //Routing_Context
BYTE opercode __attribute__((packed)); //Routing_Context statue
/*
DWORD aff_pc __attribute__((packed)); //M3UA_Affected_PC
DWORD user_cause __attribute__((packed)); //M3UA_User_Cause
DWORD cong_ind __attribute__((packed)); //M3UA_Congestion_Indications
DWORD con_dpc __attribute__((packed)); //M3UA_Concerned_Destination
*/
}xua_rc_cmd;
typedef struct _xua_up_msg
{
BYTE msg_class __attribute__((packed));
union
{
xua_lm_lk lm_lk __attribute__((packed));
xua_m2ua_msg m2ua __attribute__((packed));
xua_iua_msg iua __attribute__((packed));
xua_m3ua_msg m3ua __attribute__((packed));
xua_rc_cmd rc_cmd __attribute__((packed));
}msg __attribute__((packed));
}xua_up_msg_t;
int get_xua_msg(BYTE xUA_type, xua_up_msg_t **data_ptr);
int put_xua_msg(xua_up_msg_t *data_ptr);
int get_m3ua_msg(xua_up_msg_t **data_ptr);
int put_m3ua_msg(xua_up_msg_t *data_ptr);
#define XUAHEADOFFSET 4 //msg_class(1)+lk(1)+len(2)
#define RESERVE_FOR_IUAHEAD (28 - XUAHEADOFFSET)
#define RESERVE_FOR_M2UAHEAD (20 - XUAHEADOFFSET)
#define RESERVE_FOR_M3UAHEAD (20 - XUAHEADOFFSET -4)
#define IUA_QPTM_MSG 0x05
#define M2UA_MAUP_MSG 0x06
#define M3UA_MAUP_MSG 0x07
#define IUA_MGMT_CMD 0xA5
#define M2UA_MGMT_CMD 0xA6
#define M3UA_MGMT_CMD 0xA7
#define M3UA_RC_CMD 0xF5
#define M2UA_APP 0
#define IUA_APP 1
#define M3UA_APP 2
#endif

View File

@@ -0,0 +1,381 @@
#ifndef _M2UA_CONST__H
#define _M2UA_CONST__H
#define M2UA_MAX_LK_NUM 256
#define M2UA_MAX_MSG_LEN 300
#define M2UA_MAX_SG_NUM 512
#define M2UA_LISTEN_SG_NUM_0 512
#define M2UA_LISTEN_SG_NUM_1 513
#define IUA_LISTEN_SG_NUM_0 514
#define IUA_LISTEN_SG_NUM_1 515
#define M3UA_LISTEN_SG_NUM_0 516
#define M3UA_LISTEN_SG_NUM_1 517
#define M2UA_PORT_0 2904
#define M2UA_PORT_1 12904
#define IUA_PORT_0 9900
#define IUA_PORT_1 19900
#define M3UA_PORT_0 2905
#define M3UA_PORT_1 12905
#define M2UA_MAX_SG_FSM_NUM (512+6)//for listen m2ua*2,iua*2,m3ua*2
#define M2UA_MAX_M3MSG_NUM 2048
#define M2UA_MAX_M3MSG_NUM_1 2047
#define M2UA_SCTP_CMD_BUFSIZE 5*1024
#define M2UA_SCTP_DAT_BUFSIZE 5*1024
#define M2UA_FAILURE -1
#define M2UA_SUCCESS 0
#define M2UA_CMD_IDLEW 0xEEEE
// M2UA Message Class
#define M2UA_MCLASS_MGMT 0
#define M2UA_MCLASS_ASPSM 3
#define M2UA_MCLASS_ASPTM 4
#define M2UA_MCLASS_MAUP 6
#define M2UA_MCLASS_IIM 10
#define xUA_MCLASS_MGMT 0
#define xUA_MCLASS_TRMSG 1
#define xUA_MCLASS_SSNM 2
#define xUA_MCLASS_ASPSM 3
#define xUA_MCLASS_ASPTM 4
#define xUA_MCLASS_QPTM 5
#define xUA_MCLASS_MAUP 6
#define xUA_MCLASS_RKM 9
#define xUA_MCLASS_IIM 10
// M2UA ASPSM Message Type
#define ASP_UP 1
#define ASP_DOWN 2
#define HEARTBEAT 3
#define ASP_UP_ACK 4
#define ASP_DOWN_ACK 5
#define HEARTBEAT_ACK 6
// M2UA ASPSM Combined Message Type
#define M2UA_ASPSM_ASP_UP (M2UA_MCLASS_ASPSM << 8) + ASP_UP
#define M2UA_ASPSM_ASP_DOWN (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN
#define M2UA_ASPSM_HEARTBEAT (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT
#define M2UA_ASPSM_ASP_UP_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define M2UA_ASPSM_ASP_DOWN_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define M2UA_ASPSM_HEARTBEAT_ACK (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
#define xUA_ASPSM_ASP_UP (xUA_MCLASS_ASPSM << 8) + ASP_UP
#define xUA_ASPSM_ASP_DOWN (xUA_MCLASS_ASPSM << 8) + ASP_DOWN
#define xUA_ASPSM_HEARTBEAT (xUA_MCLASS_ASPSM << 8) + HEARTBEAT
#define xUA_ASPSM_ASP_UP_ACK (xUA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define xUA_ASPSM_ASP_DOWN_ACK (xUA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define xUA_ASPSM_HEARTBEAT_ACK (xUA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
#define ASP_ACTIVE 1
#define ASP_INACTIVE 2
#define ASP_ACTIVE_ACK 3
#define ASP_INACTIVE_ACK 4
#define M2UA_ASPTM_ASP_ACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define M2UA_ASPTM_ASP_INACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define M2UA_ASPTM_ASP_ACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define M2UA_ASPTM_ASP_INACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
#define xUA_ASPTM_ASP_ACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define xUA_ASPTM_ASP_INACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define xUA_ASPTM_ASP_ACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define xUA_ASPTM_ASP_INACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
//for MAUP
#define DATA 1
#define ESTABLISH_REQ 2
#define ESTABLISH_CFM 3
#define RELEASE_REQ 4
#define RELEASE_CFM 5
#define RELEASE_IND 6
#define STATE_REQ 7
#define STATE_CFM 8
#define STATE_IND 9
#define DATA_RETIEVE_REQ 10
#define DATA_RETIEVE_CFM 11
#define DATA_RETIEVE_IND 12
#define DATA_RETIEVE_CMP 13
#define CONGESTION_IND 14
#define DATA_ACK 15
#define M2UA_MAUP_DATA (M2UA_MCLASS_MAUP << 8) + DATA
#define M2UA_MAUP_ESTABLISH_REQ (M2UA_MCLASS_MAUP << 8) + ESTABLISH_REQ
#define M2UA_MAUP_ESTABLISH_CFM (M2UA_MCLASS_MAUP << 8) + ESTABLISH_CFM
#define M2UA_MAUP_RELEASE_REQ (M2UA_MCLASS_MAUP << 8) + RELEASE_REQ
#define M2UA_MAUP_RELEASE_CFM (M2UA_MCLASS_MAUP << 8) + RELEASE_CFM
#define M2UA_MAUP_RELEASE_IND (M2UA_MCLASS_MAUP << 8) + RELEASE_IND
#define M2UA_MAUP_STATE_REQ (M2UA_MCLASS_MAUP << 8) + STATE_REQ
#define M2UA_MAUP_STATE_CFM (M2UA_MCLASS_MAUP << 8) + STATE_CFM
#define M2UA_MAUP_STATE_IND (M2UA_MCLASS_MAUP << 8) + STATE_IND
#define M2UA_MAUP_DATA_RETIEVE_REQ (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_REQ
#define M2UA_MAUP_DATA_RETIEVE_CFM (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CFM
#define M2UA_MAUP_DATA_RETIEVE_IND (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_IND
#define M2UA_MAUP_DATA_RETIEVE_CMP (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CMP
#define M2UA_MAUP_CONGESTION_IND (M2UA_MCLASS_MAUP << 8) + CONGESTION_IND
#define M2UA_MAUP_DATA_ACK (M2UA_MCLASS_MAUP << 8) + DATA_ACK
//Transfer Messages
#define M3UA_DATA 1
//SSNM
#define SSNM_DUNA 1 // 1 Destination Unavailable (DUNA)
#define SSNM_DAVA 2 // 2 Destination Available (DAVA)
#define SSNM_DAUD 3 // 3 Destination State Audit (DAUD)
#define SSNM_SCON 4 // 4 Signalling Congestion (SCON)
#define SSNM_DUPU 5 // 5 Destination User Part Unavailable (DUPU)
#define SSNM_DRST 6 // 6 Destination Restricted (DRST)
#define M3UA_MAUP_DATA (xUA_MCLASS_TRMSG << 8) + M3UA_DATA
#define M3UA_SSNM_DUNA (xUA_MCLASS_SSNM << 8) + SSNM_DUNA
#define M3UA_SSNM_DAVA (xUA_MCLASS_SSNM << 8) + SSNM_DAVA
#define M3UA_SSNM_DAUD (xUA_MCLASS_SSNM << 8) + SSNM_DAUD
#define M3UA_SSNM_SCON (xUA_MCLASS_SSNM << 8) + SSNM_SCON
#define M3UA_SSNM_DUPU (xUA_MCLASS_SSNM << 8) + SSNM_DUPU
#define M3UA_SSNM_DRST (xUA_MCLASS_SSNM << 8) + SSNM_DRST
//QPTM
#define IUA_DATA_REQ 1
#define IUA_DATA_IND 2
#define IUA_UDATA_REQ 3
#define IUA_UDATA_IND 4
#define IUA_ESTABLISH_REQ 5
#define IUA_ESTABLISH_CFM 6
#define IUA_ESTABLISH_IND 7
#define IUA_RELEASE_REQ 8
#define IUA_RELEASE_CFM 9
#define IUA_RELEASE_IND 10
#define IUA_QPTM_DATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_DATA_REQ
#define IUA_QPTM_DATA_IND (xUA_MCLASS_QPTM << 8) + IUA_DATA_IND
#define IUA_QPTM_UDATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_UDATA_REQ
#define IUA_QPTM_UDATA_IND (xUA_MCLASS_QPTM << 8) + IUA_UDATA_IND
#define IUA_QPTM_ESTABLISH_REQ (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_REQ
#define IUA_QPTM_ESTABLISH_CFM (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_CFM
#define IUA_QPTM_ESTABLISH_IND (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_IND
#define IUA_QPTM_RELEASE_REQ (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_REQ
#define IUA_QPTM_RELEASE_CFM (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_CFM
#define IUA_QPTM_RELEASE_IND (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_IND
#define xUA_ERROR 0
#define xUA_NOTIFY 1
#define TEI_S_REQ 2
#define TEI_S_CFM 3
#define TEI_S_IND 4
#define M2UA_MGMT_ERROR (M2UA_MCLASS_MGMT << 8) + xUA_ERROR
#define M2UA_MGMT_NOTIFY (M2UA_MCLASS_MGMT << 8) + xUA_NOTIFY
#define xUA_MGMT_ERROR (xUA_MCLASS_MGMT << 8) + xUA_ERROR
#define xUA_MGMT_NOTIFY (xUA_MCLASS_MGMT << 8) + xUA_NOTIFY
#define xUA_MGMT_TEI_S_REQ (xUA_MCLASS_MGMT << 8) + TEI_S_REQ
#define xUA_MGMT_TEI_S_CFM (xUA_MCLASS_MGMT << 8) + TEI_S_CFM
#define xUA_MGMT_TEI_S_IND (xUA_MCLASS_MGMT << 8) + TEI_S_IND
#define M2UA_IIM_REG_REQ 1
#define M2UA_IIM_REG_RSP 2
#define M2UA_IIM_DEREG_REQ 3
#define M2UA_IIM_DEREG_RSP 4
#define M2UA_PAR_INTERFACE_ID_INT 0x0001
#define M2UA_PAR_INTERFACE_ID_TXT 0x0003
#define M2UA_PAR_TRAFFIC_MODE 0x000B
#define M2UA_PAR_CORRELATION_ID xUA_PAR_CORRELATION_ID
#define M2UA_PAR_ASP_IDENTIFIER 0x0011
#define M2UA_PAR_PROTO_DATA_1 0x0300
#define M2UA_PAR_STATE 0x0302
#define M2UA_PAR_STATUS 0x000D
#define M2UA_PAR_ERR_CODE 0x000C
#define xUA_Routing_Context 0x0006
#define xUA_PAR_DLCI 0x0005
#define xUA_PAR_PROTOCOL_DATA 0x000E
#define xUA_PAR_REL_REASON 0x000F
#define xUA_PAR_TEI_STATUS 0x0010
#define xUA_Affected_PC 0x0012
#define xUA_PAR_CORRELATION_ID 0x0013
//M3UA-Specific parameters
#define M3UA_Network_Appearance 0x0200
#define M3UA_User_Cause 0x0204
#define M3UA_Congestion_Indications 0x0205
#define M3UA_Concerned_Destination 0x0206
#define M3UA_Routing_Key 0x0207
#define M3UA_Registration_Result 0x0208
#define M3UA_Deregistration_Result 0x0209
#define M3UA_Local_Routing_Key_Identifier 0x020a
#define M3UA_Destination_Point_Code 0x020b
#define M3UA_Service_Indicators 0x020c
#define M3UA_Originating_Point_Code_List 0x020e
#define M3UA_Circuit_Range 0x020f
#define M3UA_Protocol_Data 0x0210
#define M2UA_STATUS_LPO_SET 0x0
#define M2UA_STATUS_LPO_CLEAR 0x1
#define M2UA_STATUS_EMER_SET 0x2
#define M2UA_STATUS_EMER_CLEAR 0x3
#define M2UA_STATUS_FLUSH_BUFFERS 0x4
#define M2UA_STATUS_CONTINUE 0x5
#define M2UA_STATUS_CLEAR_RTB 0x6
#define M2UA_STATUS_AUDIT 0x7
#define M2UA_STATUS_CONG_CLEAR 0x8
#define M2UA_STATUS_CONG_ACCEPT 0x9
#define M2UA_STATUS_CONG_DISCARD 0xa
#define M2UA_STATUS_TYPE_AS_STATE_CHG 1
#define M2UA_STATUS_TYPE_OTHER 2
#define M2UA_STATUS_INFO_AS_RESERVED 1
#define M2UA_STATUS_INFO_AS_INACTIVE 2
#define M2UA_STATUS_INFO_AS_ACTIVE 3
#define M2UA_STATUS_INFO_AS_PENDING 4
#define M2UA_ERR_INVALID_VERSION 0x1
#define M2UA_ERR_INVALID_IID 0x2
#define M2UA_ERR_UNSUPPORTED_MSG_CLASS 0x3
#define M2UA_ERR_UNSUPPORTED_MSG_TYPE 0x4
#define M2UA_ERR_UNSUPPORTED_TRA_HDL_MODE 0x5
#define M2UA_ERR_UNEXPECTED_MSG 0x6
#define M2UA_ERR_PROTOCOL_ERROR 0x7
#define M2UA_ERR_UNSUPPORTED_IIT 0x8
#define M2UA_ERR_INVALID_SID 0x9
#define M2UA_ERR_REFUSED_MGMT_BLOCK 0xd
#define M2UA_ERR_ASP_ID_REQUIRED 0xe
#define M2UA_ERR_INVALID_ASP_ID 0xf
#define M2UA_ERR_ASP_ACTIVE_FOR_IID 0x10
#define M2UA_ERR_INVALID_PARA_VAL 0x11
#define M2UA_ERR_PARA_FIELD_ERROR 0x12
#define M2UA_ERR_UNEXPECTED_PARA 0x13
#define M2UA_ERR_MISSING_PARA 0x16
//m3ua error code
#define M3UA_ERR_INVALID_DSUN 0x14 //Destination Status Unknown
#define M3UA_ERR_INVALID_NETAPP 0x16 //Invalid Network Appearance
#define M3UA_ERR_INVALID_RC 0x19
#define IUA_TEI_ASSIGNED 0x0
#define IUA_TEI_UNASSIGNED 0x1
#define IUA_RELEASE_MGMT 0x00
#define IUA_RELEASE_PHYS 0x01
#define IUA_RELEASE_DM 0x02
#define IUA_RELEASE_OTHER 0x03
#define M2UA_TRAFFIC_MODE_OVERRIDE 1
#define M2UA_TRAFFIC_MODE_LOADSHARE 2
#define M2UA_TRAFFIC_MODE_BROADCAST 3
#define M2UA_LK_IDLE 0
#define M2UA_LK_DOWN 1
#define M2UA_LK_UP 5
#define M2UA_LK_PO 6
#define M3UA_RC_DOWN 1
#define M3UA_RC_UP 5
#define M2UA_MCLASS_MTP3 1
#define M2UA_MCLASS_LM 2
#define M2UA_MTP3_SIO_CMD 0xFF
#define M2UA_SIO_CMD 0xEF
#define M2UA_MTP3_SIO_MSG 0x80
#define M2UA_LK_ATTR_SIGTRAN 1
#define M2UA_MTP3_MAX_LS_NUM 128
#define M2UA_MTP3_CMD_ACTIVE_LK 1
#define M2UA_MTP3_CMD_DEACTIVE_LK 2
#define M2UA_MTP3_CMD_STOP_L2 3
#define M2UA_MTP3_CMD_EMERG_ALIGN 4
#define xUA_MTP3_CMD_ACTIVE_RC 1
#define xUA_MTP3_CMD_DEACTIVE_RC 2
#define M2UA_T_ACK 100 // 2 seconds = 100 * 20ms
#define M2UA_T_R 100 // 2 seconds
#define M2UA_T_LK_ESTAB 4 // 10 seconds = 4 * 2.56s
#define M2UA_T_SG_ESTAB_1 500 // 10 seconds
#define M2UA_T_SG_ESTAB_2 6000 // 120 seconds
#define M2UA_T_SG_ESTAB_3 1500 // 30 seconds
#define M2UA_T_SG_WAIT 100 // 2 seconds
#define M2UA_CMD_IDLE 0
#define M2UA_CMD_PARA_SAVE 1
#define M2UA_CMD_PARA_INIT 2
#define M2UA_CMD_STATUS_INIT 3
#define M2UA_MGMT_CMD_LK_LOCK 1
#define IUA_MGMT_CMD_LK_LOCK 2
#define MAX_ASCIIIN_LEN 4096
#define MAX_ASCIIOUT_LEN 4096
#define MAX_ASCITMP_LEN 4096
#define MONITOR_NONE 0x0000
#define MONITOR_MTP3 0x0001
#define MONITOR_M2UA 0x0002
#define MONITOR_MAUP 0x0004
#define MONITOR_SCTP 0x0008
#define MONITOR_ERROR 0x0010
#define MONITOR_ALL 0xffff
#define M2UA_MAX_RETRANS 10
#define M2UA_STOP_M2UA_LINK 6
#define M2UA_ENABLE_M2UA_LINK 7
#define xUA_STOP_xUA_LINK 6
#define xUA_ENABLE_xUA_LINK 7
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_UP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_LOST & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_SHUTDOWN_COMP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_RESTART ((SCTP_ASSOC_CHANGE << 16) | (SCTP_RESTART & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC ((SCTP_ASSOC_CHANGE << 16) | (SCTP_CANT_STR_ASSOC & 0xFFFF))
#define M2UA_LKSCTP_SEND_FAILED (SCTP_SEND_FAILED << 16)
#define M2UA_LKSCTP_PEER_ADDR_CHANGE (SCTP_PEER_ADDR_CHANGE << 16)
#define M2UA_LKSCTP_REMOTE_ERROR (SCTP_REMOTE_ERROR << 16)
#define M2UA_LKSCTP_SHUTDOWN_EVENT (SCTP_SHUTDOWN_EVENT << 16)
#define M2UA_LKSCTP_DATA_IND 0x7FFFFFFE
#define M2UA_LKSCTP_UNKNOWN_EVENT 0x7FFFFFFF
#define M2UA_ALARM_CODE_NORMAL 0
#define M2UA_ALARM_CODE_SCTP_FAILURE 1
#define M2UA_ALARM_CODE_REMOTE_AS_DOWN 2
#define M2UA_ALARM_CODE_REMOTE_LINK_RELEASE 3
#define M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN 4
#define M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE 5
#define M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE 6
#define M3UA_ALARM_CODE_DEST_UNA 7
#define M3UA_ALARM_CODE_DEST_AVA 8
#endif

View File

@@ -0,0 +1,10 @@
#ifndef _M2UA_DEBUG__H
#define _M2UA_DEBUG__H
void m2ua_mon(void);
int m2ua_debug_set(void);
int m2ua_asciout_proc(BYTE *out_str);
int m2ua_hex_to_ascii(BYTE *from_hex, WORD from_len, BYTE *to_asc);
int m2ua_log_err(WORD sg_id, BYTE *err_msg);
#endif

View File

@@ -0,0 +1,69 @@
#ifndef _M2UA_DEF__H
#define _M2UA_DEF__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
const BYTE m2ua_ver[3] = {10, 0, 6};
BYTE m2ua_command = 0;
m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];
m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
m2ua_sctp_addr_t m2ua_sctp_addr;
m2ua_sctp_cmd_t m2ua_sctp_cmd;
BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE]; //receive
BYTE m2ua_sctp_dat_send[M2UA_SCTP_DAT_BUFSIZE]; //send
int m2ua_sctp_cmd_len;
int m2ua_sctp_dat_len;
#ifndef _LKSCTP
struct strbuf m2ua_sctp_ctrl = {M2UA_SCTP_CMD_BUFSIZE, 0, m2ua_sctp_cmd.cbuf};
struct strbuf m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#else
m2ua_sctp_data_t m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#endif
m2ua_para_t m2ua_para;
BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD m2ua_mtp3_sd_h;
WORD m2ua_mtp3_sd_t;
BYTE m3ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD m3ua_mtp3_sd_h;
WORD m3ua_mtp3_sd_t;
BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD iua_q931_sd_h;
WORD iua_q931_sd_t;
DWORD x256[M2UA_MAX_M3MSG_NUM];
char hostip[20];
char hostname[50];
DWORD host_ip;
BYTE plat_id;
m2ua_sctp_addr_t m2ua_sctp_server_addr;
m2ua_csta_t m2ua_csta;
BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
WORD moniter_fg;
BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
WORD m2ua_sg_mon_count;
WORD m2ua_lk_mon_count;
DWORD err[64];
BYTE init_flag;
#endif

View File

@@ -0,0 +1,67 @@
#ifndef _M2UA_EXT__H
#define _M2UA_EXT__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
extern const BYTE m2ua_ver[3];
extern BYTE m2ua_command;
extern m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];
extern m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
extern m2ua_sctp_addr_t m2ua_sctp_addr;
extern m2ua_sctp_cmd_t m2ua_sctp_cmd;
extern BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE];
extern BYTE m2ua_sctp_dat_send[M2UA_SCTP_DAT_BUFSIZE];
extern int m2ua_sctp_cmd_len;
extern int m2ua_sctp_dat_len;
#ifndef _LKSCTP
extern struct strbuf m2ua_sctp_ctrl;
extern struct strbuf m2ua_sctp_data;
#else
extern m2ua_sctp_data_t m2ua_sctp_data;
#endif
extern m2ua_para_t m2ua_para;
extern BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD m2ua_mtp3_sd_h;
extern WORD m2ua_mtp3_sd_t;
extern BYTE m3ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD m3ua_mtp3_sd_h;
extern WORD m3ua_mtp3_sd_t;
extern BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD iua_q931_sd_h;
extern WORD iua_q931_sd_t;
extern DWORD x256[M2UA_MAX_M3MSG_NUM];
extern char hostip[20];
extern char hostname[50];
extern DWORD host_ip;
extern BYTE plat_id;
extern m2ua_sctp_addr_t m2ua_sctp_server_addr;
extern m2ua_csta_t m2ua_csta;
extern BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
extern BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
extern BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
extern WORD moniter_fg;
extern BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
extern BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
extern WORD m2ua_sg_mon_count;
extern WORD m2ua_lk_mon_count;
extern DWORD err[64];
extern BYTE init_flag;
#endif

View File

@@ -0,0 +1,9 @@
#ifndef _M2UA_FSM__H
#define _M2UA_FSM__H
int m2ua_sg_fsm(WORD sg_id);
int m2ua_fsm(WORD sg_id);
int rel_sid(WORD sg, BYTE lk);
#endif

View File

@@ -0,0 +1,58 @@
#ifndef _M2UA_MSG__H
#define _M2UA_MSG__H
#define COMBO_W(par_class,par_type) ((par_class << 8) + par_type)
int m2ua_sctp_close(int fd, WORD sg_id);
int m2ua_dec_msg(WORD sg_id);
int m2ua_send_msg(WORD sg_id, WORD msg);
int m2ua_sd_mtp3_primi(BYTE lk, BYTE primi);
int m2ua_sd_mtp3_msg(WORD sg, BYTE lk);
int iua_sd_q931_primi(BYTE lk, BYTE primi);
int iua_sd_q931_msg(WORD sg, BYTE lk);
int m3ua_sd_mtp3_user_primi(BYTE lk, BYTE primi);
int m3ua_sd_mtp3_user_msg(WORD sg);
int m3ua_sd_mtp3_user_rc_cmd(WORD sg, BYTE primi);
int m2ua_sg_init(WORD id);
int m2ua_lk_init(BYTE id);
int enable_sg(WORD sg);
int rm_sg_lk(WORD sg, BYTE lk);
char *dec_sctp_primi(long sctp_primi);
#ifndef _LKSCTP
int m2ua_sctp_t_open(WORD sg);
int expect(int fd, int sg, int *msg, int want);
int m2ua_sctp_optmgmt_req(int fd, int sg, DWORD flags);
int m2ua_sctp_bind_req(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_conn_res(int fd, int fd2, int sg, long seq);
int m2ua_sctp_ordrel_req(int fd, int sg);
int m2ua_sctp_discon_req(int fd, int sg, DWORD seq);
int m2ua_sctp_conn_req(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_optdata_req(int fd, int sg, int len);
#else
int m2ua_sctp_optmgmt_req_lksctp(int fd, int sg);
int m2ua_sctp_optmgmt_req_lksctp_ext(int fd, int sg);
int m2ua_sctp_bind_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_open_lksctp(WORD sg);
int m2ua_sctp_conn_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_get_msg_lksctp(int fd, WORD sg);
int expect_lksctp(int fd, int sg, int *msg, int want);
int m2ua_sctp_discon_req_lksctp(int fd, int sg, int flag);
int m2ua_sctp_put_msg_lksctp(int fd, int sg);
int m2ua_sctp_optdata_req_lksctp(int fd, int sg, int len);
#endif
#endif

View File

@@ -0,0 +1,65 @@
#ifndef _M2UA_PUB__H
#define _M2UA_PUB__H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <netdb.h>
#include <setjmp.h>
#include <unistd.h>
#include <signal.h>
//by simon at 23/9/22
//#include <stropts.h>
#include <time.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/io.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <sys/select.h>
#ifndef _LKSCTP
#include <sys/tpi.h>
#include <sys/tpi_sctp.h>
#include <sys/xti_ip.h>
#include <sys/xti_sctp.h>
#else
// by simon at 23/9/22
#include "sctp.h"
#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
#endif

View File

@@ -0,0 +1,255 @@
#ifndef _M2UA_STRUCT__H
#define _M2UA_STRUCT__H
#include "m2ua_const.h"
#ifndef _LKSCTP
typedef union _m2ua_sctp_cmd
{
union T_primitives tpi;
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE];
}m2ua_sctp_cmd_t;
// Data Options
typedef struct _m2ua_sctp_opt_data
{
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
}m2ua_sctp_opt_data_t;
// Connect Options
typedef struct _m2ua_sctp_opt_conn
{
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
}m2ua_sctp_opt_conn_t;
// Management Options
typedef struct _m2ua_sctp_opt_optm
{
struct t_opthdr nod_hdr __attribute__((packed));
t_scalar_t nod_val __attribute__((packed));
struct t_opthdr crk_hdr __attribute__((packed));
t_scalar_t crk_val __attribute__((packed));
struct t_opthdr ppi_hdr __attribute__((packed));
t_scalar_t ppi_val __attribute__((packed));
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
struct t_opthdr rcv_hdr __attribute__((packed));
t_scalar_t rcv_val __attribute__((packed));
struct t_opthdr ckl_hdr __attribute__((packed));
t_scalar_t ckl_val __attribute__((packed));
struct t_opthdr skd_hdr __attribute__((packed));
t_scalar_t skd_val __attribute__((packed));
struct t_opthdr prt_hdr __attribute__((packed));
t_scalar_t prt_val __attribute__((packed));
struct t_opthdr art_hdr __attribute__((packed));
t_scalar_t art_val __attribute__((packed));
struct t_opthdr irt_hdr __attribute__((packed));
t_scalar_t irt_val __attribute__((packed));
struct t_opthdr hbi_hdr __attribute__((packed));
t_scalar_t hbi_val __attribute__((packed));
struct t_opthdr rin_hdr __attribute__((packed));
t_scalar_t rin_val __attribute__((packed));
struct t_opthdr rmn_hdr __attribute__((packed));
t_scalar_t rmn_val __attribute__((packed));
struct t_opthdr rmx_hdr __attribute__((packed));
t_scalar_t rmx_val __attribute__((packed));
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
struct t_opthdr cin_hdr __attribute__((packed));
t_scalar_t cin_val __attribute__((packed));
struct t_opthdr tin_hdr __attribute__((packed));
t_scalar_t tin_val __attribute__((packed));
struct t_opthdr mac_hdr __attribute__((packed));
t_scalar_t mac_val __attribute__((packed));
struct t_opthdr dbg_hdr __attribute__((packed));
t_scalar_t dbg_val __attribute__((packed));
}m2ua_sctp_opt_optm_t;
#else
typedef union _m2ua_sctp_cmd
{
struct cmsghdr cmsg __attribute__((packed));
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE] __attribute__((packed));
}m2ua_sctp_cmd_t;
typedef struct _m2ua_sctp_data
{
int len __attribute__((packed));
int sid __attribute__((packed));
BYTE *buf __attribute__((packed));
}m2ua_sctp_data_t;
#endif
typedef struct _m2ua_sctp_addr
{
uint16_t port __attribute__((packed));
struct in_addr addr __attribute__((packed));
}m2ua_sctp_addr_t;
typedef struct _m2ua_lk_info
{
BYTE enable __attribute__((packed));
BYTE lk_st __attribute__((packed));
WORD sid __attribute__((packed));
DWORD lk_timer __attribute__((packed));
BYTE alarm_code __attribute__((packed));
BYTE lk_act __attribute__((packed));
}m2ua_lk_info_t;
typedef struct _m2ua_sg_info
{
BYTE enable __attribute__((packed));
BYTE sctp_state __attribute__((packed));
BYTE sctp_state_1 __attribute__((packed));
BYTE m2ua_state __attribute__((packed));
DWORD sctp_cmd __attribute__((packed));
WORD m2ua_cmd __attribute__((packed));
WORD mtp3_cmd __attribute__((packed));
WORD mgmt_cmd __attribute__((packed));
WORD fd __attribute__((packed));
WORD iid __attribute__((packed));
DWORD sid_st[8] __attribute__((packed));
BYTE *msg __attribute__((packed));
WORD msg_len __attribute__((packed));
WORD rem_ostrs __attribute__((packed));
WORD T_ack __attribute__((packed));
WORD T_r __attribute__((packed));
BYTE con_sg __attribute__((packed));
BYTE state __attribute__((packed));
BYTE err_code __attribute__((packed));
BYTE tra_hdl_mode __attribute__((packed));
WORD act_lks __attribute__((packed));
WORD istrs __attribute__((packed));
WORD ostrs __attribute__((packed));
DWORD status __attribute__((packed));
DWORD seq __attribute__((packed));
DWORD cor_id __attribute__((packed));
WORD up_lks_pre __attribute__((packed));
WORD up_lks_cur __attribute__((packed));
DWORD sg_timer __attribute__((packed));
BYTE retrans_times __attribute__((packed));
WORD rem_port __attribute__((packed));
BYTE alarm_code __attribute__((packed));
//iua
BYTE rel_reason __attribute__((packed));
BYTE tei_state __attribute__((packed));
WORD dlci __attribute__((packed));
//m3ua
DWORD dpc __attribute__((packed)); /*Routing Label*/
DWORD opc __attribute__((packed));
BYTE sls __attribute__((packed));
BYTE mp __attribute__((packed));
BYTE ni __attribute__((packed));
BYTE si __attribute__((packed));
DWORD net_app __attribute__((packed));//Network_Appearance
DWORD rc __attribute__((packed));//Routing_Context
DWORD aff_pc __attribute__((packed));//xUA_Affected_PC
DWORD user_cause __attribute__((packed));//M3UA_User_Cause
DWORD cong_ind __attribute__((packed));//M3UA_Congestion_Indications
DWORD con_dpc __attribute__((packed));//M3UA_Concerned_Destination
}m2ua_sg_info_t;
typedef struct _m2ua_comhdr
{
BYTE version __attribute__((packed));
BYTE spare __attribute__((packed));
BYTE msg_class __attribute__((packed));
BYTE msg_type __attribute__((packed));
DWORD len __attribute__((packed));
}m2ua_comhdr_t;
typedef struct _m2ua_par_hdr
{
WORD tag __attribute__((packed));
WORD len __attribute__((packed));
}m2ua_par_hdr_t;
typedef struct _m2ua_var_par
{
m2ua_par_hdr_t hdr __attribute__((packed));
BYTE val[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_var_par_t;
typedef struct _m2ua_msg
{
m2ua_comhdr_t comhdr __attribute__((packed));
BYTE msg[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_msg_t;
typedef struct _sg_para
{
BYTE enable __attribute__((packed));
BYTE server __attribute__((packed));
BYTE xUA_ack __attribute__((packed)); //BIT 1-7:xUA_type,0/1/2:M2UA/IUA/M3UA ,Bit 0: ACK
DWORD ip __attribute__((packed));
WORD plat_port[2] __attribute__((packed));
}sg_para_t;
typedef struct _lk_para
{
BYTE enable __attribute__((packed));
WORD lk_sg __attribute__((packed));
BYTE iid __attribute__((packed));
WORD dlci __attribute__((packed));
}lk_para_t;
typedef struct _m2ua_para
{
sg_para_t sg_para[M2UA_MAX_SG_NUM] __attribute__((packed));
lk_para_t lk_para[M2UA_MAX_LK_NUM] __attribute__((packed));
BYTE cmd __attribute__((packed));
}m2ua_para_t;
typedef struct _m2ua_lk_pro
{
BYTE e1_to_linkset __attribute__((packed));
BYTE e1_to_slc __attribute__((packed));
DWORD e1_to_mtp3 __attribute__((packed));
BYTE e1_lk_type __attribute__((packed));
BYTE e1_to_sg __attribute__((packed));
BYTE e1_to_iid __attribute__((packed));
DWORD remote_ip __attribute__((packed));
BYTE inactive __attribute__((packed));
BYTE inactive_tm __attribute__((packed));
DWORD e1_to_alterMTP3 __attribute__((packed));
}m2ua_lk_pro_t;
typedef struct _m2ua_sg_csta
{
DWORD timestamp __attribute__((packed));
DWORD sg_out_msg __attribute__((packed));
DWORD sg_in_msg __attribute__((packed));
DWORD sg_out_bytes __attribute__((packed));
DWORD sg_in_bytes __attribute__((packed));
DWORD sg_asp_dn_times __attribute__((packed));
}m2ua_sg_csta_t;
typedef struct _m2ua_lk_csta
{
DWORD timestamp __attribute__((packed));
DWORD lk_out_msg __attribute__((packed));
DWORD lk_in_msg __attribute__((packed));
DWORD lk_out_bytes __attribute__((packed));
DWORD lk_in_bytes __attribute__((packed));
DWORD lk_dn_times __attribute__((packed));
}m2ua_lk_csta_t;
typedef struct _m2ua_csta
{
m2ua_sg_csta_t sg_csta[M2UA_MAX_SG_NUM] __attribute__((packed));
m2ua_lk_csta_t lk_csta[M2UA_MAX_LK_NUM] __attribute__((packed));
}m2ua_csta_t;
#endif

View File

@@ -0,0 +1,656 @@
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2004
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
*
* This file is part of the SCTP kernel reference Implementation
*
* This header represents the structures and constants needed to support
* the SCTP Extension to the Sockets API.
*
* The SCTP reference implementation is free software;
* you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* The SCTP reference implementation is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* ************************
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Please send any bug reports or fixes you make to the
* email address(es):
* lksctp developers <lksctp-developers@lists.sourceforge.net>
*
* Or submit a bug report through the following website:
* http://www.sf.net/projects/lksctp
*
* Written or modified by:
* La Monte H.P. Yarroll <piggy@acm.org>
* R. Stewart <randall@sctp.chicago.il.us>
* K. Morneau <kmorneau@cisco.com>
* Q. Xie <qxie1@email.mot.com>
* Karl Knutson <karl@athena.chicago.il.us>
* Jon Grimm <jgrimm@austin.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Inaky Perez-Gonzalez <inaky.gonzalez@intel.com>
* Sridhar Samudrala <sri@us.ibm.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
*/
#ifndef __linux_sctp_h__
#define __linux_sctp_h__
#include <stdint.h>
#include <linux/types.h>
#include <sys/socket.h>
__BEGIN_DECLS
typedef void * sctp_assoc_t;
/* Socket option layer for SCTP */
#ifndef SOL_SCTP
#define SOL_SCTP 132
#endif
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
/* 9. Preprocessor constants */
#define HAVE_SCTP
#define HAVE_KERNEL_SCTP
#define HAVE_SCTP_MULTIBUF
#define HAVE_SCTP_NOCONNECT
/* The following symbols come from the Sockets API Extensions for
* SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
*/
enum sctp_optname {
SCTP_RTOINFO,
#define SCTP_RTOINFO SCTP_RTOINFO
SCTP_ASSOCINFO,
#define SCTP_ASSOCINFO SCTP_ASSOCINFO
SCTP_INITMSG,
#define SCTP_INITMSG SCTP_INITMSG
SCTP_NODELAY, /* Get/set nodelay option. */
#define SCTP_NODELAY SCTP_NODELAY
SCTP_AUTOCLOSE,
#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
SCTP_SET_PEER_PRIMARY_ADDR,
#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
SCTP_PRIMARY_ADDR,
#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
SCTP_ADAPTION_LAYER,
#define SCTP_ADAPTION_LAYER SCTP_ADAPTION_LAYER
SCTP_DISABLE_FRAGMENTS,
#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
SCTP_PEER_ADDR_PARAMS,
#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
SCTP_DEFAULT_SEND_PARAM,
#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
SCTP_EVENTS,
#define SCTP_EVENTS SCTP_EVENTS
SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */
#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
SCTP_MAXSEG, /* Get/set maximum fragment. */
#define SCTP_MAXSEG SCTP_MAXSEG
SCTP_STATUS,
#define SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO,
#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
/* Internal Socket Options. Some of the sctp library functions are
* implemented using these socket options.
*/
SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
#define SCTP_SOCKOPT_BINDX_ADD SCTP_SOCKOPT_BINDX_ADD
SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
SCTP_SOCKOPT_PEELOFF, /* peel off association. */
#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
SCTP_GET_PEER_ADDRS_NUM, /* Get number of peer addresss. */
#define SCTP_GET_PEER_ADDRS_NUM SCTP_GET_PEER_ADDRS_NUM
SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */
#define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS
SCTP_GET_LOCAL_ADDRS_NUM, /* Get number of local addresss. */
#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM
SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */
#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS
};
/*
* 5.2.1 SCTP Initiation Structure (SCTP_INIT)
*
* This cmsghdr structure provides information for initializing new
* SCTP associations with sendmsg(). The SCTP_INITMSG socket option
* uses this same data structure. This structure is not used for
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
*
*/
struct sctp_initmsg {
__u16 sinit_num_ostreams;
__u16 sinit_max_instreams;
__u16 sinit_max_attempts;
__u16 sinit_max_init_timeo;
};
/*
* 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
*
* This cmsghdr structure specifies SCTP options for sendmsg() and
* describes SCTP header information about a received message through
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
*
*/
struct sctp_sndrcvinfo {
__u16 sinfo_stream;
__u16 sinfo_ssn;
__u16 sinfo_flags;
__u32 sinfo_ppid;
__u32 sinfo_context;
__u32 sinfo_timetolive;
__u32 sinfo_tsn;
__u32 sinfo_cumtsn;
sctp_assoc_t sinfo_assoc_id;
};
/*
* sinfo_flags: 16 bits (unsigned integer)
*
* This field may contain any of the following flags and is composed of
* a bitwise OR of these values.
*/
enum sctp_sinfo_flags {
MSG_UNORDERED = 1, /* Send/receive message unordered. */
MSG_ADDR_OVER = 2, /* Override the primary destination. */
MSG_ABORT=4, /* Send an ABORT message to the peer. */
MSG_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
};
typedef union {
__u8 raw;
struct sctp_initmsg init;
struct sctp_sndrcvinfo sndrcv;
} sctp_cmsg_data_t;
/* These are cmsg_types. */
typedef enum sctp_cmsg_type {
SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
} sctp_cmsg_t;
/*
* 5.3.1.1 SCTP_ASSOC_CHANGE
*
* Communication notifications inform the ULP that an SCTP association
* has either begun or ended. The identifier for a new association is
* provided by this notificaion. The notification information has the
* following format:
*
*/
struct sctp_assoc_change {
__u16 sac_type;
__u16 sac_flags;
__u32 sac_length;
__u16 sac_state;
__u16 sac_error;
__u16 sac_outbound_streams;
__u16 sac_inbound_streams;
sctp_assoc_t sac_assoc_id;
};
/*
* sac_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the association. They include:
*
* Note: The following state names deviate from the API draft as
* the names clash too easily with other kernel symbols.
*/
enum sctp_sac_state {
SCTP_COMM_UP,
SCTP_COMM_LOST,
SCTP_RESTART,
SCTP_SHUTDOWN_COMP,
SCTP_CANT_STR_ASSOC,
};
/*
* 5.3.1.2 SCTP_PEER_ADDR_CHANGE
*
* When a destination address on a multi-homed peer encounters a change
* an interface details event is sent. The information has the
* following structure:
*/
struct sctp_paddr_change {
__u16 spc_type;
__u16 spc_flags;
__u32 spc_length;
struct sockaddr_storage spc_aaddr;
int spc_state;
int spc_error;
sctp_assoc_t spc_assoc_id;
};
/*
* spc_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the address. They include:
*/
enum sctp_spc_state {
SCTP_ADDR_AVAILABLE,
SCTP_ADDR_UNREACHABLE,
SCTP_ADDR_REMOVED,
SCTP_ADDR_ADDED,
SCTP_ADDR_MADE_PRIM,
};
/*
* 5.3.1.3 SCTP_REMOTE_ERROR
*
* A remote peer may send an Operational Error message to its peer.
* This message indicates a variety of error conditions on an
* association. The entire error TLV as it appears on the wire is
* included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP
* specification [SCTP] and any extensions for a list of possible
* error formats. SCTP error TLVs have the format:
*/
struct sctp_remote_error {
__u16 sre_type;
__u16 sre_flags;
__u32 sre_length;
__u16 sre_error;
sctp_assoc_t sre_assoc_id;
__u8 sre_data[0];
};
/*
* 5.3.1.4 SCTP_SEND_FAILED
*
* If SCTP cannot deliver a message it may return the message as a
* notification.
*/
struct sctp_send_failed {
__u16 ssf_type;
__u16 ssf_flags;
__u32 ssf_length;
__u32 ssf_error;
struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id;
__u8 ssf_data[0];
};
/*
* ssf_flags: 16 bits (unsigned integer)
*
* The flag value will take one of the following values
*
* SCTP_DATA_UNSENT - Indicates that the data was never put on
* the wire.
*
* SCTP_DATA_SENT - Indicates that the data was put on the wire.
* Note that this does not necessarily mean that the
* data was (or was not) successfully delivered.
*/
enum sctp_ssf_flags {
SCTP_DATA_UNSENT,
SCTP_DATA_SENT,
};
/*
* 5.3.1.5 SCTP_SHUTDOWN_EVENT
*
* When a peer sends a SHUTDOWN, SCTP delivers this notification to
* inform the application that it should cease sending data.
*/
struct sctp_shutdown_event {
__u16 sse_type;
__u16 sse_flags;
__u32 sse_length;
sctp_assoc_t sse_assoc_id;
};
/*
* 5.3.1.6 SCTP_ADAPTION_INDICATION
*
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application
* that of the peers requested adaption layer.
*/
struct sctp_adaption_event {
__u16 sai_type;
__u16 sai_flags;
__u32 sai_length;
__u32 sai_adaption_ind;
sctp_assoc_t sai_assoc_id;
};
/*
* 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
*
* When a reciever is engaged in a partial delivery of a
* message this notification will be used to inidicate
* various events.
*/
struct sctp_pdapi_event {
__u16 pdapi_type;
__u16 pdapi_flags;
__u32 pdapi_length;
__u32 pdapi_indication;
sctp_assoc_t pdapi_assoc_id;
};
enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
/*
* Described in Section 7.3
* Ancillary Data and Notification Interest Options
*/
struct sctp_event_subscribe {
__u8 sctp_data_io_event;
__u8 sctp_association_event;
__u8 sctp_address_event;
__u8 sctp_send_failure_event;
__u8 sctp_peer_error_event;
__u8 sctp_shutdown_event;
__u8 sctp_partial_delivery_event;
__u8 sctp_adaptation_layer_event;
//__u8 sctp_adaption_layer_event;
};
/*
* 5.3.1 SCTP Notification Structure
*
* The notification structure is defined as the union of all
* notification types.
*
*/
union sctp_notification {
struct {
__u16 sn_type; /* Notification type. */
__u16 sn_flags;
__u32 sn_length;
} sn_header;
struct sctp_assoc_change sn_assoc_change;
struct sctp_paddr_change sn_paddr_change;
struct sctp_remote_error sn_remote_error;
struct sctp_send_failed sn_send_failed;
struct sctp_shutdown_event sn_shutdown_event;
struct sctp_adaption_event sn_adaption_event;
struct sctp_pdapi_event sn_pdapi_event;
};
/* Section 5.3.1
* All standard values for sn_type flags are greater than 2^15.
* Values from 2^15 and down are reserved.
*/
enum sctp_sn_type {
SCTP_SN_TYPE_BASE = (1<<15),
SCTP_ASSOC_CHANGE,
SCTP_PEER_ADDR_CHANGE,
SCTP_SEND_FAILED,
SCTP_REMOTE_ERROR,
SCTP_SHUTDOWN_EVENT,
SCTP_PARTIAL_DELIVERY_EVENT,
SCTP_ADAPTION_INDICATION,
};
/* Notification error codes used to fill up the error fields in some
* notifications.
* SCTP_PEER_ADDRESS_CHAGE : spc_error
* SCTP_ASSOC_CHANGE : sac_error
* These names should be potentially included in the draft 04 of the SCTP
* sockets API specification.
*/
typedef enum sctp_sn_error {
SCTP_FAILED_THRESHOLD,
SCTP_RECEIVED_SACK,
SCTP_HEARTBEAT_SUCCESS,
SCTP_RESPONSE_TO_USER_REQ,
SCTP_INTERNAL_ERROR,
SCTP_SHUTDOWN_GUARD_EXPIRES,
SCTP_PEER_FAULTY,
} sctp_sn_error_t;
/*
* 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
*
* The protocol parameters used to initialize and bound retransmission
* timeout (RTO) are tunable. See [SCTP] for more information on how
* these parameters are used in RTO calculation.
*/
struct sctp_rtoinfo {
sctp_assoc_t srto_assoc_id;
__u32 srto_initial;
__u32 srto_max;
__u32 srto_min;
};
/*
* 7.1.2 Association Parameters (SCTP_ASSOCINFO)
*
* This option is used to both examine and set various association and
* endpoint parameters.
*/
struct sctp_assocparams {
sctp_assoc_t sasoc_assoc_id;
__u16 sasoc_asocmaxrxt;
__u16 sasoc_number_peer_destinations;
__u32 sasoc_peer_rwnd;
__u32 sasoc_local_rwnd;
__u32 sasoc_cookie_life;
};
/*
* 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
*
* Requests that the peer mark the enclosed address as the association
* primary. The enclosed address must be one of the association's
* locally bound addresses. The following structure is used to make a
* set primary request:
*/
struct sctp_setpeerprim {
sctp_assoc_t sspp_assoc_id;
struct sockaddr_storage sspp_addr;
};
/*
* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
*
* Requests that the local SCTP stack use the enclosed peer address as
* the association primary. The enclosed address must be one of the
* association peer's addresses. The following structure is used to
* make a set peer primary request:
*/
struct sctp_prim {
sctp_assoc_t ssp_assoc_id;
struct sockaddr_storage ssp_addr;
};
/*
* 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
*
* Requests that the local endpoint set the specified Adaption Layer
* Indication parameter for all future INIT and INIT-ACK exchanges.
*/
struct sctp_setadaption {
__u32 ssb_adaption_ind;
};
/*
* 7.1.13 Peer Address Parameters (SCTP_PEER_ADDR_PARAMS)
*
* Applications can enable or disable heartbeats for any peer address
* of an association, modify an address's heartbeat interval, force a
* heartbeat to be sent immediately, and adjust the address's maximum
* number of retransmissions sent before an address is considered
* unreachable. The following structure is used to access and modify an
* address's parameters:
*/
struct sctp_paddrparams {
sctp_assoc_t spp_assoc_id;
struct sockaddr_storage spp_address;
__u32 spp_hbinterval;
__u16 spp_pathmaxrxt;
};
/*
* 7.2.2 Peer Address Information
*
* Applications can retrieve information about a specific peer address
* of an association, including its reachability state, congestion
* window, and retransmission timer values. This information is
* read-only. The following structure is used to access this
* information:
*/
struct sctp_paddrinfo {
sctp_assoc_t spinfo_assoc_id;
struct sockaddr_storage spinfo_address;
__s32 spinfo_state;
__u32 spinfo_cwnd;
__u32 spinfo_srtt;
__u32 spinfo_rto;
__u32 spinfo_mtu;
};
/* Peer addresses's state. */
enum sctp_spinfo_state {
SCTP_INACTIVE,
SCTP_ACTIVE,
};
/*
* 7.2.1 Association Status (SCTP_STATUS)
*
* Applications can retrieve current status information about an
* association, including association state, peer receiver window size,
* number of unacked data chunks, and number of data chunks pending
* receipt. This information is read-only. The following structure is
* used to access this information:
*/
struct sctp_status {
sctp_assoc_t sstat_assoc_id;
__s32 sstat_state;
__u32 sstat_rwnd;
__u16 sstat_unackdata;
__u16 sstat_penddata;
__u16 sstat_instrms;
__u16 sstat_outstrms;
__u32 sstat_fragmentation_point;
struct sctp_paddrinfo sstat_primary;
};
/*
* 8.3, 8.5 get all peer/local addresses on a socket
* This parameter struct is for getsockopt
*/
struct sctp_getaddrs {
sctp_assoc_t assoc_id;
int addr_num;
struct sockaddr *addrs;
};
/* These are bit fields for msghdr->msg_flags. See section 5.1. */
/* On user space Linux, these live in <bits/socket.h> as an enum. */
enum sctp_msg_flags {
MSG_NOTIFICATION = 0x8000,
#define MSG_NOTIFICATION MSG_NOTIFICATION
};
/*
* 8.1 sctp_bindx()
*
* The flags parameter is formed from the bitwise OR of zero or more of the
* following currently defined flags:
*/
#define SCTP_BINDX_ADD_ADDR 0x01
#define SCTP_BINDX_REM_ADDR 0x02
/* This is the structure that is passed as an argument(optval) to
* getsockopt(SCTP_SOCKOPT_PEELOFF).
*/
typedef struct {
sctp_assoc_t associd;
int sd;
} sctp_peeloff_arg_t;
int sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags);
int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
/* Prototype for the library function sctp_opt_info defined in
* API 7. Socket Options.
*/
int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size);
/* Get all peer address on a socket. This is a new SCTP API
* described in the section 8.3 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getpaddrs(). This is a new SCTP API
* described in the section 8.4 of the Sockets API Extensions for SCTP.
*/
int sctp_freepaddrs(struct sockaddr *addrs);
/* Get all locally bound address on a socket. This is a new SCTP API
* described in the section 8.5 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getladdrs(). This is a new SCTP API
* described in the section 8.6 of the Sockets API Extensions for SCTP.
*/
int sctp_freeladdrs(struct sockaddr *addrs);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.7 of the
* Sockets API Extensions for SCTP. This is implemented using the
* sendmsg() interface.
*/
int sctp_sendmsg(int s, const void *msg, size_t len, struct sockaddr *to,
socklen_t tolen, uint32_t ppid, uint32_t flags,
uint16_t stream_no, uint32_t timetolive, uint32_t context);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.8 of the
* Sockets API Extensions for SCTP. This is implemented using the
* recvmsg() interface.
*/
int sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from,
socklen_t *fromlen, struct sctp_sndrcvinfo *sinfo,
int *msg_flags);
__END_DECLS
#endif /* __linux_sctp_h__ */

409
plat/m2ua/src/m2ua.c Normal file
View File

@@ -0,0 +1,409 @@
/****************************************************************/
/* M2UA Implementation Program */
/* Version 10.0.3 */
/* Designed By Ying Min */
/* Last Update: 2006-2-14 */
/****************************************************************/
#include "./include/m2ua_pub.h"
#include "./include/m2ua.h"
#include "./include/m2ua_const.h"
#include "./include/m2ua_def.h"
#include "./include/m2ua_struct.h"
#include "./include/m2ua_msg.h"
#include "./include/m2ua_fsm.h"
#include "./include/m2ua_debug.h"
int m2ua_get_local_ip(void)
{
struct hostent *host;
if (gethostname(hostname, 50) == -1)
{
printf("M2UA gethostname fail!\n");
exit(3);
}
if ((host = gethostbyname(hostname)) == NULL)
{
printf("M2UA gethostbyname fail!\n");
exit(4);
}
else
{
sprintf(hostip, "%d.%d.%d.%d",
(BYTE)host->h_addr_list[0][0],
(BYTE)host->h_addr_list[0][1],
(BYTE)host->h_addr_list[0][2],
(BYTE)host->h_addr_list[0][3]);
host_ip = inet_addr(hostip); // Network byte order host_ip, like 0xE60012AC
printf("hostip: %s (0x%lX)\n", hostip, host_ip);
}
return 0;
}
/*
int m2ua_get_mtp3_para(void)
{
DWORD oid[20] = {1,3,6,1,4,1,1373,1,3,2,2,2,2,9,1}; // SG Attributes
BYTE msg[64], vartype;
int i;
printf("M2UA start to get MTP3 link_para!\n");
for (i = 0; i < M2UA_MAX_SG_NUM; i++)
{
oid[15] = i;
if (get_response(16, oid, msg, &vartype) < 0)
{
printf("M2UA get MTP3 sg_para failed, please set it from MTP3!\n");
return -1;
}
else
set_m2ua_sg(i, msg);
}
oid[14] = 5; // Link Attributes
for (i = 0; i < M2UA_MAX_LK_NUM; i++)
{
oid[15] = i;
if (get_response(16, oid, msg, &vartype) < 0)
{
printf("M2UA get MTP3 link_para failed, please set it from MTP3!\n");
return -1;
}
else
set_m2ua_link(i, msg);
}
return 0;
}
*/
void m2ua_init(BYTE system_id)
{
int id, fd;
//static DWORD init_times = 0;
printf("M2UA Init Start!\n");
plat_id = system_id%2;
m2ua_get_local_ip();
for (id = 0; id < M2UA_MAX_SG_FSM_NUM; id++)
{
m2ua_sg_init(id);
m2ua_sg_mon_fg[id] = 0;
}
m2ua_sg_mon_count = 0;
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M2UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_0 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M2UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_0 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M2UA_LISTEN_SG_NUM_0].fd = fd;
m2ua_sg_info[M2UA_LISTEN_SG_NUM_0].enable = 1;
printf("M2UA_LISTEN_SG_NUM_0 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M2UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_1 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M2UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_1 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M2UA_LISTEN_SG_NUM_1].fd = fd;
m2ua_sg_info[M2UA_LISTEN_SG_NUM_1].enable = 1;
printf("M2UA_LISTEN_SG_NUM_1 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(IUA_LISTEN_SG_NUM_0)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_0 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(IUA_LISTEN_SG_NUM_0)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_0 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[IUA_LISTEN_SG_NUM_0].fd = fd;
m2ua_sg_info[IUA_LISTEN_SG_NUM_0].enable = 1;
printf("IUA_LISTEN_SG_NUM_0 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(IUA_LISTEN_SG_NUM_1)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_1 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(IUA_LISTEN_SG_NUM_1)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_1 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[IUA_LISTEN_SG_NUM_1].fd = fd;
m2ua_sg_info[IUA_LISTEN_SG_NUM_1].enable = 1;
printf("IUA_LISTEN_SG_NUM_1 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M3UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M3UA_LISTEN_SG_NUM_0 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M3UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M3UA_LISTEN_SG_NUM_0 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M3UA_LISTEN_SG_NUM_0].fd = fd;
m2ua_sg_info[M3UA_LISTEN_SG_NUM_0].enable = 1;
printf("M3UA_LISTEN_SG_NUM_0 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M3UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M3UA_LISTEN_SG_NUM_1 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M3UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M3UA_LISTEN_SG_NUM_1 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M3UA_LISTEN_SG_NUM_1].fd = fd;
m2ua_sg_info[M3UA_LISTEN_SG_NUM_1].enable = 1;
printf("M3UA_LISTEN_SG_NUM_1 listening fd open succeed!\n");
}
for (id = 0; id < M2UA_MAX_LK_NUM; id++)
{
m2ua_lk_init(id);
m2ua_lk_mon_fg[id] = 0;
}
m2ua_lk_mon_count = 0;
for (id = 0; id < M2UA_MAX_M3MSG_NUM; id++)
x256[id] = M2UA_MAX_MSG_LEN * id;
bzero(&m2ua_csta, sizeof(m2ua_csta_t));
bzero(err, 256);
m2ua_mtp3_sd_h = 0;
m2ua_mtp3_sd_t = 0;
iua_q931_sd_h = 0;
iua_q931_sd_t = 0;
m3ua_mtp3_sd_h = 0;
m3ua_mtp3_sd_t = 0;
m2ua_sctp_cmd_len = 0;
m2ua_sctp_dat_len = 0;
m2ua_sctp_addr.port = htons(2904);
m2ua_sctp_server_addr.port = htons(2904);
inet_aton(hostip, &m2ua_sctp_addr.addr);
strcpy(m2ua_asciin_buf, "\0");
strcpy(m2ua_asciout_buf, "\0");
moniter_fg = MONITOR_NONE;
m2ua_debug_set();
init_flag = 0;
m2ua_command = M2UA_CMD_IDLE;
//if (init_times++);
//m2ua_get_mtp3_para();
printf("M2UA Init Complete!\n");
}
void m2ua_t10ms()
{
static int cnt_10ms = 0;
static int ls_hb_flag = 0;
static int ls_hb_lk = 0;
WORD nsg;
WORD i, fd;
if (ls_hb_flag)
{
if (ls_hb_lk < M2UA_MAX_LK_NUM)
{
if (m2ua_para.lk_para[ls_hb_lk].enable == 1)
{
nsg = m2ua_para.lk_para[ls_hb_lk].lk_sg;
if ((m2ua_para.sg_para[nsg].xUA_ack>>1) == M2UA_APP)
m2ua_sd_mtp3_primi(ls_hb_lk, m2ua_lk_info[ls_hb_lk].lk_st);
else if ((m2ua_para.sg_para[nsg].xUA_ack>>1) == IUA_APP)
iua_sd_q931_primi(ls_hb_lk, m2ua_lk_info[ls_hb_lk].lk_st);
else if ((m2ua_para.sg_para[nsg].xUA_ack>>1) == M3UA_APP)
m3ua_sd_mtp3_user_primi(ls_hb_lk, m2ua_lk_info[ls_hb_lk].lk_st);
}
ls_hb_lk++;
}
else
{
ls_hb_flag = 0;
ls_hb_lk = 0;
}
}
if (!(++cnt_10ms % 10))
{ // 100 ms
m2ua_mon();
if (!(cnt_10ms % 100))
{ // 1 seconds
if (m2ua_command != M2UA_CMD_IDLE)
{
sprintf(m2ua_ascitemp_buf, "M2UA Restart! m2ua_command=%d\n\r", m2ua_command);
m2ua_asciout_proc(m2ua_ascitemp_buf);
m2ua_asciout_proc("\n\r");
m2ua_command = M2UA_CMD_IDLE;
for (i = 0; i < M2UA_MAX_SG_FSM_NUM; i++)
{
if ((fd = m2ua_sg_info[i].fd) > 0)
{
if ((m2ua_sg_info[i].sctp_state > 2) ||
((m2ua_sg_info[i].sctp_state == 2) &&
(m2ua_sg_info[i].sctp_state_1 > 0)))
{
#ifndef _LKSCTP
if (i >= M2UA_MAX_SG_NUM)
m2ua_sctp_discon_req(fd, i, m2ua_sg_info[i].seq);
else
m2ua_sctp_discon_req(fd, i, 0);
#else
m2ua_sctp_discon_req_lksctp(fd, i, 0);
#endif
}
#ifndef _LKSCTP
m2ua_sctp_close(m2ua_sg_info[i].fd, i);
#endif
}
}
m2ua_init(plat_id);
}
else if (cnt_10ms >= 1500)
{ // 15 seconds
cnt_10ms = 0;
ls_hb_flag = 1;
}
}
}
}
// Called every 10 ms
void m2ua_timer(void)
{
WORD sg, sg_dual, i;
static BYTE sg_start = 0;
static BYTE lk_scan = 0;
for (sg = sg_start; sg < sg_start + 128; sg++)
{
sg_dual = sg;
if (m2ua_sg_info[sg_dual].m2ua_state == 3)
{
for (i = 0; i < 32; i++)
{
if (m2ua_sg_fsm(sg_dual) < 0)
break;
}
}
else
m2ua_sg_fsm(sg_dual);
sg_dual = sg + M2UA_MAX_SG_NUM/2;
if (m2ua_sg_info[sg_dual].m2ua_state == 3)
{
for (i = 0; i < 32; i++)
{
if (m2ua_sg_fsm(sg_dual) < 0)
break;
}
}
else
m2ua_sg_fsm(sg_dual);
}
sg_start += 128;
if (sg_start == 0)
{
m2ua_sg_fsm(M2UA_LISTEN_SG_NUM_0);
m2ua_sg_fsm(M2UA_LISTEN_SG_NUM_1);
m2ua_sg_fsm(IUA_LISTEN_SG_NUM_0);
m2ua_sg_fsm(IUA_LISTEN_SG_NUM_1);
m2ua_sg_fsm(M3UA_LISTEN_SG_NUM_0);
m2ua_sg_fsm(M3UA_LISTEN_SG_NUM_1);
}
if (m2ua_lk_info[lk_scan].lk_timer > 0)
m2ua_lk_info[lk_scan].lk_timer--;
lk_scan ++;
m2ua_t10ms();
}
int m2ua_restart()
{
if (m2ua_command != M2UA_CMD_IDLE)
return 0;
else if (init_flag == 2)
{
m2ua_command = M2UA_CMD_STATUS_INIT;
return 0;
}
return 1;
}

518
plat/m2ua/src/m2ua_debug.c Normal file
View File

@@ -0,0 +1,518 @@
#include "./include/m2ua_pub.h"
#include "./include/m2ua.h"
#include "./include/m2ua_const.h"
#include "./include/m2ua_struct.h"
#include "./include/m2ua_ext.h"
#include "../../debug/src/include/debug.h"
#define M2UA_DEBUG_ID 16
#define M2UA_VER_DEBUG "R9V0_14"
static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
static BYTE log_help[] = {
"M2UA Debug Monitor Help:\n\r\
\n\r\
1.[help] display help menu\n\r\
2.[log all/none] display all/none logs\n\r\
3.[log error on/off] display error logs (sg only)\n\r\
4.[log mtp3/maup on/off] display mtp3/maup logs (sg or link)\n\r\
5.[log m2ua/sctp on/off] display m2ua/sctp logs (sg only)\n\r\
6.[log sg-xxx/lk-xxx on/off] display sg/lk logs\n\r\n\r"
};
static WORD disp_page[10];
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,M2UA_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,M2UA_DEBUG_ID + 2,2
};
static DWORD debug_ascin_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,3
};
static DWORD debug_ascout_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,4
};
static DWORD debug_page_title[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,1,1
};
static DWORD debug_page_line[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,1,2,1
};
const static BYTE PAGE_POINT = 14;
const static BYTE LINE_POINT = 15;
const static BYTE BASE_ID_LEN = 15;
static BYTE title1_p[] =
{
" M2UA Page 01 SG Para\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_Para\n\r"
};
static BYTE title2_p[] =
{
" M2UA Page 02 Link Para\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
LK_Para\n\r"
};
static BYTE title3_p[] =
{
" M2UA Page 03 SG Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_Info\n\r"
};
static BYTE title4_p[] =
{
" M2UA Page 04 Link Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
LK_Info\n\r"
};
static BYTE title5_p[] =
{
" M2UA Page 05 SG CSTA\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_CSTA\n\r"
};
static BYTE title6_p[] =
{
" M2UA Page 06 Link CSTA\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
LK_CSTA\n\r"
};
static BYTE title7_p[] =
{
" M2UA Page 07 Watchdog\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Watchdog\n\r"
};
BYTE m2ua_disp_line(BYTE page, BYTE line)
{
BYTE disp_length;
disp_length = 16;
disp_ptr = (BYTE *) disp_page;
switch (page)
{
case 1: // Page 1: SG Para
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_para.sg_para + ((line - 1) * sizeof(sg_para_t)) + (disp_page[page] * 16 * sizeof(sg_para_t));
disp_length = sizeof(sg_para_t);
}
else
disp_length = 0;
break;
case 2: // Page 2: LK Para
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_para.lk_para + ((line - 1) * sizeof(lk_para_t)) + disp_page[page] * 16 * sizeof(lk_para_t);
disp_length = sizeof(lk_para_t);
}
else
disp_length = 0;
break;
case 3: // Page 3: SG Info
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 7)
disp_ptr = (BYTE *) &m2ua_sg_info[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 4: // Page 4: LK Info
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_lk_info + ((line - 1) * sizeof(m2ua_lk_info_t)) + disp_page[page] * 16 * sizeof(m2ua_lk_info_t);
disp_length = sizeof(m2ua_lk_info_t);
}
else
disp_length = 0;
break;
case 5: // Page 5: SG CSTA
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 3)
disp_ptr = (BYTE *) &m2ua_csta.sg_csta[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 6: // Page 6: LK CSTA
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 3)
disp_ptr = (BYTE *) &m2ua_csta.lk_csta[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 7: // Page 7: Err
if (line < 16)
disp_ptr = (BYTE *)err + (line * 16);
else
disp_length = 0;
break;
default:
disp_length = 0;
break;
}
return disp_length;
}
void m2ua_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 = m2ua_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 m2ua_debug_set(void)
{
BYTE page;
BYTE data[10];
BYTE *ptr;
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, M2UA_VER_DEBUG, 10);
debug_set_response(BASE_ID_LEN, debug_ascin_id, m2ua_asciin_buf, 4096);
debug_set_response(BASE_ID_LEN, debug_ascout_id, m2ua_asciout_buf, 4096);
for (page = 1; page < 8; 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;
case 5: //page 5
ptr = title5_p;
break;
case 6: //page 6
ptr = title6_p;
break;
case 7: //page 7
ptr = title7_p;
break;
default:
break;
}
debug_page_title[PAGE_POINT] = 5 + page;
debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
m2ua_disp_page(page);
}
return 1;
}
int m2ua_asciout_proc(BYTE *out_str)
{
int out_len;
out_len = strlen(out_str);
if (out_len + strlen(m2ua_asciout_buf) > MAX_ASCIIOUT_LEN - 2)
{
strcpy(m2ua_asciout_buf, out_str);
}
else
strcat(m2ua_asciout_buf, out_str);
return 1;
}
void m2ua_mon(void)
{
BYTE in_page, err_fg = 0;
BYTE *ascii_in_ptr = NULL;
BYTE *str_start = NULL;
WORD str_len, num;
if ((str_len = strlen(m2ua_asciin_buf)) > 0)
{
in_page = m2ua_asciin_buf[0] - 1;
ascii_in_ptr = m2ua_asciin_buf + 1;
if (in_page > 7)
err_fg = 1;
else if (strcmp(ascii_in_ptr,"c") == 0)
{
bzero(&m2ua_csta, sizeof(m2ua_csta_t));
bzero(err, 256);
}
else if (strcmp(ascii_in_ptr,"log mtp3 on") == 0)
{
moniter_fg = moniter_fg | MONITOR_MTP3;
}
else if (strcmp(ascii_in_ptr,"log mtp3 off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_MTP3);
}
else if (strcmp(ascii_in_ptr,"log m2ua on") == 0)
{
moniter_fg = moniter_fg | MONITOR_M2UA;
}
else if (strcmp(ascii_in_ptr,"log m2ua off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_M2UA);
}
else if (strcmp(ascii_in_ptr,"log maup on") == 0)
{
moniter_fg = moniter_fg | MONITOR_MAUP;
}
else if (strcmp(ascii_in_ptr,"log maup off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_MAUP);
}
else if (strcmp(ascii_in_ptr,"log sctp on") == 0)
{
moniter_fg = moniter_fg | MONITOR_SCTP;
}
else if (strcmp(ascii_in_ptr,"log sctp off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_SCTP);
}
else if (strcmp(ascii_in_ptr,"log error on") == 0)
{
moniter_fg = moniter_fg | MONITOR_ERROR;
}
else if (strcmp(ascii_in_ptr,"log error off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_ERROR);
}
else if (strcmp(ascii_in_ptr,"log all") == 0)
{
moniter_fg = MONITOR_ALL;
if (!m2ua_sg_mon_count && !m2ua_lk_mon_count)
{
memset(m2ua_sg_mon_fg, 1, M2UA_MAX_SG_FSM_NUM);
memset(m2ua_lk_mon_fg, 1, M2UA_MAX_LK_NUM);
}
else
err_fg = 2;
}
else if (strcmp(ascii_in_ptr,"log none") == 0)
{
moniter_fg = MONITOR_NONE;
memset(m2ua_sg_mon_fg, 0, M2UA_MAX_SG_FSM_NUM);
memset(m2ua_lk_mon_fg, 0, M2UA_MAX_LK_NUM);
m2ua_sg_mon_count = 0;
m2ua_lk_mon_count = 0;
}
else if (strcmp(ascii_in_ptr,"help") == 0)
{
m2ua_asciout_proc(log_help);
}
else if (strstr(ascii_in_ptr, "log sg") != NULL)
{
if ((moniter_fg == MONITOR_ALL) &&
!m2ua_sg_mon_count &&
!m2ua_lk_mon_count)
err_fg = 3;
else if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
{
num = strtoul(str_start + 1, NULL, 10);
if (num >= M2UA_MAX_SG_FSM_NUM)
err_fg = 1;
else if (strstr(ascii_in_ptr, "on") != NULL)
{
m2ua_sg_mon_fg[num] = 1;
if (m2ua_sg_mon_count < M2UA_MAX_SG_NUM+2)
m2ua_sg_mon_count++;
}
else if (strstr(ascii_in_ptr, "off") != NULL)
{
m2ua_sg_mon_fg[num] = 0;
if (m2ua_sg_mon_count > 0)
m2ua_sg_mon_count--;
}
else
err_fg = 1;
}
else
err_fg = 1;
}
else if (strstr(ascii_in_ptr, "log lk") != NULL)
{
if ((moniter_fg == MONITOR_ALL) &&
!m2ua_sg_mon_count &&
!m2ua_lk_mon_count)
err_fg = 3;
else if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
{
num = strtoul(str_start + 1, NULL, 10);
if (num >= M2UA_MAX_LK_NUM)
err_fg = 1;
else if (strstr(ascii_in_ptr, "on") != NULL)
{
m2ua_lk_mon_fg[num] = 1;
if (m2ua_lk_mon_count < M2UA_MAX_LK_NUM)
m2ua_lk_mon_count++;
}
else if (strstr(ascii_in_ptr, "off") != NULL)
{
m2ua_lk_mon_fg[num] = 0;
if (m2ua_lk_mon_count > 0)
m2ua_lk_mon_count--;
}
else
err_fg = 1;
}
else
err_fg = 1;
}
else if (isdigit(ascii_in_ptr[0]))
{
num = strtoul(ascii_in_ptr, NULL, 10);
disp_page[in_page] = num;
m2ua_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;
m2ua_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;
m2ua_disp_page(in_page);
}
else
err_fg = 1;
if (err_fg == 0)
m2ua_asciout_proc("Command OK!\n\r");
else if (err_fg == 2)
m2ua_asciout_proc("Log all for some SGs or Links!\n\r");
else if (err_fg == 3)
m2ua_asciout_proc("Log all already done for all SGs and Links, log none to clear!\n\r");
else
m2ua_asciout_proc("Command Error!\n\r");
strcpy(m2ua_asciin_buf, "\0");
}
}
int m2ua_hex_to_ascii(BYTE *from_hex, WORD from_len, BYTE *to_asc)
{
int i, j;
j = 0;
if(from_len*3 > MAX_ASCITMP_LEN)
{
m2ua_asciout_proc("\33[31m");
sprintf(m2ua_ascitemp_buf, "m2ua_hex_to_ascii log msg is too long: %d\n\r", from_len);
strcat(m2ua_ascitemp_buf, "\33[37m");
m2ua_asciout_proc(m2ua_ascitemp_buf);
return 0;
}
for (i = 0; i< from_len; i++)
{
to_asc[j] = ascii[from_hex[i] >> 4];
j++;
to_asc[j] = ascii[from_hex[i] & 0x0F];
j++;
to_asc[j] = ' ';
j++;
}
to_asc[j] = '\0';
return 1;
}
int m2ua_log_err(WORD sg_id, BYTE *err_msg)
{
if ((moniter_fg & MONITOR_ERROR) == MONITOR_ERROR)
{
if ((m2ua_sg_mon_fg[sg_id] == 0))
return 0;
m2ua_asciout_proc("\33[31m");
if (strlen(err_msg) >= MAX_ASCITMP_LEN)
sprintf(m2ua_ascitemp_buf, "SG[%d] log msg is too long: %d\n\r", sg_id, strlen(err_msg));
else
sprintf(m2ua_ascitemp_buf, "SG[%d]: %s\n\r", sg_id, err_msg);
strcat(m2ua_ascitemp_buf, "\33[37m");
m2ua_asciout_proc(m2ua_ascitemp_buf);
}
return 1;
}

1571
plat/m2ua/src/m2ua_fsm.c Normal file

File diff suppressed because it is too large Load Diff

3481
plat/m2ua/src/m2ua_msg.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
#ifndef _M2UA__H
#define _M2UA__H
typedef struct _m2ua_up_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed));
BYTE sio __attribute__((packed));
union
{
struct
{
BYTE content[256] __attribute__((packed));
}mtp3 __attribute__((packed));
struct
{
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}lm __attribute__((packed));
}msg __attribute__((packed));
}m2ua_up_msg_t;
void m2ua_init(BYTE);
void m2ua_timer(void);
int get_m2ua_msg(m2ua_up_msg_t **data_ptr);
int put_m2ua_msg(m2ua_up_msg_t *data_ptr);
int set_m2ua_link(BYTE link, BYTE *data_ptr);
int set_m2ua_sg(WORD sg, BYTE *data_ptr);
int m2ua_restart();
//add by yizane
typedef struct _xua_lm_lk
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len = 3 */
BYTE mtp3_ip __attribute__((packed));
BYTE opercode __attribute__((packed));
BYTE alarmcode __attribute__((packed));
}xua_lm_lk;
typedef struct _xua_iua_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len for content */
BYTE content[256] __attribute__((packed));
}xua_iua_msg;
typedef struct _xua_m2ua_msg
{
BYTE link __attribute__((packed));
BYTE len __attribute__((packed)); /* len for content */
BYTE content[256] __attribute__((packed));
}xua_m2ua_msg;
typedef struct _xua_up_msg
{
BYTE msg_class __attribute__((packed));
union
{
xua_lm_lk lm_lk __attribute__((packed));
xua_m2ua_msg m2ua __attribute__((packed));
xua_iua_msg iua __attribute__((packed));
}msg __attribute__((packed));
}xua_up_msg_t;
int get_xua_msg(BYTE xUA_type, xua_up_msg_t **data_ptr);
int put_xua_msg(xua_up_msg_t *data_ptr);
#define XUAHEADOFFSET 3
#define RESERVE_FOR_IUAHEAD (28 - XUAHEADOFFSET)
#define RESERVE_FOR_M2UAHEAD (20 - XUAHEADOFFSET)
//msg_class
#define IUA_QPTM_MSG 0x05
#define M2UA_MAUP_MSG 0x06
#define IUA_MGMT_CMD 0xA5
#define M2UA_MGMT_CMD 0xA6
#define IUA_APP 1
#define M2UA_APP 0
//add by yizane
#endif

View File

@@ -0,0 +1,330 @@
#ifndef _M2UA_CONST__H
#define _M2UA_CONST__H
#define M2UA_MAX_LK_NUM 256
#define M2UA_MAX_MSG_LEN 256
#define M2UA_MAX_SG_NUM 512
#define M2UA_LISTEN_SG_NUM_0 512
#define IUA_LISTEN_SG_NUM_0 513
#define IUA_PORT_0 9900
#define M2UA_PORT_0 2904
#define M2UA_LISTEN_SG_NUM_1 514
#define IUA_LISTEN_SG_NUM_1 515
#define IUA_PORT_1 9901
#define M2UA_PORT_1 2905
#define M2UA_MAX_SG_FSM_NUM (512+4)//for listen m2ua*2,iua*2
#define M2UA_MAX_M3MSG_NUM 2048
#define M2UA_MAX_M3MSG_NUM_1 2047
#define M2UA_SCTP_CMD_BUFSIZE 5*1024
#define M2UA_SCTP_DAT_BUFSIZE 5*1024
#define M2UA_FAILURE -1
#define M2UA_SUCCESS 0
#define M2UA_CMD_IDLEW 0xEEEE
// M2UA Message Class
#define M2UA_MCLASS_MGMT 0
#define M2UA_MCLASS_ASPSM 3
#define M2UA_MCLASS_ASPTM 4
#define M2UA_MCLASS_MAUP 6
#define M2UA_MCLASS_IIM 10
//add by yizane
#define xUA_MCLASS_MGMT 0
#define xUA_MCLASS_TRMSG 1
#define xUA_MCLASS_SSNM 2
#define xUA_MCLASS_ASPSM 3
#define xUA_MCLASS_ASPTM 4
#define xUA_MCLASS_QPTM 5
#define xUA_MCLASS_MAUP 6
#define xUA_MCLASS_IIM 10
//add by yizane
// M2UA ASPSM Message Type
#define ASP_UP 1
#define ASP_DOWN 2
#define HEARTBEAT 3
#define ASP_UP_ACK 4
#define ASP_DOWN_ACK 5
#define HEARTBEAT_ACK 6
// M2UA ASPSM Combined Message Type
#define M2UA_ASPSM_ASP_UP (M2UA_MCLASS_ASPSM << 8) + ASP_UP
#define M2UA_ASPSM_ASP_DOWN (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN
#define M2UA_ASPSM_HEARTBEAT (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT
#define M2UA_ASPSM_ASP_UP_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define M2UA_ASPSM_ASP_DOWN_ACK (M2UA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define M2UA_ASPSM_HEARTBEAT_ACK (M2UA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
//add by yizane
#define xUA_ASPSM_ASP_UP (xUA_MCLASS_ASPSM << 8) + ASP_UP
#define xUA_ASPSM_ASP_DOWN (xUA_MCLASS_ASPSM << 8) + ASP_DOWN
#define xUA_ASPSM_HEARTBEAT (xUA_MCLASS_ASPSM << 8) + HEARTBEAT
#define xUA_ASPSM_ASP_UP_ACK (xUA_MCLASS_ASPSM << 8) + ASP_UP_ACK
#define xUA_ASPSM_ASP_DOWN_ACK (xUA_MCLASS_ASPSM << 8) + ASP_DOWN_ACK
#define xUA_ASPSM_HEARTBEAT_ACK (xUA_MCLASS_ASPSM << 8) + HEARTBEAT_ACK
//add by yizane
#define ASP_ACTIVE 1
#define ASP_INACTIVE 2
#define ASP_ACTIVE_ACK 3
#define ASP_INACTIVE_ACK 4
#define M2UA_ASPTM_ASP_ACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define M2UA_ASPTM_ASP_INACTIVE (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define M2UA_ASPTM_ASP_ACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define M2UA_ASPTM_ASP_INACTIVE_ACK (M2UA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
//add by yizane
#define xUA_ASPTM_ASP_ACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE
#define xUA_ASPTM_ASP_INACTIVE (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE
#define xUA_ASPTM_ASP_ACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_ACTIVE_ACK
#define xUA_ASPTM_ASP_INACTIVE_ACK (xUA_MCLASS_ASPTM << 8) + ASP_INACTIVE_ACK
//add by yizane
//for MAUP
#define DATA 1
#define ESTABLISH_REQ 2
#define ESTABLISH_CFM 3
#define RELEASE_REQ 4
#define RELEASE_CFM 5
#define RELEASE_IND 6
#define STATE_REQ 7
#define STATE_CFM 8
#define STATE_IND 9
#define DATA_RETIEVE_REQ 10
#define DATA_RETIEVE_CFM 11
#define DATA_RETIEVE_IND 12
#define DATA_RETIEVE_CMP 13
#define CONGESTION_IND 14
#define DATA_ACK 15
#define M2UA_MAUP_DATA (M2UA_MCLASS_MAUP << 8) + DATA
#define M2UA_MAUP_ESTABLISH_REQ (M2UA_MCLASS_MAUP << 8) + ESTABLISH_REQ
#define M2UA_MAUP_ESTABLISH_CFM (M2UA_MCLASS_MAUP << 8) + ESTABLISH_CFM
#define M2UA_MAUP_RELEASE_REQ (M2UA_MCLASS_MAUP << 8) + RELEASE_REQ
#define M2UA_MAUP_RELEASE_CFM (M2UA_MCLASS_MAUP << 8) + RELEASE_CFM
#define M2UA_MAUP_RELEASE_IND (M2UA_MCLASS_MAUP << 8) + RELEASE_IND
#define M2UA_MAUP_STATE_REQ (M2UA_MCLASS_MAUP << 8) + STATE_REQ
#define M2UA_MAUP_STATE_CFM (M2UA_MCLASS_MAUP << 8) + STATE_CFM
#define M2UA_MAUP_STATE_IND (M2UA_MCLASS_MAUP << 8) + STATE_IND
#define M2UA_MAUP_DATA_RETIEVE_REQ (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_REQ
#define M2UA_MAUP_DATA_RETIEVE_CFM (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CFM
#define M2UA_MAUP_DATA_RETIEVE_IND (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_IND
#define M2UA_MAUP_DATA_RETIEVE_CMP (M2UA_MCLASS_MAUP << 8) + DATA_RETIEVE_CMP
#define M2UA_MAUP_CONGESTION_IND (M2UA_MCLASS_MAUP << 8) + CONGESTION_IND
#define M2UA_MAUP_DATA_ACK (M2UA_MCLASS_MAUP << 8) + DATA_ACK
//add by yizane
//for QPTM
#define IUA_DATA_REQ 1
#define IUA_DATA_IND 2
#define IUA_UDATA_REQ 3
#define IUA_UDATA_IND 4
#define IUA_ESTABLISH_REQ 5
#define IUA_ESTABLISH_CFM 6
#define IUA_ESTABLISH_IND 7
#define IUA_RELEASE_REQ 8
#define IUA_RELEASE_CFM 9
#define IUA_RELEASE_IND 10
#define IUA_QPTM_DATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_DATA_REQ
#define IUA_QPTM_DATA_IND (xUA_MCLASS_QPTM << 8) + IUA_DATA_IND
#define IUA_QPTM_UDATA_REQ (xUA_MCLASS_QPTM << 8) + IUA_UDATA_REQ
#define IUA_QPTM_UDATA_IND (xUA_MCLASS_QPTM << 8) + IUA_UDATA_IND
#define IUA_QPTM_ESTABLISH_REQ (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_REQ
#define IUA_QPTM_ESTABLISH_CFM (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_CFM
#define IUA_QPTM_ESTABLISH_IND (xUA_MCLASS_QPTM << 8) + IUA_ESTABLISH_IND
#define IUA_QPTM_RELEASE_REQ (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_REQ
#define IUA_QPTM_RELEASE_CFM (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_CFM
#define IUA_QPTM_RELEASE_IND (xUA_MCLASS_QPTM << 8) + IUA_RELEASE_IND
//add by yizane
#define ERROR 0
#define NOTIFY 1
//add by yizane
#define TEI_S_REQ 2
#define TEI_S_CFM 3
#define TEI_S_IND 4
//add by yizane
#define M2UA_MGMT_ERROR (M2UA_MCLASS_MGMT << 8) + ERROR
#define M2UA_MGMT_NOTIFY (M2UA_MCLASS_MGMT << 8) + NOTIFY
//add by yizane
#define xUA_MGMT_ERROR (xUA_MCLASS_MGMT << 8) + ERROR
#define xUA_MGMT_NOTIFY (xUA_MCLASS_MGMT << 8) + NOTIFY
#define xUA_MGMT_TEI_S_REQ (xUA_MCLASS_MGMT << 8) + TEI_S_REQ
#define xUA_MGMT_TEI_S_CFM (xUA_MCLASS_MGMT << 8) + TEI_S_CFM
#define xUA_MGMT_TEI_S_IND (xUA_MCLASS_MGMT << 8) + TEI_S_IND
//add by yizane
#define M2UA_IIM_REG_REQ 1
#define M2UA_IIM_REG_RSP 2
#define M2UA_IIM_DEREG_REQ 3
#define M2UA_IIM_DEREG_RSP 4
#define M2UA_PAR_INTERFACE_ID_INT 0x0001
#define M2UA_PAR_INTERFACE_ID_TXT 0x0003
#define M2UA_PAR_TRAFFIC_MODE 0x000B
#define M2UA_PAR_ASP_IDENTIFIER 0x0011
#define M2UA_PAR_PROTO_DATA_1 0x0300
#define M2UA_PAR_CORRELATION_ID 0x0013
#define M2UA_PAR_STATE 0x0302
#define M2UA_PAR_STATUS 0x000D
#define M2UA_PAR_ERR_CODE 0x000C
//add by yizane
#define xUA_PAR_DLCI 0x0005
#define xUA_PAR_PROTOCOL_DATA 0x000E
#define xUA_PAR_REL_REASON 0x000F
#define xUA_PAR_TEI_STATUS 0x0010
//add by yizane
#define M2UA_STATUS_LPO_SET 0x0
#define M2UA_STATUS_LPO_CLEAR 0x1
#define M2UA_STATUS_EMER_SET 0x2
#define M2UA_STATUS_EMER_CLEAR 0x3
#define M2UA_STATUS_FLUSH_BUFFERS 0x4
#define M2UA_STATUS_CONTINUE 0x5
#define M2UA_STATUS_CLEAR_RTB 0x6
#define M2UA_STATUS_AUDIT 0x7
#define M2UA_STATUS_CONG_CLEAR 0x8
#define M2UA_STATUS_CONG_ACCEPT 0x9
#define M2UA_STATUS_CONG_DISCARD 0xa
#define M2UA_STATUS_TYPE_AS_STATE_CHG 1
#define M2UA_STATUS_TYPE_OTHER 2
#define M2UA_STATUS_INFO_AS_RESERVED 1
#define M2UA_STATUS_INFO_AS_INACTIVE 2
#define M2UA_STATUS_INFO_AS_ACTIVE 3
#define M2UA_STATUS_INFO_AS_PENDING 4
#define M2UA_ERR_INVALID_VERSION 0x1
#define M2UA_ERR_INVALID_IID 0x2
#define M2UA_ERR_UNSUPPORTED_MSG_CLASS 0x3
#define M2UA_ERR_UNSUPPORTED_MSG_TYPE 0x4
#define M2UA_ERR_UNSUPPORTED_TRA_HDL_MODE 0x5
#define M2UA_ERR_UNEXPECTED_MSG 0x6
#define M2UA_ERR_PROTOCOL_ERROR 0x7
#define M2UA_ERR_UNSUPPORTED_IIT 0x8
#define M2UA_ERR_INVALID_SID 0x9
#define M2UA_ERR_REFUSED_MGMT_BLOCK 0xd
#define M2UA_ERR_ASP_ID_REQUIRED 0xe
#define M2UA_ERR_INVALID_ASP_ID 0xf
#define M2UA_ERR_ASP_ACTIVE_FOR_IID 0x10
#define M2UA_ERR_INVALID_PARA_VAL 0x11
#define M2UA_ERR_PARA_FIELD_ERROR 0x12
#define M2UA_ERR_UNEXPECTED_PARA 0x13
#define M2UA_ERR_MISSING_PARA 0x16
//add by yizane
#define IUA_TEI_ASSIGNED 0x0
#define IUA_TEI_UNASSIGNED 0x1
#define IUA_RELEASE_MGMT 0x00
#define IUA_RELEASE_PHYS 0x01
#define IUA_RELEASE_DM 0x02
#define IUA_RELEASE_OTHER 0x03
//add by yizane
#define M2UA_TRAFFIC_MODE_OVERRIDE 1
#define M2UA_TRAFFIC_MODE_LOADSHARE 2
#define M2UA_TRAFFIC_MODE_BROADCAST 3
#define M2UA_LK_IDLE 0
#define M2UA_LK_DOWN 1
#define M2UA_LK_UP 5
#define M2UA_LK_PO 6
#define M2UA_MCLASS_MTP3 1
#define M2UA_MCLASS_LM 2
#define M2UA_MTP3_SIO_CMD 0xFF
#define M2UA_SIO_CMD 0xEF
#define M2UA_MTP3_SIO_MSG 0x80
#define M2UA_LK_ATTR_SIGTRAN 1
#define M2UA_MTP3_MAX_LS_NUM 128
#define M2UA_MTP3_CMD_ACTIVE_LK 1
#define M2UA_MTP3_CMD_DEACTIVE_LK 2
#define M2UA_MTP3_CMD_STOP_L2 3
#define M2UA_MTP3_CMD_EMERG_ALIGN 4
#define M2UA_T_ACK 100 // 2 seconds = 100 * 20ms
#define M2UA_T_R 100 // 2 seconds
#define M2UA_T_LK_ESTAB 4 // 10 seconds = 4 * 2.56s
#define M2UA_T_SG_ESTAB_1 500 // 10 seconds
#define M2UA_T_SG_ESTAB_2 6000 // 120 seconds
#define M2UA_T_SG_ESTAB_3 1500 // 30 seconds
#define M2UA_T_SG_WAIT 100 // 2 seconds
#define M2UA_CMD_IDLE 0
#define M2UA_CMD_PARA_SAVE 1
#define M2UA_CMD_PARA_INIT 2
#define M2UA_CMD_STATUS_INIT 3
#define M2UA_MGMT_CMD_LK_LOCK 1
//add by yizane
#define IUA_MGMT_CMD_LK_LOCK 2
//add by yizane
#define MAX_ASCIIIN_LEN 4096
#define MAX_ASCIIOUT_LEN 4096
#define MAX_ASCITMP_LEN 4096
#define MONITOR_NONE 0x0000
#define MONITOR_MTP3 0x0001
#define MONITOR_M2UA 0x0002
#define MONITOR_MAUP 0x0004
#define MONITOR_SCTP 0x0008
#define MONITOR_ERROR 0x0010
#define MONITOR_ALL 0xffff
#define M2UA_MAX_RETRANS 10
#define M2UA_STOP_M2UA_LINK 6
#define M2UA_ENABLE_M2UA_LINK 7
//add by yizane
#define xUA_STOP_xUA_LINK 6
#define xUA_ENABLE_xUA_LINK 7
//add by yizane
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_UP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_UP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_COMM_LOST ((SCTP_ASSOC_CHANGE << 16) | (SCTP_COMM_LOST & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_SHUTDOWN_COMP ((SCTP_ASSOC_CHANGE << 16) | (SCTP_SHUTDOWN_COMP & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_RESTART ((SCTP_ASSOC_CHANGE << 16) | (SCTP_RESTART & 0xFFFF))
#define M2UA_LKSCTP_ASSOC_CHANGE_CANT_STR_ASSOC ((SCTP_ASSOC_CHANGE << 16) | (SCTP_CANT_STR_ASSOC & 0xFFFF))
#define M2UA_LKSCTP_SEND_FAILED (SCTP_SEND_FAILED << 16)
#define M2UA_LKSCTP_PEER_ADDR_CHANGE (SCTP_PEER_ADDR_CHANGE << 16)
#define M2UA_LKSCTP_REMOTE_ERROR (SCTP_REMOTE_ERROR << 16)
#define M2UA_LKSCTP_SHUTDOWN_EVENT (SCTP_SHUTDOWN_EVENT << 16)
#define M2UA_LKSCTP_DATA_IND 0x7FFFFFFE
#define M2UA_LKSCTP_UNKNOWN_EVENT 0x7FFFFFFF
#define M2UA_ALARM_CODE_NORMAL 0
#define M2UA_ALARM_CODE_SCTP_FAILURE 1
#define M2UA_ALARM_CODE_REMOTE_AS_DOWN 2
#define M2UA_ALARM_CODE_REMOTE_LINK_RELEASE 3
#define M2UA_ALARM_CODE_LOCAL_MTP3_REQUEST_LINK_DOWN 4
#define M2UA_ALARM_CODE_LOCAL_SG_MAINTENANCE 5
#define M2UA_ALARM_CODE_LOCAL_LINK_MAINTENANCE 6
#endif

View File

@@ -0,0 +1,10 @@
#ifndef _M2UA_DEBUG__H
#define _M2UA_DEBUG__H
void m2ua_mon(void);
int m2ua_debug_set(void);
int m2ua_asciout_proc(BYTE *out_str);
int m2ua_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc);
int m2ua_log_err(WORD sg_id, BYTE *err_msg);
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _M2UA_DEF__H
#define _M2UA_DEF__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
//const BYTE m2ua_ver[3] = {10, 0, 6};
BYTE m2ua_command = 0;
m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];//for listen m2ua*2,iua*2
m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
m2ua_sctp_addr_t m2ua_sctp_addr;
m2ua_sctp_cmd_t m2ua_sctp_cmd;
BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE];
int m2ua_sctp_cmd_len;
int m2ua_sctp_dat_len;
#ifndef _LKSCTP
struct strbuf m2ua_sctp_ctrl = {M2UA_SCTP_CMD_BUFSIZE, 0, m2ua_sctp_cmd.cbuf};
struct strbuf m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#else
m2ua_sctp_data_t m2ua_sctp_data = {M2UA_SCTP_DAT_BUFSIZE, 0, m2ua_sctp_dat};
#endif
m2ua_para_t m2ua_para;
BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD m2ua_mtp3_sd_h;
WORD m2ua_mtp3_sd_t;
//add by yizane
BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
WORD iua_q931_sd_h;
WORD iua_q931_sd_t;
//add by yizane
DWORD x256[M2UA_MAX_M3MSG_NUM];
char hostip[20];
char hostname[50];
DWORD host_ip;
BYTE plat_id;
m2ua_sctp_addr_t m2ua_sctp_server_addr;
m2ua_csta_t m2ua_csta;
BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
WORD moniter_fg;
BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
WORD m2ua_sg_mon_count;
WORD m2ua_lk_mon_count;
DWORD err[64];
BYTE init_flag;
#endif

View File

@@ -0,0 +1,64 @@
#ifndef _M2UA_EXT__H
#define _M2UA_EXT__H
#include "m2ua_pub.h"
#include "m2ua.h"
#include "m2ua_const.h"
#include "m2ua_struct.h"
//extern const BYTE m2ua_ver[3];
extern BYTE m2ua_command;
extern m2ua_sg_info_t m2ua_sg_info[M2UA_MAX_SG_FSM_NUM];
extern m2ua_lk_info_t m2ua_lk_info[M2UA_MAX_LK_NUM];
extern m2ua_sctp_addr_t m2ua_sctp_addr;
extern m2ua_sctp_cmd_t m2ua_sctp_cmd;
extern BYTE m2ua_sctp_dat[M2UA_SCTP_DAT_BUFSIZE];
extern int m2ua_sctp_cmd_len;
extern int m2ua_sctp_dat_len;
#ifndef _LKSCTP
extern struct strbuf m2ua_sctp_ctrl;
extern struct strbuf m2ua_sctp_data;
#else
extern m2ua_sctp_data_t m2ua_sctp_data;
#endif
extern m2ua_para_t m2ua_para;
extern BYTE m2ua_mtp3_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD m2ua_mtp3_sd_h;
extern WORD m2ua_mtp3_sd_t;
//add by yizane
extern BYTE iua_q931_sd[M2UA_MAX_MSG_LEN * M2UA_MAX_M3MSG_NUM];
extern WORD iua_q931_sd_h;
extern WORD iua_q931_sd_t;
//add by yizane
extern DWORD x256[M2UA_MAX_M3MSG_NUM];
extern char hostip[20];
extern char hostname[50];
extern DWORD host_ip;
extern BYTE plat_id;
extern m2ua_sctp_addr_t m2ua_sctp_server_addr;
extern m2ua_csta_t m2ua_csta;
extern BYTE m2ua_asciin_buf[MAX_ASCIIIN_LEN];
extern BYTE m2ua_asciout_buf[MAX_ASCIIOUT_LEN];
extern BYTE m2ua_ascitemp_buf[MAX_ASCITMP_LEN];
extern WORD moniter_fg;
extern BYTE m2ua_sg_mon_fg[M2UA_MAX_SG_FSM_NUM];
extern BYTE m2ua_lk_mon_fg[M2UA_MAX_LK_NUM];
extern WORD m2ua_sg_mon_count;
extern WORD m2ua_lk_mon_count;
extern DWORD err[64];
extern BYTE init_flag;
#endif

View File

@@ -0,0 +1,9 @@
#ifndef _M2UA_FSM__H
#define _M2UA_FSM__H
int m2ua_sg_fsm(WORD sg_id);
int m2ua_fsm(WORD sg_id);
int rel_sid(WORD sg, BYTE lk);
#endif

View File

@@ -0,0 +1,53 @@
#ifndef _M2UA_MSG__H
#define _M2UA_MSG__H
#define COMBO_W(par_class,par_type) ((par_class << 8) + par_type)
int m2ua_sctp_close(int fd, WORD sg_id);
int m2ua_dec_msg(WORD sg_id);
int m2ua_send_msg(WORD sg_id, WORD msg);
int m2ua_sd_mtp3_primi(BYTE lk, BYTE primi);
int m2ua_sd_mtp3_msg(WORD sg, BYTE lk);
//add by yizane
int iua_sd_q931_primi(BYTE lk, BYTE primi);
int iua_sd_q931_msg(WORD sg, BYTE lk);
//add by yizane
int m2ua_sg_init(WORD id);
int m2ua_lk_init(BYTE id);
int enable_sg(WORD sg);
int rm_sg_lk(WORD sg, BYTE lk);
char *dec_sctp_primi(long sctp_primi);
#ifndef _LKSCTP
int m2ua_sctp_t_open(WORD sg);
int expect(int fd, int sg, int *msg, int want);
int m2ua_sctp_optmgmt_req(int fd, int sg, DWORD flags);
int m2ua_sctp_bind_req(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_conn_res(int fd, int fd2, int sg, long seq);
int m2ua_sctp_ordrel_req(int fd, int sg);
int m2ua_sctp_discon_req(int fd, int sg, DWORD seq);
int m2ua_sctp_conn_req(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_optdata_req(int fd, int sg, BYTE len);
#else
int m2ua_sctp_optmgmt_req_lksctp(int fd, int sg);
int m2ua_sctp_optmgmt_req_lksctp_ext(int fd, int sg);
int m2ua_sctp_bind_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr, int coninds);
int m2ua_sctp_open_lksctp(WORD sg);
int m2ua_sctp_conn_req_lksctp(int fd, int sg, m2ua_sctp_addr_t *addr);
int m2ua_sctp_get_msg_lksctp(int fd, WORD sg);
int expect_lksctp(int fd, int sg, int *msg, int want);
int m2ua_sctp_discon_req_lksctp(int fd, int sg, int flag);
int m2ua_sctp_put_msg_lksctp(int fd, int sg);
int m2ua_sctp_optdata_req_lksctp(int fd, int sg, int len);
#endif
#endif

View File

@@ -0,0 +1,63 @@
#ifndef _M2UA_PUB__H
#define _M2UA_PUB__H
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <memory.h>
#include <netdb.h>
#include <setjmp.h>
#include <unistd.h>
#include <signal.h>
#include <stropts.h>
#include <time.h>
#include <syslog.h>
#include <termio.h>
#include <fcntl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/io.h>
#include <sys/poll.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <sys/socket.h>
#include <sys/select.h>
#ifndef _LKSCTP
#include <sys/tpi.h>
#include <sys/tpi_sctp.h>
#include <sys/xti_ip.h>
#include <sys/xti_sctp.h>
#else
#include <netinet/sctp.h>
#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
#endif

View File

@@ -0,0 +1,240 @@
#ifndef _M2UA_STRUCT__H
#define _M2UA_STRUCT__H
#include "m2ua_const.h"
#ifndef _LKSCTP
typedef union _m2ua_sctp_cmd
{
union T_primitives tpi;
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE];
}m2ua_sctp_cmd_t;
// Data Options
typedef struct _m2ua_sctp_opt_data
{
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
}m2ua_sctp_opt_data_t;
// Connect Options
typedef struct _m2ua_sctp_opt_conn
{
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
}m2ua_sctp_opt_conn_t;
// Management Options
typedef struct _m2ua_sctp_opt_optm
{
struct t_opthdr nod_hdr __attribute__((packed));
t_scalar_t nod_val __attribute__((packed));
struct t_opthdr crk_hdr __attribute__((packed));
t_scalar_t crk_val __attribute__((packed));
struct t_opthdr ppi_hdr __attribute__((packed));
t_scalar_t ppi_val __attribute__((packed));
struct t_opthdr sid_hdr __attribute__((packed));
t_scalar_t sid_val __attribute__((packed));
struct t_opthdr rcv_hdr __attribute__((packed));
t_scalar_t rcv_val __attribute__((packed));
struct t_opthdr ckl_hdr __attribute__((packed));
t_scalar_t ckl_val __attribute__((packed));
struct t_opthdr skd_hdr __attribute__((packed));
t_scalar_t skd_val __attribute__((packed));
struct t_opthdr prt_hdr __attribute__((packed));
t_scalar_t prt_val __attribute__((packed));
struct t_opthdr art_hdr __attribute__((packed));
t_scalar_t art_val __attribute__((packed));
struct t_opthdr irt_hdr __attribute__((packed));
t_scalar_t irt_val __attribute__((packed));
struct t_opthdr hbi_hdr __attribute__((packed));
t_scalar_t hbi_val __attribute__((packed));
struct t_opthdr rin_hdr __attribute__((packed));
t_scalar_t rin_val __attribute__((packed));
struct t_opthdr rmn_hdr __attribute__((packed));
t_scalar_t rmn_val __attribute__((packed));
struct t_opthdr rmx_hdr __attribute__((packed));
t_scalar_t rmx_val __attribute__((packed));
struct t_opthdr ist_hdr __attribute__((packed));
t_scalar_t ist_val __attribute__((packed));
struct t_opthdr ost_hdr __attribute__((packed));
t_scalar_t ost_val __attribute__((packed));
struct t_opthdr cin_hdr __attribute__((packed));
t_scalar_t cin_val __attribute__((packed));
struct t_opthdr tin_hdr __attribute__((packed));
t_scalar_t tin_val __attribute__((packed));
struct t_opthdr mac_hdr __attribute__((packed));
t_scalar_t mac_val __attribute__((packed));
struct t_opthdr dbg_hdr __attribute__((packed));
t_scalar_t dbg_val __attribute__((packed));
}m2ua_sctp_opt_optm_t;
#else
typedef union _m2ua_sctp_cmd
{
struct cmsghdr cmsg __attribute__((packed));
BYTE cbuf[M2UA_SCTP_CMD_BUFSIZE] __attribute__((packed));
}m2ua_sctp_cmd_t;
typedef struct _m2ua_sctp_data
{
int len __attribute__((packed));
int sid __attribute__((packed));
BYTE *buf __attribute__((packed));
}m2ua_sctp_data_t;
#endif
typedef struct _m2ua_sctp_addr
{
uint16_t port __attribute__((packed));
struct in_addr addr __attribute__((packed));
}m2ua_sctp_addr_t;
typedef struct _m2ua_lk_info
{
BYTE enable __attribute__((packed));
BYTE lk_st __attribute__((packed));
WORD sid __attribute__((packed));
DWORD lk_timer __attribute__((packed));
BYTE alarm_code __attribute__((packed));
BYTE lk_act __attribute__((packed));
}m2ua_lk_info_t;
typedef struct _m2ua_sg_info
{
BYTE enable __attribute__((packed));
BYTE sctp_state __attribute__((packed));
BYTE sctp_state_1 __attribute__((packed));
BYTE m2ua_state __attribute__((packed));
DWORD sctp_cmd __attribute__((packed));
WORD m2ua_cmd __attribute__((packed));
WORD mtp3_cmd __attribute__((packed));
WORD mgmt_cmd __attribute__((packed));
WORD fd __attribute__((packed));
WORD iid __attribute__((packed));
DWORD sid_st[8] __attribute__((packed));
BYTE *msg __attribute__((packed));
WORD msg_len __attribute__((packed));
WORD rem_ostrs __attribute__((packed));
WORD T_ack __attribute__((packed));
WORD T_r __attribute__((packed));
BYTE con_sg __attribute__((packed));
BYTE state __attribute__((packed));
BYTE err_code __attribute__((packed));
BYTE tra_hdl_mode __attribute__((packed));
WORD act_lks __attribute__((packed));
WORD istrs __attribute__((packed));
WORD ostrs __attribute__((packed));
DWORD status __attribute__((packed));
DWORD seq __attribute__((packed));
DWORD cor_id __attribute__((packed));
WORD up_lks_pre __attribute__((packed));
WORD up_lks_cur __attribute__((packed));
DWORD sg_timer __attribute__((packed));
BYTE retrans_times __attribute__((packed));
WORD rem_port __attribute__((packed));
BYTE alarm_code __attribute__((packed));
//add by yizane
BYTE rel_reason __attribute__((packed));
BYTE tei_state __attribute__((packed));
BYTE dlci __attribute__((packed));
//add by yizane
}m2ua_sg_info_t;
typedef struct _m2ua_comhdr
{
BYTE version __attribute__((packed));
BYTE spare __attribute__((packed));
BYTE msg_class __attribute__((packed));
BYTE msg_type __attribute__((packed));
DWORD len __attribute__((packed));
}m2ua_comhdr_t;
typedef struct _m2ua_par_hdr
{
WORD tag __attribute__((packed));
WORD len __attribute__((packed));
}m2ua_par_hdr_t;
typedef struct _m2ua_var_par
{
m2ua_par_hdr_t hdr __attribute__((packed));
BYTE val[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_var_par_t;
typedef struct _m2ua_msg
{
m2ua_comhdr_t comhdr __attribute__((packed));
BYTE msg[M2UA_MAX_MSG_LEN] __attribute__((packed));
}m2ua_msg_t;
typedef struct _sg_para
{
BYTE enable __attribute__((packed));
BYTE server __attribute__((packed));
BYTE xUA_ack __attribute__((packed)); //BIT 1-7:xUA_type,0/1:M2UA/IUA ,Bit 0: ACK
DWORD ip __attribute__((packed));
WORD plat_port[2] __attribute__((packed));
}sg_para_t;
typedef struct _lk_para
{
BYTE enable __attribute__((packed));
WORD lk_sg __attribute__((packed));
BYTE iid __attribute__((packed));
WORD dlci __attribute__((packed));
}lk_para_t;
typedef struct _m2ua_para
{
sg_para_t sg_para[M2UA_MAX_SG_NUM] __attribute__((packed));
lk_para_t lk_para[M2UA_MAX_LK_NUM] __attribute__((packed));
BYTE cmd __attribute__((packed));
}m2ua_para_t;
typedef struct _m2ua_lk_pro
{
BYTE e1_to_linkset __attribute__((packed));
BYTE e1_to_slc __attribute__((packed));
DWORD e1_to_mtp3 __attribute__((packed));
BYTE e1_lk_type __attribute__((packed));
BYTE e1_to_sg __attribute__((packed));
BYTE e1_to_iid __attribute__((packed));
DWORD remote_ip __attribute__((packed));
BYTE inactive __attribute__((packed));
BYTE inactive_tm __attribute__((packed));
DWORD e1_to_alterMTP3 __attribute__((packed));
}m2ua_lk_pro_t;
typedef struct _m2ua_sg_csta
{
DWORD timestamp __attribute__((packed));
DWORD sg_out_msg __attribute__((packed));
DWORD sg_in_msg __attribute__((packed));
DWORD sg_out_bytes __attribute__((packed));
DWORD sg_in_bytes __attribute__((packed));
DWORD sg_asp_dn_times __attribute__((packed));
}m2ua_sg_csta_t;
typedef struct _m2ua_lk_csta
{
DWORD timestamp __attribute__((packed));
DWORD lk_out_msg __attribute__((packed));
DWORD lk_in_msg __attribute__((packed));
DWORD lk_out_bytes __attribute__((packed));
DWORD lk_in_bytes __attribute__((packed));
DWORD lk_dn_times __attribute__((packed));
}m2ua_lk_csta_t;
typedef struct _m2ua_csta
{
m2ua_sg_csta_t sg_csta[M2UA_MAX_SG_NUM] __attribute__((packed));
m2ua_lk_csta_t lk_csta[M2UA_MAX_LK_NUM] __attribute__((packed));
}m2ua_csta_t;
#endif

View File

@@ -0,0 +1,655 @@
/* SCTP kernel reference Implementation
* (C) Copyright IBM Corp. 2001, 2004
* Copyright (c) 1999-2000 Cisco, Inc.
* Copyright (c) 1999-2001 Motorola, Inc.
*
* This file is part of the SCTP kernel reference Implementation
*
* This header represents the structures and constants needed to support
* the SCTP Extension to the Sockets API.
*
* The SCTP reference implementation is free software;
* you can redistribute it and/or modify it under the terms of
* the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* The SCTP reference implementation is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
* ************************
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Please send any bug reports or fixes you make to the
* email address(es):
* lksctp developers <lksctp-developers@lists.sourceforge.net>
*
* Or submit a bug report through the following website:
* http://www.sf.net/projects/lksctp
*
* Written or modified by:
* La Monte H.P. Yarroll <piggy@acm.org>
* R. Stewart <randall@sctp.chicago.il.us>
* K. Morneau <kmorneau@cisco.com>
* Q. Xie <qxie1@email.mot.com>
* Karl Knutson <karl@athena.chicago.il.us>
* Jon Grimm <jgrimm@austin.ibm.com>
* Daisy Chang <daisyc@us.ibm.com>
* Inaky Perez-Gonzalez <inaky.gonzalez@intel.com>
* Sridhar Samudrala <sri@us.ibm.com>
*
* Any bugs reported given to us we will try to fix... any fixes shared will
* be incorporated into the next SCTP release.
*/
#ifndef __linux_sctp_h__
#define __linux_sctp_h__
#include <stdint.h>
#include <linux/types.h>
#include <sys/socket.h>
__BEGIN_DECLS
typedef void * sctp_assoc_t;
/* Socket option layer for SCTP */
#ifndef SOL_SCTP
#define SOL_SCTP 132
#endif
#ifndef IPPROTO_SCTP
#define IPPROTO_SCTP 132
#endif
/* 9. Preprocessor constants */
#define HAVE_SCTP
#define HAVE_KERNEL_SCTP
#define HAVE_SCTP_MULTIBUF
#define HAVE_SCTP_NOCONNECT
/* The following symbols come from the Sockets API Extensions for
* SCTP <draft-ietf-tsvwg-sctpsocket-07.txt>.
*/
enum sctp_optname {
SCTP_RTOINFO,
#define SCTP_RTOINFO SCTP_RTOINFO
SCTP_ASSOCINFO,
#define SCTP_ASSOCINFO SCTP_ASSOCINFO
SCTP_INITMSG,
#define SCTP_INITMSG SCTP_INITMSG
SCTP_NODELAY, /* Get/set nodelay option. */
#define SCTP_NODELAY SCTP_NODELAY
SCTP_AUTOCLOSE,
#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
SCTP_SET_PEER_PRIMARY_ADDR,
#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
SCTP_PRIMARY_ADDR,
#define SCTP_PRIMARY_ADDR SCTP_PRIMARY_ADDR
SCTP_ADAPTION_LAYER,
#define SCTP_ADAPTION_LAYER SCTP_ADAPTION_LAYER
SCTP_DISABLE_FRAGMENTS,
#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
SCTP_PEER_ADDR_PARAMS,
#define SCTP_PEER_ADDR_PARAMS SCTP_PEER_ADDR_PARAMS
SCTP_DEFAULT_SEND_PARAM,
#define SCTP_DEFAULT_SEND_PARAM SCTP_DEFAULT_SEND_PARAM
SCTP_EVENTS,
#define SCTP_EVENTS SCTP_EVENTS
SCTP_I_WANT_MAPPED_V4_ADDR, /* Turn on/off mapped v4 addresses */
#define SCTP_I_WANT_MAPPED_V4_ADDR SCTP_I_WANT_MAPPED_V4_ADDR
SCTP_MAXSEG, /* Get/set maximum fragment. */
#define SCTP_MAXSEG SCTP_MAXSEG
SCTP_STATUS,
#define SCTP_STATUS SCTP_STATUS
SCTP_GET_PEER_ADDR_INFO,
#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
/* Internal Socket Options. Some of the sctp library functions are
* implemented using these socket options.
*/
SCTP_SOCKOPT_BINDX_ADD = 100,/* BINDX requests for adding addresses. */
#define SCTP_SOCKOPT_BINDX_ADD SCTP_SOCKOPT_BINDX_ADD
SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
SCTP_SOCKOPT_PEELOFF, /* peel off association. */
#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
SCTP_GET_PEER_ADDRS_NUM, /* Get number of peer addresss. */
#define SCTP_GET_PEER_ADDRS_NUM SCTP_GET_PEER_ADDRS_NUM
SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */
#define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS
SCTP_GET_LOCAL_ADDRS_NUM, /* Get number of local addresss. */
#define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM
SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */
#define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS
};
/*
* 5.2.1 SCTP Initiation Structure (SCTP_INIT)
*
* This cmsghdr structure provides information for initializing new
* SCTP associations with sendmsg(). The SCTP_INITMSG socket option
* uses this same data structure. This structure is not used for
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
*
*/
struct sctp_initmsg {
__u16 sinit_num_ostreams;
__u16 sinit_max_instreams;
__u16 sinit_max_attempts;
__u16 sinit_max_init_timeo;
};
/*
* 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
*
* This cmsghdr structure specifies SCTP options for sendmsg() and
* describes SCTP header information about a received message through
* recvmsg().
*
* cmsg_level cmsg_type cmsg_data[]
* ------------ ------------ ----------------------
* IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
*
*/
struct sctp_sndrcvinfo {
__u16 sinfo_stream;
__u16 sinfo_ssn;
__u16 sinfo_flags;
__u32 sinfo_ppid;
__u32 sinfo_context;
__u32 sinfo_timetolive;
__u32 sinfo_tsn;
__u32 sinfo_cumtsn;
sctp_assoc_t sinfo_assoc_id;
};
/*
* sinfo_flags: 16 bits (unsigned integer)
*
* This field may contain any of the following flags and is composed of
* a bitwise OR of these values.
*/
enum sctp_sinfo_flags {
MSG_UNORDERED = 1, /* Send/receive message unordered. */
MSG_ADDR_OVER = 2, /* Override the primary destination. */
MSG_ABORT=4, /* Send an ABORT message to the peer. */
MSG_EOF=MSG_FIN, /* Initiate graceful shutdown process. */
};
typedef union {
__u8 raw;
struct sctp_initmsg init;
struct sctp_sndrcvinfo sndrcv;
} sctp_cmsg_data_t;
/* These are cmsg_types. */
typedef enum sctp_cmsg_type {
SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
} sctp_cmsg_t;
/*
* 5.3.1.1 SCTP_ASSOC_CHANGE
*
* Communication notifications inform the ULP that an SCTP association
* has either begun or ended. The identifier for a new association is
* provided by this notificaion. The notification information has the
* following format:
*
*/
struct sctp_assoc_change {
__u16 sac_type;
__u16 sac_flags;
__u32 sac_length;
__u16 sac_state;
__u16 sac_error;
__u16 sac_outbound_streams;
__u16 sac_inbound_streams;
sctp_assoc_t sac_assoc_id;
};
/*
* sac_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the association. They include:
*
* Note: The following state names deviate from the API draft as
* the names clash too easily with other kernel symbols.
*/
enum sctp_sac_state {
SCTP_COMM_UP,
SCTP_COMM_LOST,
SCTP_RESTART,
SCTP_SHUTDOWN_COMP,
SCTP_CANT_STR_ASSOC,
};
/*
* 5.3.1.2 SCTP_PEER_ADDR_CHANGE
*
* When a destination address on a multi-homed peer encounters a change
* an interface details event is sent. The information has the
* following structure:
*/
struct sctp_paddr_change {
__u16 spc_type;
__u16 spc_flags;
__u32 spc_length;
struct sockaddr_storage spc_aaddr;
int spc_state;
int spc_error;
sctp_assoc_t spc_assoc_id;
};
/*
* spc_state: 32 bits (signed integer)
*
* This field holds one of a number of values that communicate the
* event that happened to the address. They include:
*/
enum sctp_spc_state {
SCTP_ADDR_AVAILABLE,
SCTP_ADDR_UNREACHABLE,
SCTP_ADDR_REMOVED,
SCTP_ADDR_ADDED,
SCTP_ADDR_MADE_PRIM,
};
/*
* 5.3.1.3 SCTP_REMOTE_ERROR
*
* A remote peer may send an Operational Error message to its peer.
* This message indicates a variety of error conditions on an
* association. The entire error TLV as it appears on the wire is
* included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP
* specification [SCTP] and any extensions for a list of possible
* error formats. SCTP error TLVs have the format:
*/
struct sctp_remote_error {
__u16 sre_type;
__u16 sre_flags;
__u32 sre_length;
__u16 sre_error;
sctp_assoc_t sre_assoc_id;
__u8 sre_data[0];
};
/*
* 5.3.1.4 SCTP_SEND_FAILED
*
* If SCTP cannot deliver a message it may return the message as a
* notification.
*/
struct sctp_send_failed {
__u16 ssf_type;
__u16 ssf_flags;
__u32 ssf_length;
__u32 ssf_error;
struct sctp_sndrcvinfo ssf_info;
sctp_assoc_t ssf_assoc_id;
__u8 ssf_data[0];
};
/*
* ssf_flags: 16 bits (unsigned integer)
*
* The flag value will take one of the following values
*
* SCTP_DATA_UNSENT - Indicates that the data was never put on
* the wire.
*
* SCTP_DATA_SENT - Indicates that the data was put on the wire.
* Note that this does not necessarily mean that the
* data was (or was not) successfully delivered.
*/
enum sctp_ssf_flags {
SCTP_DATA_UNSENT,
SCTP_DATA_SENT,
};
/*
* 5.3.1.5 SCTP_SHUTDOWN_EVENT
*
* When a peer sends a SHUTDOWN, SCTP delivers this notification to
* inform the application that it should cease sending data.
*/
struct sctp_shutdown_event {
__u16 sse_type;
__u16 sse_flags;
__u32 sse_length;
sctp_assoc_t sse_assoc_id;
};
/*
* 5.3.1.6 SCTP_ADAPTION_INDICATION
*
* When a peer sends a Adaption Layer Indication parameter , SCTP
* delivers this notification to inform the application
* that of the peers requested adaption layer.
*/
struct sctp_adaption_event {
__u16 sai_type;
__u16 sai_flags;
__u32 sai_length;
__u32 sai_adaption_ind;
sctp_assoc_t sai_assoc_id;
};
/*
* 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
*
* When a reciever is engaged in a partial delivery of a
* message this notification will be used to inidicate
* various events.
*/
struct sctp_pdapi_event {
__u16 pdapi_type;
__u16 pdapi_flags;
__u32 pdapi_length;
__u32 pdapi_indication;
sctp_assoc_t pdapi_assoc_id;
};
enum { SCTP_PARTIAL_DELIVERY_ABORTED=0, };
/*
* Described in Section 7.3
* Ancillary Data and Notification Interest Options
*/
struct sctp_event_subscribe {
__u8 sctp_data_io_event;
__u8 sctp_association_event;
__u8 sctp_address_event;
__u8 sctp_send_failure_event;
__u8 sctp_peer_error_event;
__u8 sctp_shutdown_event;
__u8 sctp_partial_delivery_event;
__u8 sctp_adaption_layer_event;
};
/*
* 5.3.1 SCTP Notification Structure
*
* The notification structure is defined as the union of all
* notification types.
*
*/
union sctp_notification {
struct {
__u16 sn_type; /* Notification type. */
__u16 sn_flags;
__u32 sn_length;
} sn_header;
struct sctp_assoc_change sn_assoc_change;
struct sctp_paddr_change sn_paddr_change;
struct sctp_remote_error sn_remote_error;
struct sctp_send_failed sn_send_failed;
struct sctp_shutdown_event sn_shutdown_event;
struct sctp_adaption_event sn_adaption_event;
struct sctp_pdapi_event sn_pdapi_event;
};
/* Section 5.3.1
* All standard values for sn_type flags are greater than 2^15.
* Values from 2^15 and down are reserved.
*/
enum sctp_sn_type {
SCTP_SN_TYPE_BASE = (1<<15),
SCTP_ASSOC_CHANGE,
SCTP_PEER_ADDR_CHANGE,
SCTP_SEND_FAILED,
SCTP_REMOTE_ERROR,
SCTP_SHUTDOWN_EVENT,
SCTP_PARTIAL_DELIVERY_EVENT,
SCTP_ADAPTION_INDICATION,
};
/* Notification error codes used to fill up the error fields in some
* notifications.
* SCTP_PEER_ADDRESS_CHAGE : spc_error
* SCTP_ASSOC_CHANGE : sac_error
* These names should be potentially included in the draft 04 of the SCTP
* sockets API specification.
*/
typedef enum sctp_sn_error {
SCTP_FAILED_THRESHOLD,
SCTP_RECEIVED_SACK,
SCTP_HEARTBEAT_SUCCESS,
SCTP_RESPONSE_TO_USER_REQ,
SCTP_INTERNAL_ERROR,
SCTP_SHUTDOWN_GUARD_EXPIRES,
SCTP_PEER_FAULTY,
} sctp_sn_error_t;
/*
* 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
*
* The protocol parameters used to initialize and bound retransmission
* timeout (RTO) are tunable. See [SCTP] for more information on how
* these parameters are used in RTO calculation.
*/
struct sctp_rtoinfo {
sctp_assoc_t srto_assoc_id;
__u32 srto_initial;
__u32 srto_max;
__u32 srto_min;
};
/*
* 7.1.2 Association Parameters (SCTP_ASSOCINFO)
*
* This option is used to both examine and set various association and
* endpoint parameters.
*/
struct sctp_assocparams {
sctp_assoc_t sasoc_assoc_id;
__u16 sasoc_asocmaxrxt;
__u16 sasoc_number_peer_destinations;
__u32 sasoc_peer_rwnd;
__u32 sasoc_local_rwnd;
__u32 sasoc_cookie_life;
};
/*
* 7.1.9 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
*
* Requests that the peer mark the enclosed address as the association
* primary. The enclosed address must be one of the association's
* locally bound addresses. The following structure is used to make a
* set primary request:
*/
struct sctp_setpeerprim {
sctp_assoc_t sspp_assoc_id;
struct sockaddr_storage sspp_addr;
};
/*
* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR)
*
* Requests that the local SCTP stack use the enclosed peer address as
* the association primary. The enclosed address must be one of the
* association peer's addresses. The following structure is used to
* make a set peer primary request:
*/
struct sctp_prim {
sctp_assoc_t ssp_assoc_id;
struct sockaddr_storage ssp_addr;
};
/*
* 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER)
*
* Requests that the local endpoint set the specified Adaption Layer
* Indication parameter for all future INIT and INIT-ACK exchanges.
*/
struct sctp_setadaption {
__u32 ssb_adaption_ind;
};
/*
* 7.1.13 Peer Address Parameters (SCTP_PEER_ADDR_PARAMS)
*
* Applications can enable or disable heartbeats for any peer address
* of an association, modify an address's heartbeat interval, force a
* heartbeat to be sent immediately, and adjust the address's maximum
* number of retransmissions sent before an address is considered
* unreachable. The following structure is used to access and modify an
* address's parameters:
*/
struct sctp_paddrparams {
sctp_assoc_t spp_assoc_id;
struct sockaddr_storage spp_address;
__u32 spp_hbinterval;
__u16 spp_pathmaxrxt;
};
/*
* 7.2.2 Peer Address Information
*
* Applications can retrieve information about a specific peer address
* of an association, including its reachability state, congestion
* window, and retransmission timer values. This information is
* read-only. The following structure is used to access this
* information:
*/
struct sctp_paddrinfo {
sctp_assoc_t spinfo_assoc_id;
struct sockaddr_storage spinfo_address;
__s32 spinfo_state;
__u32 spinfo_cwnd;
__u32 spinfo_srtt;
__u32 spinfo_rto;
__u32 spinfo_mtu;
};
/* Peer addresses's state. */
enum sctp_spinfo_state {
SCTP_INACTIVE,
SCTP_ACTIVE,
};
/*
* 7.2.1 Association Status (SCTP_STATUS)
*
* Applications can retrieve current status information about an
* association, including association state, peer receiver window size,
* number of unacked data chunks, and number of data chunks pending
* receipt. This information is read-only. The following structure is
* used to access this information:
*/
struct sctp_status {
sctp_assoc_t sstat_assoc_id;
__s32 sstat_state;
__u32 sstat_rwnd;
__u16 sstat_unackdata;
__u16 sstat_penddata;
__u16 sstat_instrms;
__u16 sstat_outstrms;
__u32 sstat_fragmentation_point;
struct sctp_paddrinfo sstat_primary;
};
/*
* 8.3, 8.5 get all peer/local addresses on a socket
* This parameter struct is for getsockopt
*/
struct sctp_getaddrs {
sctp_assoc_t assoc_id;
int addr_num;
struct sockaddr *addrs;
};
/* These are bit fields for msghdr->msg_flags. See section 5.1. */
/* On user space Linux, these live in <bits/socket.h> as an enum. */
enum sctp_msg_flags {
MSG_NOTIFICATION = 0x8000,
#define MSG_NOTIFICATION MSG_NOTIFICATION
};
/*
* 8.1 sctp_bindx()
*
* The flags parameter is formed from the bitwise OR of zero or more of the
* following currently defined flags:
*/
#define SCTP_BINDX_ADD_ADDR 0x01
#define SCTP_BINDX_REM_ADDR 0x02
/* This is the structure that is passed as an argument(optval) to
* getsockopt(SCTP_SOCKOPT_PEELOFF).
*/
typedef struct {
sctp_assoc_t associd;
int sd;
} sctp_peeloff_arg_t;
int sctp_bindx(int sd, struct sockaddr *addrs, int addrcnt, int flags);
int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
/* Prototype for the library function sctp_opt_info defined in
* API 7. Socket Options.
*/
int sctp_opt_info(int sd, sctp_assoc_t id, int opt, void *arg, socklen_t *size);
/* Get all peer address on a socket. This is a new SCTP API
* described in the section 8.3 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getpaddrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getpaddrs(). This is a new SCTP API
* described in the section 8.4 of the Sockets API Extensions for SCTP.
*/
int sctp_freepaddrs(struct sockaddr *addrs);
/* Get all locally bound address on a socket. This is a new SCTP API
* described in the section 8.5 of the Sockets API Extensions for SCTP.
* This is implemented using the getsockopt() interface.
*/
int sctp_getladdrs(int sd, sctp_assoc_t id, struct sockaddr **addrs);
/* Frees all resources allocated by sctp_getladdrs(). This is a new SCTP API
* described in the section 8.6 of the Sockets API Extensions for SCTP.
*/
int sctp_freeladdrs(struct sockaddr *addrs);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.7 of the
* Sockets API Extensions for SCTP. This is implemented using the
* sendmsg() interface.
*/
int sctp_sendmsg(int s, const void *msg, size_t len, struct sockaddr *to,
socklen_t tolen, uint32_t ppid, uint32_t flags,
uint16_t stream_no, uint32_t timetolive, uint32_t context);
/* This library function assists the user with the advanced features
* of SCTP. This is a new SCTP API described in the section 8.8 of the
* Sockets API Extensions for SCTP. This is implemented using the
* recvmsg() interface.
*/
int sctp_recvmsg(int s, void *msg, size_t len, struct sockaddr *from,
socklen_t *fromlen, struct sctp_sndrcvinfo *sinfo,
int *msg_flags);
__END_DECLS
#endif /* __linux_sctp_h__ */

362
plat/m2ua/src_old/m2ua.c Normal file
View File

@@ -0,0 +1,362 @@
/****************************************************************/
/* M2UA Implementation Program */
/* Version 10.0.3 */
/* Designed By Ying Min */
/* Last Update: 2006-2-14 */
/****************************************************************/
#include "./include/m2ua_pub.h"
#include "./include/m2ua.h"
#include "./include/m2ua_const.h"
#include "./include/m2ua_def.h"
#include "./include/m2ua_struct.h"
#include "./include/m2ua_msg.h"
#include "./include/m2ua_fsm.h"
#include "./include/m2ua_debug.h"
int m2ua_get_local_ip(void)
{
struct hostent *host;
if (gethostname(hostname, 50) == -1)
{
printf("M2UA gethostname fail!\n");
exit(3);
}
if ((host = gethostbyname(hostname)) == NULL)
{
printf("M2UA gethostbyname fail!\n");
exit(4);
}
else
{
sprintf(hostip, "%d.%d.%d.%d",
(BYTE)host->h_addr_list[0][0],
(BYTE)host->h_addr_list[0][1],
(BYTE)host->h_addr_list[0][2],
(BYTE)host->h_addr_list[0][3]);
host_ip = inet_addr(hostip); // Network byte order host_ip, like 0xE60012AC
printf("hostip: %s (0x%lX)\n", hostip, host_ip);
}
return 0;
}
/*
int m2ua_get_mtp3_para(void)
{
DWORD oid[20] = {1,3,6,1,4,1,1373,1,3,2,2,2,2,9,1}; // SG Attributes
BYTE msg[64], vartype;
int i;
printf("M2UA start to get MTP3 link_para!\n");
for (i = 0; i < M2UA_MAX_SG_NUM; i++)
{
oid[15] = i;
if (get_response(16, oid, msg, &vartype) < 0)
{
printf("M2UA get MTP3 sg_para failed, please set it from MTP3!\n");
return -1;
}
else
set_m2ua_sg(i, msg);
}
oid[14] = 5; // Link Attributes
for (i = 0; i < M2UA_MAX_LK_NUM; i++)
{
oid[15] = i;
if (get_response(16, oid, msg, &vartype) < 0)
{
printf("M2UA get MTP3 link_para failed, please set it from MTP3!\n");
return -1;
}
else
set_m2ua_link(i, msg);
}
return 0;
}
*/
void m2ua_init(BYTE system_id)
{
int id, fd;
//static DWORD init_times = 0;
printf("M2UA Init Start!\n");
plat_id = system_id%2;
m2ua_get_local_ip();
for (id = 0; id < M2UA_MAX_SG_FSM_NUM; id++)
{
m2ua_sg_init(id);
m2ua_sg_mon_fg[id] = 0;
}
m2ua_sg_mon_count = 0;
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M2UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_0 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M2UA_LISTEN_SG_NUM_0)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_0 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M2UA_LISTEN_SG_NUM_0].fd = fd;
m2ua_sg_info[M2UA_LISTEN_SG_NUM_0].enable = 1;
printf("M2UA_LISTEN_SG_NUM_0 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(M2UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_1 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(M2UA_LISTEN_SG_NUM_1)) <= 0)
{
printf("M2UA_LISTEN_SG_NUM_1 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[M2UA_LISTEN_SG_NUM_1].fd = fd;
m2ua_sg_info[M2UA_LISTEN_SG_NUM_1].enable = 1;
printf("M2UA_LISTEN_SG_NUM_1 listening fd open succeed!\n");
}
//add by yizane
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(IUA_LISTEN_SG_NUM_0)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_0 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(IUA_LISTEN_SG_NUM_0)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_0 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[IUA_LISTEN_SG_NUM_0].fd = fd;
m2ua_sg_info[IUA_LISTEN_SG_NUM_0].enable = 1;
printf("IUA_LISTEN_SG_NUM_0 listening fd open succeed!\n");
}
#ifndef _LKSCTP
if ((fd = m2ua_sctp_t_open(IUA_LISTEN_SG_NUM_1)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_1 sctp_t open failure!\n");
exit(2);
}
#else
if ((fd = m2ua_sctp_open_lksctp(IUA_LISTEN_SG_NUM_1)) <= 0)
{
printf("IUA_LISTEN_SG_NUM_1 lksctp open failure!\n");
exit(2);
}
#endif
else
{
m2ua_sg_info[IUA_LISTEN_SG_NUM_1].fd = fd;
m2ua_sg_info[IUA_LISTEN_SG_NUM_1].enable = 1;
printf("IUA_LISTEN_SG_NUM_1 listening fd open succeed!\n");
}
//add by yizane
for (id = 0; id < M2UA_MAX_LK_NUM; id++)
{
m2ua_lk_init(id);
m2ua_lk_mon_fg[id] = 0;
}
m2ua_lk_mon_count = 0;
for (id = 0; id < M2UA_MAX_M3MSG_NUM; id++)
x256[id] = 256 * id;
bzero(&m2ua_csta, sizeof(m2ua_csta_t));
bzero(err, 256);
m2ua_mtp3_sd_h = 0;
m2ua_mtp3_sd_t = 0;
iua_q931_sd_h = 0;
iua_q931_sd_t = 0;
m2ua_sctp_cmd_len = 0;
m2ua_sctp_dat_len = 0;
m2ua_sctp_addr.port = htons(2904);
m2ua_sctp_server_addr.port = htons(2904);
inet_aton(hostip, &m2ua_sctp_addr.addr);
strcpy(m2ua_asciin_buf, "\0");
strcpy(m2ua_asciout_buf, "\0");
moniter_fg = MONITOR_NONE;
m2ua_debug_set();
init_flag = 0;
m2ua_command = M2UA_CMD_IDLE;
//if (init_times++);
//m2ua_get_mtp3_para();
printf("M2UA Init Complete!\n");
}
void m2ua_t10ms()
{
static int cnt_10ms = 0;
static int ls_hb_flag = 0;
static int ls_hb_lk = 0;
WORD nsg;
WORD i, fd;
if (ls_hb_flag)
{
if (ls_hb_lk < M2UA_MAX_LK_NUM)
{
if (m2ua_para.lk_para[ls_hb_lk].enable == 1)
{
nsg = m2ua_para.lk_para[ls_hb_lk].lk_sg;
if ((m2ua_para.sg_para[nsg].xUA_ack>>1) == M2UA_APP)
m2ua_sd_mtp3_primi(ls_hb_lk, m2ua_lk_info[ls_hb_lk].lk_st);
else if ((m2ua_para.sg_para[nsg].xUA_ack>>1) == IUA_APP)
iua_sd_q931_primi(ls_hb_lk, m2ua_lk_info[ls_hb_lk].lk_st);
}
ls_hb_lk++;
}
else
{
ls_hb_flag = 0;
ls_hb_lk = 0;
}
}
if (!(++cnt_10ms % 10))
{ // 100 ms
m2ua_mon();
if (!(cnt_10ms % 100))
{ // 1 seconds
if (m2ua_command != M2UA_CMD_IDLE)
{
sprintf(m2ua_ascitemp_buf, "M2UA Restart! m2ua_command=%d\n\r", m2ua_command);
m2ua_asciout_proc(m2ua_ascitemp_buf);
m2ua_asciout_proc("\n\r");
m2ua_command = M2UA_CMD_IDLE;
for (i = 0; i < M2UA_MAX_SG_FSM_NUM; i++)
{
if ((fd = m2ua_sg_info[i].fd) > 0)
{
if ((m2ua_sg_info[i].sctp_state > 2) ||
((m2ua_sg_info[i].sctp_state == 2) &&
(m2ua_sg_info[i].sctp_state_1 > 0)))
{
#ifndef _LKSCTP
if (i >= M2UA_MAX_SG_NUM)
m2ua_sctp_discon_req(fd, i, m2ua_sg_info[i].seq);
else
m2ua_sctp_discon_req(fd, i, 0);
#else
m2ua_sctp_discon_req_lksctp(fd, i, 0);
#endif
}
#ifndef _LKSCTP
m2ua_sctp_close(m2ua_sg_info[i].fd, i);
#endif
}
}
m2ua_init(plat_id);
}
else if (cnt_10ms >= 1500)
{ // 15 seconds
cnt_10ms = 0;
ls_hb_flag = 1;
}
}
}
}
// Called every 10 ms
void m2ua_timer(void)
{
WORD sg, sg_dual, i;
static BYTE sg_start = 0;
static BYTE lk_scan = 0;
for (sg = sg_start; sg < sg_start + 128; sg++)
{
sg_dual = sg;
if (m2ua_sg_info[sg_dual].m2ua_state == 3)
{
for (i = 0; i < 32; i++)
{
if (m2ua_sg_fsm(sg_dual) < 0)
break;
}
}
else
m2ua_sg_fsm(sg_dual);
sg_dual = sg + M2UA_MAX_SG_NUM/2;
if (m2ua_sg_info[sg_dual].m2ua_state == 3)
{
for (i = 0; i < 32; i++)
{
if (m2ua_sg_fsm(sg_dual) < 0)
break;
}
}
else
m2ua_sg_fsm(sg_dual);
}
sg_start += 128;
if (sg_start == 0)
{
m2ua_sg_fsm(M2UA_LISTEN_SG_NUM_0);
m2ua_sg_fsm(M2UA_LISTEN_SG_NUM_1);
m2ua_sg_fsm(IUA_LISTEN_SG_NUM_0);
m2ua_sg_fsm(IUA_LISTEN_SG_NUM_1);
}
if (m2ua_lk_info[lk_scan].lk_timer > 0)
m2ua_lk_info[lk_scan].lk_timer--;
lk_scan ++;
m2ua_t10ms();
}
int m2ua_restart()
{
if (m2ua_command != M2UA_CMD_IDLE)
return 0;
else if (init_flag == 2)
{
m2ua_command = M2UA_CMD_STATUS_INIT;
return 0;
}
return 1;
}

View File

@@ -0,0 +1,510 @@
#include "./include/m2ua_pub.h"
#include "./include/m2ua.h"
#include "./include/m2ua_const.h"
#include "./include/m2ua_struct.h"
#include "./include/m2ua_ext.h"
#include "../../debug/src/include/debug.h"
#define M2UA_DEBUG_ID 16
#define M2UA_VER_DEBUG "R9V0_03b"
static char ascii[16] = {0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46};
static BYTE log_help[] = {
"M2UA Debug Monitor Help:\n\r\
\n\r\
1.[help] display help menu\n\r\
2.[log all/none] display all/none logs\n\r\
3.[log error on/off] display error logs (sg only)\n\r\
4.[log mtp3/maup on/off] display mtp3/maup logs (sg or link)\n\r\
5.[log m2ua/sctp on/off] display m2ua/sctp logs (sg only)\n\r\
6.[log sg-xxx/lk-xxx on/off] display sg/lk logs\n\r\n\r"
};
static WORD disp_page[10];
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,M2UA_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,M2UA_DEBUG_ID + 2,2
};
static DWORD debug_ascin_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,3
};
static DWORD debug_ascout_id[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,4
};
static DWORD debug_page_title[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,1,1
};
static DWORD debug_page_line[20] =
{
1,3,6,1,4,1,1373,1,1,2,3,1,2,M2UA_DEBUG_ID + 2,1,2,1
};
const static BYTE PAGE_POINT = 14;
const static BYTE LINE_POINT = 15;
const static BYTE BASE_ID_LEN = 15;
static BYTE title1_p[] =
{
" M2UA Page 01 SG Para\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_Para\n\r"
};
static BYTE title2_p[] =
{
" M2UA Page 02 Link Para\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
LK_Para\n\r"
};
static BYTE title3_p[] =
{
" M2UA Page 03 SG Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_Info\n\r"
};
static BYTE title4_p[] =
{
" M2UA Page 04 Link Info\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
LK_Info\n\r"
};
static BYTE title5_p[] =
{
" M2UA Page 05 SG CSTA\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Subpage\n\r\
SG_CSTA\n\r"
};
static BYTE title6_p[] =
{
" M2UA Page 06 Link CSTA\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
LK_CSTA\n\r"
};
static BYTE title7_p[] =
{
" M2UA Page 07 Watchdog\n\r\
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n\r\
Watchdog\n\r"
};
BYTE m2ua_disp_line(BYTE page, BYTE line)
{
BYTE disp_length;
disp_length = 16;
disp_ptr = (BYTE *) disp_page;
switch (page)
{
case 1: // Page 1: SG Para
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_para.sg_para + ((line - 1) * sizeof(sg_para_t)) + (disp_page[page] * 16 * sizeof(sg_para_t));
disp_length = sizeof(sg_para_t);
}
else
disp_length = 0;
break;
case 2: // Page 2: LK Para
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_para.lk_para + ((line - 1) * sizeof(lk_para_t)) + disp_page[page] * 16 * sizeof(lk_para_t);
disp_length = sizeof(lk_para_t);
}
else
disp_length = 0;
break;
case 3: // Page 3: SG Info
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 7)
disp_ptr = (BYTE *) &m2ua_sg_info[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 4: // Page 4: LK Info
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 17)
{
disp_ptr = (BYTE *) m2ua_lk_info + ((line - 1) * sizeof(m2ua_lk_info_t)) + disp_page[page] * 16 * sizeof(m2ua_lk_info_t);
disp_length = sizeof(m2ua_lk_info_t);
}
else
disp_length = 0;
break;
case 5: // Page 5: SG CSTA
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 3)
disp_ptr = (BYTE *) &m2ua_csta.sg_csta[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 6: // Page 6: LK CSTA
if (line == 0)
{
disp_ptr = (BYTE *) &disp_page[page];
disp_length = 2;
}
else if (line < 3)
disp_ptr = (BYTE *) &m2ua_csta.lk_csta[disp_page[page]] + ((line - 1) * 16);
else
disp_length = 0;
break;
case 7: // Page 7: Err
if (line < 16)
disp_ptr = (BYTE *)err + (line * 16);
else
disp_length = 0;
break;
default:
disp_length = 0;
break;
}
return disp_length;
}
void m2ua_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 = m2ua_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 m2ua_debug_set(void)
{
BYTE page;
BYTE data[10];
BYTE *ptr;
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, M2UA_VER_DEBUG, 10);
debug_set_response(BASE_ID_LEN, debug_ascin_id, m2ua_asciin_buf, 4096);
debug_set_response(BASE_ID_LEN, debug_ascout_id, m2ua_asciout_buf, 4096);
for (page = 1; page < 8; 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;
case 5: //page 5
ptr = title5_p;
break;
case 6: //page 6
ptr = title6_p;
break;
case 7: //page 7
ptr = title7_p;
break;
default:
break;
}
debug_page_title[PAGE_POINT] = 5 + page;
debug_set_response(BASE_ID_LEN + 1, debug_page_title, ptr, strlen(ptr));
m2ua_disp_page(page);
}
return 1;
}
int m2ua_asciout_proc(BYTE *out_str)
{
int out_len;
out_len = strlen(out_str);
if (out_len + strlen(m2ua_asciout_buf) > MAX_ASCIIOUT_LEN - 2)
{
strcpy(m2ua_asciout_buf, out_str);
}
else
strcat(m2ua_asciout_buf, out_str);
return 1;
}
void m2ua_mon(void)
{
BYTE in_page, err_fg = 0;
BYTE *ascii_in_ptr = NULL;
BYTE *str_start = NULL;
WORD str_len, num;
if ((str_len = strlen(m2ua_asciin_buf)) > 0)
{
in_page = m2ua_asciin_buf[0] - 1;
ascii_in_ptr = m2ua_asciin_buf + 1;
if (in_page > 7)
err_fg = 1;
else if (strcmp(ascii_in_ptr,"c") == 0)
{
bzero(&m2ua_csta, sizeof(m2ua_csta_t));
bzero(err, 256);
}
else if (strcmp(ascii_in_ptr,"log mtp3 on") == 0)
{
moniter_fg = moniter_fg | MONITOR_MTP3;
}
else if (strcmp(ascii_in_ptr,"log mtp3 off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_MTP3);
}
else if (strcmp(ascii_in_ptr,"log m2ua on") == 0)
{
moniter_fg = moniter_fg | MONITOR_M2UA;
}
else if (strcmp(ascii_in_ptr,"log m2ua off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_M2UA);
}
else if (strcmp(ascii_in_ptr,"log maup on") == 0)
{
moniter_fg = moniter_fg | MONITOR_MAUP;
}
else if (strcmp(ascii_in_ptr,"log maup off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_MAUP);
}
else if (strcmp(ascii_in_ptr,"log sctp on") == 0)
{
moniter_fg = moniter_fg | MONITOR_SCTP;
}
else if (strcmp(ascii_in_ptr,"log sctp off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_SCTP);
}
else if (strcmp(ascii_in_ptr,"log error on") == 0)
{
moniter_fg = moniter_fg | MONITOR_ERROR;
}
else if (strcmp(ascii_in_ptr,"log error off") == 0)
{
moniter_fg = moniter_fg & (~MONITOR_ERROR);
}
else if (strcmp(ascii_in_ptr,"log all") == 0)
{
moniter_fg = MONITOR_ALL;
if (!m2ua_sg_mon_count && !m2ua_lk_mon_count)
{
memset(m2ua_sg_mon_fg, 1, M2UA_MAX_SG_FSM_NUM);
memset(m2ua_lk_mon_fg, 1, M2UA_MAX_LK_NUM);
}
else
err_fg = 2;
}
else if (strcmp(ascii_in_ptr,"log none") == 0)
{
moniter_fg = MONITOR_NONE;
memset(m2ua_sg_mon_fg, 0, M2UA_MAX_SG_FSM_NUM);
memset(m2ua_lk_mon_fg, 0, M2UA_MAX_LK_NUM);
m2ua_sg_mon_count = 0;
m2ua_lk_mon_count = 0;
}
else if (strcmp(ascii_in_ptr,"help") == 0)
{
m2ua_asciout_proc(log_help);
}
else if (strstr(ascii_in_ptr, "log sg") != NULL)
{
if ((moniter_fg == MONITOR_ALL) &&
!m2ua_sg_mon_count &&
!m2ua_lk_mon_count)
err_fg = 3;
else if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
{
num = strtoul(str_start + 1, NULL, 10);
if (num >= M2UA_MAX_SG_FSM_NUM)
err_fg = 1;
else if (strstr(ascii_in_ptr, "on") != NULL)
{
m2ua_sg_mon_fg[num] = 1;
if (m2ua_sg_mon_count < M2UA_MAX_SG_NUM+2)
m2ua_sg_mon_count++;
}
else if (strstr(ascii_in_ptr, "off") != NULL)
{
m2ua_sg_mon_fg[num] = 0;
if (m2ua_sg_mon_count > 0)
m2ua_sg_mon_count--;
}
else
err_fg = 1;
}
else
err_fg = 1;
}
else if (strstr(ascii_in_ptr, "log lk") != NULL)
{
if ((moniter_fg == MONITOR_ALL) &&
!m2ua_sg_mon_count &&
!m2ua_lk_mon_count)
err_fg = 3;
else if ((str_start = strstr(ascii_in_ptr, "-")) != NULL)
{
num = strtoul(str_start + 1, NULL, 10);
if (num >= M2UA_MAX_LK_NUM)
err_fg = 1;
else if (strstr(ascii_in_ptr, "on") != NULL)
{
m2ua_lk_mon_fg[num] = 1;
if (m2ua_lk_mon_count < M2UA_MAX_LK_NUM)
m2ua_lk_mon_count++;
}
else if (strstr(ascii_in_ptr, "off") != NULL)
{
m2ua_lk_mon_fg[num] = 0;
if (m2ua_lk_mon_count > 0)
m2ua_lk_mon_count--;
}
else
err_fg = 1;
}
else
err_fg = 1;
}
else if (isdigit(ascii_in_ptr[0]))
{
num = strtoul(ascii_in_ptr, NULL, 10);
disp_page[in_page] = num;
m2ua_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;
m2ua_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;
m2ua_disp_page(in_page);
}
else
err_fg = 1;
if (err_fg == 0)
m2ua_asciout_proc("Command OK!\n\r");
else if (err_fg == 2)
m2ua_asciout_proc("Log all for some SGs or Links!\n\r");
else if (err_fg == 3)
m2ua_asciout_proc("Log all already done for all SGs and Links, log none to clear!\n\r");
else
m2ua_asciout_proc("Command Error!\n\r");
strcpy(m2ua_asciin_buf, "\0");
}
}
int m2ua_hex_to_ascii(BYTE *from_hex, WORD from_len, BYTE *to_asc)
{
int i, j;
j = 0;
for (i = 0; i< from_len; i++)
{
to_asc[j] = ascii[from_hex[i] >> 4];
j++;
to_asc[j] = ascii[from_hex[i] & 0x0F];
j++;
to_asc[j] = ' ';
j++;
}
to_asc[j] = '\0';
return 1;
}
int m2ua_log_err(WORD sg_id, BYTE *err_msg)
{
if ((moniter_fg & MONITOR_ERROR) == MONITOR_ERROR)
{
if ((m2ua_sg_mon_fg[sg_id] == 0))
return 0;
m2ua_asciout_proc("\33[31m");
if (strlen(err_msg) >= MAX_ASCITMP_LEN)
sprintf(m2ua_ascitemp_buf, "SG[%d] log msg is too long: %d\n\r", sg_id, strlen(err_msg));
else
sprintf(m2ua_ascitemp_buf, "SG[%d]: %s\n\r", sg_id, err_msg);
strcat(m2ua_ascitemp_buf, "\33[37m");
m2ua_asciout_proc(m2ua_ascitemp_buf);
}
return 1;
}

1505
plat/m2ua/src_old/m2ua_fsm.c Normal file

File diff suppressed because it is too large Load Diff

2749
plat/m2ua/src_old/m2ua_msg.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
//0 send <Release>
//A5 00 03 00 02 00
//
//10 send <Disable>
//A5 00 03 00 06 00
10 send <Enable>
A5 00 03 00 07 00
100 send <Establish>
A5 00 03 00 01 00
10 send <data>
05 00 03 FF 01 F0
1000 recv <data>
??
10 send <data>
05 00 03 FF 01 F1
1000 recv <data>
??
100 send <Release>
A5 00 03 00 02 00
50 send <Disable>
A5 00 03 00 06 00

View File

@@ -0,0 +1,52 @@
#include "headfile.txt"
test 1 sctp<SCTP>
SCTP.SET REMOTE_IP=MSC_IP
SCTP.SET REMOTE_PORT=IUA_CPORT
SCTP.SET LOCAL_PORT=IUA_PORT
SCTP.SET STREAM_ID=1
50 SCTP.SET server
1000 SCTP.RECV <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??
0 SCTP.send <asp up ack>
01 00 03 04 00 00 00 08
0 SCTP.send <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02
1000 SCTP.FLTR <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??
1000 SCTP.RECV <asp active>
01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00
0 SCTP.send <asp active ack>
01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01
0 SCTP.send <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03
1000 SCTP.RECV <Establish req>
01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00
0 SCTP.send <Establish cnf>
01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00
1000 SCTP.RECV <Data>
??
0 SCTP.SEND <Data Indication>
01 00 05 02 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0E 00 07 FF 01 F1 00
1000 SCTP.RECV <Data>
??
0 SCTP.SEND <Data Indication>
01 00 05 02 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0E 00 07 FF 01 F0 00
//1 SCTP.SEND <Release Indication>
//01 00 05 0A 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00
1000 SCTP.RECV <Release req>
01 00 05 08 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00

View File

@@ -0,0 +1,33 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
0 send <Release>
A6 02 03 00 02 00
10 send <Disable>
A6 02 03 00 06 00
10 send <Enable>
A6 02 03 00 07 00
100 send <Establish>
A6 02 03 00 01 00
10 send <data>
06 02 03 FF 01 F0
1000 recv <data>
??
10 send <data>
06 02 03 FF 01 F1
1000 recv <data>
??
100 send <Release>
A6 02 03 00 02 00
50 send <Disable>
A6 02 03 00 06 00

View File

@@ -0,0 +1,61 @@
#include "headfile.txt"
test 1 sctp<SCTP>
SCTP.SET REMOTE_IP=MSC_IP
SCTP.SET REMOTE_PORT=M2UA_CPORT
SCTP.SET LOCAL_PORT=M2UA_PORT
SCTP.SET STREAM_ID=1
50 SCTP.SET server
1000 SCTP.RECV <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??
//ip
0 SCTP.send <asp up ack>
01 00 03 04 00 00 00 08
0 SCTP.send <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02
1000 SCTP.FLTR <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ??
//ip 3
1000 SCTP.RECV <asp active>
01 00 04 01 00 00 00 18 00 0B 00 08 00 00 00 01 00 01 00 08 00 00 00 00
0 SCTP.send <asp active ack>
01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01
0 SCTP.send <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03
1000 SCTP.RECV <Establish req>
01 00 06 02 00 00 00 10 00 01 00 08 00 00 00 00
0 SCTP.send <Establish cnf>
01 00 06 03 00 00 00 10 00 01 00 08 00 00 00 00
1000 SCTP.RECV <Data>
??
0 SCTP.SEND <Data Indication>
01 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <Data>
??
0 SCTP.SEND <Data Indication>
01 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F1 00
// 1 SCTP.SEND <Release Indication>
// 01 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <Release req>
01 00 06 04 00 00 00 10 00 01 00 08 00 00 00 00
//stop
0 SCTP.send <Release cnf>
01 00 06 05 00 00 00 10 00 01 00 08 00 00 00 00
1000 SCTP.RECV <Release req>
?

View File

@@ -0,0 +1,80 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
0 send <IUA_QPTM_MSG Disable>
A5 01 03 00 06 00
10 send <IUA_QPTM_MSG Enable>
A5 01 03 00 07 00
test 2<sctp>
SCTP.SET REMOTE_IP=MSC_IP
SCTP.SET REMOTE_PORT=IUA_PORT
SCTP.SET LOCAL_PORT=IUA_CPORT
SCTP.SET STREAM_ID=0
5 SCTP.SET CLIENT
50 SCTP.SEND <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 AC 36 F0 A0 //ip
1000 SCTP.RECV <asp up ack>
01 00 03 04 00 00 00 08
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02
0 SCTP.SEND <asp active>
01 00 04 01 00 00 00 10 00 0B 00 08 00 00 00 01
1000 SCTP.RECV <asp active ack>
01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03
0 SCTP.SEND <Establish>
01 00 05 05 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00
1000 SCTP.RECV <Establish cnf>
01 00 05 06 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00
1 SCTP.SEND <version error>
02 00 05 08 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 01
1 SCTP.SEND <class error>
01 00 99 08 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 03
1 SCTP.SEND <type error>
01 00 05 99 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 04
0 SCTP.SEND <Data>
01 00 05 01 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0E 00 07 FF 01 F1 00
1000 SCTP.RECV <Data Indication>
??
0 SCTP.SEND <Data>
01 00 05 01 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0E 00 07 FF 01 F0 00
1000 SCTP.RECV <Data Indication>
??
1 SCTP.SEND <rel>
01 00 05 08 00 00 00 20 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00 00 0F 00 08 00 00 00 00
1000 SCTP.RECV <rel cnf>
01 00 05 09 00 00 00 18 00 01 00 08 00 00 00 00 00 05 00 08 00 00 00 00
1 SCTP.SEND <Inactive>
01 00 04 02 00 00 00 10
1000 SCTP.RECV <Inactive ack>
01 00 04 04 00 00 00 08
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 04
1 SCTP.SEND <Down>
01 00 03 02 00 00 00 10
1000 SCTP.RECV <Down ack>
01 00 03 05 00 00 00 08
test 3<sctp>
100 SCTP.SET ABORT

View File

@@ -0,0 +1,16 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
1000 recv <data>
??
10 send <data>
05 01 03 FF 01 F0
1000 recv <data>
??
10 send <data>
05 01 03 FF 01 F1

View File

@@ -0,0 +1,79 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
0 send <IUA_QPTM_MSG Disable>
A6 03 03 00 06 00
10 send <IUA_QPTM_MSG Enable>
A6 03 03 00 07 00
test 2<sctp>
SCTP.SET REMOTE_IP=MSC_IP
SCTP.SET REMOTE_PORT=M2UA_PORT
SCTP.SET LOCAL_PORT=M2UA_CPORT
SCTP.SET STREAM_ID=0
5 SCTP.SET CLIENT
100 SCTP.SEND <asp up>
01 00 03 01 00 00 00 10 00 11 00 08 ?? ?? ?? ?? //ip
1000 SCTP.RECV <asp up ack>
01 00 03 04 00 00 00 08
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 02
0 SCTP.SEND <asp active>
01 00 04 01 00 00 00 10 00 0B 00 08 00 00 00 01
1000 SCTP.RECV <asp active ack>
01 00 04 03 00 00 00 10 00 0B 00 08 00 00 00 01
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 03
0 SCTP.SEND <Establish>
01 00 06 02 00 00 00 10 00 01 00 08 00 00 00 00
1000 SCTP.RECV <Establish cnf>
01 00 06 03 00 00 00 10 00 01 00 08 00 00 00 00
1 SCTP.SEND <version error>
02 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 01
1 SCTP.SEND <class error>
01 00 99 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 03
1 SCTP.SEND <type error>
01 00 06 99 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <error cnf>
01 00 00 00 00 00 00 10 00 0C 00 08 00 00 00 04
0 SCTP.SEND <Data>
01 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F0 00
1000 SCTP.RECV <Data Indication>
??
0 SCTP.SEND <Data>
01 00 06 01 00 00 00 18 00 01 00 08 00 00 00 00 03 00 00 07 FF 01 F1 00
1000 SCTP.RECV <Data Indication>
??
1 SCTP.SEND <rel>
01 00 06 04 00 00 00 10 00 01 00 08 00 00 00 00
1000 SCTP.RECV <rel cnf>
??
1 SCTP.SEND <Inactive>
01 00 04 02 00 00 00 10
1000 SCTP.RECV <Inactive ack>
01 00 04 04 00 00 00 08
1000 SCTP.RECV <Notify>
01 00 00 01 00 00 00 10 00 0D 00 08 00 01 00 04
1 SCTP.SEND <Down>
01 00 03 02 00 00 00 10
1000 SCTP.RECV <Down ack>
01 00 03 05 00 00 00 08
test 3<sctp>
100 SCTP.SET ABORT

View File

@@ -0,0 +1,15 @@
#include "headfile.txt"
test 1 udp<UDP>
UDP.Set remote_port=MSG_PORT
UDP.Set local_port=MSG_PORT
UDP.Set remote_ip=MSC_IP
1000 recv <data>
??
10 send <data>
06 03 03 FF 01 F0
1000 recv <data>
??
10 send <data>
06 03 03 FF 01 F1

View File

@@ -0,0 +1,6 @@
#define MSC_IP 172.54.245.133
#define MSG_PORT 4955
#define IUA_PORT 9900
#define IUA_CPORT 19900
#define M2UA_PORT 2904
#define M2UA_CPORT 12904

View File

@@ -0,0 +1,21 @@
#==================================================
#Makefile for xUA Test.
#Created by YiZane in 2006/5/17
#==================================================
CC=gcc -c -Wall -g
#CC=gcc -c -Wall -g -D_testISDN
LINK=gcc -Wall -g
LINK_FLAGS=-L../../m2ua -lm2ua -L../../snmp -lsnmp -L../../debug -ldebug -L../../sccp -lsccp -L../../iptrans -liptrans -L../../public -lpublic -lLiS -lm
OBJ=xuatest.o
xuatest:xuatest.o $(OBJ)
@echo Linking $@
$(LINK) -o $@ $(OBJ) $(LINK_FLAGS)
#./xuatest
xuatest.o:xuatest.c
$(CC) xuatest.c
clean:
rm -rf *.o *.a xuatest

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
#application context name configure file for CAP
total data length=3
#application context name data
No.1:50 02 // gsmSSF to gsmSCF
No.2:51 02 // assist handoff gsmSSF to gsmSCF
No.3:52 02 // gsmSRF to gsmSCF

View File

@@ -0,0 +1,34 @@
# operation code configure file for CAP
total data length=30
#operation code
No.1:00 04 5 // initial DP
No.2:16 02 5 // assist request instructions
No.3:17 02 20 // establish temporary connection
No.4:18 04 5 // disconnect forward connection
No.5:19 04 5 // connect to resource
No.6:20 04 5 // connect
No.7:22 04 5 // release call
No.8:23 04 5 // request report BCSM event
No.9:24 04 5 // event report BCSM
No.10:31 04 5 // continue
No.11:33 04 5 // reset timer
No.12:34 04 5 // furnish charging information
No.13:35 04 5 // apply charging
No.14:36 04 5 // apply charging report
No.15:44 04 5 // call information report
No.16:45 04 5 // call information request
No.17:46 04 5 // send charging information
No.18:47 04 60 // play announcement
No.19:48 01 60 // prompt and collect user information
No.20:49 04 5 // specialized resource report
No.21:53 04 5 // cancel
No.22:55 04 5 // activity test
No.23:60 04 5 // initial DPSMS
No.24:61 04 5 // Furnishing charging info.SMS
No.25:62 04 5 // connect DPSMS
No.26:63 04 5 // request SMS event
No.27:64 04 5 // event report SMS
No.28:65 04 5 // continue SMS
No.29:66 04 5 // release DPSMS
No.30:67 04 5 // reset timer DPSMS

View File

@@ -0,0 +1,215 @@
# Country code table configure file
#List the country code
0086; // China
0001; // Canada & USA
0007; // Kazakhstan & Kirighzia & Kyrgyzstan & Russia & Sakhalin & Tajikistan & Uzbekistan
0020; // Egypt
0027; // South Africa
0030; // Greece
0031; // Netherlands
0036; // Hungary
0039; // Italy
0040; // Bomania
0041; // Switzerland
0042; // Czech Republic & Slovakia
0043; // Austria
0044; // United Kingdom
0045; // Denmark
0046; // Sweden
0047; // Norway
0048; // Poland
0049; // Germany
0051; // Peru
0052; // South Korea
0053; // Cuba
0054; // Argentina
0055; // Brazil
0056; // Chile
0057; // Colombia
0058; // Venezuela
0060; // Malaysia
0061; // Australia
0062; // Indonesia
0063; // Philippines
0064; // New Zealand
0065; // Singapore
0066; // Thailand
0081; // Japan
0084; // Vietnam
0090; // Turkey
0091; // India
0092; // Pakistan
0093; // Afghanistan
0094; // Sri Lanka
0095; // Myanmar (Burma)
0098; // Iran
0212; // Morocco
0213; // Algeria
0216; // Tunisia
0218; // Libya
0220; // Gambia
0221; // Senegal Republic
0222; // Mauritania
0223; // Mali Republic
0224; // Guinea
0225; // Ivory Coast
0226; // Burkina Faso
0227; // Niger
0228; // Togo
0229; // Benin
0230; // Mauritius
0231; // Liberia
0232; // Sierra Leone
0233; // Ghana
0234; // Nigeria
0235; // Chad Republic
0236; // Central Africa Republic
0237; // Cameroon
0239; // Sao Tome
0240; // Equatorial Guinea
0241; // Gabon
0242; // Congo
0243; // Zaire
0244; // Angola
0245; // Guinea Bissau
0246; // Diego Garcia
0247; // Ascension Islands
0248; // Seychelles
0249; // Sudan
0250; // Rwanda
0251; // Ethiopia
0252; // Somalia
0253; // Djibouti
0254; // Kenya
0255; // Tanzania
0256; // Uganda
0257; // Burundi
0258; // Mozambigue
0259; // Zanzibar
0260; // Zambia
0261; // Madagascar
0262; // Reunion Island
0263; // Zimbabwe
0264; // Namibia
0265; // Malawi
0266; // Lesotho
0267; // Botswana
0268; // Swaziland
0269; // Comoros
0290; // St.Helena
0291; // Eritrea
0297; // Aruba
0298; // Faeroe Islands
0299; // Greenland
#2696 // Mayotte Island
0321; // Belgium
0331; // France
0339; // Monaco
0349; // Spain
0350; // Gibraltar
0351; // Portugal
0352; // Luxembourg
0353; // Ireland
0354; // Iceland
0355; // Albania
0356; // Malta
0357; // Cyprus
0358; // Finland
0359; // Bulgaria
0370; // Lithuania
0371; // Latvia
0372; // Estonia
0373; // Moldova
0374; // Armenia
0375; // Belarus
0376; // Andorra
0380; // Ukraine
0381; // Yugoslavia
0385; // Croatia
0386; // Slovenia
0387; // Bosnia Herzegovina
0389; // Macedonia
0395; // San Marino
0396; // Vatican City
0417; // Liechtenstein
0500; // Falkland Islands
0501; // Belize
0502; // Guatemala
0503; // EI Salvador
0504; // Honduras
0505; // Nicaragua
0506; // Costa Rica
0507; // Panama
0508; // St.Pierre
0509; // Haiti
0521; // Mexico Band 1
0522; // Mexico Band 2
0523; // Mexico Band 3
0524; // Mexico Band 4
0525; // Mexico Band 5
0526; // Mexico Band 6
0527; // Mexico Band 7
0528; // Mexico Band 8
0590; // Guadeloupe
0591; // Bolivia
0592; // Ecuador & Guyana
0594; // French Guiana
0595; // Paraguay
0596; // French Antilles
0597; // Suriname
0598; // Uruguay
0599; // Netherlands Antilles
#5399 // Guantanamo Bay
0670; // Saipan
0671; // Guam
0672; // Antarctica(Casey) & Antarctica(Scott) & Christmas/Cocos
0673; // Brunei
0674; // Nauru
0675; // Papau New Guinea
0676; // Tonga
0677; // Solomon Islands
0678; // Vanuatu
0679; // Fiji Islands
0680; // Palau
0681; // Wallis/Futuna
0682; // Cook Island
0683; // Niue Island
0684; // American Samoa
0685; // West Samoa
0686; // Kiribati
0687; // New Caledonia
0688; // Tuvalu Islands
0689; // French Polynesia
0691; // Micronesia
0692; // Marshall Islands
#6723 // Norfolk Island
0787; // Puerto Rico
0809; // Anguilla & Antigua & Bahamas & Barbados & Bermuda......
0850; // North Korea
0852; // Hong Kong
0853; // Macao
0855; // Cambodia
0856; // Laos
0868; // Trinidad/Tobago
0880; // Bangladesh
0886; // Taiwan
0960; // Maldives
0961; // Lebanon
0962; // Jordan
0963; // Syria
0964; // Iraq
0965; // Kuwait
0966; // Saudi Arabia
0967; // Yemen Arab Rep.
0968; // Oman
0971; // United Arab Emirates
0972; // Israel
0973; // Bahrain
0974; // Qatar
0975; // Bhutan
0976; // Mongolia
0977; // Nepal
0994; // Azerbaijan
0995; // Georgia

Binary file not shown.

View File

@@ -0,0 +1,20 @@
******************
* HELP PAGE *
******************
Welcome to DEBUG MONITOR.
Press 's' or 'S' to enter "SUB MODULE SELECTION PAGE".
In "SUB MODULE SELECTION PAGE",
Press 'x' or 'X' to return "HELP PAGE",
Press 'a-p' or 'A-P' to select sub module.
In each sub module, Press '0-9' and 'a-f' to select pages.
There are two methods to use Debug,
1. Serial Port, use PC-to-PC serial line.
2. Telnet, use "telnet dst_host_ip 4965".
$

Binary file not shown.

View File

@@ -0,0 +1,16 @@
#ipconfig for pps
#port=type,num,interface
#type=UDP/TCP
#num=0-6
#interface=BUFFER/DIRECT
4950=UDP,6,DIRECT
4953=UDP,3,BUFFER
4954=UDP,3,BUFFER
4955=UDP,3,BUFFER
4957=UDP,4,BUFFER
4965=TCP,3,BUFFER
4960=UDP,2,BUFFER
4970=UDP,2,BUFFER
4971=UDP,2,BUFFER
4972=UDP,2,BUFFER
4973=UDP,2,BUFFER

View File

@@ -0,0 +1,40 @@
#application context name configure file
total data length=36
#application context name data
No.1:01 03 // network location update
No.2:02 03 // location cancel
No.3:03 03 // roaming number enquiry
No.4:05 03 // location info retrieval
No.5:10 02 // reset context
No.6:11 02 // handover control
No.7:13 02 // equipment management
No.8:14 02 // info retrieval
No.9:15 02 // inter VLR info retrieval
No.10:16 03 // subscriber data management
No.11:17 03 // tracing
No.12:18 02 // network functional SS
No.13:19 02 // network unstructured SS
No.14:20 03 // short message gateway
No.15:21 03 // short message MO relay
No.16:23 02 // short message alert
No.17:24 03 // short message waiting data management
No.18:25 03 // mobile terminating short message relay
No.19:26 02 // imsi retrieval
No.20:27 03 // MS purging
No.21:28 03 // subscriber info enquiry
No.22:29 03 // any time info enquiry
No.23:06 03 // call control transfer
No.24:36 03 // invocation notification
No.25:12 03 // sIWFS allocation
No.26:31 03 // group call control
No.27:32 03 // GPRS location update
No.28:33 03 // GPRS location info retrieval
No.29:34 03 // failure report
No.30:35 03 // GPRS notify
No.31:07 03 // reporting
No.32:08 03 // call completion
No.33:200 02 // security triplets (MAP-H defined by Meng Xiaozhen)
No.34:201 02 // subscriber interrogate (MAP-H defined by Meng Xiaozhen)
No.35:202 02 // HLR subscriber management (MAP-H defined by Meng Xiaozhen)
No.36:203 02 // HLR ping AUC (MAP-H defined by Meng Xiaozhen reserved)

View File

@@ -0,0 +1,67 @@
# operation code configure file
total data length=63
#operation code
No.1:02 01 20 // update location
No.2:03 01 10 // cancel location
No.3:67 01 20 // purge mobile station
No.4:55 01 05 // send identification
No.5:68 01 20 // prepare handover
No.6:29 03 108000 // send end signal
No.7:33 04 05 // process access signalling
No.8:34 04 05 // forward access signalling
No.9:69 01 20 // prepare subsequent handover
No.10:56 01 20 // send authentication info
No.11:43 01 20 // check IMEI
No.12:07 01 20 // insert subscriber data
No.13:08 01 20 // delete subscriber data
No.14:37 04 20 // reset
No.15:38 04 20 // forward check ss indication
No.16:57 01 20 // restore data
No.17:50 01 20 // active trace mode
No.18:51 01 20 // deactive trace mode
No.19:58 01 20 // send imsi
No.20:22 01 20 // send routing info
No.21:04 01 20 // provide roaming number
No.22:06 01 20 // resume call handling
No.23:31 01 20 // provide SIWFS number
No.24:32 01 20 // SIWFS signalling modify
No.25:73 01 20 // set report state
No.26:74 01 20 // status report
No.27:75 01 60 // remote user free
No.28:10 01 20 // register ss
No.29:11 01 20 // erase ss
No.30:12 01 20 // activate ss
No.31:13 01 20 // deactivate ss
No.32:14 01 20 // interrogate ss
No.33:59 01 600 // process unstructure ss request
No.34:60 01 60 // unstructure ss request
No.35:61 01 60 // unstructure ss notify
No.36:17 01 60 // register password
No.37:18 03 20 // get password
No.38:76 01 20 // register cc entry
No.39:77 01 20 // erase cc entry
No.40:45 01 20 // send routing info for sm
No.41:46 01 60 // mo forward sm
No.42:44 01 60 // mt forward sm
No.43:47 01 05 // report sm delivery status
No.44:63 04 05 // inform service centre
No.45:64 01 05 // alert service center
No.46:66 01 05 // ready for sm
No.47:70 01 20 // provider subscriber info
No.48:71 01 20 // any time interrogation
No.49:72 01 20 // ss invocatin notification
No.50:39 01 20 // prepare group call
No.51:40 03 108000 // send group call end signal
No.52:41 04 05 // process group call signalling
No.53:42 04 05 // forward group call signalling
No.54:23 01 20 // update GPRS location
No.55:24 01 20 // send routing info for GPRS
No.56:25 01 20 // failure report
No.57:26 01 20 // note ms present for GPRS
No.58:200 01 05 // security triplets (MAP-H defined by Meng Xiaozhen)
No.59:201 01 05 // interrogate subscriber (MAP-H defined by Meng Xiaozhen)
No.60:202 01 05 // hlr create subscriber (MAP-H defined by Meng Xiaozhen)
No.61:203 01 05 // hlr delete subscriber (MAP-H defined by Meng Xiaozhen)
No.62:204 01 05 // hlr ping auc (MAP-H defined by Meng Xiaozhen reserved)
No.63:09 01 20 // send parameter

View File

@@ -0,0 +1,13 @@
*******************
* MENU PAGE *
*******************
a -- IPTR i -- HLR
b -- MTP3 j -- SMSC
c -- SCCP k -- PPS
d -- TCAP l -- SNMP
e -- XAPP m --
f -- MSC n -- DEBUG
g -- VLR o -- AUC
h -- p -- EIR

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,37 @@
# /etc/profile
# System wide environment and startup programs
# Functions and aliases go in /etc/bashrc
PATH=".:$PATH:/sbin:/usr/sbin:/usr/X11R6/bin:/etc/rc.d/init.d:/usr/local/wxc2/bin"
PATH=/usr/java/jdk1.3/bin:$PATH
ulimit -c 80000
if [ `id -gn` = `id -un` -a `id -u` -gt 14 ]; then
umask 002
else
umask 022
fi
USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi
JAVA_COMPILER=javacomp ; export JAVA_COMPILER
LD_LIBRARY_PATH=/usr/local/mysql/lib ; export LD_LIBRARY_PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
for i in /etc/profile.d/*.sh ; do
if [ -x $i ]; then
. $i
fi
done
unset i
PATH=/usr/local/wxc2/bin:$PATH

View File

@@ -0,0 +1,85 @@
#SCCP Config file (R8V2_02)
[Local Node]
#ssn NetID msisdn ip0 ip1
4 0 - 172.18.128.136 -
6 0 8675557122002 172.18.133.1 172.18.99.1
7 0 8675557123005 172.18.133.133 172.18.99.1
8 2 594694000001 172.18.98.1 172.18.99.1
9 2 594694000007 172.18.98.1 172.18.99.1
11 2 594694000000 172.18.98.1 172.18.99.1
19 2 594694000009 172.18.98.1 172.18.99.1
20 2 594694000010 172.18.98.1 172.18.99.1
21 2 594694000011 172.18.128.1 172.18.129.1
22 2 594694980012 172.18.100.1 172.18.101.1
146 2 594694000004 172.18.98.1 172.18.99.1
147 2 594694000003 172.18.98.1 172.18.99.1
254 2 - 172.18.98.1 172.18.99.1
[GTT_Table]
#No NP StartDigits EndDigits NI SPC SSN RI AI S E N Rep
0 6 460020000000000 460029999999999 0 000001 6 1 7
2 1 594694001000 594694009998 2 001FD3 6 1 7
3 1 594694460000 594694469998 2 001FD3 6 1 7
4 1 594694471000 594694479998 2 001FD3 6 1 7
5 1 594694980012 594694980012 2 000003 8 0 7
6 1 594694980013 594694980013 2 000004 8 0 7
7 1 338 338 2 000B03 0 0 6
8 1 33609 33609 2 000B03 0 0 6
9 1 33603 33608 2 000B03 0 0 6 1 1 1 3383
10 1 33610 33629 2 000B03 0 0 6 1 1 1 3383
11 1 5906900 5906902 2 000B03 0 0 6 1 1 1 3385
12 1 262692 262692 2 000B03 0 0 6 1 1 1 3382
13 1 352 352 2 000B03 0 0 6 1 1 1 3383
14 1 33660 33660 2 000B03 0 0 6
15 1 33662 33662 2 000B03 0 0 6
16 6 208100000000000 208109999999999 2 000B03 6 0 6 1 5 7 33609
26 1 594694000002 594694000002 2 001FD3 6 1 7
28 1 5946941 5946941 2 000B03 0 0 6 1 1 1 3385
29 1 594694480000 594694979999 2 000B03 0 0 6 1 1 1 3385
31 7 594694000100000 594694000199999 2 001FD3 6 1 7 1 15 1 594694000002
34 1 5966960 5966961 2 000B03 0 0 6 1 1 1 3385
37 1 59035 59035 2 000B03 0 0 6
38 1 59669690 59669690 2 000B03 0 0 6
41 1 59669620 59669649 2 000B03 0 0 6
42 1 59069037 59069041 2 000B03 0 0 6
43 1 59069030 59069035 2 000B03 0 0 6
44 1 59069036 59069036 2 000B03 0 0 6 1 1 1 3385
45 1 59069047 59069065 2 000B03 0 0 6
46 1 59069067 59069068 2 000B03 0 0 6
47 1 59069071 59069076 2 000B03 0 0 6
48 1 59469420 59469426 2 000B03 0 0 6
49 1 59469438 59469438 2 000B03 0 0 6
50 1 59469440 59469445 2 000B03 0 0 6
51 1 59669680 59669686 2 000B03 0 0 6
52 1 59069066 59069066 2 000B03 0 0 6 1 1 1 3385
54 1 59669699 59669699 2 000B03 0 0 6
56 1 59069042 59069046 2 000B03 0 0 6 1 1 1 3385
57 1 59069069 59069070 2 000B03 0 0 6 1 1 1 3385
58 1 59069077 59069099 2 000B03 0 0 6 1 1 1 3385
60 1 59669650 59669679 2 000B03 0 0 6
61 1 59669691 59669698 2 000B03 0 0 6
62 1 59469427 59469437 2 000B03 0 0 6 1 1 1 3385
63 1 59469439 59469439 2 000B03 0 0 6 1 1 1 3385
65 1 594694401000 594694409999 2 0000B3 0 0 6 1 1 1 3385
70 6 746020000000000 746029999999999 2 000B03 0 0 6 1 5 7 59785
71 1 597 597 2 000B03 0 0 6
75 6 250020000000000 250029999999999 2 000B03 0 0 6 1 5 7 781296
76 1 78 79 2 000B03 0 0 6
78 6 2509900000000000 250999999999999 2 000B03 0 0 6 1 5 7 79037
80 6 222100000000000 222109999999999 2 000B03 0 0 6 1 5 7 39349
81 1 39 39 2 000B03 0 0 6
85 6 738002000000000 738002999999999 2 000B03 0 0 6 1 6 7 592640
86 1 592 592 2 000B03 0 0 6
87 1 5926400001 5926400001 2 000B03 7 0 6
90 6 338050000000000 338050999999999 2 000B03 0 0 6 1 6 7 187638
91 1 18 18 2 000B03 0 0 6
95 6 362510000000000 362519999999999 2 000B03 0 0 6 1 5 7 59952
96 1 599 599 2 000B03 0 0 6
98 6 4600000000000000 460009999999999 2 000B03 0 0 6 1 5 7 86139
100 1 86 86 2 000B03 0 0 6
102 6 724160000000000 7241699999999990 2 000B03 0 0 6 1 5 7 55016
104 1 55 55 2 000B03 0 0 6
[RL_SSN]
#NetID DPC SSN

View File

@@ -0,0 +1,87 @@
#SCCP Config file (R8V0_04)
[Local Node]
#ssn NetID msisdn ip0 ip1
4 2 594694000006 172.18.128.1 172.18.129.1
6 2 594694000002 172.18.98.1 172.18.99.1
7 2 594694000005 172.18.98.1 172.18.99.1
8 2 594694000001 172.18.98.1 172.18.99.1
9 2 594694000007 172.18.98.1 172.18.99.1
10 2 594694000008 172.18.98.1 172.18.99.1
11 2 594694000000 172.18.98.1 172.18.99.1
19 2 594694000009 172.18.98.1 172.18.99.1
20 2 594694000010 172.18.98.1 172.18.99.1
21 2 594694000011 172.18.128.1 172.18.129.1
22 2 594694980012 172.18.100.1 172.18.101.1
146 2 594694000004 172.18.98.1 172.18.99.1
147 2 594694000003 172.18.98.1 172.18.99.1
254 2 - 172.18.98.1 172.18.99.1
[GTT_Table]
#No NP StartDigits EndDigits NI SPC SSN RI AI S E N Rep
0 6 340020000000000 340029999999999 2 001FD3 6 1 7
2 1 594694001000 594694009998 2 001FD3 6 1 7
3 1 594694460000 594694469998 2 001FD3 6 1 7
4 1 594694471000 594694479998 2 001FD3 6 1 7
5 1 594694980012 594694980012 2 000003 8 0 7
6 1 594694980013 594694980013 2 000004 8 0 7
7 1 338 338 2 000B03 0 0 6
8 1 33609 33609 2 000B03 0 0 6
9 1 33603 33608 2 000B03 0 0 6 1 1 1 3383
10 1 33610 33629 2 000B03 0 0 6 1 1 1 3383
11 1 5906900 5906902 2 000B03 0 0 6 1 1 1 3385
12 1 262692 262692 2 000B03 0 0 6 1 1 1 3382
13 1 352 352 2 000B03 0 0 6 1 1 1 3383
14 1 33660 33660 2 000B03 0 0 6
15 1 33662 33662 2 000B03 0 0 6
16 6 208100000000000 208109999999999 2 000B03 6 0 6 1 5 7 33609
26 1 594694000002 594694000002 2 001FD3 6 1 7
28 1 5946941 5946941 2 000B03 0 0 6 1 1 1 3385
29 1 594694480000 594694979999 2 000B03 0 0 6 1 1 1 3385
#30 7 5946940001000000 5946940001099999 2 001FD3 6 1 7 1 16 1 594694000002
31 7 594694000100000 594694000199999 2 001FD3 6 1 7 1 15 1 594694000002
34 1 5966960 5966961 2 000B03 0 0 6 1 1 1 3385
37 1 59035 59035 2 000B03 0 0 6
38 1 59669690 59669690 2 000B03 0 0 6
41 1 59669620 59669649 2 000B03 0 0 6
42 1 59069037 59069041 2 000B03 0 0 6
43 1 59069030 59069035 2 000B03 0 0 6
44 1 59069036 59069036 2 000B03 0 0 6 1 1 1 3385
45 1 59069047 59069065 2 000B03 0 0 6
46 1 59069067 59069068 2 000B03 0 0 6
47 1 59069071 59069076 2 000B03 0 0 6
48 1 59469420 59469426 2 000B03 0 0 6
49 1 59469438 59469438 2 000B03 0 0 6
50 1 59469440 59469445 2 000B03 0 0 6
51 1 59669680 59669686 2 000B03 0 0 6
52 1 59069066 59069066 2 000B03 0 0 6 1 1 1 3385
54 1 59669699 59669699 2 000B03 0 0 6
56 1 59069042 59069046 2 000B03 0 0 6 1 1 1 3385
57 1 59069069 59069070 2 000B03 0 0 6 1 1 1 3385
58 1 59069077 59069099 2 000B03 0 0 6 1 1 1 3385
60 1 59669650 59669679 2 000B03 0 0 6
61 1 59669691 59669698 2 000B03 0 0 6
62 1 59469427 59469437 2 000B03 0 0 6 1 1 1 3385
63 1 59469439 59469439 2 000B03 0 0 6 1 1 1 3385
65 1 594694401000 594694409999 2 0000B3 0 0 6 1 1 1 3385
70 6 746020000000000 746029999999999 2 000B03 0 0 6 1 5 7 59785
71 1 597 597 2 000B03 0 0 6
75 6 250020000000000 250029999999999 2 000B03 0 0 6 1 5 7 781296
76 1 78 79 2 000B03 0 0 6
78 6 2509900000000000 250999999999999 2 000B03 0 0 6 1 5 7 79037
80 6 222100000000000 222109999999999 2 000B03 0 0 6 1 5 7 39349
81 1 39 39 2 000B03 0 0 6
85 6 738002000000000 738002999999999 2 000B03 0 0 6 1 6 7 592640
86 1 592 592 2 000B03 0 0 6
87 1 5926400001 5926400001 2 000B03 7 0 6
90 6 338050000000000 338050999999999 2 000B03 0 0 6 1 6 7 187638
91 1 18 18 2 000B03 0 0 6
95 6 362510000000000 362519999999999 2 000B03 0 0 6 1 5 7 59952
96 1 599 599 2 000B03 0 0 6
98 6 4600000000000000 460009999999999 2 000B03 0 0 6 1 5 7 86139
100 1 86 86 2 000B03 0 0 6
102 6 724160000000000 7241699999999990 2 000B03 0 0 6 1 5 7 55016
104 1 55 55 2 000B03 0 0 6
[RL_SSN]
#NetID DPC SSN

View File

@@ -0,0 +1,74 @@
#SCCP Config file (R8V0_04)
[Local Node]
#ssn NetID msisdn ip0 ip1
4 3 - 172.18.128.1 172.18.129.1
6 3 74113779892 172.18.98.1 172.18.99.1
7 3 74113779891 172.18.98.1 172.18.99.1
8 3 74113779890 172.18.98.1 172.18.99.1
9 3 74113779895 172.18.98.1 172.18.99.1
10 3 74113779894 172.18.98.1 172.18.99.1
11 3 74113779896 172.18.98.1 172.18.99.1
19 3 - 172.18.98.1 172.18.99.1
20 3 - 172.18.98.1 172.18.99.1
21 3 - 172.18.98.1 172.18.99.1
22 0 - 172.18.98.1 172.18.99.1
146 3 - 172.18.98.1 172.18.99.1
147 3 74113779899 172.18.98.1 172.18.99.1
254 3 - 172.18.98.1 172.18.99.1
[GTT_Table]
#No NP StartDigits EndDigits NI SPC SSN RI AI S E N Rep
0 6 250121300000000 250121300004999 2 000001 6 1 7
1 1 74113770000 74113779899 2 000001 6 1 7
3 1 74113779897 74113779897 3 000101 22 0 7
4 1 74113779898 74113779898 3 000202 22 0 7
5 1 74113779890 74113779890 3 003707 8 0 7
6 1 74113779891 74113779891 3 003707 7 0 7
7 1 74113779892 74113779892 3 003707 6 0 7
8 1 74113779894 74113779894 3 003707 10 0 7
11 7 7902541300000000 7902541300004999 3 003707 6 1 7 1 16 1 74113779892
13 1 74113621997 74113621997 3 003708 8 0 7
14 1 79025719995 79025719995 3 003708 11 0 7
15 1 74113621998 74113621998 3 003708 7 0 7
16 1 74113621999 74113621999 3 003708 6 0 7
20 1 79025700999 79025700999 3 003708 6 0 7
21 1 79025719000 79025719000 3 003708 7 0 7
22 6 250123000049173 250123000049173 2 000001 6 0 7
23 6 250123000548881 250123000548881 2 000001 6 1 7
24 6 250123000548882 250123000548882 2 000001 6 1 7
25 6 250121000109094 250121000109095 3 003708 6 0 6 1 5 7 790254
26 6 250123000367371 250123000367371 2 000001 6 1 7
27 6 250026510040021 250026510040021 3 003708 6 0 6 1 5 7 781296
28 6 250121100011572 250121100011572 3 003708 6 0 6 1 5 7 790254
30 6 250058899904676 250058899904676 3 003708 6 0 6 1 5 7 790298
31 1 79139889999 79139889999 3 003708 7 0 7
32 1 79029889998 79029889998 3 003708 6 0 7
33 1 74113779896 74113779896 3 003707 11 0 7
34 1 79025110001 79025110001 3 003708 6 0 7
35 1 79025110002 79025110002 3 003708 7 0 7
36 6 250121100008643 250121100008643 2 000001 6 1 7
37 6 250123000016797 250123000016797 2 000001 6 1 7
38 6 250123000003240 250123000003240 3 003708 6 0 6 1 5 7 790254
39 6 250121000118255 250121000118255 2 000001 6 1 7
41 6 250021020465012 250021020465012 3 003708 6 0 6 1 5 7 781296
49 6 250018580019726 250018580019726 3 003708 6 0 6 1 5 7 7095
50 6 250125067201454 250125067201454 3 003708 6 0 6 1 5 7 790254
51 6 250121000118256 250121000118256 2 000001 6 1 7
52 6 250121000118601 250121000118601 2 000001 6 1 7
53 6 250121000070390 250121000070390 2 000001 6 1 7
54 6 250121100006360 250121100006360 2 000001 6 1 7
57 6 250010000000000 250019999999999 3 003708 6 0 6 1 5 7 7095
58 6 250020000000000 250029999999999 3 003708 6 0 6 1 5 7 781296
59 6 250030000000000 250039999999999 3 003708 6 0 6 1 5 7 7831
60 6 250040000000000 250049999999999 3 003708 6 0 6 1 5 7 7902933
62 6 250070000000000 250079999999999 3 003708 6 0 6 1 6 7 7902370
63 6 250100000000000 250109999999999 3 003708 6 0 6 1 6 7 790245
64 6 250130000000000 250139999999999 3 003708 6 0 6 1 5 7 79160
65 6 250150000000000 250159999999999 3 003708 6 0 6 1 5 7 790237081
66 6 250160000000000 250169999999999 3 003708 6 0 6 1 5 7 7902557
67 6 250170000000000 250179999999999 3 003708 6 0 6 1 6 7 7346
200 6 2500500000000000 250059999999999 3 003708 6 0 6 1 5 7 790298
[RL_SSN]
#NetID DPC SSN

View File

@@ -0,0 +1,21 @@
# This file defines the SMSC CSTA row
# The max number of row is 20
# Attention: When you want to define the Entity name, the name of "MS" "All" and "Other" is reserved
# define the entity who send short message to SMSC
Receive from:
MS
PPS
VMS
#VMS+PPS
Other
#All
# define the entity who receive short message from SMSC
Send to:
MS
PPS
VMS
#VMS+PPS
Other
#All

Binary file not shown.

View File

@@ -0,0 +1,5 @@
#SMSC system configure file
#IP info of SMSC
wxc2-0=172.18.98.1;
wxc2-1=172.18.99.1;

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,3 @@
yizane=172.48.234.133;
pps-1=172.18.128.137;
heartbeat no=9

View File

@@ -0,0 +1,4 @@
WXC2 procedure exit log
Time: Tue Jan 18 10:22:59 2005
Now module: MSC

Binary file not shown.

View File

@@ -0,0 +1,293 @@
/************************************************/
/*Title: xuatest.c */
/*Descr: Processor for xUA Unitest */
/*Author: Yi Zane */
/*Create: 2006-05-17 */
/************************************************/
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <termio.h>
#include <sys/stat.h>
#include <sys/io.h>
#include "../../public/includes.h"
#include "../../public/asn1.h"
#include "../../public/function.h"
#include "../../debug/debug.h"
#include "../../snmp/snmp.h"
#include "../../iptrans/iptrans.h"
#include "../m2ua.h"
#define TEST_PORT 4955
#define xUA_HOST_IP pBYTE[0],pBYTE[1],pBYTE[2],pBYTE[3]
#define xUA_CLIENT_IP pBYTE[0],pBYTE[1],pBYTE[2],pBYTE[3]
static char clientip[20];
static in_buffer *inbuf;
static out_buffer *outbuf;
struct itimerval itimer,old_itimer;
void QueryUP();
void QueryIUA();
void QueryM2UA();
void On_Timer();
void SetTimer();
void init_shmPort_iptrans(WORD port,in_buffer ** inbuf,out_buffer **outbuf);
int recv_message(in_buffer *pbuf, message_list *pmsg);
int send_message(out_buffer *pbuf, message_list *pmsg);
//--------------------------------------------------
extern char hostip[20];
extern char hostname[50];
extern DWORD host_ip;
extern int iptrMainInit();
extern int m2ua_hex_to_ascii(BYTE *from_hex, BYTE from_len, BYTE *to_asc);
int main(int argc, char *argv[])
{
pid_t pid;
BYTE* pBYTE;
if(argc==2 && strstr(argv[1],"-d"))
{
if((pid=fork())!=0)
exit(0);
setsid();
}
init_shmPort_iptrans(TEST_PORT,&inbuf,&outbuf);
debug_init();
heartbeat_init(0x0400);
iptrMainInit();
snmp_init(4957);
m2ua_init();
pBYTE = (BYTE*)&host_ip;
{
//link param
//e1_to_linkset,e1_to_slc,e1_to_mtp3,e1_lk_type,e1_to_sg,e1_to_iid,remote_ip,inactive,inactive_tm,e1_to_alterMTP3
BYTE linkparam0[]={0x00,0x00,xUA_HOST_IP,0x07,0x00,0x00,xUA_HOST_IP,0x01,0x01,xUA_HOST_IP};
BYTE linkparam1[]={0x01,0x01,xUA_HOST_IP,0x07,0x01,0x00,xUA_HOST_IP,0x01,0x01,xUA_HOST_IP};
BYTE linkparam2[]={0x02,0x02,xUA_HOST_IP,0x03,0x02,0x00,xUA_HOST_IP,0x01,0x01,xUA_HOST_IP};
BYTE linkparam3[]={0x03,0x03,xUA_HOST_IP,0x03,0x03,0x00,xUA_HOST_IP,0x01,0x01,xUA_HOST_IP};
set_m2ua_link(0,linkparam0);
set_m2ua_link(1,linkparam1);
set_m2ua_link(2,linkparam2);
set_m2ua_link(3,linkparam3);
}
#ifdef _testISDN
{
BYTE sgparam1[]={0x01,0x01,0x02,0xAC,0x36,0xF2,0x70}; //iua -server 172.54.242.112
BYTE enable_lk[]={0xA5,0x01,0x03,0x00,0x07,0x00}; //iua A5 01 03 00 07 00
set_m2ua_sg(1,sgparam1); //sg=1 iua -server
if(!put_xua_msg((xua_up_msg_t*)enable_lk))
{
printf("Put message to xUA. Msg_Class = 0x%x\n", *enable_lk);
}
else
printf("Put message error\n");
}
#endif
SetTimer();
while(1)
{
usleep(50);
}
return 1;
}
void QueryUP()
{
message_list msgbuf;
BYTE buf[256];
BYTE *iua_msg;
BYTE *pBYTE;
static BYTE set_sgflag=1;
if(recv_message(inbuf, &msgbuf)==0)
return;
printf("Receive Message From User:%ld\n",msgbuf.msgSrcIP);
if(set_sgflag)
{
pBYTE = (BYTE*)&msgbuf.msgSrcIP;
sprintf(clientip,"%d.%d.%d.%d", xUA_CLIENT_IP);
#ifndef _testISDN
{
//enable,server,xUA_ack,ip
BYTE sgparam0[]={0x01,0x00,0x02,xUA_CLIENT_IP}; //iua -client
BYTE sgparam1[]={0x01,0x01,0x02,xUA_CLIENT_IP}; //iua -server
BYTE sgparam2[]={0x01,0x00,0x00,xUA_CLIENT_IP}; //m2ua -client
BYTE sgparam3[]={0x01,0x01,0x00,xUA_CLIENT_IP}; //m2ua -server
set_m2ua_sg(0,sgparam0); //sg=0 iua -client
set_m2ua_sg(1,sgparam1); //sg=1 iua -server
set_m2ua_sg(2,sgparam2); //sg=2 m2ua -client
set_m2ua_sg(3,sgparam3); //sg=3 m2ua -server
}
#endif
set_sgflag = 0;
}
memset(buf,0,sizeof(buf));
iua_msg = buf+RESERVE_FOR_IUAHEAD;
#ifndef _testISDN
memcpy(iua_msg, msgbuf.msgContent, msgbuf.msgLength);
#else
memcpy(iua_msg+3, msgbuf.msgContent, msgbuf.msgLength);
iua_msg[0]=IUA_QPTM_MSG;//msg_class
iua_msg[1]=1;//LINK
iua_msg[2]=msgbuf.msgLength+3;//len
#endif
if(!put_xua_msg((xua_up_msg_t*)iua_msg))
{
printf("Put message to xUA. Msg_Class = 0x%x\n", *iua_msg);
}
else
printf("Put message error\n");
}
void QueryIUA()
{
message_list msgbuf;
xua_up_msg_t *msgToIUAup;
int msglen;
BYTE buf[256];
if((msglen=get_xua_msg(IUA_APP,&msgToIUAup)) < 0)
return;
if(msgToIUAup->msg_class==IUA_MGMT_CMD)//hreatbeat
return;
#ifndef _testISDN
memcpy(msgbuf.msgContent, msgToIUAup, msglen);
#else
memcpy(msgbuf.msgContent, msgToIUAup->msg.iua.content,msgToIUAup->msg.iua.len);
#endif
msgbuf.msgLength = msglen;
msgbuf.msgDstIP = inet_addr(clientip);
msgbuf.msgDstPort = TEST_PORT;
msgbuf.msgSrcPort = TEST_PORT;
m2ua_hex_to_ascii((BYTE *)msgToIUAup,msglen,buf);
printf("\33[31mQueryIUA:%s\33[37m\n",buf);
send_message(outbuf, &msgbuf);
}
void QueryM2UA()
{
message_list msgbuf;
m2ua_up_msg_t *msgToM2UAup;
int msglen;
BYTE buf[256];
if((msglen=get_m2ua_msg(&msgToM2UAup)) < 0)
return;
if(msgToM2UAup->sio==0xEF)//hreatbeat
return;
memcpy(msgbuf.msgContent, msgToM2UAup,msgToM2UAup->len+2);
msgbuf.msgLength = msgToM2UAup->len+2;
msgbuf.msgDstIP = inet_addr(clientip);
msgbuf.msgDstPort = TEST_PORT;
msgbuf.msgSrcPort = TEST_PORT;
m2ua_hex_to_ascii((BYTE *)msgToM2UAup,msgbuf.msgLength,buf);
printf("\33[31mQueryIUA:%s\33[37m\n",buf);
send_message(outbuf, &msgbuf);
}
void On_Timer()
{
iptrans_timer();
snmp_timer();
debug_rt();
m2ua_timer();
QueryUP();
QueryIUA();
QueryM2UA();
}
void SetTimer()
{
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=10*1000;
itimer.it_value.tv_sec=0;
itimer.it_value.tv_usec=10*1000;
if (setitimer(ITIMER_REAL,&itimer,&old_itimer) !=0 )
{
printf("Setting Timer error! \n");
exit(1);
}
}
void init_shmPort_iptrans(WORD port,in_buffer ** inbuf,out_buffer **outbuf)
{
int shmid;
static iptrans_shm *pshm;
if((shmid=shmget(IPTRANS_SHM_KEY,sizeof(iptrans_shm),IPTRANS_SHM_PERM))==-1)
{
if((shmid=shmget(IPTRANS_SHM_KEY,sizeof(iptrans_shm),IPTRANS_SHM_PERM|IPC_CREAT))==-1)
{
printf("fail to open share memory");
exit(1);
}
}
if((pshm=(iptrans_shm *)shmat(shmid,0,0))==(iptrans_shm *)-1)
{
printf("fail to attach share memory");
exit(1);
}
*inbuf=&pshm->msgPortIn[port-PORT_BASE_NUM];
(*inbuf)->msgReadSub = (*inbuf)->msgWriteSub=0;
*outbuf=&pshm->msgPortOut;
printf("init_shmPort_iptrans() complete...Port=%d\n",port);
}
int recv_message(in_buffer *pbuf, message_list *pmsg)
{
if (pbuf->msgReadSub == pbuf->msgWriteSub)
return 0;
memcpy(pmsg, &pbuf->msgList[pbuf->msgReadSub], sizeof(message_list));
pbuf->msgReadSub=(pbuf->msgReadSub+1)%IN_LIST_NUM;
return 1;
}
int send_message(out_buffer *pbuf, message_list *pmsg)
{
memcpy(&pbuf->msgList[pbuf->msgWriteSub], pmsg, sizeof(message_list));
pbuf->msgWriteSub=(pbuf->msgWriteSub+1)%OUT_LIST_NUM;
if (pbuf->msgReadSub == pbuf->msgWriteSub)
pbuf->msgReadSub=(pbuf->msgReadSub+1)%OUT_LIST_NUM;
return 1;
}