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

View File

@@ -0,0 +1,98 @@
##----------------------------------------------------------##
## ##
## Universal Makefile for module Version : V1.4 ##
## ##
## Created : Wei Liu 07/04/11 ##
## Revision: [Last]Wei Liu 07/06/18 ##
## ##
##----------------------------------------------------------##
##---------------------------------------------------------------------##
##--------------------------------------
##
## Project correlation(Customer define)
##
##--------------------------------------
## MODULE= [Module Name]
## TYPE = app/plat => Module Type
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Debug ]
## DBUG_FLAGS_ADD = [Module Define Gcc Flags for Release]
## BUILD = lib/exef => Output file format
## CFG = debug/release => Build Configuration
## SRC_PATH = [Source file path]
## INC_PATH = [Include file path]
## APP_PATH = [App Module path]
## PLT_PATH = [Plat Module path]
## PLT_LIB = [Needed plat lib for Link] => just for test or wxc2main
## APP_LIB = [Needed app lib for Link] => just for test or wxc2main
## LIB_ADD = [Needed Extend lib for Link] => just for test or wxc2main
## PLT_LIB e.g. = haepub fsm mng proto kernel aif mgc mgcp sip rtp \
## 8ecp bicc smpp xapp tcap mtp3 m2ua \
## snmp iptrans debug sccp public
##
## APP_LIB e.g. = msc vlr ssf hlr ae pps mnp smsc vms aas
## LIB_ADD e.g. = -liba3a8 -lm
## OBJ_ADD = [Extend third party object files needed]
## TEST_OBJ_PATH = [module object files Path for test ] => just for test
##---------------------------------------------------------------------##
MODULE = sccptest
TYPE = app
DBUG_FLAGS_ADD =
RELS_FLAGS_ADD =
##Default commonly as below
BUILD = exef
CFG = debug
PLT_LIB = sccp mtp3 m2ua \
snmp iptrans debug sccp public
APP_LIB =
LIB_ADD =
SRC_PATH = .
INC_PATH = .
PLT_PATH = ../../../../plat
APP_PATH = ../../../../app
OBJ_ADD =
TEST_OBJ_PATH =
##---------------------------------------------------------------------##
##--------------------------------------
##
## 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 = on
COVER_NEED =
COVER_REPORT_PATH = ./ut/ut_doc/output
##---------------------------------------------------------------------##
##--------------------------------------
##
## include makefile.rules (Do not change)
##
##--------------------------------------
include $(MAKE_INCLUDE)/Makefile.rules

Binary file not shown.

View File

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

View File

@@ -0,0 +1,36 @@
# operation code configure file for CAP
total data length=32
#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
No.31:176 04 5 // VPS to PPS
No.32:177 04 5 // PPS to VPS

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,6 @@
#HLR/AUC/EIR system configure file
#IP info of SMSC
hlr-0=172.18.234.1;
#hlr-1=172.18.133.1;
hlr-1=172.54.240.147;

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,25 @@
#ipconfig for pps
4950=UDP,6,DIRECT
4951=UDP,0,BUFFER
4952=UDP,0,BUFFER
4953=UDP,0,BUFFER
4954=UDP,0,BUFFER
4955=UDP,3,BUFFER
4956=UDP,3,BUFFER
4957=UDP,4,BUFFER
4958=UDP,0,BUFFER
4959=UDP,0,BUFFER
4960=UDP,4,BUFFER
4961=UDP,0,BUFFER
4962=UDP,0,BUFFER
4963=UDP,0,BUFFER
4964=UDP,0,BUFFER
4965=TCP,6,BUFFER
4966=UDP,2,DIRECT
4967=UDP,4,DIRECT
4968=UDP,0,BUFFER
4969=UDP,0,BUFFER
4970=UDP,0,BUFFER
4971=UDP,0,BUFFER
4972=UDP,0,BUFFER
4973=UDP,0,BUFFER

View File

@@ -0,0 +1,42 @@
#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)
NO.37:09 01 // Send parameter

View File

@@ -0,0 +1,76 @@
# operation code configure file
total data length=72
#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 parameters
No.64:48 01 20 // not subscriber present
No.65:19 01 20 // process unstructure SS data
No.66:54 01 20 // beging subscriber activity
No.67:28 01 20 // perform handover
No.68:30 01 20 // perform subsequence handvoer
No.69:35 01 20 // note internal handover
No.70:54 01 20 // beging subscriber activity
No.71:49 01 20 // alert service center without result
No.72:52 01 20 // trace subscriber activity

View File

@@ -0,0 +1,17 @@
*******************
* MENU PAGE *
*******************
a -- IPTR m -- MNP
b -- MTP3 n -- DEBUG
c -- SCCP o -- AUC
d -- TCAP p -- SMPP
e -- XAPP r -- M2UA
f -- MSC s -- BICC
g -- VLR t -- SIP
h -- EIR u -- ISUP
i -- HLR v -- Reserved
j -- SMSC w -- SCTP
k -- PPS y -- ISDN
l -- SNMP z -- Reserved

File diff suppressed because it is too large Load Diff

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,26 @@
#SCCP Config file (R8V0_03)
[Local Node]
#ssn NetID msisdn ip0 ip1
4 2 - 172.18.128.1 172.18.129.1
6 2 8675557122002 172.18.199.1 -
7 2 8675557122001 172.18.198.1 -
8 2 8675599999999 172.18.234.3 172.18.99.1
9 2 86755920005 172.18.132.1 172.18.99.1
10 2 86755920004 172.18.132.1 172.18.99.1
11 2 86755920006 172.18.132.1 172.18.99.1
19 2 86755920007 172.18.132.1 172.18.99.1
20 2 86755920008 172.18.132.1 172.18.99.1
21 2 86755920009 172.18.132.1 172.18.99.1
22 2 867559000213 172.18.132.1 -
146 2 86755920011 172.18.132.1 172.18.99.1
147 2 86755920010 172.18.132.1 172.18.99.1
254 2 - 172.18.132.1 172.18.99.1
[GTT_Table]
#No NP StartDigits EndDigits NI SPC SSN RI AI S E N Rep
0 6 460020000000000 460029999999999 2 000028 6 0 7
#1 1 8675590000000 8675599999998 2 000028 6 0 7
[RL_SSN]
#NetID DPC SSN

View File

@@ -0,0 +1,2 @@
172.18.199.1
2000

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.

View File

@@ -0,0 +1 @@
pps-1=172.18.98.1;

View File

@@ -0,0 +1,4 @@
WXC2 procedure exit log
Time: Fri Nov 5 05:27:51 2004
Now module: MSC

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,192 @@
#include "../../src/include/sccp.h"
#include "signal.h"
#include <unistd.h>
#ifdef _WXC_FSM_TEST
#define spLogFsm printf
#else
#define spLogFsm
#endif
static struct itimerval itimer, old_itimer;
u8 sccp_timer_flag;
void mtp3_timer ( );
void send_data ( );
void showbuf ( BYTE * buf, int len )
{
int i;
for ( i = 0; i < len; i++ )
printf ( "%X", buf[i] );
printf ( "\n" );
}
void showbuf2 ( BYTE * buf, int len )
{
int i;
for ( i = 0; i < len; i++ )
printf ( "%02X", buf[i] );
printf ( "\n" );
}
void on_data ( )
{
SCLC_MSG clmsg;
SCCP_ADDR addr;
int len, len2;
if( ( len = sclc_receive ( &clmsg, 0 ) ) > 0 )
{
showbuf2 ( clmsg.msg, clmsg.msglen );
memcpy ( &addr, &clmsg.src_addr, sizeof ( SCCP_ADDR ) );
memcpy ( &clmsg.src_addr, &clmsg.dst_addr, sizeof ( SCCP_ADDR ) );
memcpy ( &clmsg.dst_addr, &addr, sizeof ( SCCP_ADDR ) );
len2 = sclc_send ( &clmsg );
if( len2 == -1 )
printf ( "fail to send message" );
}
}
u8 sccp_20ms_flag = 0;
void On_Timer ( )
{
//on_data ( );
sccp_20ms_flag++;
sccp_timer_flag++;
spLogFsm("pos plat iprtans start \r\n");
iptrans_timer ( );
spLogFsm("pos plat mpt3 start \r\n");
mtp3_proc ( );
spLogFsm("pos plat sccp start \r\n");
spWxcBackTrace();
sccp_timer ( );
spLogFsm("pos plat sccp over \r\n");
spWxcBackTrace();
if( sccp_20ms_flag >= 2 )
{
spWxcBackTrace();
sccp_20ms_flag = 0;
spLogFsm("pos plat debug start \r\n");
debug_rt ( );
spLogFsm("pos plat snmp start \r\n");
snmp_timer ( );
spLogFsm("pos plat heartbeat start \r\n");
heartbeat_timer ( );
spLogFsm("pos plat end start \r\n");
spWxcBackTrace();
}
}
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 spUserInit( )
{
}
void spUserFsm( )
{
}
u8 delay = 5;
u8 main_state = 0;
void system_init ( )
{
sleep ( 3 );
debug_init ( );
iptrMainInit ( );
snmp_init ( 4957 );
heartbeat_init ( 0x0188 );
mtp_shm_init ( );
sccp_init ( );
sccp_20ms_flag = 0;
sccp_timer_flag = 0;
}
int main ( )
{
system_init();
SetTimer ( );
while ( 1 )
{
usleep ( 1 );
if( sccp_timer_flag >= delay )
{
sccp_timer_flag = 0;
switch ( main_state )
{
case 0:
ulInit( );
main_state = 1;
break;
case 1:
spLogFsm("sccp_test.c: main->ulsapfsm in \n");
ulSapFsm( );
spLogFsm("sccp_test.c: main->ulsapfsm out \n");
break;
}
}
}
return 1;
}
void send_data ( )
{
SCLC_MSG clmsg;
BYTE value[100] = { 1, 2, 3, 4, 5, 6 };
BYTE number[20] = { 0x68, 0x57, 0x55, 0x17, 0x32, 0x00, 0xF3 };
clmsg.msglen = 6;
memcpy ( clmsg.msg, value, clmsg.msglen );
clmsg.src_addr.DPC = 0x111111;
clmsg.src_addr.SSN = 8;
clmsg.src_addr.GTI = 0;
clmsg.dst_addr.DPC = 0;
clmsg.dst_addr.SSN = 8;
clmsg.dst_addr.GTI = 4;
clmsg.dst_addr.NP = 1;
clmsg.dst_addr.NAI = 4;
clmsg.dst_addr.len = 13;
clmsg.dst_addr.NetID = 0;
memcpy ( clmsg.dst_addr.GTAI, number, 7 );
if( sclc_send ( &clmsg ) == -1 )
printf ( "fail to send message\n" );
}

View File

@@ -0,0 +1,616 @@
//////////////////////////////////////////////////
//Title : fsm_test.c
//Auhtor : Liu Wei
//Desc : sccp fsm testing
//Created : 2007-05-25
//Revision :
//
//Revision :
//
//////////////////////////////////////////////////
#include "../../src/include/sccp.h"
#include "../../src/include/sccp_pub.h"
#include "../../src/include/scoc_if.h"
extern unsigned long spLogDebug_mask ;
extern BYTE sccpFilterIndex ;
extern BYTE mtp_asciin_buf[80];
#ifdef _WXC_FSM_TEST
#define spLogFsm printf
#else
#define spLogFsm
#endif
typedef enum UL_ORG_STATE
{
ORG_IDLE = 1,
ORG_CR, //CM LU
ORG_CC, //CC
ORG_LUR, //lu reject
ORG_CLCD, //clean command
ORG_CLCE, //clean complete
ORG_DISCONN,
ORG_SEND_UDT, //PRN
ORG_RECV_UDT, //PRN ack
}
UL_OrgState;
typedef enum UL_DST_STATE
{
DST_IDLE = 1,
DST_CR, //CM LU
DST_CC, //CC
DST_LUR, //lu reject
DST_CLCD, //clean command
DST_CLCE, //clean complete
DST_DISCONN,
DST_RECV_UDT, //PRN
DST_SEND_UDT, //PRN ack
}
UL_DstState;
typedef struct SCCP_UL
{
u8 uUlSide;
u8 uUlState;
u32 uUlTestStartTimer;
u32 uUlStateInterval;
u32 uWaitTimer;
u32 wConnId;
int nPort;
int nRemoteIP;
int nSock;
}
SP_UL;
SP_UL tUl;
#define aifprn_udt_msg_len 0x52
static u8 aifprn_udt_msg[] = {
0x51, 0x62, 0x4f,
0x48, 0x04, 0x01, 0x62, 0x00, 0x35, 0x6b, 0x1e,
0x28, 0x1c, 0x06, 0x07, 0x00, 0x11, 0x86, 0x05,
0x01, 0x01, 0x01, 0xa0, 0x11, 0x60, 0x0f, 0x80,
0x02, 0x07, 0x80, 0xa1, 0x09, 0x06, 0x07, 0x04,
0x00, 0x00, 0x01, 0x00, 0x03, 0x02, 0x6c, 0x27,
0xa1, 0x25, 0x02, 0x01, 0x80, 0x02, 0x01, 0x04,
0x30, 0x1d, 0x80, 0x08, 0x64, 0x00, 0x92, 0x00,
0x00, 0x00, 0x83, 0xf4, 0x81, 0x08, 0x91, 0x44,
0x57, 0x55, 0x06, 0x00, 0x00, 0xf0, 0x82, 0x07,
0x91, 0x68, 0x57, 0x95, 0x00, 0x83, 0xf4,
};
#define aifprnak_udt_msg_len 0x4b
static u8 aifprnak_udt_msg[] = {
0x4a, 0x64, 0x48,
0x49, 0x04, 0x01, 0x62, 0x00, 0x35, 0x6b, 0x2a,
0x28, 0x28, 0x06, 0x07, 0x00, 0x11, 0x86, 0x05,
0x01, 0x01, 0x01, 0xa0, 0x1d, 0x61, 0x1b, 0x80,
0x02, 0x07, 0x80, 0xa1, 0x09, 0x06, 0x07, 0x04,
0x00, 0x00, 0x01, 0x00, 0x03, 0x02, 0xa2, 0x03,
0x02, 0x01, 0x00, 0xa3, 0x05, 0xa1, 0x03, 0x02,
0x01, 0x00, 0x6c, 0x14, 0xa2, 0x12, 0x02, 0x01,
0x80, 0x30, 0x0d, 0x02, 0x01, 0x04, 0x04, 0x08,
0x91, 0x44, 0x57, 0x25, 0x31, 0x06, 0x00, 0xf6
};
#define aiflu_cr_msg_len 0x25
static u8 aiflu_cr_msg[] = {
0x0f, 0x23, 0x00, 0x21, 0x57,
0x05, 0x08, 0x00, 0x57, 0xf0, 0x10, 0x0b, 0xb9,
0x0a, 0xfb, 0x17, 0x12, 0x05, 0x08, 0x70, 0x45,
0xf0, 0x10, 0x00, 0x01, 0x30, 0x08, 0x59, 0x04,
0x10, 0x25, 0x00, 0x20, 0x30, 0x62, 0x21, 0x01,
};
#define aifcc_dt1_msg_len 0x00
static u8 aifcc_dt1_msg[] = {
};
#define aiflurj_dt1_msg_len 0x07
static u8 aiflurj_dt1_msg[] = {
0x06, 0x01, 0x00 , 0x03, 0x05, 0x04, 0x0b
};
#define aifclcd_dt1_msg_len 0x07
static u8 aifclcd_dt1_msg[] = {
0x06, 0x00, 0x04 , 0x20, 0x04, 0x01, 0x09
};
#define aifclce_dt1_msg_len 0x05
static u8 aifclce_dt1_msg[] = {
0x03, 0x00, 0x01 , 0x21, 0x00
};
#define aiflu_rlsd_msg_len 0x00
static u8 aiflu_rlsd_msg[] = {
};
#define aiflu_rlc_msg_len 0x00
static u8 aiflu_rlc_msg[] = {
};
int get_socket(u_int32_t ip, int port)
{
int sock;
int on = 1;
DWORD cmdarg = 1;
struct sockaddr_in sin_addr;
sin_addr.sin_family = AF_INET;
sin_addr.sin_port = htons(port);
sin_addr.sin_addr.s_addr = htonl(INADDR_ANY);
if(!(sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
perror("Get socket");
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if(bind(sock, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr_in)) != 0)
{
perror("bind");
return 0;
}
ioctl(sock, FIONBIO, &cmdarg);
return (sock);
}
int ulRecv( u8 *pBuff )
{
struct sockaddr_in sin_addr;
int addr_len;
return recvfrom(tUl.nSock, (char *)pBuff, 256, 0, (struct sockaddr *)&sin_addr, &addr_len);
}
void ulSend( u8 *pBuff , u8 uLen )
{
struct sockaddr_in sin_addr;
WxcAssert( uLen < 255 , "ulSend too long msg");
sin_addr.sin_family = AF_INET;
sin_addr.sin_port = htons(tUl.nPort);
sin_addr.sin_addr.s_addr = tUl.nRemoteIP;
sendto(tUl.nSock, (char *)pBuff, 256, 0, (struct sockaddr *)&sin_addr, sizeof(struct sockaddr));
}
int ulSpecPeer()
{
char msg[256];
memset(msg, 0, 256);
ulRecv(msg);
if( msg[0] )
{
printf("Recv test msg: %s\r\n", msg);
if( !strcmp(msg, "SCCP_TEST") )
{
tUl.uUlSide = 0;
printf("slave mode\r\n");
ulSend("SCCP_OK" , 7);
tUl.uUlStateInterval=0;
return 1;
}
else if( !strcmp(msg, "SCCP_OK") )
{
tUl.uUlSide = 1;
printf("master mode\r\n");
tUl.uUlStateInterval=0;
return 1;
}
}
if( tUl.uUlStateInterval++ % 200 )
{
ulSend("SCCP_TEST" , 9);
}
return 0;
}
void ulInit()
{
int ip;
struct in_addr sin_addr;
sin_addr.s_addr = tUl.nRemoteIP;
memset(&tUl, 0, sizeof(SP_UL));
tUl.uUlSide = 1;
tUl.nPort = 6999;
ip = GetLocalIP();
tUl.nRemoteIP = ( ip ^ 0x00010000 );
tUl.uWaitTimer = 20;
memcpy( &sin_addr , &tUl.nRemoteIP , 4);
printf("Remote ip : %s Start timer :%d \n" , inet_ntoa(sin_addr) ,tUl.uWaitTimer );
tUl.nSock = get_socket(tUl.nRemoteIP, tUl.nPort);
printf("get sock :%d \r\n",tUl.nSock);
register_ssn ( 0xfe, 3 );
mtp_asciin_buf[0] = 1;
strcpy( &mtp_asciin_buf[1] , "log all" );
printf("sizeof[sizeof(CO_ConnSection)* 4096]=%d\n", sizeof(CO_ConnSection)* 4096);
}
void ulLogMsg ( SP_UiPriPara * pSpPri, u8 uDirection , SP_UD *pUD )
{
char *pStr;
spGetUlPrimitiveStr ( pSpPri->uUiPri, pStr );
if( uDirection )
{
spLogDebug ( SCCPDB_AIF , "UL=>SP : %s ", pStr );
}
else
{
spLogDebug ( SCCPDB_AIF , "UL<=SP : %s ", pStr );
}
if( NULL != pUD )
{
spShowBCD ( 1, pUD->aUserData, pUD->uDataLen );
}
}
extern void spLog ( char *info );
void ulLogState ( u8 uSide , u8 *pStr )
{
char aStr[256];
if( uSide )
sprintf(aStr ,"]Org Node[: %s state \n" , pStr);
else
sprintf(aStr ,"]Dst Node[: %s state \n" , pStr);
spLog(aStr);
}
void ul_sccp_addr( SCCP_ADDR *pAddr )
{
memset( pAddr , 0 , sizeof(SCCP_ADDR) );
pAddr->ip = tUl.nRemoteIP;
pAddr->DPC = 40;
pAddr->NetID = 2;
pAddr->SSN = 254;
pAddr->RI = RI_SSN;
pAddr->GTI = 0;
pAddr->AI = 3;
return;
}
void ulSapFsm ( )
{
SP_UiPriPara tSpPri;
SP_UiPriUnion *pUPri;
pUPri = &tSpPri.tPriUnion;
if( !tUl.uUlState )
{
if( ulSpecPeer() )
{
printf("----------------------OK------------------\r\n");
tUl.uUlState++;
}else
{
return;
}
}
sccpFilterIndex = 0;
spLogDebug_mask = 0xFFFFFFFF;
//printf("Side : %d state : %d \n",tUl.uUlSide ,tUl.uUlState );
if( tUl.uUlSide )
{
switch ( tUl.uUlState )
{
case ORG_IDLE:
break;
case ORG_SEND_UDT: //PRN
tSpPri.uUiPri = N_UNITDATA_REQ;
ul_sccp_addr ( &pUPri->tPriNUDataReq.tCDA );
ul_sccp_addr ( &pUPri->tPriNUDataReq.tCGA );
pUPri->tPriNUDataReq.tRO.uRO = 1;
pUPri->tPriNUDataReq.tUD.uDataLen = aifprn_udt_msg_len;
memcpy ( &pUPri->tPriNUDataReq.tUD.aUserData, aifprn_udt_msg, pUPri->tPriNUDataReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNUDataReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while ORG_SEND_UDT state" );
ulLogState( tUl.uUlSide ,"ORG_SEND_UDT" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
return;
case ORG_RECV_UDT: //PRN ack
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_UNITDATA_IND, "ul recv pri error while ORG_RECV_UDT state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNUDataInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_RECV_UDT" );
return ;
}
break;
case ORG_CR: //CM LU
tSpPri.uUiPri = N_CONNECT_REQ;
ul_sccp_addr ( &pUPri->tPriNConnReq.tCDA );
pUPri->tPriNConnReq.uOptFlag = 0x08;
pUPri->tPriNConnReq.tUD.uDataLen = aiflu_cr_msg_len;
memcpy ( &pUPri->tPriNConnReq.tUD.aUserData, aiflu_cr_msg, pUPri->tPriNConnReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNConnReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while ORG_CR state" );
tUl.wConnId = tSpPri.wConnId;
WxcAssert ( tUl.wConnId < CO_CS_MPORT, "wConnId error " );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_CR" );
return;
case ORG_CC: //CC
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_CONNECT_CFM, "ul recv pri error while ORG_CC state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNConnCfm.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_CC" );
return ;
}
break;
case ORG_LUR: //lu reject
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_DATA_IND, "ul recv pri error while ORG_LUR state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNDataInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_LUR" );
return ;
}
break;
case ORG_CLCD: //clean command
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_DATA_IND, "ul recv pri error while ORG_CLCD state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNDataInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_CLCD" );
return ;
}
break;
case ORG_CLCE: //clean complete
tSpPri.uUiPri = N_DATA_REQ;
pUPri->tPriNDataReq.tUD.uDataLen = aifclce_dt1_msg_len;
memcpy ( &pUPri->tPriNDataReq.tUD.aUserData, aifclce_dt1_msg, pUPri->tPriNDataReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNDataReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while ORG_CLCE state" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_CLCE" );
return;
case ORG_DISCONN:
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_DISCONNECT_IND, "ul recv pri error while ORG_RLSD state" );
ulLogMsg ( &tSpPri, 0 , NULL );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"ORG_CLCE" );
return ;
}
break;
default:
printf ( "\n\n\n======================SP Org Test End=================\n\n\n" );
exit(1);
break;
}
if( ORG_IDLE == tUl.uUlState )
{
if( tUl.uUlTestStartTimer++ >= tUl.uWaitTimer )
{
printf ( "\n\n\n======================SP Org Test Start=================\n\n\n" );
tUl.uUlState++;
}
}
else
{
if( tUl.uUlStateInterval++ >= 200 )
{
//WxcAssert ( tUl.uUlState != ORG_RECV_UDT, "ORG_RECV_UDT state timer out" );
//WxcAssert ( tUl.uUlState != ORG_CC, "ORG_CC state timer out" );
//WxcAssert ( tUl.uUlState != ORG_LUR, "ORG_LUR state timer out" );
//WxcAssert ( tUl.uUlState != ORG_CLCD, "ORG_CLCD state timer out" );
//WxcAssert ( tUl.uUlState != ORG_DISCONN, "ORG_DISCONN state timer out" );
tUl.uUlStateInterval = 0;
}
}
}
else
{
switch ( tUl.uUlState )
{
case DST_IDLE:
break;
case DST_RECV_UDT: //PRN
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_UNITDATA_IND, "ul recv pri error while DST_RECV_UDT state" );
ulLogMsg ( &tSpPri, 0 ,&pUPri->tPriNUDataInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_RECV_UDT" );
return ;
}
break;
case DST_SEND_UDT: //PRN ack
tSpPri.uUiPri = N_UNITDATA_REQ;
ul_sccp_addr ( &pUPri->tPriNUDataReq.tCDA );
ul_sccp_addr ( &pUPri->tPriNUDataReq.tCGA );
pUPri->tPriNUDataReq.tRO.uRO = 1;
pUPri->tPriNUDataReq.tUD.uDataLen = aifprnak_udt_msg_len;
memcpy ( &pUPri->tPriNUDataReq.tUD.aUserData, aifprnak_udt_msg, pUPri->tPriNUDataReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNUDataReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while DST_SEND_UDT state" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_SEND_UDT" );
return;
case DST_CR: //CM LU
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( (tSpPri.uUiPri == N_CONNECT_IND), "ul recv pri error while DST_CR state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNConnInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_CR" );
return ;
}
break;
case DST_CC: //CC
tSpPri.uUiPri = N_CONNECT_RSP;
tSpPri.wConnId = tUl.wConnId;
pUPri->tPriNConnRsp.tUD.uDataLen = aifcc_dt1_msg_len;
pUPri->tPriNConnRsp.uOptFlag = 0x00;
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNConnRsp.tUD );
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while DST_CC state" );
WxcAssert ( tUl.wConnId < CO_CS_MPORT, "wConnId error " );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_CC" );
return;
case DST_LUR: //lu reject
tSpPri.uUiPri = N_DATA_REQ;
tSpPri.wConnId = tUl.wConnId;
pUPri->tPriNDataReq.tUD.uDataLen = aiflurj_dt1_msg_len;
memcpy ( &pUPri->tPriNDataReq.tUD.aUserData, aiflurj_dt1_msg, pUPri->tPriNDataReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 , &pUPri->tPriNDataReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while DST_LUR state" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_LUR" );
return;
case DST_CLCD: //clean command
tSpPri.uUiPri = N_DATA_REQ;
tSpPri.wConnId = tUl.wConnId;
pUPri->tPriNDataReq.tUD.uDataLen = aifclcd_dt1_msg_len;
memcpy ( &pUPri->tPriNDataReq.tUD.aUserData, aifclcd_dt1_msg, pUPri->tPriNDataReq.tUD.uDataLen );
ulLogMsg ( &tSpPri, 1 ,&pUPri->tPriNDataReq.tUD);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while DST_CLCD state" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_CLCD" );
return;
case DST_CLCE: //clean complete
if( SpSubmit ( &tSpPri , 3) )
{
WxcAssert ( tSpPri.uUiPri == N_DATA_IND, "ul recv pri error while DST_CLCE state" );
ulLogMsg ( &tSpPri, 0 , &pUPri->tPriNDataInd.tUD);
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_CLCE" );
return ;
}
break;
case DST_DISCONN:
tSpPri.uUiPri = N_DISCONNECT_REQ;
tSpPri.wConnId = tUl.wConnId;
pUPri->tPriNDisconnReq.eREA = REA_UDISC_EUF;
pUPri->tPriNDisconnReq.tUD.uDataLen = aiflu_rlsd_msg_len;
pUPri->tPriNDisconnReq.uOptFlag = 0x00;
ulLogMsg ( &tSpPri, 1 , NULL);
WxcAssert ( PostSp ( &tSpPri ), "ul post pri error while DST_DISCONN state" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
ulLogState( tUl.uUlSide ,"DST_DISCONN" );
return;
default:
printf ( "\n\n\n======================SP Dst Test End=================\n\n\n" );
exit(1);
break;
}
if( DST_IDLE == tUl.uUlState )
{
if( tUl.uUlTestStartTimer++ >= tUl.uWaitTimer )
{
printf ( "\n\n\n======================SP Dst Test Start=================\n\n\n" );
tUl.uUlState++;
tUl.uUlStateInterval = 0;
}
}
else
{
if( tUl.uUlStateInterval++ >= 200 )
{
//WxcAssert ( tUl.uUlState != DST_RECV_UDT, "DST_RECV_UDT state timer out" );
//WxcAssert ( tUl.uUlState != DST_CR, "DST_CR state timer out" );
//WxcAssert ( tUl.uUlState != DST_CLCE, "DST_CLCE state timer out" );
tUl.uUlStateInterval = 0;
}
}
}
}
void ll_cr ( )
{
}
void ll_cc ( )
{
}
void ll_cref ( )
{
}
void ll_rlsd ( )
{
}
void ll_rlc ( )
{
}
void ll_udt ( )
{
}
void ll_dt1 ( )
{
}
void ll_sap ( )
{
}